[PATCH v2 8/9] PCI: rockchip: Use u32 variable to access 32-bit registers
Damien Le Moal
damien.lemoal at opensource.wdc.com
Wed Feb 15 03:20:20 PST 2023
On 2/15/23 19:46, David Laight wrote:
> From: Damien Le Moal
>> Sent: 15 February 2023 01:34
>>
>> On 2/14/23 23:08, Rick Wertenbroek wrote:
>>> Previously u16 variables were used to access 32-bit registers, this
>>> resulted in not all of the data being read from the registers. Also
>>> the left shift of more than 16-bits would result in moving data out
>>> of the variable. Use u32 variables to access 32-bit registers
>>>
>>> Fixes: cf590b078391 ("PCI: rockchip: Add EP driver for Rockchip PCIe controller")
>>> Cc: stable at vger.kernel.org
>>> Signed-off-by: Rick Wertenbroek <rick.wertenbroek at gmail.com>
>>> ---
>>> drivers/pci/controller/pcie-rockchip-ep.c | 10 +++++-----
>>> drivers/pci/controller/pcie-rockchip.h | 1 +
>>> 2 files changed, 6 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/pci/controller/pcie-rockchip-ep.c b/drivers/pci/controller/pcie-rockchip-ep.c
>>> index ca5b363ba..b7865a94e 100644
>>> --- a/drivers/pci/controller/pcie-rockchip-ep.c
>>> +++ b/drivers/pci/controller/pcie-rockchip-ep.c
>>> @@ -292,15 +292,15 @@ static int rockchip_pcie_ep_set_msi(struct pci_epc *epc, u8 fn, u8 vfn,
>>> {
>>> struct rockchip_pcie_ep *ep = epc_get_drvdata(epc);
>>> struct rockchip_pcie *rockchip = &ep->rockchip;
>>> - u16 flags;
>>> + u32 flags;
>>>
>>> flags = rockchip_pcie_read(rockchip,
>>> ROCKCHIP_PCIE_EP_FUNC_BASE(fn) +
>>> ROCKCHIP_PCIE_EP_MSI_CTRL_REG);
>>> flags &= ~ROCKCHIP_PCIE_EP_MSI_CTRL_MMC_MASK;
>>> flags |=
>>> - ((multi_msg_cap << 1) << ROCKCHIP_PCIE_EP_MSI_CTRL_MMC_OFFSET) |
>>> - PCI_MSI_FLAGS_64BIT;
>>> + (multi_msg_cap << ROCKCHIP_PCIE_EP_MSI_CTRL_MMC_OFFSET) |
>>
>> ROCKCHIP_PCIE_EP_MSI_CTRL_MMC_OFFSET is 17 and multi_msg_cap is a u8...
>> Not nice.
>
> It really doesn't matter.
> As soon as you do any arithmetic char and short are promoted to int.
OK. Thanks.
--
Damien Le Moal
Western Digital Research
More information about the Linux-rockchip
mailing list