Skip to contentSkip to conversation

PCI: rcar: Replace unsigned long with u32 for register values

PATCH In review [email protected] 4 participants 20 messages Mar 17, 2019 – Mar 22, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 PCI: rcar: Replace unsigned long with u32 for register values

From: Marek Vasut <[email protected]>

Replace unsigned long with u32 type for variables holding register values, since the registers are 32bit. Note that rcar_pcie_msi_irq() still uses unsigned long because both find_first_bit() and __fls() require unsigned long as an argument.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>

To: [email protected]

---
 drivers/pci/controller/pcie-rcar.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/pci/controller/pcie-rcar.c +5 -5
index 1408c8aa758b..857d88fd03d5 100644
@@ -169,7 +169,7 @@ enum {
 
 static void rcar_rmw32(struct rcar_pcie *pcie, int where, u32 mask, u32 data)
 {
-	int shift = 8 * (where & 3);
+	u32 shift = 8 * (where & 3);
 	u32 val = rcar_pci_read_reg(pcie, where & ~3);
 
 	val &= ~(mask << shift);
@@ -179,7 +179,7 @@ static void rcar_rmw32(struct rcar_pcie *pcie, int where, u32 mask, u32 data)
 
 static u32 rcar_read_conf(struct rcar_pcie *pcie, int where)
 {
-	int shift = 8 * (where & 3);
+	u32 shift = 8 * (where & 3);
 	u32 val = rcar_pci_read_reg(pcie, where & ~3);
 
 	return val >> shift;
@@ -190,7 +190,7 @@ static int rcar_pcie_config_access(struct rcar_pcie *pcie,
 		unsigned char access_type, struct pci_bus *bus,
 		unsigned int devfn, int where, u32 *data)
 {
-	int dev, func, reg, index;
+	u32 dev, func, reg, index;
 
 	dev = PCI_SLOT(devfn);
 	func = PCI_FUNC(devfn);
@@ -508,7 +508,7 @@ static void phy_write_reg(struct rcar_pcie *pcie,
 				 unsigned int rate, unsigned int addr,
 				 unsigned int lane, unsigned int data)
 {
-	unsigned long phyaddr;
+	u32 phyaddr;
 
 	phyaddr = WRITE_CMD |
 		((rate & 1) << RATE_POS) |
@@ -1116,7 +1116,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct rcar_pcie *pcie;
-	unsigned int data;
+	u32 data;
 	int err;
 	int (*phy_init_fn)(struct rcar_pcie *);
 	struct pci_host_bridge *bridge;
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/3 PCI: rcar: Allow 64bit MSI addresses

From: Marek Vasut <[email protected]>

The MSI address can be 64bit. Switch the data type used to hold the result of virt_to_phys() to phys_addr_t to reflect it's properties correctly and program the top 32bits of PA into PCIEMSIAUR.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>

To: [email protected]

---
 drivers/pci/controller/pcie-rcar.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/pcie-rcar.c +2 -2
index 857d88fd03d5..801925a136ae 100644
@@ -888,7 +888,7 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie)
 {
 	struct device *dev = pcie->dev;
 	struct rcar_msi *msi = &pcie->msi;
-	unsigned long base;
+	phys_addr_t base;
 	int err, i;
 
 	mutex_init(&msi->lock);
@@ -930,7 +930,7 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie)
 	base = virt_to_phys((void *)msi->pages);
 
 	rcar_pci_write_reg(pcie, base | MSIFE, PCIEMSIALR);
-	rcar_pci_write_reg(pcie, 0, PCIEMSIAUR);
+	rcar_pci_write_reg(pcie, base >> 32, PCIEMSIAUR);
 
 	/* enable all MSI interrupts */
 	rcar_pci_write_reg(pcie, 0xffffffff, PCIEMSIIER);
Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH 2/3] PCI: rcar: Allow 64bit MSI addresses

Hello!

Quoted 4 lines · On 17.03.2019 3:06, [email protected] wrote:

From: Marek Vasut <[email protected]>

The MSI address can be 64bit. Switch the data type used to hold the result of virt_to_phys() to phys_addr_t to reflect it's properties

Its.

Quoted 9 lines

correctly and program the top 32bits of PA into PCIEMSIAUR.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>

To: [email protected]

[...]

MBR, Sergei

#3 lore raw

Re: [PATCH 2/3] PCI: rcar: Allow 64bit MSI addresses

Quoted 10 lines · Sergei Shtylyov

Hello!

Quoted 4 lines · On 17.03.2019 3:06, [email protected] wrote:

From: Marek Vasut <[email protected]>

The MSI address can be 64bit. Switch the data type used to hold the result of virt_to_phys() to phys_addr_t to reflect it's properties

   Its.

Fixed

Quoted 12 lines
Quoted 9 lines

correctly and program the top 32bits of PA into PCIEMSIAUR.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>

To: [email protected]

[...]

MBR, Sergei

Signature · 2 lines
Best regards,
Marek Vasut
#4 lore raw

Re: [PATCH 2/3] PCI: rcar: Allow 64bit MSI addresses

In reply to [email protected]
Quoted 7 lines · On Sun, Mar 17, 2019 at 01:06:07AM +0100, [email protected] wrote:

From: Marek Vasut <[email protected]>

The MSI address can be 64bit. Switch the data type used to hold the result of virt_to_phys() to phys_addr_t to reflect it's properties correctly and program the top 32bits of PA into PCIEMSIAUR.

Looks sane. Not being a PCI expert, I wonder: Were we just lucky to not hit a 64-bit MSI address before? Is this tied to our 32-bit limitation?

#5 lore raw

Re: [PATCH 2/3] PCI: rcar: Allow 64bit MSI addresses

Quoted 11 lines · Wolfram Sang
Quoted 7 lines · On Sun, Mar 17, 2019 at 01:06:07AM +0100, [email protected] wrote:

From: Marek Vasut <[email protected]>

The MSI address can be 64bit. Switch the data type used to hold the result of virt_to_phys() to phys_addr_t to reflect it's properties correctly and program the top 32bits of PA into PCIEMSIAUR.

Looks sane. Not being a PCI expert, I wonder: Were we just lucky to not hit a 64-bit MSI address before?

I wonder about that, virt_to_phys(__get_free_pages(GFP_KERNEL, 0)) would happily return 64bit address, but with the cards I tested (a few intel NICs [igb, e1000e], PCIe NVME SSDs and xHCI HCD), I am getting the MSIs either way.

Quoted 1 line

Is this tied to our 32-bit limitation?

This might be a question for the HW team. I would be tempted to cautiously say yes.

Signature · 2 lines
Best regards,
Marek Vasut
#6 lore raw

Re: [PATCH 2/3] PCI: rcar: Allow 64bit MSI addresses

Hi Marek,

Quoted 10 lines · Marek Vasut
Quoted 9 lines · Wolfram Sang
Quoted 7 lines · On Sun, Mar 17, 2019 at 01:06:07AM +0100, [email protected] wrote:

From: Marek Vasut <[email protected]>

The MSI address can be 64bit. Switch the data type used to hold the result of virt_to_phys() to phys_addr_t to reflect it's properties correctly and program the top 32bits of PA into PCIEMSIAUR.

Quoted 7 lines
Quoted 2 lines

Looks sane. Not being a PCI expert, I wonder: Were we just lucky to not hit a 64-bit MSI address before?

I wonder about that, virt_to_phys(__get_free_pages(GFP_KERNEL, 0)) would happily return 64bit address, but with the cards I tested (a few intel NICs [igb, e1000e], PCIe NVME SSDs and xHCI HCD), I am getting the MSIs either way.

No doubt you would be receiving the MSIs, if you have RAM at the truncated address, but wouldn't that cause memory corruption?

Fixes 290c1fb358605402 ("PCI: rcar: Add MSI support for PCIe")

When MSI support was added, only R-Car H1 and Gen2 were supported. H1 doesn't have LPAE. Gen2 has, but it might have been disabled.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#7 lore raw

Re: [PATCH 2/3] PCI: rcar: Allow 64bit MSI addresses

Hi Marek,

Quoted 19 lines · Geert Uytterhoeven
Quoted 10 lines · Marek Vasut
Quoted 9 lines · Wolfram Sang
Quoted 7 lines · On Sun, Mar 17, 2019 at 01:06:07AM +0100, [email protected] wrote:

From: Marek Vasut <[email protected]>

The MSI address can be 64bit. Switch the data type used to hold the result of virt_to_phys() to phys_addr_t to reflect it's properties correctly and program the top 32bits of PA into PCIEMSIAUR.

Quoted 7 lines
Quoted 2 lines

Looks sane. Not being a PCI expert, I wonder: Were we just lucky to not hit a 64-bit MSI address before?

I wonder about that, virt_to_phys(__get_free_pages(GFP_KERNEL, 0)) would happily return 64bit address, but with the cards I tested (a few intel NICs [igb, e1000e], PCIe NVME SSDs and xHCI HCD), I am getting the MSIs either way.

Quoted 7 lines

No doubt you would be receiving the MSIs, if you have RAM at the truncated address, but wouldn't that cause memory corruption?

Fixes 290c1fb358605402 ("PCI: rcar: Add MSI support for PCIe")

When MSI support was added, only R-Car H1 and Gen2 were supported. H1 doesn't have LPAE. Gen2 has, but it might have been disabled.

Correction: as this is always mapped kernel memory, LPAE doesn't matter. So the bug matters for arm64 only.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#8 lore raw

Re: [PATCH 2/3] PCI: rcar: Allow 64bit MSI addresses

Quoted 25 lines · Geert Uytterhoeven

Hi Marek,

Quoted 22 lines · Geert Uytterhoeven
Quoted 10 lines · Marek Vasut
Quoted 9 lines · Wolfram Sang
Quoted 7 lines · On Sun, Mar 17, 2019 at 01:06:07AM +0100, [email protected] wrote:

From: Marek Vasut <[email protected]>

The MSI address can be 64bit. Switch the data type used to hold the result of virt_to_phys() to phys_addr_t to reflect it's properties correctly and program the top 32bits of PA into PCIEMSIAUR.

Quoted 7 lines
Quoted 2 lines

Looks sane. Not being a PCI expert, I wonder: Were we just lucky to not hit a 64-bit MSI address before?

I wonder about that, virt_to_phys(__get_free_pages(GFP_KERNEL, 0)) would happily return 64bit address, but with the cards I tested (a few intel NICs [igb, e1000e], PCIe NVME SSDs and xHCI HCD), I am getting the MSIs either way.

No doubt you would be receiving the MSIs, if you have RAM at the truncated address, but wouldn't that cause memory corruption?

Quoted 7 lines
Quoted 4 lines
Fixes 290c1fb358605402 ("PCI: rcar: Add MSI support for PCIe")

When MSI support was added, only R-Car H1 and Gen2 were supported. H1 doesn't have LPAE. Gen2 has, but it might have been disabled.

Correction: as this is always mapped kernel memory, LPAE doesn't matter. So the bug matters for arm64 only.

And since the address is in the 0x7_3xxx_xxxx range on H3 S-XS, there is no visible memory corruption. Joy ...

Signature · 2 lines
Best regards,
Marek Vasut
Reviewed-by on v1 2/3
#9 lore raw

Re: [PATCH 2/3] PCI: rcar: Allow 64bit MSI addresses

In reply to [email protected]
Quoted 4 lines · On Sun, Mar 17, 2019 at 1:06 AM <[email protected]> wrote:

From: Marek Vasut <[email protected]>

The MSI address can be 64bit. Switch the data type used to hold the result of virt_to_phys() to phys_addr_t to reflect it's properties

Side note: probably this should use a proper DMA API instead of get_free_pages()/virt_to_phys().

Quoted 3 lines

correctly and program the top 32bits of PA into PCIEMSIAUR.

drivers/pci/controller/pcie-rcar.c static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) · line 933

Quoted 9 lines
drivers/pci/controller/pcie-rcar.c +1 -1
@@ -930,7 +930,7 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie)
        base = virt_to_phys((void *)msi->pages);
 
        rcar_pci_write_reg(pcie, base | MSIFE, PCIEMSIALR);
-       rcar_pci_write_reg(pcie, 0, PCIEMSIAUR);
+       rcar_pci_write_reg(pcie, base >> 32, PCIEMSIAUR);

Note that his register is now non-zero.
According to the documentation, clearing PCIEMSIALR.MSIFE should be sufficient to disable MSI, and thus there's no need to zero PCIEMSIAUR in rcar_pcie_teardown_msi().
So nothing to change there, good.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#10 lore raw

Re: [PATCH 2/3] PCI: rcar: Allow 64bit MSI addresses

Quoted 8 lines · Geert Uytterhoeven
Quoted 4 lines · On Sun, Mar 17, 2019 at 1:06 AM <[email protected]> wrote:

From: Marek Vasut <[email protected]>

The MSI address can be 64bit. Switch the data type used to hold the result of virt_to_phys() to phys_addr_t to reflect it's properties

Side note: probably this should use a proper DMA API instead of get_free_pages()/virt_to_phys().

In fact, I think it doesn't matter. The MSI message is never written into this page as an actual memory write, it is interpreted by the hardware as an interrupt when it arrives. So I believe this page is just a safety net, which is never actually written.

Quoted 3 lines
Quoted 3 lines

correctly and program the top 32bits of PA into PCIEMSIAUR.

[...]

Signature · 2 lines
Best regards,
Marek Vasut
#11 lore raw

PATCH 3/3 PCI: rcar: Clean up debug messages

In reply to [email protected]

From: Marek Vasut <[email protected]>

Drop useless casts from debug messages, they are no longer needed due to the data type cleanup.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>

To: [email protected]

---
 drivers/pci/controller/pcie-rcar.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pci/controller/pcie-rcar.c +4 -4
index 801925a136ae..2a012654686e 100644
@@ -283,8 +283,8 @@ static int rcar_pcie_read_conf(struct pci_bus *bus, unsigned int devfn,
 	else if (size == 2)
 		*val = (*val >> (8 * (where & 2))) & 0xffff;
 
-	dev_dbg(&bus->dev, "pcie-config-read: bus=%3d devfn=0x%04x where=0x%04x size=%d val=0x%08lx\n",
-		bus->number, devfn, where, size, (unsigned long)*val);
+	dev_dbg(&bus->dev, "pcie-config-read: bus=%3d devfn=0x%04x where=0x%04x size=%d val=0x%08x\n",
+		bus->number, devfn, where, size, *val);
 
 	return ret;
 }
@@ -302,8 +302,8 @@ static int rcar_pcie_write_conf(struct pci_bus *bus, unsigned int devfn,
 	if (ret != PCIBIOS_SUCCESSFUL)
 		return ret;
 
-	dev_dbg(&bus->dev, "pcie-config-write: bus=%3d devfn=0x%04x where=0x%04x size=%d val=0x%08lx\n",
-		bus->number, devfn, where, size, (unsigned long)val);
+	dev_dbg(&bus->dev, "pcie-config-write: bus=%3d devfn=0x%04x where=0x%04x size=%d val=0x%08x\n",
+		bus->number, devfn, where, size, val);
 
 	if (size == 1) {
 		shift = 8 * (where & 3);
Signature · 1 line
2.20.1
Reviewed-by on v1 3/3
#13 lore raw

Re: [PATCH 3/3] PCI: rcar: Clean up debug messages

In reply to [email protected]
Quoted 6 lines · On Sun, Mar 17, 2019 at 1:06 AM <[email protected]> wrote:

From: Marek Vasut <[email protected]>

Drop useless casts from debug messages, they are no longer needed due to the data type cleanup.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#14 lore raw
In reply to [email protected]
Quoted 3 lines · On Sun, Mar 17, 2019 at 01:06:06AM +0100, [email protected] wrote:

From: Marek Vasut <[email protected]>

Replace unsigned long with u32 type for variables holding

s/unsigned long/various variable types/

Quoted 6 lines

register values, since the registers are 32bit. Note that rcar_pcie_msi_irq() still uses unsigned long because both find_first_bit() and __fls() require unsigned long as an argument.

...

Review

Quoted 2 lines
(quoted diff) +1 -1
-	int shift = 8 * (where & 3);
+	u32 shift = 8 * (where & 3);

Minor nit: Since this is about shifting, maybe replace 8 with << 3 while we are here?

There is also a 'shift' var in rcar_pcie_write_conf(). I think we should convert this for consistency, too?

#15 lore raw
Quoted 6 lines · Wolfram Sang
Quoted 3 lines · On Sun, Mar 17, 2019 at 01:06:06AM +0100, [email protected] wrote:

From: Marek Vasut <[email protected]>

Replace unsigned long with u32 type for variables holding

s/unsigned long/various variable types/

Fixed

Quoted 8 lines
Quoted 6 lines

register values, since the registers are 32bit. Note that rcar_pcie_msi_irq() still uses unsigned long because both find_first_bit() and __fls() require unsigned long as an argument.

...

Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +1 -1
-	int shift = 8 * (where & 3);
+	u32 shift = 8 * (where & 3);

Minor nit: Since this is about shifting, maybe replace 8 with << 3 while we are here?

There is also a 'shift' var in rcar_pcie_write_conf(). I think we should convert this for consistency, too?

OK, I might as well collect this and the other cleanup series and repost it together as a V2 to make it easier to pick.

Signature · 2 lines
Best regards,
Marek Vasut
#16 lore raw
Quoted 6 lines
Quoted 3 lines

There is also a 'shift' var in rcar_pcie_write_conf(). I think we should convert this for consistency, too?

OK, I might as well collect this and the other cleanup series and repost it together as a V2 to make it easier to pick.

Sounds good!

Reviewed-by on v1 1/3
#17 lore raw
In reply to [email protected]

Hi Marek,

Quoted 24 lines · On Sun, Mar 17, 2019 at 1:06 AM <[email protected]> wrote:

From: Marek Vasut <[email protected]>

Replace unsigned long with u32 type for variables holding register values, since the registers are 32bit. Note that rcar_pcie_msi_irq() still uses unsigned long because both find_first_bit() and __fls() require unsigned long as an argument.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>

To: [email protected]

---
 drivers/pci/controller/pcie-rcar.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/pci/controller/pcie-rcar.c +0 -0
index 1408c8aa758b..857d88fd03d5 100644

drivers/pci/controller/pcie-rcar.c enum { · line 172

Quoted 5 lines
drivers/pci/controller/pcie-rcar.c +1 -1
@@ -169,7 +169,7 @@ enum {
 
 static void rcar_rmw32(struct rcar_pcie *pcie, int where, u32 mask, u32 data)
 {
-       int shift = 8 * (where & 3);
+       u32 shift = 8 * (where & 3);

shift is not a register value, so IMHO the original type is fine (the "int" comes from the pci_ops API, BTW).

drivers/pci/controller/pcie-rcar.c static void rcar_rmw32(struct rcar_pcie *pcie, int where, u32 mask, u32 data) · line 182

Quoted 9 lines
drivers/pci/controller/pcie-rcar.c +1 -1
        u32 val = rcar_pci_read_reg(pcie, where & ~3);
 
        val &= ~(mask << shift);
@@ -179,7 +179,7 @@ static void rcar_rmw32(struct rcar_pcie *pcie, int where, u32 mask, u32 data)
 
 static u32 rcar_read_conf(struct rcar_pcie *pcie, int where)
 {
-       int shift = 8 * (where & 3);
+       u32 shift = 8 * (where & 3);

Likewise

drivers/pci/controller/pcie-rcar.c static int rcar_pcie_config_access(struct rcar_pcie *pcie, · line 193

Quoted 9 lines
drivers/pci/controller/pcie-rcar.c +1 -1
        u32 val = rcar_pci_read_reg(pcie, where & ~3);
 
        return val >> shift;
@@ -190,7 +190,7 @@ static int rcar_pcie_config_access(struct rcar_pcie *pcie,
                unsigned char access_type, struct pci_bus *bus,
                unsigned int devfn, int where, u32 *data)
 {
-       int dev, func, reg, index;
+       u32 dev, func, reg, index;

reg is the only register value, isn't it?

Quoted 13 lines
drivers/pci/controller/pcie-rcar.c +1 -1
        dev = PCI_SLOT(devfn);
        func = PCI_FUNC(devfn);
@@ -508,7 +508,7 @@ static void phy_write_reg(struct rcar_pcie *pcie,
                                 unsigned int rate, unsigned int addr,
                                 unsigned int lane, unsigned int data)
 {
-       unsigned long phyaddr;
+       u32 phyaddr;
 
        phyaddr = WRITE_CMD |
                ((rate & 1) << RATE_POS) |

drivers/pci/controller/pcie-rcar.c static int rcar_pcie_probe(struct platform_device *pdev) · line 1122

Quoted 8 lines
drivers/pci/controller/pcie-rcar.c +1 -1
@@ -1116,7 +1116,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct rcar_pcie *pcie;
-       unsigned int data;
+       u32 data;
        int err;
        int (*phy_init_fn)(struct rcar_pcie *);
        struct pci_host_bridge *bridge;

For the last two changes:

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#18 lore raw
Quoted 28 lines · Geert Uytterhoeven

Hi Marek,

Quoted 25 lines · On Sun, Mar 17, 2019 at 1:06 AM <[email protected]> wrote:

From: Marek Vasut <[email protected]>

Replace unsigned long with u32 type for variables holding register values, since the registers are 32bit. Note that rcar_pcie_msi_irq() still uses unsigned long because both find_first_bit() and __fls() require unsigned long as an argument.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>

To: [email protected]

---
 drivers/pci/controller/pcie-rcar.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/pci/controller/pcie-rcar.c +0 -0
index 1408c8aa758b..857d88fd03d5 100644
@@ -169,7 +169,7 @@ enum {
 
Quoted 7 lines

drivers/pci/controller/pcie-rcar.c enum { · line 172

Quoted 4 lines
drivers/pci/controller/pcie-rcar.c +1 -1
 static void rcar_rmw32(struct rcar_pcie *pcie, int where, u32 mask, u32 data)
 {
-       int shift = 8 * (where & 3);
+       u32 shift = 8 * (where & 3);

shift is not a register value, so IMHO the original type is fine (the "int" comes from the pci_ops API, BTW).

I presume it should be at least unsigned ?

[...]

Signature · 2 lines
Best regards,
Marek Vasut
#19 lore raw

Hi Marek,

Quoted 35 lines · Marek Vasut
Quoted 26 lines · Geert Uytterhoeven
Quoted 25 lines · On Sun, Mar 17, 2019 at 1:06 AM <[email protected]> wrote:

From: Marek Vasut <[email protected]>

Replace unsigned long with u32 type for variables holding register values, since the registers are 32bit. Note that rcar_pcie_msi_irq() still uses unsigned long because both find_first_bit() and __fls() require unsigned long as an argument.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>

To: [email protected]

---
 drivers/pci/controller/pcie-rcar.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/pci/controller/pcie-rcar.c +0 -0
index 1408c8aa758b..857d88fd03d5 100644
@@ -169,7 +169,7 @@ enum {
 
Quoted 7 lines

drivers/pci/controller/pcie-rcar.c enum { · line 172

Quoted 4 lines
drivers/pci/controller/pcie-rcar.c +1 -1
 static void rcar_rmw32(struct rcar_pcie *pcie, int where, u32 mask, u32 data)
 {
-       int shift = 8 * (where & 3);
+       u32 shift = 8 * (where & 3);

shift is not a register value, so IMHO the original type is fine (the "int" comes from the pci_ops API, BTW).

Quoted 1 line

I presume it should be at least unsigned ?

Yes, and "where" too.

Note that the other uses of "where" are also int, and IMHO should be unsigned, too. But changing that means changing the PCI API and all drivers, sigh...

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds