Skip to contentSkip to conversation

ACPI: EC: trust DSDT GPE for certain HP laptop

PATCH Applied Zhang Rui 2 participants 3 messages Jun 21, 2021 ACPI

lore
Share & tools
lore

Zhang Rui

author
#0 lore raw

PATCH 1/1 ACPI: EC: trust DSDT GPE for certain HP laptop

On HP Pavilion Gaming Laptop 15-cx0xxx, the ECDT EC and DSDT EC share the same port addresses but different GPEs. And the DSDT GPE is the right one to use.

The current code duplicates DSDT EC with ECDT EC if the port addresses are the same, and uses ECDT GPE as a result, which breaks this machine.

Introduce a new quirk for the HP laptop to trust the DSDT GPE, and avoid duplicating even if the port addresses are the same.

---
 drivers/acpi/ec.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
drivers/acpi/ec.c +20 -1
index 9555c65f2f94..8d8abd0c6cfb 100644
@@ -183,6 +183,7 @@ static struct workqueue_struct *ec_query_wq;
 
 static int EC_FLAGS_CORRECT_ECDT; /* Needs ECDT port address correction */
 static int EC_FLAGS_IGNORE_DSDT_GPE; /* Needs ECDT GPE as correction setting */
+static int EC_FLAGS_TRUST_DSDT_GPE; /* Needs DSDT GPE as correction setting */
 static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on boot/resume */
 static int EC_FLAGS_FORCE_EC_REG; /* Needs EC _REG evaluated explicitly */
 
