PCI: iproc: fix 32-bit build
Subsystems (2)
PATCH 1/2 PCI: iproc: fix 32-bit build
The newly added code to setup the inbound ranges causes a link error on 32-bit machines from a 32-bit division:
drivers/pci/host/pcie-iproc.o: In function `iproc_pcie_setup_ib':
pcie-iproc.c:(.text.iproc_pcie_setup_ib+0x14c): undefined reference to `__aeabi_uldivmod'
As both sides of the division are always power-of-two numbers and we already rely on that, we can use a shift instead.
--- drivers/pci/host/pcie-iproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/host/pcie-iproc.c +1 -1
@@ -865,7 +865,7 @@ static int iproc_pcie_ib_write(struct iproc_pcie *pcie, int region_idx,* Now program the IMAP registers. Each IARR region may have one or * more IMAP windows. */ - size /= nr_windows; + size >>=ilog2 (nr_windows);for (window_idx =0 ; window_idx < nr_windows; window_idx++) { val =readl (pcie->base + imap_offset); val |=lower_32_bits (axi_addr) |IMAP_VALID ;
Signature · 1 line
2.9.0
PATCH 2/2 PCI: iproc: avoid maybe-uninitialized warning
gcc notices that calling iproc_pcie_setup_ib with ib->nr_regions==0 would result in an uninitialized return value:
drivers/pci/host/pcie-iproc.c: In function 'iproc_pcie_setup_ib':drivers/pci/host/pcie-iproc.c:894:6: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
This can't really happen, but the correct behavior of the function is probably to return -EINVAL if it ever did.
--- drivers/pci/host/pcie-iproc.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/host/pcie-iproc.c +1 -0
@@ -936,6 +936,7 @@ static int iproc_pcie_setup_ib(struct iproc_pcie *pcie, } } + ret = -EINVAL ; err_ib:dev_err (dev,"unable to configure inbound mapping\n" ); dev_err(dev, "axi %pap, pci %pap, res size %pap\n",
Signature · 1 line
2.9.0
Re: [PATCH 2/2] PCI: iproc: avoid maybe-uninitialized warning
Hi Arnd,
Quoted 21 lines · Arnd Bergmann
gcc notices that calling
iproc_pcie_setup_ibwith ib->nr_regions==0 would result in an uninitialized return value:
drivers/pci/host/pcie-iproc.c: In function 'iproc_pcie_setup_ib':drivers/pci/host/pcie-iproc.c:894:6: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]This can't really happen, but the correct behavior of the function is probably to return
-EINVALif it ever did.Fixes 4213e15c364e ("PCI: iproc: Make outbound mapping code more generic")Signed-off-by Arnd Bergmann <[email protected]>--- drivers/pci/host/pcie-iproc.c | 1 + 1 file changed, 1 insertion(+)drivers/pci/host/pcie-iproc.c +0
-0
drivers/pci/host/pcie-iproc.c static int iproc_pcie_setup_ib(struct iproc_pcie *pcie, · line 942
Quoted 7 lines
drivers/pci/host/pcie-iproc.c +1
-0@@ -936,6 +936,7 @@ static int iproc_pcie_setup_ib(struct iproc_pcie *pcie, } } + ret = -EINVAL ; err_ib:dev_err (dev,"unable to configure inbound mapping\n" ); dev_err(dev, "axi %pap, pci %pap, res size %pap\n",
This change is good, but in my opinion, a further improvement for clarity would be to initialize 'ret' to -EINVAL in the beginning of this function when 'ret' is declared. What do you think?
Thanks,
Ray
Re: [PATCH 2/2] PCI: iproc: avoid maybe-uninitialized warning
Quoted 6 lines · CET Ray Jui
Quoted 6 lines
drivers/pci/host/pcie-iproc.c +0
-0@@ -936,6 +936,7 @@ static int iproc_pcie_setup_ib(struct iproc_pcie *pcie,
Quoted 12 lines
drivers/pci/host/pcie-iproc.c static int iproc_pcie_setup_ib(struct iproc_pcie *pcie, · line 942
Quoted 7 lines
drivers/pci/host/pcie-iproc.c +1
-0} } + ret = -EINVAL ; err_ib:dev_err (dev,"unable to configure inbound mapping\n" ); dev_err(dev, "axi %pap, pci %pap, res size %pap\n",This change is good, but in my opinion, a further improvement for clarity would be to initialize 'ret' to
-EINVALin the beginning of this function when 'ret' is declared. What do you think?
I never do that, see https://rusty.ozlabs.org/?p=232 for a great explanation about why.
Arnd
Re: [PATCH 2/2] PCI: iproc: avoid maybe-uninitialized warning
Quoted 20 lines · Arnd Bergmann
Quoted 6 lines · CET Ray Jui
Quoted 6 lines
drivers/pci/host/pcie-iproc.c +0
-0@@ -936,6 +936,7 @@ static int iproc_pcie_setup_ib(struct iproc_pcie *pcie,Quoted 12 lines
drivers/pci/host/pcie-iproc.c static int iproc_pcie_setup_ib(struct iproc_pcie *pcie, · line 942
Quoted 7 lines
drivers/pci/host/pcie-iproc.c +1
-0} } + ret = -EINVAL ; err_ib:dev_err (dev,"unable to configure inbound mapping\n" ); dev_err(dev, "axi %pap, pci %pap, res size %pap\n",This change is good, but in my opinion, a further improvement for clarity would be to initialize 'ret' to
-EINVALin the beginning of this function when 'ret' is declared. What do you think?
Quoted 5 lines
I never do that, see https://rusty.ozlabs.org/?p=232 for a great explanation about why.
Arnd
Okay got it. Thanks!
Ray
Quoted 21 lines · Arnd Bergmann
The newly added code to setup the inbound ranges causes a link error on 32-bit machines from a 32-bit division:
drivers/pci/host/pcie-iproc.o: In function `iproc_pcie_setup_ib':
pcie-iproc.c:(.text.iproc_pcie_setup_ib+0x14c): undefined reference to `__aeabi_uldivmod'As both sides of the division are always power-of-two numbers and we already rely on that, we can use a shift instead.
Fixes 87c240b19bba ("PCI: iproc: Add inbound DMA mapping support")Signed-off-by Arnd Bergmann <[email protected]>--- drivers/pci/host/pcie-iproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/host/pcie-iproc.c +0
-0
drivers/pci/host/pcie-iproc.c static int iproc_pcie_ib_write(struct iproc_pcie *pcie, int region_idx, · line 871
Quoted 8 lines
drivers/pci/host/pcie-iproc.c +1
-1@@ -865,7 +865,7 @@ static int iproc_pcie_ib_write(struct iproc_pcie *pcie, int region_idx,* Now program the IMAP registers. Each IARR region may have one or * more IMAP windows. */ - size /= nr_windows; + size >>=ilog2 (nr_windows);for (window_idx =0 ; window_idx < nr_windows; window_idx++) { val =readl (pcie->base + imap_offset); val |=lower_32_bits (axi_addr) |IMAP_VALID ;
Hmmm, somehow we've never seen this link error for the ARM32 based platforms that we build for. Does it behave differently between different versions of compilers?
Nevertheless, this is a good change to take, thanks!
Quoted 6 lines · CET Ray Jui
Hmmm, somehow we've never seen this link error for the ARM32 based platforms that we build for. Does it behave differently between different versions of compilers?
Nevertheless, this is a good change to take, thanks!
I looked at it again, and see now that it only happens with a 64-bit RESOURCE_SIZE_T, which is only used on 32-bit platforms with more than 4GB of memory addresses. It would however show up in a multiplatform distro build for ARMv7VE, so the fix is still clearly needed.
Arnd
Quoted 8 lines · Arnd Bergmann
Quoted 6 lines · CET Ray Jui
Hmmm, somehow we've never seen this link error for the ARM32 based platforms that we build for. Does it behave differently between different versions of compilers?
Nevertheless, this is a good change to take, thanks!
Quoted 8 lines
I looked at it again, and see now that it only happens with a 64-bit
RESOURCE_SIZE_T, which is only used on 32-bit platforms with more than 4GB of memory addresses. It would however show up in a multiplatform distro build for ARMv7VE, so the fix is still clearly needed.Arnd
Yes, got it for how it showed up in your environment, :)
This change stands good as it has been.
Thanks,
Ray
Quoted 11 lines · Arnd Bergmann
The newly added code to setup the inbound ranges causes a link error on 32-bit machines from a 32-bit division:
drivers/pci/host/pcie-iproc.o: In function `iproc_pcie_setup_ib':
pcie-iproc.c:(.text.iproc_pcie_setup_ib+0x14c): undefined reference to `__aeabi_uldivmod'As both sides of the division are always power-of-two numbers and we already rely on that, we can use a shift instead.
Fixes 87c240b19bba ("PCI: iproc: Add inbound DMA mapping support")Signed-off-by Arnd Bergmann <[email protected]>
I folded these fixes into the pci/host-iproc branch for v4.10, thanks!
For some reason, I don't see Ray's responses on the list. Maybe still some email problem?
Quoted 25 lines
--- drivers/pci/host/pcie-iproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/host/pcie-iproc.c +1
-1@@ -865,7 +865,7 @@ static int iproc_pcie_ib_write(struct iproc_pcie *pcie, int region_idx,* Now program the IMAP registers. Each IARR region may have one or * more IMAP windows. */ - size /= nr_windows; + size >>=ilog2 (nr_windows);for (window_idx =0 ; window_idx < nr_windows; window_idx++) { val =readl (pcie->base + imap_offset); val |=lower_32_bits (axi_addr) |IMAP_VALID ;Signature · 7 lines
2.9.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel