i386 PCI IRQ parameters patch #3
Subsystems (3)
Hi, this is the next in my iteration of PCI IRQ parameters patches.
This one adds:
1) Correct setting of IRQ parameters
2) Enforces strict checks during ACPI-based PCI link device setup. If anything odd is found, it aborts ACPI-based IRQ routing (drops back to the default strategy).
Basically, there are several calls used during pci link setup which I'm now checking for failure on:
I'm now calling acpi_pci_link_get_current() before calling _SRS from pci_link.c/acpi_pci_link_set(). This is to check if the ACPI has somehow disabled a device, but not assigned it an IRQ.... (pci_link_get_current() already returns an error in this case). Now, for some BIOSes, this may work fine, but for others (e.g. Jurriaan's KT400 board), this is the only warning we get that ACPI-based routing is duff. Probably best to play it safe.
I've enforced the check in pci_link.c/acpi_pci_link_check() so that if the IRQ that was set is not the IRQ that was requested ACPI-based IRQ routing is aborted.
Oh, it also prints a nice error message warning about a potential buggy BIOS so we can track down problem boards from user feedback.
I also had experimented with trying to reprogram any IRQs I setup before detecting a problem... but on my board, this proved impossible.
So with this patch, it should detect more buggy BIOSes, and drop back to non-ACPI routing if it finds one.
I agree that these buggy boards should be blacklisted, but from the user's point of view, thats kinda after the fact if their board is not yet in the list; its already crashed for "mysterious" reasons.
arch/i386/kernel/io_apic.c +9 -5
@@ -2313,7 +2313,7 @@ } -int io_apic_set_pci_routing (int ioapic,int pin,int irq) +int io_apic_set_pci_routing (int ioapic,int pin,int irq,int edge_level,int active_high_low) {struct IO_APIC_route_entry entry;unsigned long flags;
@@ -2336,18 +2336,22 @@ entry.dest_mode =INT_DEST_MODE ; entry.dest.logical.logical_dest =cpu_mask_to_apicid (TARGET_CPUS ); entry.mask =1 ;/* Disabled (masked) */ - entry.trigger =1 ;/* Level sensitive */ - entry.polarity =1 ;/* Low active */ + entry.trigger = edge_level; + entry.polarity = active_high_low;add_pin_to_irq (irq, ioapic, pin); entry.vector =assign_irq_vector (irq);printk (KERN_DEBUG "IOAPIC[%d]: Set PCI routing entry (%d-%d -> 0x%x -> " -"IRQ %d)\n" , ioapic, - mp_ioapics[ioapic].mpc_apicid, pin, entry.vector, irq); +"IRQ %d Mode:%i Active:%i)\n" , ioapic, + mp_ioapics[ioapic].mpc_apicid, pin, entry.vector, irq, edge_level, active_high_low); +if (edge_level) { irq_desc[irq].handler = &ioapic_level_irq_type; + }else { + irq_desc[irq].handler = &ioapic_edge_irq_type; + }set_intr_gate (entry.vector, interrupt[irq]);
arch/i386/kernel/mpparse.c +5 -3
@@ -1065,7 +1065,7 @@ ioapic_pin = irq - mp_ioapic_routing[ioapic].irq_start; - io_apic_set_pci_routing(ioapic, ioapic_pin, irq); + io_apic_set_pci_routing(ioapic, ioapic_pin, irq, 1, 1); // Active low, edge triggered }#endif /*CONFIG_ACPI_HT_ONLY*/
@@ -1080,6 +1080,8 @@int ioapic_pin =0 ;int irq =0 ;int idx, bit =0 ; +int edge_level =0 ; +int active_high_low =0 ;/* * Parsing through the PCI Interrupt Routing Table (PRT) and program
@@ -1090,7 +1092,7 @@/* Need to get irq for dynamic entry */ if (entry->link.handle) { - irq =acpi_pci_link_get_irq (entry->link.handle, entry->link.index); + irq =acpi_pci_link_get_irq (entry->link.handle, entry->link.index, &edge_level, &active_high_low);if (!irq)continue ; }
@@ -1130,7 +1132,7 @@ mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1 <<bit); -if (!io_apic_set_pci_routing (ioapic, ioapic_pin, irq)) +if (!io_apic_set_pci_routing (ioapic, ioapic_pin, irq, edge_level, active_high_low)) entry->irq = irq; printk(KERN_DEBUG "%02x:%02x:%02x[%c] -> %d-%d -> IRQ %d\n",
drivers/acpi/pci_irq.c +4 -2
@@ -249,7 +249,7 @@ }if (!entry->irq && entry->link.handle) { - entry->irq =acpi_pci_link_get_irq (entry->link.handle, entry->link.index); + entry->irq =acpi_pci_link_get_irq (entry->link.handle, entry->link.index,NULL ,NULL );if (!entry->irq) {ACPI_DEBUG_PRINT ((ACPI_DB_WARN ,"Invalid IRQ link routing entry\n" ));return_VALUE (0 );
@@ -389,7 +389,9 @@ }/* Make sure all link devices have a valid IRQ. */ -acpi_pci_link_check (); +if (acpi_pci_link_check ()) { +return_VALUE (-ENODEV ); + }#ifdef CONFIG_X86_IO_APIC /* Program IOAPICs using data from PRT entries. */
drivers/acpi/pci_link.c +34 -9
106 lines not on this page · raw message
include/acpi/acpi_drivers.h +1 -1
@@ -60,7 +60,7 @@/* ACPI PCI Interrupt Link (pci_link.c) */ int acpi_pci_link_check (void ); -int acpi_pci_link_get_irq (acpi_handle handle,int index); +int acpi_pci_link_get_irq (acpi_handle handle,int index,int * edge_level,int * active_high_low);/* ACPI PCI Interrupt Routing (pci_irq.c) */
include/asm-i386/io_apic.h +1 -1
@@ -170,7 +170,7 @@extern int io_apic_get_unique_id (int ioapic,int apic_id);extern int io_apic_get_version (int ioapic);extern int io_apic_get_redir_entries (int ioapic); -extern int io_apic_set_pci_routing (int ioapic,int pin,int irq); +extern int io_apic_set_pci_routing (int ioapic,int pin,int irq,int edge_level,int active_high_low);#endif /*CONFIG_ACPI_BOOT*/ #else /* !CONFIG_X86_IO_APIC */