Commit 06df8085 authored by Nathan Bryant's avatar Nathan Bryant Committed by Len Brown

[ACPI] restore PCI Interrupt Link Devices upon resume

* register as as a sys_device so that we can get resume callbacks and restore
  interrupt routing state.
* add acpi_pci_link_resume(), which will be called when resuming from a suspend
  state that needs IRQ routing to be restored. This fixes issues reported on
  the mailing lists, e.g.:
http://marc.theaimsgroup.com/?l=acpi4linux&m=109142999328643&w=2
* rename setonboot --> initialized
* change to test acpi_noirq in init

We want to initialize everything on S3 resume in case the BIOS points an
interrupt link somewhere we didn't expect. (Doing so avoids "missing interrupt"
or "irq x: nobody cared" problems.) According to Len, past experience has shown
that it's a good idea to initialize only devices that exist or were explicitly
asked for, so we try to initialize only the IRQ's that were previously
initialized at some point before suspend, by checking the "initialized" flag.
This corresponds to links that have PCI devices attached.  Everything else, we
leave alone. Assuming the BIOS does the same thing on resume that it did on
boot, this will leave all the unused links in the same state that they were on
boot.

We are registered as a sysdev in order to do this work fairly early during
resume, before devices are resumed; some devices may not call
pci_device_enable.

Previous "setonboot once" behavior is left in place, to be conservative.
parent b34b7911
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
* for IRQ management (e.g. start()->_SRS). * for IRQ management (e.g. start()->_SRS).
*/ */
#include <linux/sysdev.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -71,7 +72,7 @@ struct acpi_pci_link_irq { ...@@ -71,7 +72,7 @@ struct acpi_pci_link_irq {
u8 active; /* Current IRQ */ u8 active; /* Current IRQ */
u8 edge_level; /* All IRQs */ u8 edge_level; /* All IRQs */
u8 active_high_low; /* All IRQs */ u8 active_high_low; /* All IRQs */
u8 setonboot; u8 initialized;
u8 resource_type; u8 resource_type;
u8 possible_count; u8 possible_count;
u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE]; u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
...@@ -517,7 +518,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link* link) { ...@@ -517,7 +518,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link* link) {
ACPI_FUNCTION_TRACE("acpi_pci_link_allocate"); ACPI_FUNCTION_TRACE("acpi_pci_link_allocate");
if (link->irq.setonboot) if (link->irq.initialized)
return_VALUE(0); return_VALUE(0);
/* /*
...@@ -571,7 +572,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link* link) { ...@@ -571,7 +572,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link* link) {
acpi_device_bid(link->device), link->irq.active); acpi_device_bid(link->device), link->irq.active);
} }
link->irq.setonboot = 1; link->irq.initialized = 1;
return_VALUE(0); return_VALUE(0);
} }
...@@ -694,6 +695,42 @@ acpi_pci_link_add ( ...@@ -694,6 +695,42 @@ acpi_pci_link_add (
} }
static int
acpi_pci_link_resume (
struct acpi_pci_link *link)
{
ACPI_FUNCTION_TRACE("acpi_pci_link_resume");
if (link->irq.active && link->irq.initialized)
return_VALUE(acpi_pci_link_set(link, link->irq.active));
else
return_VALUE(0);
}
static int
irqrouter_resume(
struct sys_device *dev)
{
struct list_head *node = NULL;
struct acpi_pci_link *link = NULL;
ACPI_FUNCTION_TRACE("irqrouter_resume");
list_for_each(node, &acpi_link.entries) {
link = list_entry(node, struct acpi_pci_link, node);
if (!link) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
continue;
}
acpi_pci_link_resume(link);
}
return_VALUE(0);
}
static int static int
acpi_pci_link_remove ( acpi_pci_link_remove (
struct acpi_device *device, struct acpi_device *device,
...@@ -786,11 +823,42 @@ int __init acpi_irq_balance_set(char *str) ...@@ -786,11 +823,42 @@ int __init acpi_irq_balance_set(char *str)
__setup("acpi_irq_balance", acpi_irq_balance_set); __setup("acpi_irq_balance", acpi_irq_balance_set);
static struct sysdev_class irqrouter_sysdev_class = {
set_kset_name("irqrouter"),
.resume = irqrouter_resume,
};
static struct sys_device device_irqrouter = {
.id = 0,
.cls = &irqrouter_sysdev_class,
};
static int __init irqrouter_init_sysfs(void)
{
int error;
ACPI_FUNCTION_TRACE("irqrouter_init_sysfs");
if (acpi_disabled || acpi_noirq)
return_VALUE(0);
error = sysdev_class_register(&irqrouter_sysdev_class);
if (!error)
error = sysdev_register(&device_irqrouter);
return_VALUE(error);
}
device_initcall(irqrouter_init_sysfs);
static int __init acpi_pci_link_init (void) static int __init acpi_pci_link_init (void)
{ {
ACPI_FUNCTION_TRACE("acpi_pci_link_init"); ACPI_FUNCTION_TRACE("acpi_pci_link_init");
if (acpi_pci_disabled) if (acpi_noirq)
return_VALUE(0); return_VALUE(0);
acpi_link.count = 0; acpi_link.count = 0;
......
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