diff mbox

PCI: fix probe.c warning on !CONFIG_ARCH_DMA_ADDR_T_64BIT platforms

Message ID 1416321927-29120-1-git-send-email-thomas.petazzoni@free-electrons.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Thomas Petazzoni Nov. 18, 2014, 2:45 p.m. UTC
Commit 3a02517d5e2a ("PCI: Support 64-bit bridge windows if we have
64-bit dma_addr_t") modified the pci_read_bridge_mmio_pref() function
to support 64 bits bridge windows if the dma_addr_t type if 64 bits.

However, even though it accounts for platforms where dma_addr_t is 32
bits, it introduced a compile-time warning on such platforms:

drivers/pci/probe.c: In function ‘pci_read_bridge_mmio_pref’:
drivers/pci/probe.c:430:5: warning: left shift count >= width of type
     base |= ((dma_addr_t) mem_base_hi) << 32;
     ^
drivers/pci/probe.c:431:5: warning: left shift count >= width of type
     limit |= ((dma_addr_t) mem_limit_hi) << 32;

This is due to the fact that the code that gets used on platforms
where dma_addr_t is 64 bits is also compiled on platforms where
dma_addr_t is 32 bits.

To solve this, this patch switches from using the runtime
'sizeof(dma_addr_t) < 8' test to a compile time test on
CONFIG_ARCH_DMA_ADDR_T_64BIT, which is the configuration option used
by <linux/types.h> to decide whether dma_addr_t is 32 bits or 64 bits.

Note that in the case mentionned in the commit log of 3a02517d5e2a,
i.e x86 32 bits with PAE enabled, CONFIG_ARCH_DMA_ADDR_T_64BIT is
enabled, because this option is enabled when either x86-64 is used, or
x86 with HIGHMEM64G.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Fixes: 3a02517d5e2a ("PCI: Support 64-bit bridge windows if we have 64-bit dma_addr_t")
---
Applies on top of pci/for-linus

 drivers/pci/probe.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 1c5b1ca..9de2994 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -429,15 +429,15 @@  static void pci_read_bridge_mmio_pref(struct pci_bus *child)
 		 * this, just assume they are not being used.
 		 */
 		if (mem_base_hi <= mem_limit_hi) {
-			if (sizeof(dma_addr_t) < 8) {
-				if (mem_base_hi || mem_limit_hi) {
-					dev_err(&dev->dev, "can't handle 64-bit address space for bridge\n");
-					return;
-				}
-			} else  {
-				base |= ((dma_addr_t) mem_base_hi) << 32;
-				limit |= ((dma_addr_t) mem_limit_hi) << 32;
+#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
+			base |= ((dma_addr_t) mem_base_hi) << 32;
+			limit |= ((dma_addr_t) mem_limit_hi) << 32;
+#else
+			if (mem_base_hi || mem_limit_hi) {
+				dev_err(&dev->dev, "can't handle 64-bit address space for bridge\n");
+				return;
 			}
+#endif
 		}
 	}
 	if (base <= limit) {