Commit 9dfbbd91 authored by Paul Mackerras's avatar Paul Mackerras Committed by Linus Torvalds

[PATCH] ppc32: Make ppc32 PCI code more robust

The main thrust of this patch is to make the ppc32 PCI code more
robust by checking for bus->resource[] being NULL before using it.  We
can legitimately get elements of bus->resource being NULL and I have
actually hit that on some machines.  This patch also allows resources
starting at 0 to be accepted as assigned (we can and do get PCI
resources starting at 0 in I/O space on PPC machines) and provides a
sensible default for the case where Open Firmware doesn't give us a
bus-range property for a PCI bridge.
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent e7de4bdb
...@@ -128,7 +128,7 @@ pcibios_fixup_resources(struct pci_dev *dev) ...@@ -128,7 +128,7 @@ pcibios_fixup_resources(struct pci_dev *dev)
struct resource *res = dev->resource + i; struct resource *res = dev->resource + i;
if (!res->flags) if (!res->flags)
continue; continue;
if (!res->start || res->end == 0xffffffff) { if (res->end == 0xffffffff) {
DBG("PCI:%s Resource %d [%08lx-%08lx] is unassigned\n", DBG("PCI:%s Resource %d [%08lx-%08lx] is unassigned\n",
pci_name(dev), i, res->start, res->end); pci_name(dev), i, res->start, res->end);
res->end -= res->start; res->end -= res->start;
...@@ -347,6 +347,8 @@ pci_relocate_bridge_resource(struct pci_bus *bus, int i) ...@@ -347,6 +347,8 @@ pci_relocate_bridge_resource(struct pci_bus *bus, int i)
return -1; return -1;
} }
res = bus->resource[i]; res = bus->resource[i];
if (res == NULL)
return -1;
pr = NULL; pr = NULL;
for (j = 0; j < 4; j++) { for (j = 0; j < 4; j++) {
struct resource *r = parent->resource[j]; struct resource *r = parent->resource[j];
...@@ -659,11 +661,11 @@ make_one_node_map(struct device_node* node, u8 pci_bus) ...@@ -659,11 +661,11 @@ make_one_node_map(struct device_node* node, u8 pci_bus)
return; return;
bus_range = (int *) get_property(node, "bus-range", &len); bus_range = (int *) get_property(node, "bus-range", &len);
if (bus_range == NULL || len < 2 * sizeof(int)) { if (bus_range == NULL || len < 2 * sizeof(int)) {
printk(KERN_WARNING "Can't get bus-range for %s\n", printk(KERN_WARNING "Can't get bus-range for %s, "
node->full_name); "assuming it starts at 0\n", node->full_name);
return; pci_to_OF_bus_map[pci_bus] = 0;
} } else
pci_to_OF_bus_map[pci_bus] = bus_range[0]; pci_to_OF_bus_map[pci_bus] = bus_range[0];
for (node=node->child; node != 0;node = node->sibling) { for (node=node->child; node != 0;node = node->sibling) {
struct pci_dev* dev; struct pci_dev* dev;
...@@ -1073,6 +1075,8 @@ do_update_p2p_io_resource(struct pci_bus *bus, int enable_vga) ...@@ -1073,6 +1075,8 @@ do_update_p2p_io_resource(struct pci_bus *bus, int enable_vga)
u16 w; u16 w;
struct resource res; struct resource res;
if (bus->resource[0] == NULL)
return;
res = *(bus->resource[0]); res = *(bus->resource[0]);
DBG("Remapping Bus %d, bridge: %s\n", bus->number, bridge->slot_name); DBG("Remapping Bus %d, bridge: %s\n", bus->number, bridge->slot_name);
...@@ -1168,7 +1172,8 @@ do_fixup_p2p_level(struct pci_bus *bus) ...@@ -1168,7 +1172,8 @@ do_fixup_p2p_level(struct pci_bus *bus)
int has_vga = 0; int has_vga = 0;
for (parent_io=0; parent_io<4; parent_io++) for (parent_io=0; parent_io<4; parent_io++)
if (bus->resource[parent_io]->flags & IORESOURCE_IO) if (bus->resource[parent_io]
&& bus->resource[parent_io]->flags & IORESOURCE_IO)
break; break;
if (parent_io >= 4) if (parent_io >= 4)
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment