Skip to contentSkip to conversation

ACPI : don't always override the acpi irq

PATCH Superseded Hui Wang 2 participants 2 messages Jun 8, 2021 ACPI

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Hui Wang

author
#0 lore raw

PATCH v2 1/1 ACPI : don't always override the acpi irq

The laptop keyboard doesn't work on many MEDION notebooks, but the keyboard works well under Windows and Unix.

Through debugging, we found this log in the dmesg:
ACPI: IRQ 1 override to edge, high
pnp 00:03: Plug and Play ACPI device, IDs PNP0303 (active)

And we checked the IRQ definition in the DSDT, it is:
IRQ (Level, ActiveLow, Exclusive, )
{1}

So the BIOS defines the keyboard irq to Level_Low, but the linux kernel override it to Edge_High. If let the linux kernel skip the irq override, the keyboard will work normally.

From the existing comment in the acpi_dev_get_irqresource(), the override function only needs to be called when BIOS defines IRQ() or IRQNoFlags, and according to the Section 6.4.2.1 of ACPI 6.4 spec [1], if IRQ() is empty or defines IRQNoFlags, the IRQ is High true, edge sensitive and non-shareable. The linux ACPI driver (acpi_rs_set_irq[] in rsirq.c) also assumes so.

Here check 3 conditions to decide if the legacy is true or not, if it is true, it means the IRQ() is empty or defines IRQNoFlags and need to call irq_override().

---
 drivers/acpi/resource.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/acpi/resource.c +6 -1
index ee78a210c606..5e4341ca6790 100644
@@ -447,6 +447,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
 {
 	struct acpi_resource_irq *irq;
 	struct acpi_resource_extended_irq *ext_irq;
+	bool irq_legacy;
 
 	switch (ares->type) {
 	case ACPI_RESOURCE_TYPE_IRQ:
@@ -459,9 +460,13 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
 			irqresource_disabled(res, 0);
 			return false;
 		}
+
+		irq_legacy = (irq->triggering == ACPI_EDGE_SENSITIVE && irq->polarity ==
+			      ACPI_ACTIVE_HIGH && irq->shareable == ACPI_EXCLUSIVE);
+
 		acpi_dev_get_irqresource(res, irq->interrupts[index],
 					 irq->triggering, irq->polarity,
-					 irq->shareable, true);
+					 irq->shareable, irq_legacy);
 		break;
 	case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
 		ext_irq = &ares->data.extended_irq;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 50 lines · Hui Wang

The laptop keyboard doesn't work on many MEDION notebooks, but the keyboard works well under Windows and Unix.

Through debugging, we found this log in the dmesg:
ACPI: IRQ 1 override to edge, high
pnp 00:03: Plug and Play ACPI device, IDs PNP0303 (active)

And we checked the IRQ definition in the DSDT, it is:
IRQ (Level, ActiveLow, Exclusive, )
{1}

So the BIOS defines the keyboard irq to Level_Low, but the linux kernel override it to Edge_High. If let the linux kernel skip the irq override, the keyboard will work normally.

From the existing comment in the acpi_dev_get_irqresource(), the override function only needs to be called when BIOS defines IRQ() or IRQNoFlags, and according to the Section 6.4.2.1 of ACPI 6.4 spec [1], if IRQ() is empty or defines IRQNoFlags, the IRQ is High true, edge sensitive and non-shareable. The linux ACPI driver (acpi_rs_set_irq[] in rsirq.c) also assumes so.

Here check 3 conditions to decide if the legacy is true or not, if it is true, it means the IRQ() is empty or defines IRQNoFlags and need to call irq_override().

---
 drivers/acpi/resource.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/acpi/resource.c +1 -0
index ee78a210c606..5e4341ca6790 100644
@@ -447,6 +447,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
 {
        struct acpi_resource_irq *irq;
        struct acpi_resource_extended_irq *ext_irq;
+       bool irq_legacy;
 
        switch (ares->type) {
        case ACPI_RESOURCE_TYPE_IRQ:

drivers/acpi/resource.c bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, · line 465

Quoted 6 lines
drivers/acpi/resource.c +3 -0
@@ -459,9 +460,13 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
                        irqresource_disabled(res, 0);
                        return false;
                }
+
+               irq_legacy = (irq->triggering == ACPI_EDGE_SENSITIVE && irq->polarity ==
+                             ACPI_ACTIVE_HIGH && irq->shareable == ACPI_EXCLUSIVE);

Now it would make sense to use a wrapper function for this:

static bool irq_is_legacy(struct acpi_resource_irq *irq)

{
        return irq->triggering == ACPI_EDGE_SENSITIVE &&
                irq->polarity == ACPI_ACTIVE_HIGH &&
                irq->shareable == ACPI_EXCLUSIVE;
}

drivers/acpi/resource.c bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, · line 469

Quoted 5 lines
drivers/acpi/resource.c +2 -1
+
                acpi_dev_get_irqresource(res, irq->interrupts[index],
                                         irq->triggering, irq->polarity,
-                                        irq->shareable, true);
+                                        irq->shareable, irq_legacy);

+ irq->shareable, irq_is_legacy(irq));

Quoted 4 lines
drivers/acpi/resource.c +0 -1
                break;
        case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
                ext_irq = &ares->data.extended_irq;
--