@@ -1601,7 +1602,8 @@ static int acpi_ec_add(struct acpi_device *device)
 		}
 
 		if (boot_ec && ec->command_addr == boot_ec->command_addr &&
-		    ec->data_addr == boot_ec->data_addr) {
+		    ec->data_addr == boot_ec->data_addr &&
+		    !EC_FLAGS_TRUST_DSDT_GPE) {
 			/*
 			 * Trust PNP0C09 namespace location rather than
 			 * ECDT ID. But trust ECDT GPE rather than _GPE
@@ -1836,6 +1838,18 @@ static int ec_honor_ecdt_gpe(const struct dmi_system_id *id)
 	return 0;
 }
 
+/*
+ * Some ECDTs contain wrong GPE setting, but they share the same port addresses
+ * with DSDT EC, don't duplicate the DSDT EC with ECDT EC in this case.
+ * https://bugzilla.kernel.org/show_bug.cgi?id=209989
+ */
+static int ec_honor_dsdt_gpe(const struct dmi_system_id *id)
+{
+	pr_debug("Detected system needing DSDT GPE setting.\n");
+	EC_FLAGS_TRUST_DSDT_GPE = 1;
+	return 0;
+}
+
 /*
  * Some buggy BIOS does not have EC OperationRegion, this results in the
  * EC._REG fails to be evaluated when installing the EC address space handler.
@@ -1876,6 +1890,11 @@ static const struct dmi_system_id ec_dmi_table[] __initconst = {
 	DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
 	DMI_MATCH(DMI_PRODUCT_NAME, "X580VD"),}, NULL},
 	{
+	/* https://bugzilla.kernel.org/show_bug.cgi?id=209989 */
+	ec_honor_dsdt_gpe, "HP Pavilion Gaming Laptop 15-cx0xxx", {
+	DMI_MATCH(DMI_SYS_VENDOR, "HP"),
+	DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Gaming Laptop 15-cx0xxx"),}, NULL},
+	{
 	ec_clear_on_resume, "Samsung hardware", {
 	DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD.")}, NULL},
 	{
Signature · 1 line
2.17.1
author
#1 lore raw

Sorry that this patch is based on top of some local changes and can not be applied cleanly to latest upstream git.
Patch rebased on top of v5.13-rc7 and resent.

thanks,
rui

Quoted 87 lines · Zhang Rui

On HP Pavilion Gaming Laptop 15-cx0xxx, the ECDT EC and DSDT EC share the same port addresses but different GPEs. And the DSDT GPE is the right one to use.

The current code duplicates DSDT EC with ECDT EC if the port addresses
are the same, and uses ECDT GPE as a result, which breaks this machine.

Introduce a new quirk for the HP laptop to trust the DSDT GPE, and avoid duplicating even if the port addresses are the same.

---
 drivers/acpi/ec.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
drivers/acpi/ec.c +0 -0
index 9555c65f2f94..8d8abd0c6cfb 100644
@@ -183,6 +183,7 @@ static struct workqueue_struct *ec_query_wq;
 
 static int EC_FLAGS_CORRECT_ECDT; /* Needs ECDT port address

correction */
static int EC_FLAGS_IGNORE_DSDT_GPE; /* Needs ECDT GPE as correction
setting */
+static int EC_FLAGS_TRUST_DSDT_GPE; /* Needs DSDT GPE as correction setting */
static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on
boot/resume */
static int EC_FLAGS_FORCE_EC_REG; /* Needs EC _REG evaluated
explicitly */

drivers/acpi/ec.c +0 -0
@@ -1601,7 +1602,8 @@ static int acpi_ec_add(struct acpi_device
 *device)
 		}
 
 		if (boot_ec && ec->command_addr == boot_ec-
Quoted 1 line

command_addr &&

drivers/acpi/ec.c +4 -1
-		    ec->data_addr == boot_ec->data_addr) {
+		    ec->data_addr == boot_ec->data_addr &&
+		    !EC_FLAGS_TRUST_DSDT_GPE) {
 			/*
 			 * Trust PNP0C09 namespace location rather than
 			 * ECDT ID. But trust ECDT GPE rather than _GPE
@@ -1836,6 +1838,18 @@ static int ec_honor_ecdt_gpe(const struct
 dmi_system_id *id)
 	return 0;
 }
 
+/*
+ * Some ECDTs contain wrong GPE setting, but they share the same

port addresses
+ * with DSDT EC, don't duplicate the DSDT EC with ECDT EC in this case.
+ * https://bugzilla.kernel.org/show_bug.cgi?id=209989
+ */

drivers/acpi/ec.c +7 -0
+static int ec_honor_dsdt_gpe(const struct dmi_system_id *id)
+{
+	pr_debug("Detected system needing DSDT GPE setting.\n");
+	EC_FLAGS_TRUST_DSDT_GPE = 1;
+	return 0;
+}
+
 /*
  * Some buggy BIOS does not have EC OperationRegion, this results in

the
* EC._REG fails to be evaluated when installing the EC address
space handler.

drivers/acpi/ec.c +5 -0
@@ -1876,6 +1890,11 @@ static const struct dmi_system_id
 ec_dmi_table[] __initconst = {
 	DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
 	DMI_MATCH(DMI_PRODUCT_NAME, "X580VD"),}, NULL},
 	{
+	/* https://bugzilla.kernel.org/show_bug.cgi?id=209989 */
+	ec_honor_dsdt_gpe, "HP Pavilion Gaming Laptop 15-cx0xxx", {
+	DMI_MATCH(DMI_SYS_VENDOR, "HP"),
+	DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Gaming Laptop 15-
 cx0xxx"),}, NULL},
+	{
 	ec_clear_on_resume, "Samsung hardware", {

DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD.")},
NULL},
{

maintainer Applied
#2 lore raw
In reply to Zhang Rui
Quoted 62 lines · Zhang Rui

On HP Pavilion Gaming Laptop 15-cx0xxx, the ECDT EC and DSDT EC share the same port addresses but different GPEs. And the DSDT GPE is the right one to use.

The current code duplicates DSDT EC with ECDT EC if the port addresses are the same, and uses ECDT GPE as a result, which breaks this machine.

Introduce a new quirk for the HP laptop to trust the DSDT GPE, and avoid duplicating even if the port addresses are the same.

---
 drivers/acpi/ec.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
drivers/acpi/ec.c +15 -1
index 9555c65f2f94..8d8abd0c6cfb 100644
@@ -183,6 +183,7 @@ static struct workqueue_struct *ec_query_wq;
 
 static int EC_FLAGS_CORRECT_ECDT; /* Needs ECDT port address correction */
 static int EC_FLAGS_IGNORE_DSDT_GPE; /* Needs ECDT GPE as correction setting */
+static int EC_FLAGS_TRUST_DSDT_GPE; /* Needs DSDT GPE as correction setting */
 static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on boot/resume */
 static int EC_FLAGS_FORCE_EC_REG; /* Needs EC _REG evaluated explicitly */
 
@@ -1601,7 +1602,8 @@ static int acpi_ec_add(struct acpi_device *device)
                }
 
                if (boot_ec && ec->command_addr == boot_ec->command_addr &&
-                   ec->data_addr == boot_ec->data_addr) {
+                   ec->data_addr == boot_ec->data_addr &&
+                   !EC_FLAGS_TRUST_DSDT_GPE) {
                        /*
                         * Trust PNP0C09 namespace location rather than
                         * ECDT ID. But trust ECDT GPE rather than _GPE
@@ -1836,6 +1838,18 @@ static int ec_honor_ecdt_gpe(const struct dmi_system_id *id)
        return 0;
 }
 
+/*
+ * Some ECDTs contain wrong GPE setting, but they share the same port addresses
+ * with DSDT EC, don't duplicate the DSDT EC with ECDT EC in this case.
+ * https://bugzilla.kernel.org/show_bug.cgi?id=209989
+ */
+static int ec_honor_dsdt_gpe(const struct dmi_system_id *id)
+{
+       pr_debug("Detected system needing DSDT GPE setting.\n");
+       EC_FLAGS_TRUST_DSDT_GPE = 1;
+       return 0;
+}
+
 /*
  * Some buggy BIOS does not have EC OperationRegion, this results in the
  * EC._REG fails to be evaluated when installing the EC address space handler.
@@ -1876,6 +1890,11 @@ static const struct dmi_system_id ec_dmi_table[] __initconst = {
        DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
        DMI_MATCH(DMI_PRODUCT_NAME, "X580VD"),}, NULL},

drivers/acpi/ec.c static const struct dmi_system_id ec_dmi_table[] __initconst = {

Quoted 10 lines
drivers/acpi/ec.c +5 -1
        {
+       /* https://bugzilla.kernel.org/show_bug.cgi?id=209989 */
+       ec_honor_dsdt_gpe, "HP Pavilion Gaming Laptop 15-cx0xxx", {
+       DMI_MATCH(DMI_SYS_VENDOR, "HP"),
+       DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Gaming Laptop 15-cx0xxx"),}, NULL},
+       {
        ec_clear_on_resume, "Samsung hardware", {
        DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD.")}, NULL},
        {
--

Applied as 5.14 material, thanks!