aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/pci_irq.c
diff options
context:
space:
mode:
authorDavid Shaohua Li <shaohua.li@intel.com>2005-07-27 23:02:00 -0400
committerLen Brown <len.brown@intel.com>2005-07-29 22:49:38 -0400
commit87bec66b9691522414862dd8d41e430b063735ef (patch)
treef9976d7f6bb92fe3ebeda3b5d3644ac048147e62 /drivers/acpi/pci_irq.c
parent68ac767686fd72f37a25bb4895fb4ab0080ba755 (diff)
[ACPI] suspend/resume ACPI PCI Interrupt Links
Add reference count and disable ACPI PCI Interrupt Link when no device still uses it. Warn when drivers have not released Link at suspend time. http://bugzilla.kernel.org/show_bug.cgi?id=3469 Signed-off-by: David Shaohua Li <shaohua.li@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/pci_irq.c')
-rw-r--r--drivers/acpi/pci_irq.c85
1 files changed, 59 insertions, 26 deletions
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 8093f2e00321..c536ccfc5413 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -269,7 +269,51 @@ acpi_pci_irq_del_prt (int segment, int bus)
269/* -------------------------------------------------------------------------- 269/* --------------------------------------------------------------------------
270 PCI Interrupt Routing Support 270 PCI Interrupt Routing Support
271 -------------------------------------------------------------------------- */ 271 -------------------------------------------------------------------------- */
272typedef int (*irq_lookup_func)(struct acpi_prt_entry *, int *, int *, char **);
272 273
274static int
275acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
276 int *edge_level,
277 int *active_high_low,
278 char **link)
279{
280 int irq;
281
282 ACPI_FUNCTION_TRACE("acpi_pci_allocate_irq");
283
284 if (entry->link.handle) {
285 irq = acpi_pci_link_allocate_irq(entry->link.handle,
286 entry->link.index, edge_level, active_high_low, link);
287 if (irq < 0) {
288 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid IRQ link routing entry\n"));
289 return_VALUE(-1);
290 }
291 } else {
292 irq = entry->link.index;
293 *edge_level = ACPI_LEVEL_SENSITIVE;
294 *active_high_low = ACPI_ACTIVE_LOW;
295 }
296
297 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq));
298 return_VALUE(irq);
299}
300
301static int
302acpi_pci_free_irq(struct acpi_prt_entry *entry,
303 int *edge_level,
304 int *active_high_low,
305 char **link)
306{
307 int irq;
308
309 ACPI_FUNCTION_TRACE("acpi_pci_free_irq");
310 if (entry->link.handle) {
311 irq = acpi_pci_link_free_irq(entry->link.handle);
312 } else {
313 irq = entry->link.index;
314 }
315 return_VALUE(irq);
316}
273/* 317/*
274 * acpi_pci_irq_lookup 318 * acpi_pci_irq_lookup
275 * success: return IRQ >= 0 319 * success: return IRQ >= 0
@@ -282,12 +326,13 @@ acpi_pci_irq_lookup (
282 int pin, 326 int pin,
283 int *edge_level, 327 int *edge_level,
284 int *active_high_low, 328 int *active_high_low,
285 char **link) 329 char **link,
330 irq_lookup_func func)
286{ 331{
287 struct acpi_prt_entry *entry = NULL; 332 struct acpi_prt_entry *entry = NULL;
288 int segment = pci_domain_nr(bus); 333 int segment = pci_domain_nr(bus);
289 int bus_nr = bus->number; 334 int bus_nr = bus->number;
290 int irq; 335 int ret;
291 336
292 ACPI_FUNCTION_TRACE("acpi_pci_irq_lookup"); 337 ACPI_FUNCTION_TRACE("acpi_pci_irq_lookup");
293 338
@@ -301,22 +346,8 @@ acpi_pci_irq_lookup (
301 return_VALUE(-1); 346 return_VALUE(-1);
302 } 347 }
303 348
304 if (entry->link.handle) { 349 ret = func(entry, edge_level, active_high_low, link);
305 irq = acpi_pci_link_get_irq(entry->link.handle, 350 return_VALUE(ret);
306 entry->link.index, edge_level, active_high_low, link);
307 if (irq < 0) {
308 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid IRQ link routing entry\n"));
309 return_VALUE(-1);
310 }
311 } else {
312 irq = entry->link.index;
313 *edge_level = ACPI_LEVEL_SENSITIVE;
314 *active_high_low = ACPI_ACTIVE_LOW;
315 }
316
317 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq));
318
319 return_VALUE(irq);
320} 351}
321 352
322/* 353/*
@@ -330,7 +361,8 @@ acpi_pci_irq_derive (
330 int pin, 361 int pin,
331 int *edge_level, 362 int *edge_level,
332 int *active_high_low, 363 int *active_high_low,
333 char **link) 364 char **link,
365 irq_lookup_func func)
334{ 366{
335 struct pci_dev *bridge = dev; 367 struct pci_dev *bridge = dev;
336 int irq = -1; 368 int irq = -1;
@@ -363,7 +395,7 @@ acpi_pci_irq_derive (
363 } 395 }
364 396
365 irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn), 397 irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn),
366 pin, edge_level, active_high_low, link); 398 pin, edge_level, active_high_low, link, func);
367 } 399 }
368 400
369 if (irq < 0) { 401 if (irq < 0) {
@@ -415,7 +447,7 @@ acpi_pci_irq_enable (
415 * values override any BIOS-assigned IRQs set during boot. 447 * values override any BIOS-assigned IRQs set during boot.
416 */ 448 */
417 irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, 449 irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
418 &edge_level, &active_high_low, &link); 450 &edge_level, &active_high_low, &link, acpi_pci_allocate_irq);
419 451
420 /* 452 /*
421 * If no PRT entry was found, we'll try to derive an IRQ from the 453 * If no PRT entry was found, we'll try to derive an IRQ from the
@@ -423,7 +455,7 @@ acpi_pci_irq_enable (
423 */ 455 */
424 if (irq < 0) 456 if (irq < 0)
425 irq = acpi_pci_irq_derive(dev, pin, &edge_level, 457 irq = acpi_pci_irq_derive(dev, pin, &edge_level,
426 &active_high_low, &link); 458 &active_high_low, &link, acpi_pci_allocate_irq);
427 459
428 /* 460 /*
429 * No IRQ known to the ACPI subsystem - maybe the BIOS / 461 * No IRQ known to the ACPI subsystem - maybe the BIOS /
@@ -461,7 +493,9 @@ acpi_pci_irq_enable (
461EXPORT_SYMBOL(acpi_pci_irq_enable); 493EXPORT_SYMBOL(acpi_pci_irq_enable);
462 494
463 495
464#ifdef CONFIG_ACPI_DEALLOCATE_IRQ 496/* FIXME: implement x86/x86_64 version */
497void __attribute__((weak)) acpi_unregister_gsi(u32 i) {}
498
465void 499void
466acpi_pci_irq_disable ( 500acpi_pci_irq_disable (
467 struct pci_dev *dev) 501 struct pci_dev *dev)
@@ -488,14 +522,14 @@ acpi_pci_irq_disable (
488 * First we check the PCI IRQ routing table (PRT) for an IRQ. 522 * First we check the PCI IRQ routing table (PRT) for an IRQ.
489 */ 523 */
490 gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, 524 gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
491 &edge_level, &active_high_low, NULL); 525 &edge_level, &active_high_low, NULL, acpi_pci_free_irq);
492 /* 526 /*
493 * If no PRT entry was found, we'll try to derive an IRQ from the 527 * If no PRT entry was found, we'll try to derive an IRQ from the
494 * device's parent bridge. 528 * device's parent bridge.
495 */ 529 */
496 if (gsi < 0) 530 if (gsi < 0)
497 gsi = acpi_pci_irq_derive(dev, pin, 531 gsi = acpi_pci_irq_derive(dev, pin,
498 &edge_level, &active_high_low, NULL); 532 &edge_level, &active_high_low, NULL, acpi_pci_free_irq);
499 if (gsi < 0) 533 if (gsi < 0)
500 return_VOID; 534 return_VOID;
501 535
@@ -511,4 +545,3 @@ acpi_pci_irq_disable (
511 545
512 return_VOID; 546 return_VOID;
513} 547}
514#endif /* CONFIG_ACPI_DEALLOCATE_IRQ */