Subject: acpi SCI interrupt override bug
To: None <port-i386@netbsd.org, port-amd64@netbsd.org>
From: Cherry G. Mathew <cherry.g.mathew@gmail.com>
List: port-amd64
Date: 02/24/2007 23:36:59
Hi,

I've been trying to trouble shoot why the acpi_ec was not interrupting
(SCI) on my laptop. I finally narrowed it down to the patch below.

The reason the SCI was misrouted is that the check
if (mip->global_int == InterruptNumber)
would never succeed, because the acpi framework calls
AcpiOsInstallHandler() with the FADT interrupt number, while the MADT
parser (mpacpi.c) has already updated mip->global_int to the MADT
override. This meant that the fallback would pick up the old FADT irq
and setup the interrupt vector to it. Result: SCI was not serviced.

On the whole, my impression of reading the MD interrupt code is that
there much ambiguity between the use of terms IRQ, pin, interrupt etc.
Or perhaps it reflects my lack of understanding of the whole
situation. In any case, the patch fixed my SCI issues and my laptop
now has acpi happily running.

I have no idea whether this is the best or even the right way to fix
the problem. But this is a _bug_ no doubt.

Cheers,

Cherry.


--- acpi_machdep.c.~1.13.~      2007-02-22 02:00:50.000000000 +0000
+++ acpi_machdep.c      2007-02-25 01:34:09.000000000 +0000
@@ -152,7 +152,7 @@
        for (i = 0; i < mp_nbus; i++) {
                for (mip = mp_busses[i].mb_intrs; mip != NULL;
                     mip = mip->next) {
-                       if (mip->global_int == (int)InterruptNumber) {
+                       if (mip->bus_pin  == (int)InterruptNumber) {
                                h = mip->ioapic_ih;
                                if (APIC_IRQ_ISLEGACY(h)) {
                                        irq = APIC_IRQ_LEGACY_IRQ(h);
@@ -213,6 +213,7 @@
                mip->flags &= ~3;
                mip->flags |= MPS_INTPO_ACTLO;
                mip->redir |= IOAPIC_REDLO_ACTLO;
+               pin = mip->bus_pin;
        }
 #endif