Skip to contentSkip to conversation

ACPICA: Also handle "orphan" _REG methods for GPIO OpRegions

PATCH In review Hans de Goede 3 participants 9 messages Oct 25, 2020 – Nov 4, 2020

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

PATCH 1/1 ACPICA: Also handle "orphan" _REG methods for GPIO OpRegions

Before this commit acpi_ev_execute_reg_methods() had special handling to handle "orphan" (no matching OpRegion declared) _REG methods for EC nodes.

On Intel Cherry Trail devices there are 2 possible ACPI OpRegions for accessing GPIOs. The standard GeneralPurposeIo OpRegion and the Cherry Trail specific UserDefined 0x9X OpRegions.

Having 2 different types of OpRegions leads to potential issues with checks for OpRegion availability, or in other words checks if _REG has been called for the OpRegion which the ACPI code wants to use.

Except for the "orphan" EC handling, ACPICA core does not call _REG on an ACPI node which does not define an OpRegion matching the type being registered; and the reference design DSDT, from which most Cherry Trail DSDTs are derived, does not define GeneralPurposeIo, nor UserDefined(0x93) OpRegions for the GPO2 (UID 3) device, because no pins were assigned ACPI controlled functions in the reference design.

Together this leads to the perfect storm, at least on the Cherry Trail based Medion Akayo E1239T. This design does use a GPO2 pin from its ACPI code and has added the Cherry Trail specific UserDefined(0x93) opregion to its GPO2 ACPI node to access this pin.

But it uses a has _REG been called availability check for the standard GeneralPurposeIo OpRegion. This clearly is a bug in the DSDT, but this does work under Windows. This issue leads to the intel_vbtn driver reporting the device always being in tablet-mode at boot, even if it is in laptop mode. Which in turn causes userspace to ignore touchpad events. So iow this issues causes the touchpad to not work at boot.

This commit fixes this by extending the "orphan" _REG method handling to also apply to GPIO address-space handlers.

Note it seems that Windows always calls "orphan" _REG methods so me may want to consider dropping the space-id check and always do "orphan" _REG method handling.

---
 drivers/acpi/acpica/evregion.c | 54 +++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 27 deletions(-)
drivers/acpi/acpica/evregion.c +27 -27
index 738d4b231f34..21ff341e34a4 100644
@@ -21,7 +21,8 @@ extern u8 acpi_gbl_default_address_spaces[];
 /* Local prototypes */
 
 static void
-acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node *ec_device_node);
+acpi_ev_execute_orphan_reg_method(struct acpi_namespace_node *device_node,
+				  acpi_adr_space_type space_id);
 
 static acpi_status
 acpi_ev_reg_run(acpi_handle obj_handle,
@@ -684,10 +685,12 @@ acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
 				     ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run, NULL,
 				     &info, NULL);
 
