Commit e857b33d authored by Len Brown's avatar Len Brown

Merge branch 'bjorn-cleanups' into release

parents 9a38f4ee 1c48aa36
This diff is collapsed.
...@@ -319,7 +319,7 @@ static struct acpi_prt_entry *acpi_pci_irq_lookup(struct pci_dev *dev, int pin) ...@@ -319,7 +319,7 @@ static struct acpi_prt_entry *acpi_pci_irq_lookup(struct pci_dev *dev, int pin)
*/ */
bridge = dev->bus->self; bridge = dev->bus->self;
while (bridge) { while (bridge) {
pin = (((pin - 1) + PCI_SLOT(dev->devfn)) % 4) + 1; pin = pci_swizzle_interrupt_pin(dev, pin);
if ((bridge->class >> 8) == PCI_CLASS_BRIDGE_CARDBUS) { if ((bridge->class >> 8) == PCI_CLASS_BRIDGE_CARDBUS) {
/* PC card has the same IRQ as its cardbridge */ /* PC card has the same IRQ as its cardbridge */
......
...@@ -43,13 +43,14 @@ ...@@ -43,13 +43,14 @@
#include <acpi/acpi_bus.h> #include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h> #include <acpi/acpi_drivers.h>
#define _COMPONENT ACPI_PCI_COMPONENT #define _COMPONENT ACPI_PCI_COMPONENT
ACPI_MODULE_NAME("pci_link"); ACPI_MODULE_NAME("pci_link");
#define ACPI_PCI_LINK_CLASS "pci_irq_routing" #define ACPI_PCI_LINK_CLASS "pci_irq_routing"
#define ACPI_PCI_LINK_DEVICE_NAME "PCI Interrupt Link" #define ACPI_PCI_LINK_DEVICE_NAME "PCI Interrupt Link"
#define ACPI_PCI_LINK_FILE_INFO "info" #define ACPI_PCI_LINK_FILE_INFO "info"
#define ACPI_PCI_LINK_FILE_STATUS "state" #define ACPI_PCI_LINK_FILE_STATUS "state"
#define ACPI_PCI_LINK_MAX_POSSIBLE 16 #define ACPI_PCI_LINK_MAX_POSSIBLE 16
static int acpi_pci_link_add(struct acpi_device *device); static int acpi_pci_link_add(struct acpi_device *device);
static int acpi_pci_link_remove(struct acpi_device *device, int type); static int acpi_pci_link_remove(struct acpi_device *device, int type);
...@@ -66,7 +67,7 @@ static struct acpi_driver acpi_pci_link_driver = { ...@@ -66,7 +67,7 @@ static struct acpi_driver acpi_pci_link_driver = {
.ops = { .ops = {
.add = acpi_pci_link_add, .add = acpi_pci_link_add,
.remove = acpi_pci_link_remove, .remove = acpi_pci_link_remove,
}, },
}; };
/* /*
...@@ -76,7 +77,7 @@ static struct acpi_driver acpi_pci_link_driver = { ...@@ -76,7 +77,7 @@ static struct acpi_driver acpi_pci_link_driver = {
struct acpi_pci_link_irq { struct acpi_pci_link_irq {
u8 active; /* Current IRQ */ u8 active; /* Current IRQ */
u8 triggering; /* All IRQs */ u8 triggering; /* All IRQs */
u8 polarity; /* All IRQs */ u8 polarity; /* All IRQs */
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];
...@@ -85,16 +86,13 @@ struct acpi_pci_link_irq { ...@@ -85,16 +86,13 @@ struct acpi_pci_link_irq {
}; };
struct acpi_pci_link { struct acpi_pci_link {
struct list_head node; struct list_head list;
struct acpi_device *device; struct acpi_device *device;
struct acpi_pci_link_irq irq; struct acpi_pci_link_irq irq;
int refcnt; int refcnt;
}; };
static struct { static LIST_HEAD(acpi_link_list);
int count;
struct list_head entries;
} acpi_link;
static DEFINE_MUTEX(acpi_link_lock); static DEFINE_MUTEX(acpi_link_lock);
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
...@@ -104,12 +102,11 @@ static DEFINE_MUTEX(acpi_link_lock); ...@@ -104,12 +102,11 @@ static DEFINE_MUTEX(acpi_link_lock);
/* /*
* set context (link) possible list from resource list * set context (link) possible list from resource list
*/ */
static acpi_status static acpi_status acpi_pci_link_check_possible(struct acpi_resource *resource,
acpi_pci_link_check_possible(struct acpi_resource *resource, void *context) void *context)
{ {
struct acpi_pci_link *link = context; struct acpi_pci_link *link = context;
u32 i = 0; u32 i;
switch (resource->type) { switch (resource->type) {
case ACPI_RESOURCE_TYPE_START_DEPENDENT: case ACPI_RESOURCE_TYPE_START_DEPENDENT:
...@@ -179,10 +176,6 @@ static int acpi_pci_link_get_possible(struct acpi_pci_link *link) ...@@ -179,10 +176,6 @@ static int acpi_pci_link_get_possible(struct acpi_pci_link *link)
{ {
acpi_status status; acpi_status status;
if (!link)
return -EINVAL;
status = acpi_walk_resources(link->device->handle, METHOD_NAME__PRS, status = acpi_walk_resources(link->device->handle, METHOD_NAME__PRS,
acpi_pci_link_check_possible, link); acpi_pci_link_check_possible, link);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
...@@ -197,11 +190,10 @@ static int acpi_pci_link_get_possible(struct acpi_pci_link *link) ...@@ -197,11 +190,10 @@ static int acpi_pci_link_get_possible(struct acpi_pci_link *link)
return 0; return 0;
} }
static acpi_status static acpi_status acpi_pci_link_check_current(struct acpi_resource *resource,
acpi_pci_link_check_current(struct acpi_resource *resource, void *context) void *context)
{ {
int *irq = (int *)context; int *irq = context;
switch (resource->type) { switch (resource->type) {
case ACPI_RESOURCE_TYPE_START_DEPENDENT: case ACPI_RESOURCE_TYPE_START_DEPENDENT:
...@@ -258,12 +250,9 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context) ...@@ -258,12 +250,9 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
static int acpi_pci_link_get_current(struct acpi_pci_link *link) static int acpi_pci_link_get_current(struct acpi_pci_link *link)
{ {
int result = 0; int result = 0;
acpi_status status = AE_OK; acpi_status status;
int irq = 0; int irq = 0;
if (!link)
return -EINVAL;
link->irq.active = 0; link->irq.active = 0;
/* in practice, status disabled is meaningless, ignore it */ /* in practice, status disabled is meaningless, ignore it */
...@@ -308,16 +297,15 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link) ...@@ -308,16 +297,15 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
{ {
int result = 0; int result;
acpi_status status = AE_OK; acpi_status status;
struct { struct {
struct acpi_resource res; struct acpi_resource res;
struct acpi_resource end; struct acpi_resource end;
} *resource; } *resource;
struct acpi_buffer buffer = { 0, NULL }; struct acpi_buffer buffer = { 0, NULL };
if (!irq)
if (!link || !irq)
return -EINVAL; return -EINVAL;
resource = kzalloc(sizeof(*resource) + 1, irqs_disabled() ? GFP_ATOMIC: GFP_KERNEL); resource = kzalloc(sizeof(*resource) + 1, irqs_disabled() ? GFP_ATOMIC: GFP_KERNEL);
...@@ -479,30 +467,22 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = { ...@@ -479,30 +467,22 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ9 PCI, often acpi */ PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ9 PCI, often acpi */
PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ10 PCI */ PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ10 PCI */
PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ11 PCI */ PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ11 PCI */
PIRQ_PENALTY_ISA_USED, /* IRQ12 mouse */ PIRQ_PENALTY_ISA_USED, /* IRQ12 mouse */
PIRQ_PENALTY_ISA_USED, /* IRQ13 fpe, sometimes */ PIRQ_PENALTY_ISA_USED, /* IRQ13 fpe, sometimes */
PIRQ_PENALTY_ISA_USED, /* IRQ14 ide0 */ PIRQ_PENALTY_ISA_USED, /* IRQ14 ide0 */
PIRQ_PENALTY_ISA_USED, /* IRQ15 ide1 */ PIRQ_PENALTY_ISA_USED, /* IRQ15 ide1 */
/* >IRQ15 */ /* >IRQ15 */
}; };
int __init acpi_irq_penalty_init(void) int __init acpi_irq_penalty_init(void)
{ {
struct list_head *node = NULL; struct acpi_pci_link *link;
struct acpi_pci_link *link = NULL; int i;
int i = 0;
/* /*
* Update penalties to facilitate IRQ balancing. * Update penalties to facilitate IRQ balancing.
*/ */
list_for_each(node, &acpi_link.entries) { list_for_each_entry(link, &acpi_link_list, list) {
link = list_entry(node, struct acpi_pci_link, node);
if (!link) {
printk(KERN_ERR PREFIX "Invalid link context\n");
continue;
}
/* /*
* reflect the possible and active irqs in the penalty table -- * reflect the possible and active irqs in the penalty table --
...@@ -527,7 +507,6 @@ int __init acpi_irq_penalty_init(void) ...@@ -527,7 +507,6 @@ int __init acpi_irq_penalty_init(void)
} }
/* Add a penalty for the SCI */ /* Add a penalty for the SCI */
acpi_irq_penalty[acpi_gbl_FADT.sci_interrupt] += PIRQ_PENALTY_PCI_USING; acpi_irq_penalty[acpi_gbl_FADT.sci_interrupt] += PIRQ_PENALTY_PCI_USING;
return 0; return 0;
} }
...@@ -538,7 +517,6 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link) ...@@ -538,7 +517,6 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
int irq; int irq;
int i; int i;
if (link->irq.initialized) { if (link->irq.initialized) {
if (link->refcnt == 0) if (link->refcnt == 0)
/* This means the link is disabled but initialized */ /* This means the link is disabled but initialized */
...@@ -566,11 +544,10 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link) ...@@ -566,11 +544,10 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
/* /*
* if active found, use it; else pick entry from end of possible list. * if active found, use it; else pick entry from end of possible list.
*/ */
if (link->irq.active) { if (link->irq.active)
irq = link->irq.active; irq = link->irq.active;
} else { else
irq = link->irq.possible[link->irq.possible_count - 1]; irq = link->irq.possible[link->irq.possible_count - 1];
}
if (acpi_irq_balance || !link->irq.active) { if (acpi_irq_balance || !link->irq.active) {
/* /*
...@@ -599,7 +576,6 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link) ...@@ -599,7 +576,6 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
} }
link->irq.initialized = 1; link->irq.initialized = 1;
return 0; return 0;
} }
...@@ -608,16 +584,12 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link) ...@@ -608,16 +584,12 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
* success: return IRQ >= 0 * success: return IRQ >= 0
* failure: return -1 * failure: return -1
*/ */
int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *triggering,
int int *polarity, char **name)
acpi_pci_link_allocate_irq(acpi_handle handle,
int index,
int *triggering, int *polarity, char **name)
{ {
int result = 0; int result;
struct acpi_device *device = NULL; struct acpi_device *device;
struct acpi_pci_link *link = NULL; struct acpi_pci_link *link;
result = acpi_bus_get_device(handle, &device); result = acpi_bus_get_device(handle, &device);
if (result) { if (result) {
...@@ -669,11 +641,10 @@ acpi_pci_link_allocate_irq(acpi_handle handle, ...@@ -669,11 +641,10 @@ acpi_pci_link_allocate_irq(acpi_handle handle,
*/ */
int acpi_pci_link_free_irq(acpi_handle handle) int acpi_pci_link_free_irq(acpi_handle handle)
{ {
struct acpi_device *device = NULL; struct acpi_device *device;
struct acpi_pci_link *link = NULL; struct acpi_pci_link *link;
acpi_status result; acpi_status result;
result = acpi_bus_get_device(handle, &device); result = acpi_bus_get_device(handle, &device);
if (result) { if (result) {
printk(KERN_ERR PREFIX "Invalid link device\n"); printk(KERN_ERR PREFIX "Invalid link device\n");
...@@ -708,9 +679,9 @@ int acpi_pci_link_free_irq(acpi_handle handle) ...@@ -708,9 +679,9 @@ int acpi_pci_link_free_irq(acpi_handle handle)
"Link %s is dereferenced\n", "Link %s is dereferenced\n",
acpi_device_bid(link->device))); acpi_device_bid(link->device)));
if (link->refcnt == 0) { if (link->refcnt == 0)
acpi_evaluate_object(link->device->handle, "_DIS", NULL, NULL); acpi_evaluate_object(link->device->handle, "_DIS", NULL, NULL);
}
mutex_unlock(&acpi_link_lock); mutex_unlock(&acpi_link_lock);
return (link->irq.active); return (link->irq.active);
} }
...@@ -721,15 +692,11 @@ int acpi_pci_link_free_irq(acpi_handle handle) ...@@ -721,15 +692,11 @@ int acpi_pci_link_free_irq(acpi_handle handle)
static int acpi_pci_link_add(struct acpi_device *device) static int acpi_pci_link_add(struct acpi_device *device)
{ {
int result = 0; int result;
struct acpi_pci_link *link = NULL; struct acpi_pci_link *link;
int i = 0; int i;
int found = 0; int found = 0;
if (!device)
return -EINVAL;
link = kzalloc(sizeof(struct acpi_pci_link), GFP_KERNEL); link = kzalloc(sizeof(struct acpi_pci_link), GFP_KERNEL);
if (!link) if (!link)
return -ENOMEM; return -ENOMEM;
...@@ -767,9 +734,7 @@ static int acpi_pci_link_add(struct acpi_device *device) ...@@ -767,9 +734,7 @@ static int acpi_pci_link_add(struct acpi_device *device)
printk("\n"); printk("\n");
/* TBD: Acquire/release lock */ list_add_tail(&link->list, &acpi_link_list);
list_add_tail(&link->node, &acpi_link.entries);
acpi_link.count++;
end: end:
/* disable all links -- to be activated on use */ /* disable all links -- to be activated on use */
...@@ -784,24 +749,17 @@ static int acpi_pci_link_add(struct acpi_device *device) ...@@ -784,24 +749,17 @@ static int acpi_pci_link_add(struct acpi_device *device)
static int acpi_pci_link_resume(struct acpi_pci_link *link) static int acpi_pci_link_resume(struct acpi_pci_link *link)
{ {
if (link->refcnt && link->irq.active && link->irq.initialized) if (link->refcnt && link->irq.active && link->irq.initialized)
return (acpi_pci_link_set(link, link->irq.active)); return (acpi_pci_link_set(link, link->irq.active));
else
return 0; return 0;
} }
static int irqrouter_resume(struct sys_device *dev) static int irqrouter_resume(struct sys_device *dev)
{ {
struct list_head *node = NULL; struct acpi_pci_link *link;
struct acpi_pci_link *link = NULL;
list_for_each(node, &acpi_link.entries) { list_for_each_entry(link, &acpi_link_list, list) {
link = list_entry(node, struct acpi_pci_link, node);
if (!link) {
printk(KERN_ERR PREFIX "Invalid link context\n");
continue;
}
acpi_pci_link_resume(link); acpi_pci_link_resume(link);
} }
return 0; return 0;
...@@ -809,20 +767,15 @@ static int irqrouter_resume(struct sys_device *dev) ...@@ -809,20 +767,15 @@ static int irqrouter_resume(struct sys_device *dev)
static int acpi_pci_link_remove(struct acpi_device *device, int type) static int acpi_pci_link_remove(struct acpi_device *device, int type)
{ {
struct acpi_pci_link *link = NULL; struct acpi_pci_link *link;
if (!device || !acpi_driver_data(device))
return -EINVAL;
link = acpi_driver_data(device); link = acpi_driver_data(device);
mutex_lock(&acpi_link_lock); mutex_lock(&acpi_link_lock);
list_del(&link->node); list_del(&link->list);
mutex_unlock(&acpi_link_lock); mutex_unlock(&acpi_link_lock);
kfree(link); kfree(link);
return 0; return 0;
} }
...@@ -931,7 +884,6 @@ static int __init irqrouter_init_sysfs(void) ...@@ -931,7 +884,6 @@ static int __init irqrouter_init_sysfs(void)
{ {
int error; int error;
if (acpi_disabled || acpi_noirq) if (acpi_disabled || acpi_noirq)
return 0; return 0;
...@@ -957,9 +909,6 @@ static int __init acpi_pci_link_init(void) ...@@ -957,9 +909,6 @@ static int __init acpi_pci_link_init(void)
acpi_irq_balance = 0; acpi_irq_balance = 0;
} }
acpi_link.count = 0;
INIT_LIST_HEAD(&acpi_link.entries);
if (acpi_bus_register_driver(&acpi_pci_link_driver) < 0) if (acpi_bus_register_driver(&acpi_pci_link_driver) < 0)
return -ENODEV; return -ENODEV;
......
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