Commit ec9f168f authored by Len Brown's avatar Len Brown

Merge branch 'simplify_PRT' into release

Conflicts:
	drivers/acpi/pci_irq.c

Note that this merge disables
e1d3a908
pci, acpi: reroute PCI interrupt to legacy boot interrupt equivalent
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parents b2576e1d 087da3b4
...@@ -99,7 +99,7 @@ acpi_status acpi_get_pci_id(acpi_handle handle, struct acpi_pci_id *id) ...@@ -99,7 +99,7 @@ acpi_status acpi_get_pci_id(acpi_handle handle, struct acpi_pci_id *id)
*/ */
ACPI_DEBUG_PRINT((ACPI_DB_INFO, ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Device %s has PCI address %02x:%02x:%02x.%02x\n", "Device %s has PCI address %04x:%02x:%02x.%d\n",
acpi_device_bid(device), id->segment, id->bus, acpi_device_bid(device), id->segment, id->bus,
id->device, id->function)); id->device, id->function));
...@@ -111,12 +111,11 @@ EXPORT_SYMBOL(acpi_get_pci_id); ...@@ -111,12 +111,11 @@ EXPORT_SYMBOL(acpi_get_pci_id);
int acpi_pci_bind(struct acpi_device *device) int acpi_pci_bind(struct acpi_device *device)
{ {
int result = 0; int result = 0;
acpi_status status = AE_OK; acpi_status status;
struct acpi_pci_data *data = NULL; struct acpi_pci_data *data;
struct acpi_pci_data *pdata = NULL; struct acpi_pci_data *pdata;
char *pathname = NULL; struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
struct acpi_buffer buffer = { 0, NULL }; acpi_handle handle;
acpi_handle handle = NULL;
struct pci_dev *dev; struct pci_dev *dev;
struct pci_bus *bus; struct pci_bus *bus;
...@@ -124,21 +123,18 @@ int acpi_pci_bind(struct acpi_device *device) ...@@ -124,21 +123,18 @@ int acpi_pci_bind(struct acpi_device *device)
if (!device || !device->parent) if (!device || !device->parent)
return -EINVAL; return -EINVAL;
pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
if (!pathname)
return -ENOMEM;
buffer.length = ACPI_PATHNAME_MAX;
buffer.pointer = pathname;
data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
if (!data) { if (!data)
kfree(pathname);
return -ENOMEM; return -ENOMEM;
status = acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
if (ACPI_FAILURE(status)) {
kfree(data);
return -ENODEV;
} }
acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n", ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n",
pathname)); (char *)buffer.pointer));
/* /*
* Segment & Bus * Segment & Bus
...@@ -166,7 +162,7 @@ int acpi_pci_bind(struct acpi_device *device) ...@@ -166,7 +162,7 @@ int acpi_pci_bind(struct acpi_device *device)
data->id.device = device->pnp.bus_address >> 16; data->id.device = device->pnp.bus_address >> 16;
data->id.function = device->pnp.bus_address & 0xFFFF; data->id.function = device->pnp.bus_address & 0xFFFF;
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "...to %02x:%02x:%02x.%02x\n", ACPI_DEBUG_PRINT((ACPI_DB_INFO, "...to %04x:%02x:%02x.%d\n",
data->id.segment, data->id.bus, data->id.device, data->id.segment, data->id.bus, data->id.device,
data->id.function)); data->id.function));
...@@ -196,7 +192,7 @@ int acpi_pci_bind(struct acpi_device *device) ...@@ -196,7 +192,7 @@ int acpi_pci_bind(struct acpi_device *device)
} }
if (!data->dev) { if (!data->dev) {
ACPI_DEBUG_PRINT((ACPI_DB_INFO, ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Device %02x:%02x:%02x.%02x not present in PCI namespace\n", "Device %04x:%02x:%02x.%d not present in PCI namespace\n",
data->id.segment, data->id.bus, data->id.segment, data->id.bus,
data->id.device, data->id.function)); data->id.device, data->id.function));
result = -ENODEV; result = -ENODEV;
...@@ -204,7 +200,7 @@ int acpi_pci_bind(struct acpi_device *device) ...@@ -204,7 +200,7 @@ int acpi_pci_bind(struct acpi_device *device)
} }
if (!data->dev->bus) { if (!data->dev->bus) {
printk(KERN_ERR PREFIX printk(KERN_ERR PREFIX
"Device %02x:%02x:%02x.%02x has invalid 'bus' field\n", "Device %04x:%02x:%02x.%d has invalid 'bus' field\n",
data->id.segment, data->id.bus, data->id.segment, data->id.bus,
data->id.device, data->id.function); data->id.device, data->id.function);
result = -ENODEV; result = -ENODEV;
...@@ -219,7 +215,7 @@ int acpi_pci_bind(struct acpi_device *device) ...@@ -219,7 +215,7 @@ int acpi_pci_bind(struct acpi_device *device)
*/ */
if (data->dev->subordinate) { if (data->dev->subordinate) {
ACPI_DEBUG_PRINT((ACPI_DB_INFO, ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Device %02x:%02x:%02x.%02x is a PCI bridge\n", "Device %04x:%02x:%02x.%d is a PCI bridge\n",
data->id.segment, data->id.bus, data->id.segment, data->id.bus,
data->id.device, data->id.function)); data->id.device, data->id.function));
data->bus = data->dev->subordinate; data->bus = data->dev->subordinate;
...@@ -262,7 +258,7 @@ int acpi_pci_bind(struct acpi_device *device) ...@@ -262,7 +258,7 @@ int acpi_pci_bind(struct acpi_device *device)
} }
end: end:
kfree(pathname); kfree(buffer.pointer);
if (result) if (result)
kfree(data); kfree(data);
...@@ -272,25 +268,21 @@ int acpi_pci_bind(struct acpi_device *device) ...@@ -272,25 +268,21 @@ int acpi_pci_bind(struct acpi_device *device)
static int acpi_pci_unbind(struct acpi_device *device) static int acpi_pci_unbind(struct acpi_device *device)
{ {
int result = 0; int result = 0;
acpi_status status = AE_OK; acpi_status status;
struct acpi_pci_data *data = NULL; struct acpi_pci_data *data;
char *pathname = NULL; struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
struct acpi_buffer buffer = { 0, NULL };
if (!device || !device->parent) if (!device || !device->parent)
return -EINVAL; return -EINVAL;
pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); status = acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
if (!pathname) if (ACPI_FAILURE(status))
return -ENOMEM; return -ENODEV;
buffer.length = ACPI_PATHNAME_MAX;
buffer.pointer = pathname;
acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unbinding PCI device [%s]...\n", ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unbinding PCI device [%s]...\n",
pathname)); (char *) buffer.pointer));
kfree(pathname); kfree(buffer.pointer);
status = status =
acpi_get_data(device->handle, acpi_pci_data_handler, acpi_get_data(device->handle, acpi_pci_data_handler,
...@@ -322,50 +314,44 @@ acpi_pci_bind_root(struct acpi_device *device, ...@@ -322,50 +314,44 @@ acpi_pci_bind_root(struct acpi_device *device,
struct acpi_pci_id *id, struct pci_bus *bus) struct acpi_pci_id *id, struct pci_bus *bus)
{ {
int result = 0; int result = 0;
acpi_status status = AE_OK; acpi_status status;
struct acpi_pci_data *data = NULL; struct acpi_pci_data *data = NULL;
char *pathname = NULL; struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
struct acpi_buffer buffer = { 0, NULL };
pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
if (!pathname)
return -ENOMEM;
buffer.length = ACPI_PATHNAME_MAX;
buffer.pointer = pathname;
if (!device || !id || !bus) { if (!device || !id || !bus) {
kfree(pathname);
return -EINVAL; return -EINVAL;
} }
data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
if (!data) { if (!data)
kfree(pathname);
return -ENOMEM; return -ENOMEM;
}
data->id = *id; data->id = *id;
data->bus = bus; data->bus = bus;
device->ops.bind = acpi_pci_bind; device->ops.bind = acpi_pci_bind;
device->ops.unbind = acpi_pci_unbind; device->ops.unbind = acpi_pci_unbind;
acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); status = acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
if (ACPI_FAILURE(status)) {
kfree (data);
return -ENODEV;
}
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI root bridge [%s] to " ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI root bridge [%s] to "
"%02x:%02x\n", pathname, id->segment, id->bus)); "%04x:%02x\n", (char *)buffer.pointer,
id->segment, id->bus));
status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, ACPI_EXCEPTION((AE_INFO, status,
"Unable to attach ACPI-PCI context to device %s", "Unable to attach ACPI-PCI context to device %s",
pathname)); (char *)buffer.pointer));
result = -ENODEV; result = -ENODEV;
goto end; goto end;
} }
end: end:
kfree(pathname); kfree(buffer.pointer);
if (result != 0) if (result != 0)
kfree(data); kfree(data);
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
* Copyright (C) 2002 Dominik Brodowski <devel@brodo.de> * Copyright (C) 2002 Dominik Brodowski <devel@brodo.de>
* (c) Copyright 2008 Hewlett-Packard Development Company, L.P.
* Bjorn Helgaas <bjorn.helgaas@hp.com>
* *
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* *
...@@ -41,29 +43,36 @@ ...@@ -41,29 +43,36 @@
#define _COMPONENT ACPI_PCI_COMPONENT #define _COMPONENT ACPI_PCI_COMPONENT
ACPI_MODULE_NAME("pci_irq"); ACPI_MODULE_NAME("pci_irq");
static struct acpi_prt_list acpi_prt; struct acpi_prt_entry {
struct list_head list;
struct acpi_pci_id id;
u8 pin;
acpi_handle link;
u32 index; /* GSI, or link _CRS index */
};
static LIST_HEAD(acpi_prt_list);
static DEFINE_SPINLOCK(acpi_prt_lock); static DEFINE_SPINLOCK(acpi_prt_lock);
static inline char pin_name(int pin)
{
return 'A' + pin - 1;
}
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
PCI IRQ Routing Table (PRT) Support PCI IRQ Routing Table (PRT) Support
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment, static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(struct pci_dev *dev,
int bus, int pin)
int device, int pin)
{ {
struct acpi_prt_entry *entry = NULL; struct acpi_prt_entry *entry;
int segment = pci_domain_nr(dev->bus);
if (!acpi_prt.count) int bus = dev->bus->number;
return NULL; int device = PCI_SLOT(dev->devfn);
/*
* Parse through all PRT entries looking for a match on the specified
* PCI device's segment, bus, device, and pin (don't care about func).
*
*/
spin_lock(&acpi_prt_lock); spin_lock(&acpi_prt_lock);
list_for_each_entry(entry, &acpi_prt.entries, node) { list_for_each_entry(entry, &acpi_prt_list, list) {
if ((segment == entry->id.segment) if ((segment == entry->id.segment)
&& (bus == entry->id.bus) && (bus == entry->id.bus)
&& (device == entry->id.device) && (device == entry->id.device)
...@@ -72,7 +81,6 @@ static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment, ...@@ -72,7 +81,6 @@ static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment,
return entry; return entry;
} }
} }
spin_unlock(&acpi_prt_lock); spin_unlock(&acpi_prt_lock);
return NULL; return NULL;
} }
...@@ -124,25 +132,27 @@ struct prt_quirk { ...@@ -124,25 +132,27 @@ struct prt_quirk {
char *actual_source; char *actual_source;
}; };
#define PCI_INTX_PIN(c) (c - 'A' + 1)
/* /*
* These systems have incorrect _PRT entries. The BIOS claims the PCI * These systems have incorrect _PRT entries. The BIOS claims the PCI
* interrupt at the listed segment/bus/device/pin is connected to the first * interrupt at the listed segment/bus/device/pin is connected to the first
* link device, but it is actually connected to the second. * link device, but it is actually connected to the second.
*/ */
static struct prt_quirk prt_quirks[] = { static struct prt_quirk prt_quirks[] = {
{ medion_md9580, 0, 0, 9, 'A', { medion_md9580, 0, 0, 9, PCI_INTX_PIN('A'),
"\\_SB_.PCI0.ISA_.LNKA", "\\_SB_.PCI0.ISA_.LNKA",
"\\_SB_.PCI0.ISA_.LNKB"}, "\\_SB_.PCI0.ISA_.LNKB"},
{ dell_optiplex, 0, 0, 0xd, 'A', { dell_optiplex, 0, 0, 0xd, PCI_INTX_PIN('A'),
"\\_SB_.LNKB", "\\_SB_.LNKB",
"\\_SB_.LNKA"}, "\\_SB_.LNKA"},
{ hp_t5710, 0, 0, 1, 'A', { hp_t5710, 0, 0, 1, PCI_INTX_PIN('A'),
"\\_SB_.PCI0.LNK1", "\\_SB_.PCI0.LNK1",
"\\_SB_.PCI0.LNK3"}, "\\_SB_.PCI0.LNK3"},
}; };
static void static void do_prt_fixups(struct acpi_prt_entry *entry,
do_prt_fixups(struct acpi_prt_entry *entry, struct acpi_pci_routing_table *prt) struct acpi_pci_routing_table *prt)
{ {
int i; int i;
struct prt_quirk *quirk; struct prt_quirk *quirk;
...@@ -158,42 +168,43 @@ do_prt_fixups(struct acpi_prt_entry *entry, struct acpi_pci_routing_table *prt) ...@@ -158,42 +168,43 @@ do_prt_fixups(struct acpi_prt_entry *entry, struct acpi_pci_routing_table *prt)
entry->id.segment == quirk->segment && entry->id.segment == quirk->segment &&
entry->id.bus == quirk->bus && entry->id.bus == quirk->bus &&
entry->id.device == quirk->device && entry->id.device == quirk->device &&
entry->pin + 'A' == quirk->pin && entry->pin == quirk->pin &&
!strcmp(prt->source, quirk->source) && !strcmp(prt->source, quirk->source) &&
strlen(prt->source) >= strlen(quirk->actual_source)) { strlen(prt->source) >= strlen(quirk->actual_source)) {
printk(KERN_WARNING PREFIX "firmware reports " printk(KERN_WARNING PREFIX "firmware reports "
"%04x:%02x:%02x PCI INT %c connected to %s; " "%04x:%02x:%02x PCI INT %c connected to %s; "
"changing to %s\n", "changing to %s\n",
entry->id.segment, entry->id.bus, entry->id.segment, entry->id.bus,
entry->id.device, 'A' + entry->pin, entry->id.device, pin_name(entry->pin),
prt->source, quirk->actual_source); prt->source, quirk->actual_source);
strcpy(prt->source, quirk->actual_source); strcpy(prt->source, quirk->actual_source);
} }
} }
} }
static int static int acpi_pci_irq_add_entry(acpi_handle handle, int segment, int bus,
acpi_pci_irq_add_entry(acpi_handle handle, struct acpi_pci_routing_table *prt)
int segment, int bus, struct acpi_pci_routing_table *prt)
{ {
struct acpi_prt_entry *entry = NULL; struct acpi_prt_entry *entry;
if (!prt)
return -EINVAL;
entry = kzalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL); entry = kzalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL);
if (!entry) if (!entry)
return -ENOMEM; return -ENOMEM;
/*
* Note that the _PRT uses 0=INTA, 1=INTB, etc, while PCI uses
* 1=INTA, 2=INTB. We use the PCI encoding throughout, so convert
* it here.
*/
entry->id.segment = segment; entry->id.segment = segment;
entry->id.bus = bus; entry->id.bus = bus;
entry->id.device = (prt->address >> 16) & 0xFFFF; entry->id.device = (prt->address >> 16) & 0xFFFF;
entry->id.function = prt->address & 0xFFFF; entry->pin = prt->pin + 1;
entry->pin = prt->pin;
do_prt_fixups(entry, prt); do_prt_fixups(entry, prt);
entry->index = prt->source_index;
/* /*
* Type 1: Dynamic * Type 1: Dynamic
* --------------- * ---------------
...@@ -207,10 +218,9 @@ acpi_pci_irq_add_entry(acpi_handle handle, ...@@ -207,10 +218,9 @@ acpi_pci_irq_add_entry(acpi_handle handle,
* (e.g. exists somewhere 'below' this _PRT entry in the ACPI * (e.g. exists somewhere 'below' this _PRT entry in the ACPI
* namespace). * namespace).
*/ */
if (prt->source[0]) { if (prt->source[0])
acpi_get_handle(handle, prt->source, &entry->link.handle); acpi_get_handle(handle, prt->source, &entry->link);
entry->link.index = prt->source_index;
}
/* /*
* Type 2: Static * Type 2: Static
* -------------- * --------------
...@@ -218,84 +228,38 @@ acpi_pci_irq_add_entry(acpi_handle handle, ...@@ -218,84 +228,38 @@ acpi_pci_irq_add_entry(acpi_handle handle,
* the IRQ value, which is hardwired to specific interrupt inputs on * the IRQ value, which is hardwired to specific interrupt inputs on
* the interrupt controller. * the interrupt controller.
*/ */
else
entry->link.index = prt->source_index;
ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO, ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO,
" %02X:%02X:%02X[%c] -> %s[%d]\n", " %04x:%02x:%02x[%c] -> %s[%d]\n",
entry->id.segment, entry->id.bus, entry->id.segment, entry->id.bus,
entry->id.device, ('A' + entry->pin), prt->source, entry->id.device, pin_name(entry->pin),
entry->link.index)); prt->source, entry->index));
spin_lock(&acpi_prt_lock); spin_lock(&acpi_prt_lock);
list_add_tail(&entry->node, &acpi_prt.entries); list_add_tail(&entry->list, &acpi_prt_list);
acpi_prt.count++;
spin_unlock(&acpi_prt_lock); spin_unlock(&acpi_prt_lock);
return 0; return 0;
} }
static void
acpi_pci_irq_del_entry(int segment, int bus, struct acpi_prt_entry *entry)
{
if (segment == entry->id.segment && bus == entry->id.bus) {
acpi_prt.count--;
list_del(&entry->node);
kfree(entry);
}
}
int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
{ {
acpi_status status = AE_OK; acpi_status status;
char *pathname = NULL; struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
struct acpi_buffer buffer = { 0, NULL }; struct acpi_pci_routing_table *entry;
struct acpi_pci_routing_table *prt = NULL;
struct acpi_pci_routing_table *entry = NULL;
static int first_time = 1;
pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
if (!pathname)
return -ENOMEM;
if (first_time) {
acpi_prt.count = 0;
INIT_LIST_HEAD(&acpi_prt.entries);
first_time = 0;
}
/*
* NOTE: We're given a 'handle' to the _PRT object's parent device
* (either a PCI root bridge or PCI-PCI bridge).
*/
buffer.length = ACPI_PATHNAME_MAX; /* 'handle' is the _PRT's parent (root bridge or PCI-PCI bridge) */
buffer.pointer = pathname; status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); if (ACPI_FAILURE(status))
return -ENODEV;
printk(KERN_DEBUG "ACPI: PCI Interrupt Routing Table [%s._PRT]\n", printk(KERN_DEBUG "ACPI: PCI Interrupt Routing Table [%s._PRT]\n",
pathname); (char *) buffer.pointer);
/* kfree(buffer.pointer);
* Evaluate this _PRT and add its entries to our global list (acpi_prt).
*/
buffer.length = 0; buffer.length = ACPI_ALLOCATE_BUFFER;
buffer.pointer = NULL; buffer.pointer = NULL;
kfree(pathname);
status = acpi_get_irq_routing_table(handle, &buffer);
if (status != AE_BUFFER_OVERFLOW) {
ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]",
acpi_format_exception(status)));
return -ENODEV;
}
prt = kzalloc(buffer.length, GFP_KERNEL);
if (!prt) {
return -ENOMEM;
}
buffer.pointer = prt;
status = acpi_get_irq_routing_table(handle, &buffer); status = acpi_get_irq_routing_table(handle, &buffer);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
...@@ -305,36 +269,30 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) ...@@ -305,36 +269,30 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
return -ENODEV; return -ENODEV;
} }
entry = prt; entry = buffer.pointer;
while (entry && (entry->length > 0)) { while (entry && (entry->length > 0)) {
acpi_pci_irq_add_entry(handle, segment, bus, entry); acpi_pci_irq_add_entry(handle, segment, bus, entry);
entry = (struct acpi_pci_routing_table *) entry = (struct acpi_pci_routing_table *)
((unsigned long)entry + entry->length); ((unsigned long)entry + entry->length);
} }
kfree(prt); kfree(buffer.pointer);
return 0; return 0;
} }
void acpi_pci_irq_del_prt(int segment, int bus) void acpi_pci_irq_del_prt(int segment, int bus)
{ {
struct list_head *node = NULL, *n = NULL; struct acpi_prt_entry *entry, *tmp;
struct acpi_prt_entry *entry = NULL;
if (!acpi_prt.count) {
return;
}
printk(KERN_DEBUG printk(KERN_DEBUG
"ACPI: Delete PCI Interrupt Routing Table for %x:%x\n", segment, "ACPI: Delete PCI Interrupt Routing Table for %04x:%02x\n",
bus); segment, bus);
spin_lock(&acpi_prt_lock); spin_lock(&acpi_prt_lock);
list_for_each_safe(node, n, &acpi_prt.entries) { list_for_each_entry_safe(entry, tmp, &acpi_prt_list, list) {
entry = list_entry(node, struct acpi_prt_entry, node); if (segment == entry->id.segment && bus == entry->id.bus) {
list_del(&entry->list);
acpi_pci_irq_del_entry(segment, bus, entry); kfree(entry);
}
} }
spin_unlock(&acpi_prt_lock); spin_unlock(&acpi_prt_lock);
} }
...@@ -342,162 +300,26 @@ void acpi_pci_irq_del_prt(int segment, int bus) ...@@ -342,162 +300,26 @@ void acpi_pci_irq_del_prt(int segment, int bus)
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
PCI Interrupt Routing Support PCI Interrupt Routing Support
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
typedef int (*irq_lookup_func) (struct acpi_prt_entry *, int *, int *, char **); static struct acpi_prt_entry *acpi_pci_irq_lookup(struct pci_dev *dev, int pin)
static int
acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
int *triggering, int *polarity, char **link)
{
int irq;
if (entry->link.handle) {
irq = acpi_pci_link_allocate_irq(entry->link.handle,
entry->link.index, triggering,
polarity, link);
if (irq < 0) {
printk(KERN_WARNING PREFIX
"Invalid IRQ link routing entry\n");
return -1;
}
} else {
irq = entry->link.index;
*triggering = ACPI_LEVEL_SENSITIVE;
*polarity = ACPI_ACTIVE_LOW;
}
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq));
return irq;
}
static int
acpi_pci_free_irq(struct acpi_prt_entry *entry,
int *triggering, int *polarity, char **link)
{
int irq;
if (entry->link.handle) {
irq = acpi_pci_link_free_irq(entry->link.handle);
} else {
irq = entry->link.index;
}
return irq;
}
#ifdef CONFIG_X86_IO_APIC
extern int noioapicquirk;
static int bridge_has_boot_interrupt_variant(struct pci_bus *bus)
{ {
struct pci_bus *bus_it; struct acpi_prt_entry *entry;
struct pci_dev *bridge;
for (bus_it = bus ; bus_it ; bus_it = bus_it->parent) { u8 bridge_pin, orig_pin = pin;
if (!bus_it->self)
return 0; entry = acpi_pci_irq_find_prt_entry(dev, pin);
if (entry) {
printk(KERN_INFO "vendor=%04x device=%04x\n", bus_it->self->vendor, ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %s[%c] _PRT entry\n",
bus_it->self->device); pci_name(dev), pin_name(pin)));
return entry;
if (bus_it->self->irq_reroute_variant)
return bus_it->self->irq_reroute_variant;
}
return 0;
}
#endif /* CONFIG_X86_IO_APIC */
/*
* acpi_pci_irq_lookup
* success: return IRQ >= 0
* failure: return -1
*/
static int
acpi_pci_irq_lookup(struct pci_bus *bus,
int device,
int pin,
int *triggering,
int *polarity, char **link, irq_lookup_func func)
{
struct acpi_prt_entry *entry = NULL;
int segment = pci_domain_nr(bus);
int bus_nr = bus->number;
int ret;
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Searching for PRT entry for %02x:%02x:%02x[%c]\n",
segment, bus_nr, device, ('A' + pin)));
entry = acpi_pci_irq_find_prt_entry(segment, bus_nr, device, pin);
if (!entry) {
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "PRT entry not found\n"));
return -1;
}
ret = func(entry, triggering, polarity, link);
#ifdef CONFIG_X86_IO_APIC
/*
* Some chipsets (e.g. intel 6700PXH) generate a legacy INTx when the
* IRQ entry in the chipset's IO-APIC is masked (as, e.g. the RT kernel
* does during interrupt handling). When this INTx generation cannot be
* disabled, we reroute these interrupts to their legacy equivalent to
* get rid of spurious interrupts.
*/
if (!noioapicquirk) {
switch (bridge_has_boot_interrupt_variant(bus)) {
case 0:
/* no rerouting necessary */
break;
case INTEL_IRQ_REROUTE_VARIANT:
/*
* Remap according to INTx routing table in 6700PXH
* specs, intel order number 302628-002, section
* 2.15.2. Other chipsets (80332, ...) have the same
* mapping and are handled here as well.
*/
printk(KERN_INFO "pci irq %d -> rerouted to legacy "
"irq %d\n", ret, (ret % 4) + 16);
ret = (ret % 4) + 16;
break;
default:
printk(KERN_INFO "not rerouting irq %d to legacy irq: "
"unknown mapping\n", ret);
break;
}
} }
#endif /* CONFIG_X86_IO_APIC */
return ret;
}
/*
* acpi_pci_irq_derive
* success: return IRQ >= 0
* failure: return < 0
*/
static int
acpi_pci_irq_derive(struct pci_dev *dev,
int pin,
int *triggering,
int *polarity, char **link, irq_lookup_func func)
{
struct pci_dev *bridge = dev;
int irq = -1;
u8 bridge_pin = 0, orig_pin = pin;
if (!dev)
return -EINVAL;
/* /*
* Attempt to derive an IRQ for this device from a parent bridge's * Attempt to derive an IRQ for this device from a parent bridge's
* PCI interrupt routing entry (eg. yenta bridge and add-in card bridge). * PCI interrupt routing entry (eg. yenta bridge and add-in card bridge).
*/ */
while (irq < 0 && bridge->bus->self) { bridge = dev->bus->self;
pin = (pin + PCI_SLOT(bridge->devfn)) % 4; while (bridge) {
bridge = bridge->bus->self; pin = (((pin - 1) + PCI_SLOT(dev->devfn)) % 4) + 1;
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 */
...@@ -506,50 +328,40 @@ acpi_pci_irq_derive(struct pci_dev *dev, ...@@ -506,50 +328,40 @@ acpi_pci_irq_derive(struct pci_dev *dev,
ACPI_DEBUG_PRINT((ACPI_DB_INFO, ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"No interrupt pin configured for device %s\n", "No interrupt pin configured for device %s\n",
pci_name(bridge))); pci_name(bridge)));
return -1; return NULL;
} }
/* Pin is from 0 to 3 */
bridge_pin--;
pin = bridge_pin; pin = bridge_pin;
} }
irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn), entry = acpi_pci_irq_find_prt_entry(bridge, pin);
pin, triggering, polarity, if (entry) {
link, func); ACPI_DEBUG_PRINT((ACPI_DB_INFO,
} "Derived GSI for %s INT %c from %s\n",
pci_name(dev), pin_name(orig_pin),
pci_name(bridge)));
return entry;
}
if (irq < 0) { dev = bridge;
dev_warn(&dev->dev, "can't derive routing for PCI INT %c\n", bridge = dev->bus->self;
'A' + orig_pin);
return -1;
} }
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Derive IRQ %d for device %s from %s\n", dev_warn(&dev->dev, "can't derive routing for PCI INT %c\n",
irq, pci_name(dev), pci_name(bridge))); pin_name(orig_pin));
return NULL;
return irq;
} }
/*
* acpi_pci_irq_enable
* success: return 0
* failure: return < 0
*/
int acpi_pci_irq_enable(struct pci_dev *dev) int acpi_pci_irq_enable(struct pci_dev *dev)
{ {
int irq = 0; struct acpi_prt_entry *entry;
u8 pin = 0; int gsi;
u8 pin;
int triggering = ACPI_LEVEL_SENSITIVE; int triggering = ACPI_LEVEL_SENSITIVE;
int polarity = ACPI_ACTIVE_LOW; int polarity = ACPI_ACTIVE_LOW;
char *link = NULL; char *link = NULL;
char link_desc[16]; char link_desc[16];
int rc; int rc;
if (!dev)
return -EINVAL;
pin = dev->pin; pin = dev->pin;
if (!pin) { if (!pin) {
ACPI_DEBUG_PRINT((ACPI_DB_INFO, ACPI_DEBUG_PRINT((ACPI_DB_INFO,
...@@ -557,31 +369,9 @@ int acpi_pci_irq_enable(struct pci_dev *dev) ...@@ -557,31 +369,9 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
pci_name(dev))); pci_name(dev)));
return 0; return 0;
} }
pin--;
if (!dev->bus) {
dev_err(&dev->dev, "invalid (NULL) 'bus' field\n");
return -ENODEV;
}
/*
* First we check the PCI IRQ routing table (PRT) for an IRQ. PRT
* values override any BIOS-assigned IRQs set during boot.
*/
irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
&triggering, &polarity, &link,
acpi_pci_allocate_irq);
/*
* If no PRT entry was found, we'll try to derive an IRQ from the
* device's parent bridge.
*/
if (irq < 0)
irq = acpi_pci_irq_derive(dev, pin, &triggering,
&polarity, &link,
acpi_pci_allocate_irq);
if (irq < 0) { entry = acpi_pci_irq_lookup(dev, pin);
if (!entry) {
/* /*
* IDE legacy mode controller IRQs are magic. Why do compat * IDE legacy mode controller IRQs are magic. Why do compat
* extensions always make such a nasty mess. * extensions always make such a nasty mess.
...@@ -590,12 +380,24 @@ int acpi_pci_irq_enable(struct pci_dev *dev) ...@@ -590,12 +380,24 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
(dev->class & 0x05) == 0) (dev->class & 0x05) == 0)
return 0; return 0;
} }
if (entry) {
if (entry->link)
gsi = acpi_pci_link_allocate_irq(entry->link,
entry->index,
&triggering, &polarity,
&link);
else
gsi = entry->index;
} else
gsi = -1;
/* /*
* No IRQ known to the ACPI subsystem - maybe the BIOS / * No IRQ known to the ACPI subsystem - maybe the BIOS /
* driver reported one, then use it. Exit in any case. * driver reported one, then use it. Exit in any case.
*/ */
if (irq < 0) { if (gsi < 0) {
dev_warn(&dev->dev, "PCI INT %c: no GSI", 'A' + pin); dev_warn(&dev->dev, "PCI INT %c: no GSI", pin_name(pin));
/* Interrupt Line values above 0xF are forbidden */ /* Interrupt Line values above 0xF are forbidden */
if (dev->irq > 0 && (dev->irq <= 0xF)) { if (dev->irq > 0 && (dev->irq <= 0xF)) {
printk(" - using IRQ %d\n", dev->irq); printk(" - using IRQ %d\n", dev->irq);
...@@ -608,10 +410,10 @@ int acpi_pci_irq_enable(struct pci_dev *dev) ...@@ -608,10 +410,10 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
} }
} }
rc = acpi_register_gsi(irq, triggering, polarity); rc = acpi_register_gsi(gsi, triggering, polarity);
if (rc < 0) { if (rc < 0) {
dev_warn(&dev->dev, "PCI INT %c: failed to register GSI\n", dev_warn(&dev->dev, "PCI INT %c: failed to register GSI\n",
'A' + pin); pin_name(pin));
return rc; return rc;
} }
dev->irq = rc; dev->irq = rc;
...@@ -622,7 +424,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev) ...@@ -622,7 +424,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
link_desc[0] = '\0'; link_desc[0] = '\0';
dev_info(&dev->dev, "PCI INT %c%s -> GSI %u (%s, %s) -> IRQ %d\n", dev_info(&dev->dev, "PCI INT %c%s -> GSI %u (%s, %s) -> IRQ %d\n",
'A' + pin, link_desc, irq, pin_name(pin), link_desc, gsi,
(triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge",
(polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq); (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq);
...@@ -636,42 +438,28 @@ void __attribute__ ((weak)) acpi_unregister_gsi(u32 i) ...@@ -636,42 +438,28 @@ void __attribute__ ((weak)) acpi_unregister_gsi(u32 i)
void acpi_pci_irq_disable(struct pci_dev *dev) void acpi_pci_irq_disable(struct pci_dev *dev)
{ {
int gsi = 0; struct acpi_prt_entry *entry;
u8 pin = 0; int gsi;
int triggering = ACPI_LEVEL_SENSITIVE; u8 pin;
int polarity = ACPI_ACTIVE_LOW;
if (!dev || !dev->bus)
return;
pin = dev->pin; pin = dev->pin;
if (!pin) if (!pin)
return; return;
pin--;
/* entry = acpi_pci_irq_lookup(dev, pin);
* First we check the PCI IRQ routing table (PRT) for an IRQ. if (!entry)
*/
gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
&triggering, &polarity, NULL,
acpi_pci_free_irq);
/*
* If no PRT entry was found, we'll try to derive an IRQ from the
* device's parent bridge.
*/
if (gsi < 0)
gsi = acpi_pci_irq_derive(dev, pin,
&triggering, &polarity, NULL,
acpi_pci_free_irq);
if (gsi < 0)
return; return;
if (entry->link)
gsi = acpi_pci_link_free_irq(entry->link);
else
gsi = entry->index;
/* /*
* TBD: It might be worth clearing dev->irq by magic constant * TBD: It might be worth clearing dev->irq by magic constant
* (e.g. PCI_UNDEFINED_IRQ). * (e.g. PCI_UNDEFINED_IRQ).
*/ */
dev_info(&dev->dev, "PCI INT %c disabled\n", 'A' + pin); dev_info(&dev->dev, "PCI INT %c disabled\n", pin_name(pin));
acpi_unregister_gsi(gsi); acpi_unregister_gsi(gsi);
} }
...@@ -71,9 +71,6 @@ ...@@ -71,9 +71,6 @@
#define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol); #define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol);
#define strtoul simple_strtoul #define strtoul simple_strtoul
/* Full namespace pathname length limit - arbitrary */
#define ACPI_PATHNAME_MAX 256
#else /* !__KERNEL__ */ #else /* !__KERNEL__ */
#include <stdarg.h> #include <stdarg.h>
......
...@@ -131,22 +131,6 @@ extern int acpi_get_override_irq(int bus_irq, int *trigger, int *polarity); ...@@ -131,22 +131,6 @@ extern int acpi_get_override_irq(int bus_irq, int *trigger, int *polarity);
*/ */
void acpi_unregister_gsi (u32 gsi); void acpi_unregister_gsi (u32 gsi);
struct acpi_prt_entry {
struct list_head node;
struct acpi_pci_id id;
u8 pin;
struct {
acpi_handle handle;
u32 index;
} link;
u32 irq;
};
struct acpi_prt_list {
int count;
struct list_head entries;
};
struct pci_dev; struct pci_dev;
int acpi_pci_irq_enable (struct pci_dev *dev); int acpi_pci_irq_enable (struct pci_dev *dev);
......
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