Skip to contentSkip to conversation

ACPI: GED: add support for _Exx / _Lxx handler methods

PATCH Applied Ard Biesheuvel 2 participants 4 messages May 15, 2020 – May 26, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: GED: add support for _Exx / _Lxx handler methods

Per the ACPI spec, interrupts in the range [0, 255] may be handled in AML using individual methods whose naming is based on the format _Exx or _Lxx, where xx is the hex representation of the interrupt index.

Add support for this missing feature to our ACPI GED driver.

---
 drivers/acpi/evged.c | 22 +++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/acpi/evged.c +19 -3
index aba0d0027586..6d7a522952bf 100644
@@ -79,6 +79,8 @@ static acpi_status acpi_ged_request_interrupt(struct acpi_resource *ares,
 	struct resource r;
 	struct acpi_resource_irq *p = &ares->data.irq;
 	struct acpi_resource_extended_irq *pext = &ares->data.extended_irq;
+	char ev_name[5];
+	u8 trigger;
 
 	if (ares->type == ACPI_RESOURCE_TYPE_END_TAG)
 		return AE_OK;
@@ -87,14 +89,28 @@ static acpi_status acpi_ged_request_interrupt(struct acpi_resource *ares,
 		dev_err(dev, "unable to parse IRQ resource\n");
 		return AE_ERROR;
 	}
-	if (ares->type == ACPI_RESOURCE_TYPE_IRQ)
+	if (ares->type == ACPI_RESOURCE_TYPE_IRQ) {
 		gsi = p->interrupts[0];
-	else
+		trigger = p->triggering;
+	} else {
 		gsi = pext->interrupts[0];
+		trigger = p->triggering;
+	}
 
 	irq = r.start;
 
-	if (ACPI_FAILURE(acpi_get_handle(handle, "_EVT", &evt_handle))) {
+	switch (gsi) {
+	case 0 ... 255:
+		sprintf(ev_name, "_%c%02hhX",
+			trigger == ACPI_EDGE_SENSITIVE ? 'E' : 'L', gsi);
+
+		if (ACPI_SUCCESS(acpi_get_handle(handle, ev_name, &evt_handle)))
+			break;
+		/* fall through */
+	default:
+		if (ACPI_SUCCESS(acpi_get_handle(handle, "_EVT", &evt_handle)))
+			break;
+
 		dev_err(dev, "cannot locate _EVT method\n");
 		return AE_ERROR;
 	}
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw
Quoted 53 lines · Ard Biesheuvel

Per the ACPI spec, interrupts in the range [0, 255] may be handled in AML using individual methods whose naming is based on the format _Exx or _Lxx, where xx is the hex representation of the interrupt index.

Add support for this missing feature to our ACPI GED driver.

---
 drivers/acpi/evged.c | 22 +++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/acpi/evged.c +13 -3
index aba0d0027586..6d7a522952bf 100644
@@ -79,6 +79,8 @@ static acpi_status acpi_ged_request_interrupt(struct acpi_resource *ares,
        struct resource r;
        struct acpi_resource_irq *p = &ares->data.irq;
        struct acpi_resource_extended_irq *pext = &ares->data.extended_irq;
+       char ev_name[5];
+       u8 trigger;
 
        if (ares->type == ACPI_RESOURCE_TYPE_END_TAG)
                return AE_OK;
@@ -87,14 +89,28 @@ static acpi_status acpi_ged_request_interrupt(struct acpi_resource *ares,
                dev_err(dev, "unable to parse IRQ resource\n");
                return AE_ERROR;
        }
-       if (ares->type == ACPI_RESOURCE_TYPE_IRQ)
+       if (ares->type == ACPI_RESOURCE_TYPE_IRQ) {
                gsi = p->interrupts[0];
-       else
+               trigger = p->triggering;
+       } else {
                gsi = pext->interrupts[0];
+               trigger = p->triggering;
+       }
 
        irq = r.start;
 
-       if (ACPI_FAILURE(acpi_get_handle(handle, "_EVT", &evt_handle))) {
+       switch (gsi) {
+       case 0 ... 255:
+               sprintf(ev_name, "_%c%02hhX",
+                       trigger == ACPI_EDGE_SENSITIVE ? 'E' : 'L', gsi);
+
+               if (ACPI_SUCCESS(acpi_get_handle(handle, ev_name, &evt_handle)))

drivers/acpi/evged.c static acpi_status acpi_ged_request_interrupt(struct acpi_resource *ares,

Quoted 10 lines
drivers/acpi/evged.c +6 -1
+                       break;
+               /* fall through */
+       default:
+               if (ACPI_SUCCESS(acpi_get_handle(handle, "_EVT", &evt_handle)))
+                       break;
+
                dev_err(dev, "cannot locate _EVT method\n");
                return AE_ERROR;
        }
--

Applied as 5.8 material, thanks!

#2 lore raw

Hello Rafael,

I spotted an issue with this patch. Please see below.

Quoted 30 lines · Rafael J. Wysocki
Quoted 28 lines · Ard Biesheuvel

Per the ACPI spec, interrupts in the range [0, 255] may be handled in AML using individual methods whose naming is based on the format _Exx or _Lxx, where xx is the hex representation of the interrupt index.

Add support for this missing feature to our ACPI GED driver.

---
 drivers/acpi/evged.c | 22 +++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/acpi/evged.c +2 -0
index aba0d0027586..6d7a522952bf 100644
@@ -79,6 +79,8 @@ static acpi_status acpi_ged_request_interrupt(struct acpi_resource *ares,
        struct resource r;
        struct acpi_resource_irq *p = &ares->data.irq;
        struct acpi_resource_extended_irq *pext = &ares->data.extended_irq;
+       char ev_name[5];
+       u8 trigger;
 
Quoted 14 lines
Quoted 4 lines
drivers/acpi/evged.c +0 -0
        if (ares->type == ACPI_RESOURCE_TYPE_END_TAG)
                return AE_OK;
@@ -87,14 +89,28 @@ static acpi_status acpi_ged_request_interrupt(struct acpi_resource *ares,
                dev_err(dev, "unable to parse IRQ resource\n");

drivers/acpi/evged.c static acpi_status acpi_ged_request_interrupt(struct acpi_resource *ares, · line 97

Quoted 10 lines
drivers/acpi/evged.c +4 -2
                return AE_ERROR;
        }
-       if (ares->type == ACPI_RESOURCE_TYPE_IRQ)
+       if (ares->type == ACPI_RESOURCE_TYPE_IRQ) {
                gsi = p->interrupts[0];
-       else
+               trigger = p->triggering;
+       } else {
                gsi = pext->interrupts[0];
+               trigger = p->triggering;

This should be 'pext->triggering' instead.

In practice, it doesn't matter, since p and pext point to the same union, and the 'triggering' field happens to be at the same offset. But it should still be fixed, of course.

Would you prefer a followup patch? Or can you fix it locally?

Quoted 23 lines
Quoted 11 lines
drivers/acpi/evged.c +7 -1
+       }
 
        irq = r.start;
 
-       if (ACPI_FAILURE(acpi_get_handle(handle, "_EVT", &evt_handle))) {
+       switch (gsi) {
+       case 0 ... 255:
+               sprintf(ev_name, "_%c%02hhX",
+                       trigger == ACPI_EDGE_SENSITIVE ? 'E' : 'L', gsi);
+
+               if (ACPI_SUCCESS(acpi_get_handle(handle, ev_name, &evt_handle)))

drivers/acpi/evged.c static acpi_status acpi_ged_request_interrupt(struct acpi_resource *ares,

Quoted 10 lines
drivers/acpi/evged.c +6 -1
+                       break;
+               /* fall through */
+       default:
+               if (ACPI_SUCCESS(acpi_get_handle(handle, "_EVT", &evt_handle)))
+                       break;
+
                dev_err(dev, "cannot locate _EVT method\n");
                return AE_ERROR;
        }
--

Applied as 5.8 material, thanks!

#3 lore raw
Quoted 54 lines · Ard Biesheuvel

Hello Rafael,

I spotted an issue with this patch. Please see below.

Quoted 30 lines · Rafael J. Wysocki
Quoted 28 lines · Ard Biesheuvel

Per the ACPI spec, interrupts in the range [0, 255] may be handled in AML using individual methods whose naming is based on the format _Exx or _Lxx, where xx is the hex representation of the interrupt index.

Add support for this missing feature to our ACPI GED driver.

---
 drivers/acpi/evged.c | 22 +++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/acpi/evged.c +2 -0
index aba0d0027586..6d7a522952bf 100644
@@ -79,6 +79,8 @@ static acpi_status acpi_ged_request_interrupt(struct acpi_resource *ares,
        struct resource r;
        struct acpi_resource_irq *p = &ares->data.irq;
        struct acpi_resource_extended_irq *pext = &ares->data.extended_irq;
+       char ev_name[5];
+       u8 trigger;
 
Quoted 14 lines
Quoted 4 lines
drivers/acpi/evged.c +0 -0
        if (ares->type == ACPI_RESOURCE_TYPE_END_TAG)
                return AE_OK;
@@ -87,14 +89,28 @@ static acpi_status acpi_ged_request_interrupt(struct acpi_resource *ares,
                dev_err(dev, "unable to parse IRQ resource\n");

drivers/acpi/evged.c static acpi_status acpi_ged_request_interrupt(struct acpi_resource *ares, · line 97

Quoted 10 lines
drivers/acpi/evged.c +4 -2
                return AE_ERROR;
        }
-       if (ares->type == ACPI_RESOURCE_TYPE_IRQ)
+       if (ares->type == ACPI_RESOURCE_TYPE_IRQ) {
                gsi = p->interrupts[0];
-       else
+               trigger = p->triggering;
+       } else {
                gsi = pext->interrupts[0];
+               trigger = p->triggering;

This should be 'pext->triggering' instead.

Quoted 5 lines

In practice, it doesn't matter, since p and pext point to the same union, and the 'triggering' field happens to be at the same offset. But it should still be fixed, of course.

Would you prefer a followup patch? Or can you fix it locally?

A followup, please.