-	/* Special case for EC: handle "orphan" _REG methods with no region */
-
-	if (space_id == ACPI_ADR_SPACE_EC) {
-		acpi_ev_orphan_ec_reg_method(node);
+	/*
+	 * Special case for EC and GPIO: handle "orphan" _REG methods with
+	 * no region.
+	 */
+	if (space_id == ACPI_ADR_SPACE_EC || space_id == ACPI_ADR_SPACE_GPIO) {
+		acpi_ev_execute_orphan_reg_method(node, space_id);
 	}
 
 	ACPI_DEBUG_PRINT_RAW((ACPI_DB_NAMES,
@@ -760,31 +763,28 @@ acpi_ev_reg_run(acpi_handle obj_handle,
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_ev_orphan_ec_reg_method
+ * FUNCTION:    acpi_ev_execute_orphan_reg_method
  *
- * PARAMETERS:  ec_device_node      - Namespace node for an EC device
+ * PARAMETERS:  device_node     - Namespace node for an ACPI device
+ *              space_id        - The address space ID
  *
  * RETURN:      None
  *
- * DESCRIPTION: Execute an "orphan" _REG method that appears under the EC
+ * DESCRIPTION: Execute an "orphan" _REG method that appears under an ACPI
  *              device. This is a _REG method that has no corresponding region
- *              within the EC device scope. The orphan _REG method appears to
- *              have been enabled by the description of the ECDT in the ACPI
- *              specification: "The availability of the region space can be
- *              detected by providing a _REG method object underneath the
- *              Embedded Controller device."
- *
- *              To quickly access the EC device, we use the ec_device_node used
- *              during EC handler installation. Otherwise, we would need to
- *              perform a time consuming namespace walk, executing _HID
- *              methods to find the EC device.
+ *              within the device's scope. ACPI tables depending on these
+ *              "orphan" _REG methods have been seen for both EC and GPIO
+ *              Operation Regions. Presumably the Windows ACPI implementation
+ *              always calls the _REG method independent of the presence of
+ *              an actual Operation Region with the correct address space ID.
  *
  *  MUTEX:      Assumes the namespace is locked
  *
  ******************************************************************************/
 
 static void
-acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node *ec_device_node)
+acpi_ev_execute_orphan_reg_method(struct acpi_namespace_node *device_node,
+				  acpi_adr_space_type space_id)
 {
 	acpi_handle reg_method;
 	struct acpi_namespace_node *next_node;
@@ -792,9 +792,9 @@ acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node *ec_device_node)
 	struct acpi_object_list args;
 	union acpi_object objects[2];
 
-	ACPI_FUNCTION_TRACE(ev_orphan_ec_reg_method);
+	ACPI_FUNCTION_TRACE(ev_execute_orphan_reg_method);
 
-	if (!ec_device_node) {
+	if (!device_node) {
 		return_VOID;
 	}
 
@@ -804,7 +804,7 @@ acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node *ec_device_node)
 
 	/* Get a handle to a _REG method immediately under the EC device */
 
-	status = acpi_get_handle(ec_device_node, METHOD_NAME__REG, &reg_method);
+	status = acpi_get_handle(device_node, METHOD_NAME__REG, &reg_method);
 	if (ACPI_FAILURE(status)) {
 		goto exit;	/* There is no _REG method present */
 	}
@@ -816,23 +816,23 @@ acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node *ec_device_node)
 	 * with other space IDs to be present; but the code below will then
 	 * execute the _REG method with the embedded_control space_ID argument.
 	 */
-	next_node = acpi_ns_get_next_node(ec_device_node, NULL);
+	next_node = acpi_ns_get_next_node(device_node, NULL);
 	while (next_node) {
 		if ((next_node->type == ACPI_TYPE_REGION) &&
 		    (next_node->object) &&
-		    (next_node->object->region.space_id == ACPI_ADR_SPACE_EC)) {
+		    (next_node->object->region.space_id == space_id)) {
 			goto exit;	/* Do not execute the _REG */
 		}
 
-		next_node = acpi_ns_get_next_node(ec_device_node, next_node);
+		next_node = acpi_ns_get_next_node(device_node, next_node);
 	}
 
-	/* Evaluate the _REG(embedded_control,Connect) method */
+	/* Evaluate the _REG(space_id, Connect) method */
 
 	args.count = 2;
 	args.pointer = objects;
 	objects[0].type = ACPI_TYPE_INTEGER;
-	objects[0].integer.value = ACPI_ADR_SPACE_EC;
+	objects[0].integer.value = space_id;
 	objects[1].type = ACPI_TYPE_INTEGER;
 	objects[1].integer.value = ACPI_REG_CONNECT;
 
Signature · 1 line
2.28.0
#1 lore raw
Quoted 206 lines

-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: Sunday, October 25, 2020 2:46 AM
To: Rafael J . Wysocki <[email protected]>; Len Brown <[email protected]>; Moore, Robert <[email protected]>; Kaneda, Erik <[email protected]>
Cc: Hans de Goede <[email protected]>; [email protected]; [email protected]
Subject: [PATCH] ACPICA: Also handle "orphan" _REG methods for GPIO OpRegions

Before this commit acpi_ev_execute_reg_methods() had special handling to handle "orphan" (no matching OpRegion declared) _REG methods for EC nodes.

On Intel Cherry Trail devices there are 2 possible ACPI OpRegions for accessing GPIOs. The standard GeneralPurposeIo OpRegion and the Cherry Trail specific UserDefined 0x9X OpRegions.

Having 2 different types of OpRegions leads to potential issues with checks for OpRegion availability, or in other words checks if _REG has been called for the OpRegion which the ACPI code wants to use.

Except for the "orphan" EC handling, ACPICA core does not call _REG on an ACPI node which does not define an OpRegion matching the type being registered; and the reference design DSDT, from which most Cherry Trail DSDTs are derived, does not define GeneralPurposeIo, nor UserDefined(0x93)
OpRegions for the GPO2 (UID 3) device, because no pins were assigned ACPI controlled functions in the reference design.

Together this leads to the perfect storm, at least on the Cherry Trail based Medion Akayo E1239T. This design does use a GPO2 pin from its ACPI code and has added the Cherry Trail specific UserDefined(0x93) opregion to its GPO2 ACPI node to access this pin.

But it uses a has _REG been called availability check for the standard GeneralPurposeIo OpRegion. This clearly is a bug in the DSDT, but this does work under Windows. This issue leads to the intel_vbtn driver reporting the device always being in tablet-mode at boot, even if it is in laptop mode. Which in turn causes userspace to ignore touchpad events. So iow this issues causes the touchpad to not work at boot.

This commit fixes this by extending the "orphan" _REG method handling to also apply to GPIO address-space handlers.

Note it seems that Windows always calls "orphan" _REG methods so me may want to consider dropping the space-id check and always do "orphan" _REG method handling.

---
 drivers/acpi/acpica/evregion.c | 54 +++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 27 deletions(-)
drivers/acpi/acpica/evregion.c +2 -1
index 738d4b231f34..21ff341e34a4 100644
@@ -21,7 +21,8 @@ extern u8 acpi_gbl_default_address_spaces[];
 /* Local prototypes */
 
 static void
-acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node
 *ec_device_node);
+acpi_ev_execute_orphan_reg_method(struct acpi_namespace_node
 *device_node,
+				  acpi_adr_space_type space_id);
 

static acpi_status
acpi_ev_reg_run(acpi_handle obj_handle,

drivers/acpi/acpica/evregion.c +5 -4
@@ -684,10 +685,12 @@ acpi_ev_execute_reg_methods(struct
 acpi_namespace_node *node,
 				     ACPI_NS_WALK_UNLOCK,
 acpi_ev_reg_run, NULL,
 				     &info, NULL);
 
-	/* Special case for EC: handle "orphan" _REG methods with no region
 */
-
-	if (space_id == ACPI_ADR_SPACE_EC) {
-		acpi_ev_orphan_ec_reg_method(node);
+	/*
+	 * Special case for EC and GPIO: handle "orphan" _REG methods with
+	 * no region.
+	 */
+	if (space_id == ACPI_ADR_SPACE_EC || space_id ==

ACPI_ADR_SPACE_GPIO) {

drivers/acpi/acpica/evregion.c +4 -3
+		acpi_ev_execute_orphan_reg_method(node, space_id);
 	}
 
 	ACPI_DEBUG_PRINT_RAW((ACPI_DB_NAMES,
@@ -760,31 +763,28 @@ acpi_ev_reg_run(acpi_handle obj_handle,
 
 
 /**********************************************************
 *********************
  *
- * FUNCTION:    acpi_ev_orphan_ec_reg_method
+ * FUNCTION:    acpi_ev_execute_orphan_reg_method
  *
- * PARAMETERS:  ec_device_node      - Namespace node for an EC device
+ * PARAMETERS:  device_node     - Namespace node for an ACPI device
+ *              space_id        - The address space ID
  *
  * RETURN:      None
  *
- * DESCRIPTION: Execute an "orphan" _REG method that appears under the

EC
+ * DESCRIPTION: Execute an "orphan" _REG method that appears under an ACPI

  *              device. This is a _REG method that has no corresponding region
- *              within the EC device scope. The orphan _REG method appears to
- *              have been enabled by the description of the ECDT in the ACPI
- *              specification: "The availability of the region space can be
- *              detected by providing a _REG method object underneath the
- *              Embedded Controller device."
- *
- *              To quickly access the EC device, we use the ec_device_node used
- *              during EC handler installation. Otherwise, we would need to
- *              perform a time consuming namespace walk, executing _HID
- *              methods to find the EC device.
+ *              within the device's scope. ACPI tables depending on these
+ *              "orphan" _REG methods have been seen for both EC and GPIO
+ *              Operation Regions. Presumably the Windows ACPI implementation
+ *              always calls the _REG method independent of the presence of
+ *              an actual Operation Region with the correct address space ID.

*
* MUTEX: Assumes the namespace is locked
*

**********************************************************
********************/

static void
-acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node *ec_device_node) +acpi_ev_execute_orphan_reg_method(struct acpi_namespace_node *device_node,

drivers/acpi/acpica/evregion.c +4 -3
+				  acpi_adr_space_type space_id)
 {
 	acpi_handle reg_method;
 	struct acpi_namespace_node *next_node;
@@ -792,9 +792,9 @@ acpi_ev_orphan_ec_reg_method(struct
 acpi_namespace_node *ec_device_node)
 	struct acpi_object_list args;
 	union acpi_object objects[2];
 
-	ACPI_FUNCTION_TRACE(ev_orphan_ec_reg_method);
+	ACPI_FUNCTION_TRACE(ev_execute_orphan_reg_method);
 
-	if (!ec_device_node) {
+	if (!device_node) {
 		return_VOID;
 	}
@@ -804,7 +804,7 @@ acpi_ev_orphan_ec_reg_method(struct
 acpi_namespace_node *ec_device_node)
 
 	/* Get a handle to a _REG method immediately under the EC device
 */
 
-	status = acpi_get_handle(ec_device_node, METHOD_NAME__REG,
 &reg_method);
+	status = acpi_get_handle(device_node, METHOD_NAME__REG,

&reg_method);

drivers/acpi/acpica/evregion.c +0 -0
 	if (ACPI_FAILURE(status)) {
 		goto exit;	/* There is no _REG method present */
 	}
@@ -816,23 +816,23 @@ acpi_ev_orphan_ec_reg_method(struct
 acpi_namespace_node *ec_device_node)
 	 * with other space IDs to be present; but the code below will then
 	 * execute the _REG method with the embedded_control space_ID

argument.

drivers/acpi/acpica/evregion.c +1 -2
 	 */
-	next_node = acpi_ns_get_next_node(ec_device_node, NULL);
+	next_node = acpi_ns_get_next_node(device_node, NULL);
 	while (next_node) {
 		if ((next_node->type == ACPI_TYPE_REGION) &&
 		    (next_node->object) &&
-		    (next_node->object->region.space_id ==

ACPI_ADR_SPACE_EC)) {

drivers/acpi/acpica/evregion.c +1 -1
+		    (next_node->object->region.space_id == space_id)) {
 			goto exit;	/* Do not execute the _REG */
 		}
 
-		next_node = acpi_ns_get_next_node(ec_device_node,

next_node);

drivers/acpi/acpica/evregion.c +1 -0
+		next_node = acpi_ns_get_next_node(device_node,

next_node);

drivers/acpi/acpica/evregion.c +2 -3
 	}
 
-	/* Evaluate the _REG(embedded_control,Connect) method */
+	/* Evaluate the _REG(space_id, Connect) method */
 
 	args.count = 2;
 	args.pointer = objects;
 	objects[0].type = ACPI_TYPE_INTEGER;
-	objects[0].integer.value = ACPI_ADR_SPACE_EC;
+	objects[0].integer.value = space_id;
 	objects[1].type = ACPI_TYPE_INTEGER;
 	objects[1].integer.value = ACPI_REG_CONNECT;
 
--
Quoted 1 line

2.28.0

This looks good to me. Bob, any thoughts?

Erik

#2 lore raw

Looks OK to me.
Bob

-----Original Message-----
From: Kaneda, Erik <erik.kaneda(a)intel.com>
Sent: Monday, October 26, 2020 1:56 PM
To: Hans de Goede <hdegoede(a)redhat.com>; Rafael J . Wysocki <rjw(a)rjwysocki.net>; Len Brown <lenb(a)kernel.org>; Moore, Robert <robert.moore(a)intel.com>
Cc: linux-acpi(a)vger.kernel.org; devel(a)acpica.org
Subject: RE: [PATCH] ACPICA: Also handle "orphan" _REG methods for GPIO OpRegions

Quoted 205 lines

-----Original Message-----
From: Hans de Goede <hdegoede(a)redhat.com>
Sent: Sunday, October 25, 2020 2:46 AM
To: Rafael J . Wysocki <rjw(a)rjwysocki.net>; Len Brown <lenb(a)kernel.org>; Moore, Robert <robert.moore(a)intel.com>; Kaneda, Erik <erik.kaneda(a)intel.com>
Cc: Hans de Goede <hdegoede(a)redhat.com>; linux-acpi(a)vger.kernel.org; devel(a)acpica.org
Subject: [PATCH] ACPICA: Also handle "orphan" _REG methods for GPIO OpRegions

Before this commit acpi_ev_execute_reg_methods() had special handling to handle "orphan" (no matching OpRegion declared) _REG methods for EC nodes.

On Intel Cherry Trail devices there are 2 possible ACPI OpRegions for accessing GPIOs. The standard GeneralPurposeIo OpRegion and the Cherry Trail specific UserDefined 0x9X OpRegions.

Having 2 different types of OpRegions leads to potential issues with checks for OpRegion availability, or in other words checks if _REG has been called for the OpRegion which the ACPI code wants to use.

Except for the "orphan" EC handling, ACPICA core does not call _REG on an ACPI node which does not define an OpRegion matching the type being registered; and the reference design DSDT, from which most Cherry Trail DSDTs are derived, does not define GeneralPurposeIo, nor UserDefined(0x93)
OpRegions for the GPO2 (UID 3) device, because no pins were assigned ACPI controlled functions in the reference design.

Together this leads to the perfect storm, at least on the Cherry Trail based Medion Akayo E1239T. This design does use a GPO2 pin from its ACPI code and has added the Cherry Trail specific UserDefined(0x93) opregion to its GPO2 ACPI node to access this pin.

But it uses a has _REG been called availability check for the standard GeneralPurposeIo OpRegion. This clearly is a bug in the DSDT, but this does work under Windows. This issue leads to the intel_vbtn driver reporting the device always being in tablet-mode at boot, even if it is in laptop mode. Which in turn causes userspace to ignore touchpad events. So iow this issues causes the touchpad to not work at boot.

This commit fixes this by extending the "orphan" _REG method handling to also apply to GPIO address-space handlers.

Note it seems that Windows always calls "orphan" _REG methods so me may want to consider dropping the space-id check and always do "orphan" _REG method handling.

Signed-off-by Hans de Goede <hdegoede(a)redhat.com>
---
 drivers/acpi/acpica/evregion.c | 54 
+++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 27 deletions(-)
(quoted diff) +0 -0

b/drivers/acpi/acpica/evregion.c index 738d4b231f34..21ff341e34a4 100644

drivers/acpi/acpica/evregion.c +2 -1
@@ -21,7 +21,8 @@ extern u8 acpi_gbl_default_address_spaces[];
 /* Local prototypes */
 
 static void
-acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node 
 *ec_device_node);
+acpi_ev_execute_orphan_reg_method(struct acpi_namespace_node
 *device_node,
+				  acpi_adr_space_type space_id);
 

static acpi_status
acpi_ev_reg_run(acpi_handle obj_handle, @@ -684,10 +685,12 @@
acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
ACPI_NS_WALK_UNLOCK,
acpi_ev_reg_run, NULL,

drivers/acpi/acpica/evregion.c +0 -1
 				     &info, NULL);
 
-	/* Special case for EC: handle "orphan" _REG methods with no region

*/

drivers/acpi/acpica/evregion.c +5 -3
-
-	if (space_id == ACPI_ADR_SPACE_EC) {
-		acpi_ev_orphan_ec_reg_method(node);
+	/*
+	 * Special case for EC and GPIO: handle "orphan" _REG methods with
+	 * no region.
+	 */
+	if (space_id == ACPI_ADR_SPACE_EC || space_id ==

ACPI_ADR_SPACE_GPIO) {

drivers/acpi/acpica/evregion.c +4 -3
+		acpi_ev_execute_orphan_reg_method(node, space_id);
 	}
 
 	ACPI_DEBUG_PRINT_RAW((ACPI_DB_NAMES,
@@ -760,31 +763,28 @@ acpi_ev_reg_run(acpi_handle obj_handle,
 
 
 /**********************************************************
 *********************
  *
- * FUNCTION:    acpi_ev_orphan_ec_reg_method
+ * FUNCTION:    acpi_ev_execute_orphan_reg_method
  *
- * PARAMETERS:  ec_device_node      - Namespace node for an EC device
+ * PARAMETERS:  device_node     - Namespace node for an ACPI device
+ *              space_id        - The address space ID
  *
  * RETURN:      None
  *
- * DESCRIPTION: Execute an "orphan" _REG method that appears under 

the EC
+ * DESCRIPTION: Execute an "orphan" _REG method that appears under an ACPI

  *              device. This is a _REG method that has no corresponding region
- *              within the EC device scope. The orphan _REG method appears to
- *              have been enabled by the description of the ECDT in the ACPI
- *              specification: "The availability of the region space can be
- *              detected by providing a _REG method object underneath the
- *              Embedded Controller device."
- *
- *              To quickly access the EC device, we use the ec_device_node used
- *              during EC handler installation. Otherwise, we would need to
- *              perform a time consuming namespace walk, executing _HID
- *              methods to find the EC device.
+ *              within the device's scope. ACPI tables depending on these
+ *              "orphan" _REG methods have been seen for both EC and GPIO
+ *              Operation Regions. Presumably the Windows ACPI implementation
+ *              always calls the _REG method independent of the presence of
+ *              an actual Operation Region with the correct address space ID.

*
* MUTEX: Assumes the namespace is locked
*

**********************************************************
********************/

static void
-acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node *ec_device_node) +acpi_ev_execute_orphan_reg_method(struct acpi_namespace_node *device_node,

drivers/acpi/acpica/evregion.c +1 -0
+				  acpi_adr_space_type space_id)
 {
 	acpi_handle reg_method;
 	struct acpi_namespace_node *next_node; @@ -792,9 +792,9 @@ 

acpi_ev_orphan_ec_reg_method(struct
acpi_namespace_node *ec_device_node)

drivers/acpi/acpica/evregion.c +3 -3
 	struct acpi_object_list args;
 	union acpi_object objects[2];
 
-	ACPI_FUNCTION_TRACE(ev_orphan_ec_reg_method);
+	ACPI_FUNCTION_TRACE(ev_execute_orphan_reg_method);
 
-	if (!ec_device_node) {
+	if (!device_node) {
 		return_VOID;
 	}
@@ -804,7 +804,7 @@ acpi_ev_orphan_ec_reg_method(struct
 acpi_namespace_node *ec_device_node)
 
 	/* Get a handle to a _REG method immediately under the EC device */
 
-	status = acpi_get_handle(ec_device_node, METHOD_NAME__REG,
 &reg_method);
+	status = acpi_get_handle(device_node, METHOD_NAME__REG,
 &reg_method);
drivers/acpi/acpica/evregion.c +0 -0
 	if (ACPI_FAILURE(status)) {
 		goto exit;	/* There is no _REG method present */
 	}
@@ -816,23 +816,23 @@ acpi_ev_orphan_ec_reg_method(struct
 acpi_namespace_node *ec_device_node)
 	 * with other space IDs to be present; but the code below will then
 	 * execute the _REG method with the embedded_control space_ID 

argument.

drivers/acpi/acpica/evregion.c +1 -2
 	 */
-	next_node = acpi_ns_get_next_node(ec_device_node, NULL);
+	next_node = acpi_ns_get_next_node(device_node, NULL);
 	while (next_node) {
 		if ((next_node->type == ACPI_TYPE_REGION) &&
 		    (next_node->object) &&
-		    (next_node->object->region.space_id ==

ACPI_ADR_SPACE_EC)) {

drivers/acpi/acpica/evregion.c +1 -1
+		    (next_node->object->region.space_id == space_id)) {
 			goto exit;	/* Do not execute the _REG */
 		}
 
-		next_node = acpi_ns_get_next_node(ec_device_node,

next_node);

drivers/acpi/acpica/evregion.c +1 -0
+		next_node = acpi_ns_get_next_node(device_node,

next_node);

drivers/acpi/acpica/evregion.c +2 -3
 	}
 
-	/* Evaluate the _REG(embedded_control,Connect) method */
+	/* Evaluate the _REG(space_id, Connect) method */
 
 	args.count = 2;
 	args.pointer = objects;
 	objects[0].type = ACPI_TYPE_INTEGER;
-	objects[0].integer.value = ACPI_ADR_SPACE_EC;
+	objects[0].integer.value = space_id;
 	objects[1].type = ACPI_TYPE_INTEGER;
 	objects[1].integer.value = ACPI_REG_CONNECT;
 
--
Quoted 1 line

2.28.0

This looks good to me. Bob, any thoughts?

Erik

#3 lore raw
Quoted 12 lines

-----Original Message-----
From: Moore, Robert <[email protected]>
Sent: Tuesday, October 27, 2020 7:17 AM
To: Kaneda, Erik <[email protected]>; Hans de Goede <[email protected]>; Rafael J . Wysocki <[email protected]>; Len Brown <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] ACPICA: Also handle "orphan" _REG methods for GPIO OpRegions

Quoted 1 line

Looks OK to me.

Ok, I'll make a pull request of this to ACPICA on behalf of Hans and it will be in the next ACPICA release.

Rafael, let me know if you have any issues with this.

Thanks,
Erik

Quoted 230 lines

Bob

-----Original Message-----
From: Kaneda, Erik <[email protected]>
Sent: Monday, October 26, 2020 1:56 PM
To: Hans de Goede <[email protected]>; Rafael J . Wysocki <[email protected]>; Len Brown <[email protected]>; Moore, Robert <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] ACPICA: Also handle "orphan" _REG methods for GPIO OpRegions

Quoted 95 lines

-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: Sunday, October 25, 2020 2:46 AM
To: Rafael J . Wysocki <[email protected]>; Len Brown <[email protected]>; Moore, Robert <[email protected]>; Kaneda, Erik <[email protected]>
Cc: Hans de Goede <[email protected]>; [email protected]; [email protected]
Subject: [PATCH] ACPICA: Also handle "orphan" _REG methods for GPIO OpRegions

Before this commit acpi_ev_execute_reg_methods() had special handling to handle "orphan" (no matching OpRegion declared) _REG methods for EC nodes.

On Intel Cherry Trail devices there are 2 possible ACPI OpRegions for accessing GPIOs. The standard GeneralPurposeIo OpRegion and the Cherry Trail specific UserDefined 0x9X OpRegions.

Having 2 different types of OpRegions leads to potential issues with checks for OpRegion availability, or in other words checks if _REG has been called for the OpRegion which the ACPI code wants to use.

Except for the "orphan" EC handling, ACPICA core does not call _REG on an ACPI node which does not define an OpRegion matching the type being registered; and the reference design DSDT, from which most Cherry Trail DSDTs are derived, does not define GeneralPurposeIo, nor UserDefined(0x93)
OpRegions for the GPO2 (UID 3) device, because no pins were assigned ACPI controlled functions in the reference design.

Together this leads to the perfect storm, at least on the Cherry Trail based Medion Akayo E1239T. This design does use a GPO2 pin from its ACPI code and has added the Cherry Trail specific UserDefined(0x93) opregion to its GPO2 ACPI node to access this pin.

But it uses a has _REG been called availability check for the standard GeneralPurposeIo OpRegion. This clearly is a bug in the DSDT, but this does work under Windows. This issue leads to the intel_vbtn driver reporting the device always being in tablet-mode at boot, even if it is in laptop mode. Which in turn causes userspace to ignore touchpad events. So iow this issues causes the touchpad to not work at boot.

This commit fixes this by extending the "orphan" _REG method handling to also apply to GPIO address-space handlers.

Note it seems that Windows always calls "orphan" _REG methods so me may want to consider dropping the space-id check and always do "orphan" _REG method handling.

---
 drivers/acpi/acpica/evregion.c | 54
+++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 27 deletions(-)
(quoted diff) +0 -0

b/drivers/acpi/acpica/evregion.c index 738d4b231f34..21ff341e34a4 100644

drivers/acpi/acpica/evregion.c +2 -1
@@ -21,7 +21,8 @@ extern u8 acpi_gbl_default_address_spaces[];
 /* Local prototypes */
 
 static void
-acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node
 *ec_device_node);
+acpi_ev_execute_orphan_reg_method(struct acpi_namespace_node
 *device_node,
+				  acpi_adr_space_type space_id);
 

static acpi_status
acpi_ev_reg_run(acpi_handle obj_handle, @@ -684,10 +685,12 @@
acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
ACPI_NS_WALK_UNLOCK,
acpi_ev_reg_run, NULL,

drivers/acpi/acpica/evregion.c +0 -1
 				     &info, NULL);
 
-	/* Special case for EC: handle "orphan" _REG methods with no region

*/

drivers/acpi/acpica/evregion.c +5 -3
-
-	if (space_id == ACPI_ADR_SPACE_EC) {
-		acpi_ev_orphan_ec_reg_method(node);
+	/*
+	 * Special case for EC and GPIO: handle "orphan" _REG methods with
+	 * no region.
+	 */
+	if (space_id == ACPI_ADR_SPACE_EC || space_id ==

ACPI_ADR_SPACE_GPIO) {

drivers/acpi/acpica/evregion.c +1 -0
+		acpi_ev_execute_orphan_reg_method(node, space_id);
 	}
 
 	ACPI_DEBUG_PRINT_RAW((ACPI_DB_NAMES,

drivers/acpi/acpica/evregion.c acpi_ev_reg_run(acpi_handle obj_handle, · line 765

Quoted 3 lines
drivers/acpi/acpica/evregion.c +0 -0
@@ -760,31 +763,28 @@ acpi_ev_reg_run(acpi_handle obj_handle,
 
 
 

/**********************************************************

Quoted 12 lines
drivers/acpi/acpica/evregion.c +3 -3
 *********************
  *
- * FUNCTION:    acpi_ev_orphan_ec_reg_method
+ * FUNCTION:    acpi_ev_execute_orphan_reg_method
  *
- * PARAMETERS:  ec_device_node      - Namespace node for an EC device
+ * PARAMETERS:  device_node     - Namespace node for an ACPI device
+ *              space_id        - The address space ID
  *
  * RETURN:      None
  *
- * DESCRIPTION: Execute an "orphan" _REG method that appears under
Quoted 2 lines

the EC
+ * DESCRIPTION: Execute an "orphan" _REG method that appears under

an

Quoted 15 lines

ACPI

  *              device. This is a _REG method that has no corresponding region
- *              within the EC device scope. The orphan _REG method appears to
- *              have been enabled by the description of the ECDT in the ACPI
- *              specification: "The availability of the region space can be
- *              detected by providing a _REG method object underneath the
- *              Embedded Controller device."
- *
- *              To quickly access the EC device, we use the ec_device_node used
- *              during EC handler installation. Otherwise, we would need to
- *              perform a time consuming namespace walk, executing _HID
- *              methods to find the EC device.
+ *              within the device's scope. ACPI tables depending on these
+ *              "orphan" _REG methods have been seen for both EC and GPIO
+ *              Operation Regions. Presumably the Windows ACPI

implementation

Quoted 7 lines

+ * always calls the _REG method independent of the presence of
+ * an actual Operation Region with the correct address space ID.
*
* MUTEX: Assumes the namespace is locked
*

**********************************************************

Quoted 25 lines

********************/

static void
-acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node *ec_device_node) +acpi_ev_execute_orphan_reg_method(struct acpi_namespace_node *device_node,

drivers/acpi/acpica/evregion.c +1 -0
+				  acpi_adr_space_type space_id)
 {
 	acpi_handle reg_method;
 	struct acpi_namespace_node *next_node; @@ -792,9 +792,9 @@

acpi_ev_orphan_ec_reg_method(struct
acpi_namespace_node *ec_device_node)

drivers/acpi/acpica/evregion.c +2 -2
 	struct acpi_object_list args;
 	union acpi_object objects[2];
 
-	ACPI_FUNCTION_TRACE(ev_orphan_ec_reg_method);
+	ACPI_FUNCTION_TRACE(ev_execute_orphan_reg_method);
 
-	if (!ec_device_node) {
+	if (!device_node) {
 		return_VOID;
 	}

drivers/acpi/acpica/evregion.c acpi_ev_orphan_ec_reg_method(struct · line 806

Quoted 3 lines
drivers/acpi/acpica/evregion.c +0 -0
@@ -804,7 +804,7 @@ acpi_ev_orphan_ec_reg_method(struct
 acpi_namespace_node *ec_device_node)
 
 	/* Get a handle to a _REG method immediately under the EC device

*/

Quoted 43 lines
drivers/acpi/acpica/evregion.c +1 -1
-	status = acpi_get_handle(ec_device_node, METHOD_NAME__REG,
 &reg_method);
+	status = acpi_get_handle(device_node, METHOD_NAME__REG,
 &reg_method);
 	if (ACPI_FAILURE(status)) {
drivers/acpi/acpica/evregion.c +0 -0
 		goto exit;	/* There is no _REG method present */
 	}
@@ -816,23 +816,23 @@ acpi_ev_orphan_ec_reg_method(struct
 acpi_namespace_node *ec_device_node)
 	 * with other space IDs to be present; but the code below will then
 	 * execute the _REG method with the embedded_control space_ID

argument.

drivers/acpi/acpica/evregion.c +1 -2
 	 */
-	next_node = acpi_ns_get_next_node(ec_device_node, NULL);
+	next_node = acpi_ns_get_next_node(device_node, NULL);
 	while (next_node) {
 		if ((next_node->type == ACPI_TYPE_REGION) &&
 		    (next_node->object) &&
-		    (next_node->object->region.space_id ==

ACPI_ADR_SPACE_EC)) {

drivers/acpi/acpica/evregion.c +1 -1
+		    (next_node->object->region.space_id == space_id)) {
 			goto exit;	/* Do not execute the _REG */
 		}
 
-		next_node = acpi_ns_get_next_node(ec_device_node,

next_node);

drivers/acpi/acpica/evregion.c +1 -0
+		next_node = acpi_ns_get_next_node(device_node,

next_node);

drivers/acpi/acpica/evregion.c +2 -3
 	}
 
-	/* Evaluate the _REG(embedded_control,Connect) method */
+	/* Evaluate the _REG(space_id, Connect) method */
 
 	args.count = 2;
 	args.pointer = objects;
 	objects[0].type = ACPI_TYPE_INTEGER;
-	objects[0].integer.value = ACPI_ADR_SPACE_EC;
+	objects[0].integer.value = space_id;
 	objects[1].type = ACPI_TYPE_INTEGER;
 	objects[1].integer.value = ACPI_REG_CONNECT;
 
--
Quoted 1 line

2.28.0

This looks good to me. Bob, any thoughts?

Erik

#4 lore raw

Hi,

Quoted 12 lines · Erik
Quoted 12 lines

-----Original Message-----
From: Moore, Robert <[email protected]>
Sent: Tuesday, October 27, 2020 7:17 AM
To: Kaneda, Erik <[email protected]>; Hans de Goede <[email protected]>; Rafael J . Wysocki <[email protected]>; Len Brown <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] ACPICA: Also handle "orphan" _REG methods for GPIO OpRegions

Quoted 3 lines
Quoted 1 line

Looks OK to me.

Ok, I'll make a pull request of this to ACPICA on behalf of Hans and it will be in the next ACPICA release.

Great, thank you.

Regards,

Hans

Quoted 228 lines
Quoted 227 lines

-----Original Message-----
From: Kaneda, Erik <[email protected]>
Sent: Monday, October 26, 2020 1:56 PM
To: Hans de Goede <[email protected]>; Rafael J . Wysocki <[email protected]>; Len Brown <[email protected]>; Moore, Robert <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] ACPICA: Also handle "orphan" _REG methods for GPIO OpRegions

Quoted 95 lines

-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: Sunday, October 25, 2020 2:46 AM
To: Rafael J . Wysocki <[email protected]>; Len Brown <[email protected]>; Moore, Robert <[email protected]>; Kaneda, Erik <[email protected]>
Cc: Hans de Goede <[email protected]>; [email protected]; [email protected]
Subject: [PATCH] ACPICA: Also handle "orphan" _REG methods for GPIO OpRegions

Before this commit acpi_ev_execute_reg_methods() had special handling to handle "orphan" (no matching OpRegion declared) _REG methods for EC nodes.

On Intel Cherry Trail devices there are 2 possible ACPI OpRegions for accessing GPIOs. The standard GeneralPurposeIo OpRegion and the Cherry Trail specific UserDefined 0x9X OpRegions.

Having 2 different types of OpRegions leads to potential issues with checks for OpRegion availability, or in other words checks if _REG has been called for the OpRegion which the ACPI code wants to use.

Except for the "orphan" EC handling, ACPICA core does not call _REG on an ACPI node which does not define an OpRegion matching the type being registered; and the reference design DSDT, from which most Cherry Trail DSDTs are derived, does not define GeneralPurposeIo, nor UserDefined(0x93)
OpRegions for the GPO2 (UID 3) device, because no pins were assigned ACPI controlled functions in the reference design.

Together this leads to the perfect storm, at least on the Cherry Trail based Medion Akayo E1239T. This design does use a GPO2 pin from its ACPI code and has added the Cherry Trail specific UserDefined(0x93) opregion to its GPO2 ACPI node to access this pin.

But it uses a has _REG been called availability check for the standard GeneralPurposeIo OpRegion. This clearly is a bug in the DSDT, but this does work under Windows. This issue leads to the intel_vbtn driver reporting the device always being in tablet-mode at boot, even if it is in laptop mode. Which in turn causes userspace to ignore touchpad events. So iow this issues causes the touchpad to not work at boot.

This commit fixes this by extending the "orphan" _REG method handling to also apply to GPIO address-space handlers.

Note it seems that Windows always calls "orphan" _REG methods so me may want to consider dropping the space-id check and always do "orphan" _REG method handling.

---
 drivers/acpi/acpica/evregion.c | 54
+++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 27 deletions(-)
(quoted diff) +0 -0

b/drivers/acpi/acpica/evregion.c index 738d4b231f34..21ff341e34a4 100644

drivers/acpi/acpica/evregion.c +2 -1
@@ -21,7 +21,8 @@ extern u8 acpi_gbl_default_address_spaces[];
 /* Local prototypes */
 
 static void
-acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node
 *ec_device_node);
+acpi_ev_execute_orphan_reg_method(struct acpi_namespace_node
 *device_node,
+				  acpi_adr_space_type space_id);
 

static acpi_status
acpi_ev_reg_run(acpi_handle obj_handle, @@ -684,10 +685,12 @@
acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
ACPI_NS_WALK_UNLOCK,
acpi_ev_reg_run, NULL,

drivers/acpi/acpica/evregion.c +0 -1
 				     &info, NULL);
 
-	/* Special case for EC: handle "orphan" _REG methods with no region

*/

drivers/acpi/acpica/evregion.c +5 -3
-
-	if (space_id == ACPI_ADR_SPACE_EC) {
-		acpi_ev_orphan_ec_reg_method(node);
+	/*
+	 * Special case for EC and GPIO: handle "orphan" _REG methods with
+	 * no region.
+	 */
+	if (space_id == ACPI_ADR_SPACE_EC || space_id ==

ACPI_ADR_SPACE_GPIO) {

drivers/acpi/acpica/evregion.c +1 -0
+		acpi_ev_execute_orphan_reg_method(node, space_id);
 	}
 
 	ACPI_DEBUG_PRINT_RAW((ACPI_DB_NAMES,

drivers/acpi/acpica/evregion.c acpi_ev_reg_run(acpi_handle obj_handle, · line 765

Quoted 3 lines
drivers/acpi/acpica/evregion.c +0 -0
@@ -760,31 +763,28 @@ acpi_ev_reg_run(acpi_handle obj_handle,
 
 
 

/**********************************************************

Quoted 12 lines
drivers/acpi/acpica/evregion.c +3 -3
 *********************
  *
- * FUNCTION:    acpi_ev_orphan_ec_reg_method
+ * FUNCTION:    acpi_ev_execute_orphan_reg_method
  *
- * PARAMETERS:  ec_device_node      - Namespace node for an EC device
+ * PARAMETERS:  device_node     - Namespace node for an ACPI device
+ *              space_id        - The address space ID
  *
  * RETURN:      None
  *
- * DESCRIPTION: Execute an "orphan" _REG method that appears under
Quoted 2 lines

the EC
+ * DESCRIPTION: Execute an "orphan" _REG method that appears under

an

Quoted 15 lines

ACPI

  *              device. This is a _REG method that has no corresponding region
- *              within the EC device scope. The orphan _REG method appears to
- *              have been enabled by the description of the ECDT in the ACPI
- *              specification: "The availability of the region space can be
- *              detected by providing a _REG method object underneath the
- *              Embedded Controller device."
- *
- *              To quickly access the EC device, we use the ec_device_node used
- *              during EC handler installation. Otherwise, we would need to
- *              perform a time consuming namespace walk, executing _HID
- *              methods to find the EC device.
+ *              within the device's scope. ACPI tables depending on these
+ *              "orphan" _REG methods have been seen for both EC and GPIO
+ *              Operation Regions. Presumably the Windows ACPI

implementation

Quoted 7 lines

+ * always calls the _REG method independent of the presence of
+ * an actual Operation Region with the correct address space ID.
*
* MUTEX: Assumes the namespace is locked
*

**********************************************************

Quoted 25 lines

********************/

static void
-acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node *ec_device_node) +acpi_ev_execute_orphan_reg_method(struct acpi_namespace_node *device_node,

drivers/acpi/acpica/evregion.c +1 -0
+				  acpi_adr_space_type space_id)
 {
 	acpi_handle reg_method;
 	struct acpi_namespace_node *next_node; @@ -792,9 +792,9 @@

acpi_ev_orphan_ec_reg_method(struct
acpi_namespace_node *ec_device_node)

drivers/acpi/acpica/evregion.c +2 -2
 	struct acpi_object_list args;
 	union acpi_object objects[2];
 
-	ACPI_FUNCTION_TRACE(ev_orphan_ec_reg_method);
+	ACPI_FUNCTION_TRACE(ev_execute_orphan_reg_method);
 
-	if (!ec_device_node) {
+	if (!device_node) {
 		return_VOID;
 	}

drivers/acpi/acpica/evregion.c acpi_ev_orphan_ec_reg_method(struct · line 806

Quoted 3 lines
drivers/acpi/acpica/evregion.c +0 -0
@@ -804,7 +804,7 @@ acpi_ev_orphan_ec_reg_method(struct
 acpi_namespace_node *ec_device_node)
 
 	/* Get a handle to a _REG method immediately under the EC device

*/

Quoted 43 lines
drivers/acpi/acpica/evregion.c +1 -1
-	status = acpi_get_handle(ec_device_node, METHOD_NAME__REG,
 &reg_method);
+	status = acpi_get_handle(device_node, METHOD_NAME__REG,
 &reg_method);
 	if (ACPI_FAILURE(status)) {
drivers/acpi/acpica/evregion.c +0 -0
 		goto exit;	/* There is no _REG method present */
 	}
@@ -816,23 +816,23 @@ acpi_ev_orphan_ec_reg_method(struct
 acpi_namespace_node *ec_device_node)
 	 * with other space IDs to be present; but the code below will then
 	 * execute the _REG method with the embedded_control space_ID

argument.

drivers/acpi/acpica/evregion.c +1 -2
 	 */
-	next_node = acpi_ns_get_next_node(ec_device_node, NULL);
+	next_node = acpi_ns_get_next_node(device_node, NULL);
 	while (next_node) {
 		if ((next_node->type == ACPI_TYPE_REGION) &&
 		    (next_node->object) &&
-		    (next_node->object->region.space_id ==

ACPI_ADR_SPACE_EC)) {

drivers/acpi/acpica/evregion.c +1 -1
+		    (next_node->object->region.space_id == space_id)) {
 			goto exit;	/* Do not execute the _REG */
 		}
 
-		next_node = acpi_ns_get_next_node(ec_device_node,

next_node);

drivers/acpi/acpica/evregion.c +1 -0
+		next_node = acpi_ns_get_next_node(device_node,

next_node);

drivers/acpi/acpica/evregion.c +2 -3
 	}
 
-	/* Evaluate the _REG(embedded_control,Connect) method */
+	/* Evaluate the _REG(space_id, Connect) method */
 
 	args.count = 2;
 	args.pointer = objects;
 	objects[0].type = ACPI_TYPE_INTEGER;
-	objects[0].integer.value = ACPI_ADR_SPACE_EC;
+	objects[0].integer.value = space_id;
 	objects[1].type = ACPI_TYPE_INTEGER;
 	objects[1].integer.value = ACPI_REG_CONNECT;
 
--
Quoted 1 line

2.28.0

This looks good to me. Bob, any thoughts?

Erik

#5 lore raw
Quoted 26 lines

-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: Tuesday, October 27, 2020 12:00 PM
To: Kaneda, Erik <[email protected]>; Moore, Robert <[email protected]>; Rafael J . Wysocki <[email protected]>; Len Brown <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] ACPICA: Also handle "orphan" _REG methods for GPIO OpRegions

Hi,

Quoted 10 lines · Erik
Quoted 10 lines

-----Original Message-----
From: Moore, Robert <[email protected]>
Sent: Tuesday, October 27, 2020 7:17 AM
To: Kaneda, Erik <[email protected]>; Hans de Goede <[email protected]>; Rafael J . Wysocki <[email protected]>; Len Brown <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] ACPICA: Also handle "orphan" _REG methods for

GPIO

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

OpRegions

Looks OK to me.

Ok, I'll make a pull request of this to ACPICA on behalf of Hans and it will be

in the next ACPICA release.

Great, thank you.

Pull request is available here: https://github.com/acpica/acpica/pull/644

Once it's merged, it'll be a part of the next ACPICA release.

Thanks,
Erik

Quoted 248 lines

Regards,

Hans

Quoted 8 lines
Quoted 8 lines

-----Original Message-----
From: Kaneda, Erik <[email protected]>
Sent: Monday, October 26, 2020 1:56 PM
To: Hans de Goede <[email protected]>; Rafael J . Wysocki <[email protected]>; Len Brown <[email protected]>; Moore, Robert <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] ACPICA: Also handle "orphan" _REG methods for

GPIO

Quoted 11 lines
Quoted 11 lines

OpRegions

Quoted 7 lines

-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: Sunday, October 25, 2020 2:46 AM
To: Rafael J . Wysocki <[email protected]>; Len Brown <[email protected]>; Moore, Robert <[email protected]>; Kaneda, Erik <[email protected]>
Cc: Hans de Goede <[email protected]>; linux-

[email protected];

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

[email protected]
Subject: [PATCH] ACPICA: Also handle "orphan" _REG methods for GPIO OpRegions

Before this commit acpi_ev_execute_reg_methods() had special

handling

Quoted 1 line
Quoted 1 line
Quoted 1 line

to handle "orphan" (no matching OpRegion declared) _REG methods for

EC

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

nodes.

On Intel Cherry Trail devices there are 2 possible ACPI OpRegions for accessing GPIOs. The standard GeneralPurposeIo OpRegion and the

Cherry

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Trail specific UserDefined 0x9X OpRegions.

Having 2 different types of OpRegions leads to potential issues with checks for OpRegion availability, or in other words checks if _REG has been called for the OpRegion which the ACPI code wants to use.

Except for the "orphan" EC handling, ACPICA core does not call _REG on an ACPI node which does not define an OpRegion matching the type

being

Quoted 68 lines
Quoted 68 lines
Quoted 68 lines

registered; and the reference design DSDT, from which most Cherry Trail DSDTs are derived, does not define GeneralPurposeIo, nor UserDefined(0x93)
OpRegions for the GPO2 (UID 3) device, because no pins were assigned ACPI controlled functions in the reference design.

Together this leads to the perfect storm, at least on the Cherry Trail based Medion Akayo E1239T. This design does use a GPO2 pin from its ACPI code and has added the Cherry Trail specific UserDefined(0x93) opregion to its GPO2 ACPI node to access this pin.

But it uses a has _REG been called availability check for the standard GeneralPurposeIo OpRegion. This clearly is a bug in the DSDT, but this does work under Windows. This issue leads to the intel_vbtn driver reporting the device always being in tablet-mode at boot, even if it is in laptop mode. Which in turn causes userspace to ignore touchpad events. So iow this issues causes the touchpad to not work at boot.

This commit fixes this by extending the "orphan" _REG method handling to also apply to GPIO address-space handlers.

Note it seems that Windows always calls "orphan" _REG methods so me may want to consider dropping the space-id check and always do "orphan" _REG method handling.

---
 drivers/acpi/acpica/evregion.c | 54
+++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 27 deletions(-)
(quoted diff) +0 -0

b/drivers/acpi/acpica/evregion.c index 738d4b231f34..21ff341e34a4 100644

drivers/acpi/acpica/evregion.c +2 -1
@@ -21,7 +21,8 @@ extern u8 acpi_gbl_default_address_spaces[];
 /* Local prototypes */
 
 static void
-acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node
 *ec_device_node);
+acpi_ev_execute_orphan_reg_method(struct acpi_namespace_node
 *device_node,
+				  acpi_adr_space_type space_id);
 

static acpi_status
acpi_ev_reg_run(acpi_handle obj_handle, @@ -684,10 +685,12 @@
acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
ACPI_NS_WALK_UNLOCK,
acpi_ev_reg_run, NULL,

drivers/acpi/acpica/evregion.c +0 -1
 				     &info, NULL);
 
-	/* Special case for EC: handle "orphan" _REG methods with no region

*/

drivers/acpi/acpica/evregion.c +5 -3
-
-	if (space_id == ACPI_ADR_SPACE_EC) {
-		acpi_ev_orphan_ec_reg_method(node);
+	/*
+	 * Special case for EC and GPIO: handle "orphan" _REG methods with
+	 * no region.
+	 */
+	if (space_id == ACPI_ADR_SPACE_EC || space_id ==

ACPI_ADR_SPACE_GPIO) {

drivers/acpi/acpica/evregion.c +1 -0
+		acpi_ev_execute_orphan_reg_method(node, space_id);
 	}
Quoted 6 lines
Quoted 6 lines

drivers/acpi/acpica/evregion.c acpi_ev_reg_run(acpi_handle obj_handle, · line 765

Quoted 5 lines
drivers/acpi/acpica/evregion.c +0 -0
 	ACPI_DEBUG_PRINT_RAW((ACPI_DB_NAMES,
@@ -760,31 +763,28 @@ acpi_ev_reg_run(acpi_handle obj_handle,
 
 
 

/**********************************************************

Quoted 6 lines
Quoted 6 lines

drivers/acpi/acpica/evregion.c acpi_ev_reg_run(acpi_handle obj_handle,

Quoted 6 lines
drivers/acpi/acpica/evregion.c +1 -2
 *********************
  *
- * FUNCTION:    acpi_ev_orphan_ec_reg_method
+ * FUNCTION:    acpi_ev_execute_orphan_reg_method
  *
- * PARAMETERS:  ec_device_node      - Namespace node for an EC

device

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/acpi/acpica/evregion.c +2 -1
+ * PARAMETERS:  device_node     - Namespace node for an ACPI device
+ *              space_id        - The address space ID
  *
  * RETURN:      None
  *
- * DESCRIPTION: Execute an "orphan" _REG method that appears under

the EC
+ * DESCRIPTION: Execute an "orphan" _REG method that appears

under

Quoted 4 lines
Quoted 4 lines

an

Quoted 3 lines

ACPI
* device. This is a _REG method that has no corresponding region
- * within the EC device scope. The orphan _REG method appears

to

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
- *              have been enabled by the description of the ECDT in the ACPI
- *              specification: "The availability of the region space can be
- *              detected by providing a _REG method object underneath the
- *              Embedded Controller device."

- *
- * To quickly access the EC device, we use the ec_device_node

used

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
- *              during EC handler installation. Otherwise, we would need to
- *              perform a time consuming namespace walk, executing _HID
- *              methods to find the EC device.
+ *              within the device's scope. ACPI tables depending on these
+ *              "orphan" _REG methods have been seen for both EC and

GPIO

Quoted 10 lines
Quoted 10 lines
Quoted 1 line

+ * Operation Regions. Presumably the Windows ACPI

implementation

Quoted 7 lines

+ * always calls the _REG method independent of the presence of
+ * an actual Operation Region with the correct address space ID.
*
* MUTEX: Assumes the namespace is locked
*

**********************************************************

Quoted 78 lines
Quoted 77 lines
Quoted 25 lines

********************/

static void
-acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node *ec_device_node) +acpi_ev_execute_orphan_reg_method(struct acpi_namespace_node *device_node,

drivers/acpi/acpica/evregion.c +1 -0
+				  acpi_adr_space_type space_id)
 {
 	acpi_handle reg_method;
 	struct acpi_namespace_node *next_node; @@ -792,9 +792,9 @@

acpi_ev_orphan_ec_reg_method(struct
acpi_namespace_node *ec_device_node)

drivers/acpi/acpica/evregion.c +2 -2
 	struct acpi_object_list args;
 	union acpi_object objects[2];
 
-	ACPI_FUNCTION_TRACE(ev_orphan_ec_reg_method);
+	ACPI_FUNCTION_TRACE(ev_execute_orphan_reg_method);
 
-	if (!ec_device_node) {
+	if (!device_node) {
 		return_VOID;
 	}

drivers/acpi/acpica/evregion.c acpi_ev_orphan_ec_reg_method(struct · line 806

Quoted 3 lines
drivers/acpi/acpica/evregion.c +0 -0
@@ -804,7 +804,7 @@ acpi_ev_orphan_ec_reg_method(struct
 acpi_namespace_node *ec_device_node)
 
 	/* Get a handle to a _REG method immediately under the EC device

*/

Quoted 43 lines
drivers/acpi/acpica/evregion.c +1 -1
-	status = acpi_get_handle(ec_device_node, METHOD_NAME__REG,
 &reg_method);
+	status = acpi_get_handle(device_node, METHOD_NAME__REG,
 &reg_method);
 	if (ACPI_FAILURE(status)) {
drivers/acpi/acpica/evregion.c +0 -0
 		goto exit;	/* There is no _REG method present */
 	}
@@ -816,23 +816,23 @@ acpi_ev_orphan_ec_reg_method(struct
 acpi_namespace_node *ec_device_node)
 	 * with other space IDs to be present; but the code below will then
 	 * execute the _REG method with the embedded_control space_ID

argument.

drivers/acpi/acpica/evregion.c +1 -2
 	 */
-	next_node = acpi_ns_get_next_node(ec_device_node, NULL);
+	next_node = acpi_ns_get_next_node(device_node, NULL);
 	while (next_node) {
 		if ((next_node->type == ACPI_TYPE_REGION) &&
 		    (next_node->object) &&
-		    (next_node->object->region.space_id ==

ACPI_ADR_SPACE_EC)) {

drivers/acpi/acpica/evregion.c +1 -1
+		    (next_node->object->region.space_id == space_id)) {
 			goto exit;	/* Do not execute the _REG */
 		}
 
-		next_node = acpi_ns_get_next_node(ec_device_node,

next_node);

drivers/acpi/acpica/evregion.c +1 -0
+		next_node = acpi_ns_get_next_node(device_node,

next_node);

drivers/acpi/acpica/evregion.c +2 -3
 	}
 
-	/* Evaluate the _REG(embedded_control,Connect) method */
+	/* Evaluate the _REG(space_id, Connect) method */
 
 	args.count = 2;
 	args.pointer = objects;
 	objects[0].type = ACPI_TYPE_INTEGER;
-	objects[0].integer.value = ACPI_ADR_SPACE_EC;
+	objects[0].integer.value = space_id;
 	objects[1].type = ACPI_TYPE_INTEGER;
 	objects[1].integer.value = ACPI_REG_CONNECT;
 
--
Quoted 1 line

2.28.0

This looks good to me. Bob, any thoughts?

Erik

#6 lore raw

Hi,

Quoted 30 lines · Erik
Quoted 30 lines

-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: Tuesday, October 27, 2020 12:00 PM
To: Kaneda, Erik <[email protected]>; Moore, Robert <[email protected]>; Rafael J . Wysocki <[email protected]>; Len Brown <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] ACPICA: Also handle "orphan" _REG methods for GPIO OpRegions

Hi,

Quoted 10 lines · Erik
Quoted 10 lines

-----Original Message-----
From: Moore, Robert <[email protected]>
Sent: Tuesday, October 27, 2020 7:17 AM
To: Kaneda, Erik <[email protected]>; Hans de Goede <[email protected]>; Rafael J . Wysocki <[email protected]>; Len Brown <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] ACPICA: Also handle "orphan" _REG methods for

GPIO

Quoted 4 lines
Quoted 3 lines

OpRegions

Looks OK to me.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Ok, I'll make a pull request of this to ACPICA on behalf of Hans and it will be

in the next ACPICA release.

Great, thank you.

Pull request is available here: https://github.com/acpica/acpica/pull/644

Once it's merged, it'll be a part of the next ACPICA release.

Thank you for porting this to the ACPICA upstream code, unfortunately you missed one change when porting this. I've added a review pointing the missing bit out on github.

Specifically you missed this bit:

if ((next_node->type == ACPI_TYPE_REGION) &&
(next_node->object) &&
- (next_node->object->region.space_id == ACPI_ADR_SPACE_EC)) {
+ (next_node->object->region.space_id == space_id)) {
goto exit; /* Do not execute the _REG */
}

Regards,

Hans

#7 lore raw
Quoted 68 lines

-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: Thursday, October 29, 2020 2:49 AM
To: Kaneda, Erik <[email protected]>; Moore, Robert <[email protected]>; Rafael J . Wysocki <[email protected]>; Len Brown <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] ACPICA: Also handle "orphan" _REG methods for GPIO OpRegions

Hi,

Quoted 10 lines · Erik
Quoted 10 lines

-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: Tuesday, October 27, 2020 12:00 PM
To: Kaneda, Erik <[email protected]>; Moore, Robert <[email protected]>; Rafael J . Wysocki <[email protected]>; Len Brown <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] ACPICA: Also handle "orphan" _REG methods for

GPIO

Quoted 4 lines
Quoted 4 lines

OpRegions

Hi,

Quoted 8 lines
Quoted 8 lines · Erik
Quoted 7 lines
Quoted 7 lines

-----Original Message-----
From: Moore, Robert <[email protected]>
Sent: Tuesday, October 27, 2020 7:17 AM
To: Kaneda, Erik <[email protected]>; Hans de Goede <[email protected]>; Rafael J . Wysocki <[email protected]>;

Len

Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines

Brown <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] ACPICA: Also handle "orphan" _REG methods for

GPIO

Quoted 5 lines
Quoted 3 lines

OpRegions

Looks OK to me.

Ok, I'll make a pull request of this to ACPICA on behalf of Hans and it will

be

Quoted 7 lines
Quoted 3 lines

in the next ACPICA release.

Great, thank you.

Pull request is available here: https://github.com/acpica/acpica/pull/644

Once it's merged, it'll be a part of the next ACPICA release.

Thank you for porting this to the ACPICA upstream code, unfortunately you missed one change when porting this. I've added a review pointing the missing bit out on github.

Specifically you missed this bit:

(quoted diff) +0 -1
 		if ((next_node->type == ACPI_TYPE_REGION) &&
 		    (next_node->object) &&
-		    (next_node->object->region.space_id ==

ACPI_ADR_SPACE_EC)) {

Review

Quoted 3 lines
(quoted diff) +1 -0
+		    (next_node->object->region.space_id == space_id)) {
 			goto exit;	/* Do not execute the _REG */
 		}

Updated the PR.

Thanks for catching this,
Erik

Quoted 4 lines

Regards,

Hans

#8 lore raw
In reply to Kaneda, Erik

I've merged this one.

-----Original Message-----
From: Kaneda, Erik <erik.kaneda(a)intel.com>
Sent: Wednesday, October 28, 2020 3:34 PM
To: Hans de Goede <hdegoede(a)redhat.com>; Moore, Robert <robert.moore(a)intel.com>; Rafael J . Wysocki <rjw(a)rjwysocki.net>; Len Brown <lenb(a)kernel.org>
Cc: linux-acpi(a)vger.kernel.org; devel(a)acpica.org
Subject: RE: [PATCH] ACPICA: Also handle "orphan" _REG methods for GPIO OpRegions

Quoted 26 lines

-----Original Message-----
From: Hans de Goede <hdegoede(a)redhat.com>
Sent: Tuesday, October 27, 2020 12:00 PM
To: Kaneda, Erik <erik.kaneda(a)intel.com>; Moore, Robert <robert.moore(a)intel.com>; Rafael J . Wysocki <rjw(a)rjwysocki.net>; Len Brown <lenb(a)kernel.org>
Cc: linux-acpi(a)vger.kernel.org; devel(a)acpica.org
Subject: Re: [PATCH] ACPICA: Also handle "orphan" _REG methods for GPIO OpRegions

Hi,

Quoted 10 lines · Erik
Quoted 10 lines

-----Original Message-----
From: Moore, Robert <robert.moore(a)intel.com>
Sent: Tuesday, October 27, 2020 7:17 AM
To: Kaneda, Erik <erik.kaneda(a)intel.com>; Hans de Goede <hdegoede(a)redhat.com>; Rafael J . Wysocki <rjw(a)rjwysocki.net>; Len Brown <lenb(a)kernel.org>
Cc: linux-acpi(a)vger.kernel.org; devel(a)acpica.org
Subject: RE: [PATCH] ACPICA: Also handle "orphan" _REG methods for

GPIO

Quoted 2 lines
Quoted 2 lines

OpRegions

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Looks OK to me.

Ok, I'll make a pull request of this to ACPICA on behalf of Hans and it will be

in the next ACPICA release.

Great, thank you.

Pull request is available here: https://github.com/acpica/acpica/pull/644

Once it's merged, it'll be a part of the next ACPICA release.

Thanks,
Erik

Quoted 251 lines

Regards,

Hans

Quoted 8 lines
Quoted 8 lines

-----Original Message-----
From: Kaneda, Erik <erik.kaneda(a)intel.com>
Sent: Monday, October 26, 2020 1:56 PM
To: Hans de Goede <hdegoede(a)redhat.com>; Rafael J . Wysocki <rjw(a)rjwysocki.net>; Len Brown <lenb(a)kernel.org>; Moore, Robert <robert.moore(a)intel.com>
Cc: linux-acpi(a)vger.kernel.org; devel(a)acpica.org
Subject: RE: [PATCH] ACPICA: Also handle "orphan" _REG methods for

GPIO

Quoted 11 lines
Quoted 11 lines

OpRegions

Quoted 7 lines

-----Original Message-----
From: Hans de Goede <hdegoede(a)redhat.com>
Sent: Sunday, October 25, 2020 2:46 AM
To: Rafael J . Wysocki <rjw(a)rjwysocki.net>; Len Brown <lenb(a)kernel.org>; Moore, Robert <robert.moore(a)intel.com>; Kaneda, Erik <erik.kaneda(a)intel.com>
Cc: Hans de Goede <hdegoede(a)redhat.com>; linux-

acpi(a)vger.kernel.org;

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

devel(a)acpica.org
Subject: [PATCH] ACPICA: Also handle "orphan" _REG methods for GPIO OpRegions

Before this commit acpi_ev_execute_reg_methods() had special

handling

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

to handle "orphan" (no matching OpRegion declared) _REG methods for

EC

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

nodes.

On Intel Cherry Trail devices there are 2 possible ACPI OpRegions for accessing GPIOs. The standard GeneralPurposeIo OpRegion and the

Cherry

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Trail specific UserDefined 0x9X OpRegions.

Having 2 different types of OpRegions leads to potential issues with checks for OpRegion availability, or in other words checks if _REG has been called for the OpRegion which the ACPI code wants to use.

Except for the "orphan" EC handling, ACPICA core does not call _REG on an ACPI node which does not define an OpRegion matching the type

being

Quoted 68 lines
Quoted 68 lines
Quoted 68 lines

registered; and the reference design DSDT, from which most Cherry Trail DSDTs are derived, does not define GeneralPurposeIo, nor UserDefined(0x93)
OpRegions for the GPO2 (UID 3) device, because no pins were assigned ACPI controlled functions in the reference design.

Together this leads to the perfect storm, at least on the Cherry Trail based Medion Akayo E1239T. This design does use a GPO2 pin from its ACPI code and has added the Cherry Trail specific UserDefined(0x93) opregion to its GPO2 ACPI node to access this pin.

But it uses a has _REG been called availability check for the
standard GeneralPurposeIo OpRegion. This clearly is a bug in the
DSDT, but this does work under Windows. This issue leads to the
intel_vbtn driver reporting the device always being in tablet-mode
at boot, even if it is in laptop mode. Which in turn causes
userspace to ignore touchpad events. So iow this issues causes the touchpad to not work at boot.

This commit fixes this by extending the "orphan" _REG method handling to also apply to GPIO address-space handlers.

Note it seems that Windows always calls "orphan" _REG methods so me may want to consider dropping the space-id check and always do "orphan" _REG method handling.

Signed-off-by Hans de Goede <hdegoede(a)redhat.com>
---
 drivers/acpi/acpica/evregion.c | 54
+++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 27 deletions(-)
(quoted diff) +0 -0

b/drivers/acpi/acpica/evregion.c index 738d4b231f34..21ff341e34a4 100644

drivers/acpi/acpica/evregion.c +2 -1
@@ -21,7 +21,8 @@ extern u8 acpi_gbl_default_address_spaces[];
 /* Local prototypes */
 
 static void
-acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node 
 *ec_device_node);
+acpi_ev_execute_orphan_reg_method(struct acpi_namespace_node
 *device_node,
+				  acpi_adr_space_type space_id);
 

static acpi_status
acpi_ev_reg_run(acpi_handle obj_handle, @@ -684,10 +685,12 @@
acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
ACPI_NS_WALK_UNLOCK,
acpi_ev_reg_run, NULL,

drivers/acpi/acpica/evregion.c +0 -1
 				     &info, NULL);
 
-	/* Special case for EC: handle "orphan" _REG methods with no region

*/

drivers/acpi/acpica/evregion.c +5 -3
-
-	if (space_id == ACPI_ADR_SPACE_EC) {
-		acpi_ev_orphan_ec_reg_method(node);
+	/*
+	 * Special case for EC and GPIO: handle "orphan" _REG methods with
+	 * no region.
+	 */
+	if (space_id == ACPI_ADR_SPACE_EC || space_id ==

ACPI_ADR_SPACE_GPIO) {

drivers/acpi/acpica/evregion.c +1 -0
+		acpi_ev_execute_orphan_reg_method(node, space_id);
 	}
Quoted 6 lines
Quoted 6 lines

drivers/acpi/acpica/evregion.c acpi_ev_reg_run(acpi_handle obj_handle, · line 765

Quoted 5 lines
drivers/acpi/acpica/evregion.c +0 -0
 	ACPI_DEBUG_PRINT_RAW((ACPI_DB_NAMES,
@@ -760,31 +763,28 @@ acpi_ev_reg_run(acpi_handle obj_handle,
 
 
 

/**********************************************************

Quoted 6 lines
Quoted 6 lines

drivers/acpi/acpica/evregion.c acpi_ev_reg_run(acpi_handle obj_handle,

Quoted 6 lines
drivers/acpi/acpica/evregion.c +1 -2
 *********************
  *
- * FUNCTION:    acpi_ev_orphan_ec_reg_method
+ * FUNCTION:    acpi_ev_execute_orphan_reg_method
  *
- * PARAMETERS:  ec_device_node      - Namespace node for an EC

device

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/acpi/acpica/evregion.c +2 -1
+ * PARAMETERS:  device_node     - Namespace node for an ACPI device
+ *              space_id        - The address space ID
  *
  * RETURN:      None
  *
- * DESCRIPTION: Execute an "orphan" _REG method that appears 

under the EC
+ * DESCRIPTION: Execute an "orphan" _REG method that appears

under

Quoted 4 lines
Quoted 4 lines

an

Quoted 3 lines

ACPI
* device. This is a _REG method that has no corresponding region
- * within the EC device scope. The orphan _REG method appears

to

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
- *              have been enabled by the description of the ECDT in the ACPI
- *              specification: "The availability of the region space can be
- *              detected by providing a _REG method object underneath the
- *              Embedded Controller device."

- *
- * To quickly access the EC device, we use the ec_device_node

used

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
- *              during EC handler installation. Otherwise, we would need to
- *              perform a time consuming namespace walk, executing _HID
- *              methods to find the EC device.
+ *              within the device's scope. ACPI tables depending on these
+ *              "orphan" _REG methods have been seen for both EC and

GPIO

Quoted 10 lines
Quoted 10 lines
Quoted 1 line

+ * Operation Regions. Presumably the Windows ACPI

implementation

Quoted 7 lines

+ * always calls the _REG method independent of the presence of
+ * an actual Operation Region with the correct address space ID.
*
* MUTEX: Assumes the namespace is locked
*

**********************************************************

Quoted 78 lines
Quoted 77 lines
Quoted 25 lines

********************/

static void
-acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node *ec_device_node) +acpi_ev_execute_orphan_reg_method(struct acpi_namespace_node *device_node,

drivers/acpi/acpica/evregion.c +1 -0
+				  acpi_adr_space_type space_id)
 {
 	acpi_handle reg_method;
 	struct acpi_namespace_node *next_node; @@ -792,9 +792,9 @@ 

acpi_ev_orphan_ec_reg_method(struct
acpi_namespace_node *ec_device_node)

drivers/acpi/acpica/evregion.c +2 -2
 	struct acpi_object_list args;
 	union acpi_object objects[2];
 
-	ACPI_FUNCTION_TRACE(ev_orphan_ec_reg_method);
+	ACPI_FUNCTION_TRACE(ev_execute_orphan_reg_method);
 
-	if (!ec_device_node) {
+	if (!device_node) {
 		return_VOID;
 	}

drivers/acpi/acpica/evregion.c acpi_ev_orphan_ec_reg_method(struct · line 806

Quoted 3 lines
drivers/acpi/acpica/evregion.c +0 -0
@@ -804,7 +804,7 @@ acpi_ev_orphan_ec_reg_method(struct
 acpi_namespace_node *ec_device_node)
 
 	/* Get a handle to a _REG method immediately under the EC device

*/

Quoted 43 lines
drivers/acpi/acpica/evregion.c +1 -1
-	status = acpi_get_handle(ec_device_node, METHOD_NAME__REG,
 &reg_method);
+	status = acpi_get_handle(device_node, METHOD_NAME__REG,
 &reg_method);
 	if (ACPI_FAILURE(status)) {
drivers/acpi/acpica/evregion.c +0 -0
 		goto exit;	/* There is no _REG method present */
 	}
@@ -816,23 +816,23 @@ acpi_ev_orphan_ec_reg_method(struct
 acpi_namespace_node *ec_device_node)
 	 * with other space IDs to be present; but the code below will then
 	 * execute the _REG method with the embedded_control space_ID 

argument.

drivers/acpi/acpica/evregion.c +1 -2
 	 */
-	next_node = acpi_ns_get_next_node(ec_device_node, NULL);
+	next_node = acpi_ns_get_next_node(device_node, NULL);
 	while (next_node) {
 		if ((next_node->type == ACPI_TYPE_REGION) &&
 		    (next_node->object) &&
-		    (next_node->object->region.space_id ==

ACPI_ADR_SPACE_EC)) {

drivers/acpi/acpica/evregion.c +1 -1
+		    (next_node->object->region.space_id == space_id)) {
 			goto exit;	/* Do not execute the _REG */
 		}
 
-		next_node = acpi_ns_get_next_node(ec_device_node,

next_node);

drivers/acpi/acpica/evregion.c +1 -0
+		next_node = acpi_ns_get_next_node(device_node,

next_node);

drivers/acpi/acpica/evregion.c +2 -3
 	}
 
-	/* Evaluate the _REG(embedded_control,Connect) method */
+	/* Evaluate the _REG(space_id, Connect) method */
 
 	args.count = 2;
 	args.pointer = objects;
 	objects[0].type = ACPI_TYPE_INTEGER;
-	objects[0].integer.value = ACPI_ADR_SPACE_EC;
+	objects[0].integer.value = space_id;
 	objects[1].type = ACPI_TYPE_INTEGER;
 	objects[1].integer.value = ACPI_REG_CONNECT;
 
--
Quoted 1 line

2.28.0

This looks good to me. Bob, any thoughts?

Erik