aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2015-01-15 17:21:50 -0500
committerBjorn Helgaas <bhelgaas@google.com>2015-01-16 11:04:43 -0500
commit4e348ba2dd1c1d6ea191566d7591655bbe9dde64 (patch)
tree806ae5f2f4e09f8225663b523a6ba6e607951bae
parent576e4385ff59f52ca0e9a6a953a55f1f76fc196b (diff)
mn10300/PCI: Clip bridge windows to fit in upstream windows
Every PCI-PCI bridge window should fit inside an upstream bridge window because orphaned address space is unreachable from the primary side of the upstream bridge. If we inherit invalid bridge windows that overlap an upstream window from firmware, clip them to fit and update the bridge accordingly. [bhelgaas: changelog] Link: https://bugzilla.kernel.org/show_bug.cgi?id=85491 Reported-by: Marek Kordik <kordikmarek@gmail.com> Fixes: 5b28541552ef ("PCI: Restrict 64-bit prefetchable bridge windows to 64-bit resources") Signed-off-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> CC: David Howells <dhowells@redhat.com> CC: Koichi Yasutake <yasutake.koichi@jp.panasonic.com> CC: linux-am33-list@redhat.com
-rw-r--r--arch/mn10300/unit-asb2305/pci-asb2305.c2
-rw-r--r--arch/mn10300/unit-asb2305/pci.c47
2 files changed, 22 insertions, 27 deletions
diff --git a/arch/mn10300/unit-asb2305/pci-asb2305.c b/arch/mn10300/unit-asb2305/pci-asb2305.c
index febb9cd83177..b5b036f64275 100644
--- a/arch/mn10300/unit-asb2305/pci-asb2305.c
+++ b/arch/mn10300/unit-asb2305/pci-asb2305.c
@@ -106,7 +106,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
106 if (!r->flags) 106 if (!r->flags)
107 continue; 107 continue;
108 if (!r->start || 108 if (!r->start ||
109 pci_claim_resource(dev, idx) < 0) { 109 pci_claim_bridge_resource(dev, idx) < 0) {
110 printk(KERN_ERR "PCI:" 110 printk(KERN_ERR "PCI:"
111 " Cannot allocate resource" 111 " Cannot allocate resource"
112 " region %d of bridge %s\n", 112 " region %d of bridge %s\n",
diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c
index 6b4339f8c9c2..471ff398090c 100644
--- a/arch/mn10300/unit-asb2305/pci.c
+++ b/arch/mn10300/unit-asb2305/pci.c
@@ -281,42 +281,37 @@ static int __init pci_check_direct(void)
281 return -ENODEV; 281 return -ENODEV;
282} 282}
283 283
284static int is_valid_resource(struct pci_dev *dev, int idx) 284static void pcibios_fixup_device_resources(struct pci_dev *dev)
285{ 285{
286 unsigned int i, type_mask = IORESOURCE_IO | IORESOURCE_MEM; 286 int idx;
287 struct resource *devr = &dev->resource[idx], *busr;
288
289 if (dev->bus) {
290 pci_bus_for_each_resource(dev->bus, busr, i) {
291 if (!busr || (busr->flags ^ devr->flags) & type_mask)
292 continue;
293
294 if (devr->start &&
295 devr->start >= busr->start &&
296 devr->end <= busr->end)
297 return 1;
298 }
299 }
300 287
301 return 0; 288 if (!dev->bus)
289 return;
290
291 for (idx = 0; idx < PCI_BRIDGE_RESOURCES; idx++) {
292 struct resource *r = &dev->resource[idx];
293
294 if (!r->flags || r->parent || !r->start)
295 continue;
296
297 pci_claim_resource(dev, idx);
298 }
302} 299}
303 300
304static void pcibios_fixup_device_resources(struct pci_dev *dev) 301static void pcibios_fixup_bridge_resources(struct pci_dev *dev)
305{ 302{
306 int limit, i; 303 int idx;
307 304
308 if (dev->bus->number != 0) 305 if (!dev->bus)
309 return; 306 return;
310 307
311 limit = (dev->hdr_type == PCI_HEADER_TYPE_NORMAL) ? 308 for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) {
312 PCI_BRIDGE_RESOURCES : PCI_NUM_RESOURCES; 309 struct resource *r = &dev->resource[idx];
313 310
314 for (i = 0; i < limit; i++) { 311 if (!r->flags || r->parent || !r->start)
315 if (!dev->resource[i].flags)
316 continue; 312 continue;
317 313
318 if (is_valid_resource(dev, i)) 314 pci_claim_bridge_resource(dev, idx);
319 pci_claim_resource(dev, i);
320 } 315 }
321} 316}
322 317
@@ -330,7 +325,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)
330 325
331 if (bus->self) { 326 if (bus->self) {
332 pci_read_bridge_bases(bus); 327 pci_read_bridge_bases(bus);
333 pcibios_fixup_device_resources(bus->self); 328 pcibios_fixup_bridge_resources(bus->self);
334 } 329 }
335 330
336 list_for_each_entry(dev, &bus->devices, bus_list) 331 list_for_each_entry(dev, &bus->devices, bus_list)