aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2013-02-16 13:58:34 -0500
committerBjorn Helgaas <bhelgaas@google.com>2013-02-16 13:58:34 -0500
commit181380b702eee1a9aca51354d7b87c7b08541fcf (patch)
treec95dc8c7649fe97c18a99d3ee69ad014adf8cfaa /drivers
parentbe6d2867b4f68a575c78fa368abd3ad49980c514 (diff)
PCI/ACPI: Don't cache _PRT, and don't associate them with bus numbers
Previously, we cached _PRT (PCI routing table, ACPI 5.0 sec 6.2.12) contents and associated each _PRT entry with a PCI bus number. The bus number association means dependencies on PCI device enumeration and bus number assignment, as well as on the PCI/ACPI binding process. After 4f535093cf ("PCI: Put pci_dev in device tree as early as possible"), these dependencies caused the IRQ issues reported by Peter: pci 0000:00:1e.0: PCI bridge to [bus 09] (subtractive decode) pci 0000:00:1e.0: can't derive routing for PCI INT A snd_ctxfi 0000:09:02.0: PCI INT A: no GSI - using ISA IRQ 5 irq 18: nobody cared (try booting with the "irqpoll" option) This patch removes _PRT caching. Instead, we evaluate _PRT as needed in the pci_enable_device() path. This also removes the dependency on PCI bus numbers: we can simply look at the _PRT associated with each bridge as we walk upstream toward the root. [bhelgaas: changelog] Reference: https://bugzilla.kernel.org/show_bug.cgi?id=53561 Reported-and-tested-by: Peter Hurley <peter@hurleysoftware.com> Suggested-by: Bjorn Helgaas <bhelgaas@google.com> Signed-off-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/pci_irq.c102
-rw-r--r--drivers/acpi/pci_root.c18
-rw-r--r--drivers/pci/pci-acpi.c24
3 files changed, 34 insertions, 110 deletions
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 68a921d03247..41c5e1b799ef 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -53,9 +53,6 @@ struct acpi_prt_entry {
53 u32 index; /* GSI, or link _CRS index */ 53 u32 index; /* GSI, or link _CRS index */
54}; 54};
55 55
56static LIST_HEAD(acpi_prt_list);
57static DEFINE_SPINLOCK(acpi_prt_lock);
58
59static inline char pin_name(int pin) 56static inline char pin_name(int pin)
60{ 57{
61 return 'A' + pin - 1; 58 return 'A' + pin - 1;
@@ -65,28 +62,6 @@ static inline char pin_name(int pin)
65 PCI IRQ Routing Table (PRT) Support 62 PCI IRQ Routing Table (PRT) Support
66 -------------------------------------------------------------------------- */ 63 -------------------------------------------------------------------------- */
67 64
68static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(struct pci_dev *dev,
69 int pin)
70{
71 struct acpi_prt_entry *entry;
72 int segment = pci_domain_nr(dev->bus);
73 int bus = dev->bus->number;
74 int device = PCI_SLOT(dev->devfn);
75
76 spin_lock(&acpi_prt_lock);
77 list_for_each_entry(entry, &acpi_prt_list, list) {
78 if ((segment == entry->id.segment)
79 && (bus == entry->id.bus)
80 && (device == entry->id.device)
81 && (pin == entry->pin)) {
82 spin_unlock(&acpi_prt_lock);
83 return entry;
84 }
85 }
86 spin_unlock(&acpi_prt_lock);
87 return NULL;
88}
89
90/* http://bugzilla.kernel.org/show_bug.cgi?id=4773 */ 65/* http://bugzilla.kernel.org/show_bug.cgi?id=4773 */
91static const struct dmi_system_id medion_md9580[] = { 66static const struct dmi_system_id medion_md9580[] = {
92 { 67 {
@@ -184,11 +159,19 @@ static void do_prt_fixups(struct acpi_prt_entry *entry,
184 } 159 }
185} 160}
186 161
187static int acpi_pci_irq_add_entry(acpi_handle handle, int segment, int bus, 162static int acpi_pci_irq_check_entry(acpi_handle handle, struct pci_dev *dev,
188 struct acpi_pci_routing_table *prt) 163 int pin, struct acpi_pci_routing_table *prt,
164 struct acpi_prt_entry **entry_ptr)
189{ 165{
166 int segment = pci_domain_nr(dev->bus);
167 int bus = dev->bus->number;
168 int device = PCI_SLOT(dev->devfn);
190 struct acpi_prt_entry *entry; 169 struct acpi_prt_entry *entry;
191 170
171 if (((prt->address >> 16) & 0xffff) != device ||
172 prt->pin + 1 != pin)
173 return -ENODEV;
174
192 entry = kzalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL); 175 entry = kzalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL);
193 if (!entry) 176 if (!entry)
194 return -ENOMEM; 177 return -ENOMEM;
@@ -237,43 +220,37 @@ static int acpi_pci_irq_add_entry(acpi_handle handle, int segment, int bus,
237 entry->id.device, pin_name(entry->pin), 220 entry->id.device, pin_name(entry->pin),
238 prt->source, entry->index)); 221 prt->source, entry->index));
239 222
240 spin_lock(&acpi_prt_lock); 223 *entry_ptr = entry;
241 list_add_tail(&entry->list, &acpi_prt_list);
242 spin_unlock(&acpi_prt_lock);
243 224
244 return 0; 225 return 0;
245} 226}
246 227
247int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) 228static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev,
229 int pin, struct acpi_prt_entry **entry_ptr)
248{ 230{
249 acpi_status status; 231 acpi_status status;
250 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 232 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
251 struct acpi_pci_routing_table *entry; 233 struct acpi_pci_routing_table *entry;
234 acpi_handle handle = NULL;
252 235
253 /* 'handle' is the _PRT's parent (root bridge or PCI-PCI bridge) */ 236 if (dev->bus->bridge)
254 status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); 237 handle = ACPI_HANDLE(dev->bus->bridge);
255 if (ACPI_FAILURE(status))
256 return -ENODEV;
257
258 printk(KERN_DEBUG "ACPI: PCI Interrupt Routing Table [%s._PRT]\n",
259 (char *) buffer.pointer);
260
261 kfree(buffer.pointer);
262 238
263 buffer.length = ACPI_ALLOCATE_BUFFER; 239 if (!handle)
264 buffer.pointer = NULL; 240 return -ENODEV;
265 241
242 /* 'handle' is the _PRT's parent (root bridge or PCI-PCI bridge) */
266 status = acpi_get_irq_routing_table(handle, &buffer); 243 status = acpi_get_irq_routing_table(handle, &buffer);
267 if (ACPI_FAILURE(status)) { 244 if (ACPI_FAILURE(status)) {
268 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]",
269 acpi_format_exception(status)));
270 kfree(buffer.pointer); 245 kfree(buffer.pointer);
271 return -ENODEV; 246 return -ENODEV;
272 } 247 }
273 248
274 entry = buffer.pointer; 249 entry = buffer.pointer;
275 while (entry && (entry->length > 0)) { 250 while (entry && (entry->length > 0)) {
276 acpi_pci_irq_add_entry(handle, segment, bus, entry); 251 if (!acpi_pci_irq_check_entry(handle, dev, pin,
252 entry, entry_ptr))
253 break;
277 entry = (struct acpi_pci_routing_table *) 254 entry = (struct acpi_pci_routing_table *)
278 ((unsigned long)entry + entry->length); 255 ((unsigned long)entry + entry->length);
279 } 256 }
@@ -282,23 +259,6 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
282 return 0; 259 return 0;
283} 260}
284 261
285void acpi_pci_irq_del_prt(int segment, int bus)
286{
287 struct acpi_prt_entry *entry, *tmp;
288
289 printk(KERN_DEBUG
290 "ACPI: Delete PCI Interrupt Routing Table for %04x:%02x\n",
291 segment, bus);
292 spin_lock(&acpi_prt_lock);
293 list_for_each_entry_safe(entry, tmp, &acpi_prt_list, list) {
294 if (segment == entry->id.segment && bus == entry->id.bus) {
295 list_del(&entry->list);
296 kfree(entry);
297 }
298 }
299 spin_unlock(&acpi_prt_lock);
300}
301
302/* -------------------------------------------------------------------------- 262/* --------------------------------------------------------------------------
303 PCI Interrupt Routing Support 263 PCI Interrupt Routing Support
304 -------------------------------------------------------------------------- */ 264 -------------------------------------------------------------------------- */
@@ -359,12 +319,13 @@ static int acpi_reroute_boot_interrupt(struct pci_dev *dev,
359 319
360static struct acpi_prt_entry *acpi_pci_irq_lookup(struct pci_dev *dev, int pin) 320static struct acpi_prt_entry *acpi_pci_irq_lookup(struct pci_dev *dev, int pin)
361{ 321{
362 struct acpi_prt_entry *entry; 322 struct acpi_prt_entry *entry = NULL;
363 struct pci_dev *bridge; 323 struct pci_dev *bridge;
364 u8 bridge_pin, orig_pin = pin; 324 u8 bridge_pin, orig_pin = pin;
325 int ret;
365 326
366 entry = acpi_pci_irq_find_prt_entry(dev, pin); 327 ret = acpi_pci_irq_find_prt_entry(dev, pin, &entry);
367 if (entry) { 328 if (!ret && entry) {
368#ifdef CONFIG_X86_IO_APIC 329#ifdef CONFIG_X86_IO_APIC
369 acpi_reroute_boot_interrupt(dev, entry); 330 acpi_reroute_boot_interrupt(dev, entry);
370#endif /* CONFIG_X86_IO_APIC */ 331#endif /* CONFIG_X86_IO_APIC */
@@ -373,7 +334,7 @@ static struct acpi_prt_entry *acpi_pci_irq_lookup(struct pci_dev *dev, int pin)
373 return entry; 334 return entry;
374 } 335 }
375 336
376 /* 337 /*
377 * Attempt to derive an IRQ for this device from a parent bridge's 338 * Attempt to derive an IRQ for this device from a parent bridge's
378 * PCI interrupt routing entry (eg. yenta bridge and add-in card bridge). 339 * PCI interrupt routing entry (eg. yenta bridge and add-in card bridge).
379 */ 340 */
@@ -393,8 +354,8 @@ static struct acpi_prt_entry *acpi_pci_irq_lookup(struct pci_dev *dev, int pin)
393 pin = bridge_pin; 354 pin = bridge_pin;
394 } 355 }
395 356
396 entry = acpi_pci_irq_find_prt_entry(bridge, pin); 357 ret = acpi_pci_irq_find_prt_entry(bridge, pin, &entry);
397 if (entry) { 358 if (!ret && entry) {
398 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 359 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
399 "Derived GSI for %s INT %c from %s\n", 360 "Derived GSI for %s INT %c from %s\n",
400 pci_name(dev), pin_name(orig_pin), 361 pci_name(dev), pin_name(orig_pin),
@@ -470,6 +431,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
470 dev_warn(&dev->dev, "PCI INT %c: no GSI\n", 431 dev_warn(&dev->dev, "PCI INT %c: no GSI\n",
471 pin_name(pin)); 432 pin_name(pin));
472 } 433 }
434
473 return 0; 435 return 0;
474 } 436 }
475 437
@@ -477,6 +439,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
477 if (rc < 0) { 439 if (rc < 0) {
478 dev_warn(&dev->dev, "PCI INT %c: failed to register GSI\n", 440 dev_warn(&dev->dev, "PCI INT %c: failed to register GSI\n",
479 pin_name(pin)); 441 pin_name(pin));
442 kfree(entry);
480 return rc; 443 return rc;
481 } 444 }
482 dev->irq = rc; 445 dev->irq = rc;
@@ -491,6 +454,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
491 (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", 454 (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge",
492 (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq); 455 (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq);
493 456
457 kfree(entry);
494 return 0; 458 return 0;
495} 459}
496 460
@@ -513,6 +477,8 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
513 else 477 else
514 gsi = entry->index; 478 gsi = entry->index;
515 479
480 kfree(entry);
481
516 /* 482 /*
517 * TBD: It might be worth clearing dev->irq by magic constant 483 * TBD: It might be worth clearing dev->irq by magic constant
518 * (e.g. PCI_UNDEFINED_IRQ). 484 * (e.g. PCI_UNDEFINED_IRQ).
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index fd59f57d3829..8545b1d22811 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -434,7 +434,6 @@ static int acpi_pci_root_add(struct acpi_device *device)
434 acpi_status status; 434 acpi_status status;
435 int result; 435 int result;
436 struct acpi_pci_root *root; 436 struct acpi_pci_root *root;
437 acpi_handle handle;
438 struct acpi_pci_driver *driver; 437 struct acpi_pci_driver *driver;
439 u32 flags, base_flags; 438 u32 flags, base_flags;
440 bool is_osc_granted = false; 439 bool is_osc_granted = false;
@@ -489,16 +488,6 @@ static int acpi_pci_root_add(struct acpi_device *device)
489 acpi_device_name(device), acpi_device_bid(device), 488 acpi_device_name(device), acpi_device_bid(device),
490 root->segment, &root->secondary); 489 root->segment, &root->secondary);
491 490
492 /*
493 * PCI Routing Table
494 * -----------------
495 * Evaluate and parse _PRT, if exists.
496 */
497 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
498 if (ACPI_SUCCESS(status))
499 result = acpi_pci_irq_add_prt(device->handle, root->segment,
500 root->secondary.start);
501
502 root->mcfg_addr = acpi_pci_root_get_mcfg_addr(device->handle); 491 root->mcfg_addr = acpi_pci_root_get_mcfg_addr(device->handle);
503 492
504 /* 493 /*
@@ -623,7 +612,6 @@ out_del_root:
623 list_del(&root->node); 612 list_del(&root->node);
624 mutex_unlock(&acpi_pci_root_lock); 613 mutex_unlock(&acpi_pci_root_lock);
625 614
626 acpi_pci_irq_del_prt(root->segment, root->secondary.start);
627end: 615end:
628 kfree(root); 616 kfree(root);
629 return result; 617 return result;
@@ -631,8 +619,6 @@ end:
631 619
632static int acpi_pci_root_remove(struct acpi_device *device, int type) 620static int acpi_pci_root_remove(struct acpi_device *device, int type)
633{ 621{
634 acpi_status status;
635 acpi_handle handle;
636 struct acpi_pci_root *root = acpi_driver_data(device); 622 struct acpi_pci_root *root = acpi_driver_data(device);
637 struct acpi_pci_driver *driver; 623 struct acpi_pci_driver *driver;
638 624
@@ -647,10 +633,6 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type)
647 device_set_run_wake(root->bus->bridge, false); 633 device_set_run_wake(root->bus->bridge, false);
648 pci_acpi_remove_bus_pm_notifier(device); 634 pci_acpi_remove_bus_pm_notifier(device);
649 635
650 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
651 if (ACPI_SUCCESS(status))
652 acpi_pci_irq_del_prt(root->segment, root->secondary.start);
653
654 pci_remove_root_bus(root->bus); 636 pci_remove_root_bus(root->bus);
655 637
656 mutex_lock(&acpi_pci_root_lock); 638 mutex_lock(&acpi_pci_root_lock);
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 42736e213f25..9ba9df5f6161 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -325,25 +325,6 @@ static void pci_acpi_setup(struct device *dev)
325 struct pci_dev *pci_dev = to_pci_dev(dev); 325 struct pci_dev *pci_dev = to_pci_dev(dev);
326 acpi_handle handle = ACPI_HANDLE(dev); 326 acpi_handle handle = ACPI_HANDLE(dev);
327 struct acpi_device *adev; 327 struct acpi_device *adev;
328 acpi_status status;
329 acpi_handle dummy;
330
331 /*
332 * Evaluate and parse _PRT, if exists. This code allows parsing of
333 * _PRT objects within the scope of non-bridge devices. Note that
334 * _PRTs within the scope of a PCI bridge assume the bridge's
335 * subordinate bus number.
336 *
337 * TBD: Can _PRTs exist within the scope of non-bridge PCI devices?
338 */
339 status = acpi_get_handle(handle, METHOD_NAME__PRT, &dummy);
340 if (ACPI_SUCCESS(status)) {
341 unsigned char bus;
342
343 bus = pci_dev->subordinate ?
344 pci_dev->subordinate->number : pci_dev->bus->number;
345 acpi_pci_irq_add_prt(handle, pci_domain_nr(pci_dev->bus), bus);
346 }
347 328
348 acpi_power_resource_register_device(dev, handle); 329 acpi_power_resource_register_device(dev, handle);
349 if (acpi_bus_get_device(handle, &adev) || !adev->wakeup.flags.valid) 330 if (acpi_bus_get_device(handle, &adev) || !adev->wakeup.flags.valid)
@@ -359,7 +340,6 @@ static void pci_acpi_setup(struct device *dev)
359 340
360static void pci_acpi_cleanup(struct device *dev) 341static void pci_acpi_cleanup(struct device *dev)
361{ 342{
362 struct pci_dev *pci_dev = to_pci_dev(dev);
363 acpi_handle handle = ACPI_HANDLE(dev); 343 acpi_handle handle = ACPI_HANDLE(dev);
364 struct acpi_device *adev; 344 struct acpi_device *adev;
365 345
@@ -369,10 +349,6 @@ static void pci_acpi_cleanup(struct device *dev)
369 pci_acpi_remove_pm_notifier(adev); 349 pci_acpi_remove_pm_notifier(adev);
370 } 350 }
371 acpi_power_resource_unregister_device(dev, handle); 351 acpi_power_resource_unregister_device(dev, handle);
372
373 if (pci_dev->subordinate)
374 acpi_pci_irq_del_prt(pci_domain_nr(pci_dev->bus),
375 pci_dev->subordinate->number);
376} 352}
377 353
378static struct acpi_bus_type acpi_pci_bus = { 354static struct acpi_bus_type acpi_pci_bus = {