]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
powerpc/PCI: convert devtree bus addresses to resource
authorBjorn Helgaas <bhelgaas@google.com>
Fri, 16 Mar 2012 23:48:14 +0000 (17:48 -0600)
committerJesse Barnes <jbarnes@virtuousgeek.org>
Tue, 20 Mar 2012 17:41:51 +0000 (10:41 -0700)
Normal PCI enumeration via PCI config space uses __pci_read_base(), where
the PCI core applies any bus-to-resource offset.  But powerpc doesn't use
that path when enumerating via the device tree.

In 6c5705fec63d, I converted powerpc to use the PCI core bus-to-resource
conversion, but I missed these powerpc-specific paths.  Some powerpc
platforms fail to boot ("Cannot allocate resource region," "device not
available," etc.) between that commit and this one.

This adds the corresponding bus-to-resource conversion in the paths that
read BAR values from the OF device tree.

CC: Anton Blanchard <anton@samba.org>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
arch/powerpc/kernel/pci_of_scan.c

index b37d0b5a796e941fb079a737936dbb1fa29e1179..89dde171a6fabfafc23d1e29f3cba0bf00350bbe 100644 (file)
@@ -75,6 +75,7 @@ static void of_pci_parse_addrs(struct device_node *node, struct pci_dev *dev)
 {
        u64 base, size;
        unsigned int flags;
+       struct pci_bus_region region;
        struct resource *res;
        const u32 *addrs;
        u32 i;
@@ -106,10 +107,11 @@ static void of_pci_parse_addrs(struct device_node *node, struct pci_dev *dev)
                        printk(KERN_ERR "PCI: bad cfg reg num 0x%x\n", i);
                        continue;
                }
-               res->start = base;
-               res->end = base + size - 1;
                res->flags = flags;
                res->name = pci_name(dev);
+               region.start = base;
+               region.end = base + size - 1;
+               pcibios_bus_to_resource(dev, res, &region);
        }
 }
 
@@ -209,6 +211,7 @@ void __devinit of_scan_pci_bridge(struct pci_dev *dev)
        struct pci_bus *bus;
        const u32 *busrange, *ranges;
        int len, i, mode;
+       struct pci_bus_region region;
        struct resource *res;
        unsigned int flags;
        u64 size;
@@ -270,9 +273,10 @@ void __devinit of_scan_pci_bridge(struct pci_dev *dev)
                        res = bus->resource[i];
                        ++i;
                }
-               res->start = of_read_number(&ranges[1], 2);
-               res->end = res->start + size - 1;
                res->flags = flags;
+               region.start = of_read_number(&ranges[1], 2);
+               region.end = region.start + size - 1;
+               pcibios_bus_to_resource(dev, res, &region);
        }
        sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus),
                bus->number);