mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] HID: amd_sfh: accept op_idx acks with sensor_id 13 on ROG Flow X16 GV601R
@ 2026-12-02 12:52 Denis Benato
  2026-12-02 12:53 ` Denis Benato
  0 siblings, 1 reply; 2+ messages in thread
From: Denis Benato @ 2026-12-02 12:52 UTC (permalink / raw)
  To: linux-kernel, Basavaraj Natikar
  Cc: linux-input, kernel, Benjamin Tissoires, Jiri Kosina,
	Luke D . Jones, Mateusz Schyboll, Denis Benato,
	Mario Limonciello, Akshata MukundShetty, ratcashdev,
	Denis Benato

From: ratcashdev <developer@ratcash.net>

The MP2 v2 firmware of the ASUS ROG Flow X16 2022 (GV601R) acks
ENABLE/DISABLE of the operating-mode sensor (op_idx, 15) with
sensor_id 13 in P2C_MSG0:

  start: P2C_MSG0=0x000d0248 status=0 response=4 sub_cmd=2 sensor_id=13
  stop:  P2C_MSG0=0x000d0258 status=0 response=5 sub_cmd=2 sensor_id=13

amd_sfh_wait_response_v2() requires sensor_id == sid, so sensor setup
at probe stalls for the 10 s ack timeout and op_idx stays
SENSOR_DISABLED. The "tabletmode" auxiliary device is then not created
and no SW_TABLET_MODE switch is reported.

Add a DMI quirk with the sensor_id this firmware uses in op_idx acks
and match op_idx acks against it.

Trees without the tabletmode auxiliary device (6.17, 6.18) only have
the stall; there the patch needs its context adjusted, as struct
amd_mp2_dev has no tm_auxdev and mp2_select_ops() does not set
mp2_ver.

Fixes: 3a807f3ff9ea ("HID: amd_sfh: Enable operating mode")
Signed-off-by: Denis Benato <denis.benato@linux.dev>
Signed-off-by: ratcashdev <developer@ratcash.net>
---
Notes:

Tested on a GV601RM (BIOS GV601RM.500.U4, 10/28/2022) with
next-20261201 and v7.3.4, each plus this patch: the 10 s stall in SFH
probe is gone, amd_sfh.tabletmode is created and SW_TABLET_MODE toggles
correctly when the screen is folded back (libinput disables the
keyboard/touchpad, the desktop shows the on-screen keyboard). The
switch keeps working across suspend/resume on both kernels. Not tested
on GV601RE/GV601RW; they are matched on the assumption that they share
the firmware.

The stall fix was not tested on 6.17/6.18 (no adjusted backport built).

Questions for Basavaraj:
- Is 13 the firmware's own id for the operating-mode sensor on this
  MP2 generation? This machine's sensor mask (P2C_MSG3 >> 4 = 0x2a409)
  also sets bit 13, which the driver does not decode. If 13 is the
  native id, a mapping in the driver may be preferable to a DMI quirk.
- Is there a firmware update that fixes the ack instead?

On the same machine asus-nb-wmi logs "This device has
tablet-mode-switch quirk but got ENODEV checking it. This is a bug."
(Cc Denis); with this patch SW_TABLET_MODE comes from amd_sfh_tabletmode
instead.

Tool use: the root-cause analysis (a debug build logging P2C_MSG0 after
the op_idx commands), the patch and this changelog were drafted with an
AI coding assistant (Claude Code). I reviewed the code, ran the debug
build and tested the patch on the hardware above.

 drivers/hid/amd-sfh-hid/amd_sfh_common.h |  2 ++
 drivers/hid/amd-sfh-hid/amd_sfh_pcie.c   | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_common.h b/drivers/hid/amd-sfh-hid/amd_sfh_common.h
index 4481a5035..eebe46149 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_common.h
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_common.h
@@ -77,6 +77,8 @@ struct amd_mp2_dev {
 	u8 init_done;
 	u8 rver;
 	u8 mp2_ver;
+	/* sensor_id the firmware puts in op_idx acks, 0 = op_idx */
+	u8 op_ack_sid;
 	struct auxiliary_device *tm_auxdev;
 };
 
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
index a0a7cfaa2..84191bb7e 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
@@ -48,6 +48,9 @@ static int amd_sfh_wait_response_v2(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_
 {
 	union cmd_response cmd_resp;
 
+	if (sid == op_idx && mp2->op_ack_sid)
+		sid = mp2->op_ack_sid;
+
 	/* Get response with status within a max of 10 seconds timeout */
 	if (!readl_poll_timeout(mp2->mmio + AMD_P2C_MSG(0), cmd_resp.resp,
 				(cmd_resp.response_v2.response == sensor_sts &&
@@ -278,8 +281,22 @@ static struct amd_mp2_ops amd_sfh_ops = {
 	.remove = amd_mp2_pci_remove,
 };
 
+/* firmware that acks op_idx commands with a different sensor_id */
+static const struct dmi_system_id dmi_op_ack_sid_quirks[] = {
+	{
+		/* ROG Flow X16 2022: GV601RM, GV601RE, GV601RW */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+			DMI_MATCH(DMI_BOARD_NAME, "GV601R"),
+		},
+		.driver_data = (void *)13,
+	},
+	{ }
+};
+
 static void mp2_select_ops(struct amd_mp2_dev *privdata)
 {
+	const struct dmi_system_id *dmi_id;
 	u8 acs;
 
 	privdata->mp2_acs = readl(privdata->mmio + AMD_P2C_MSG3);
@@ -289,6 +306,9 @@ static void mp2_select_ops(struct amd_mp2_dev *privdata)
 	case V2_STATUS:
 		privdata->mp2_ops = &amd_sfh_ops_v2;
 		privdata->mp2_ver = MP2_VER_V2;
+		dmi_id = dmi_first_match(dmi_op_ack_sid_quirks);
+		if (dmi_id)
+			privdata->op_ack_sid = (uintptr_t)dmi_id->driver_data;
 		break;
 	default:
 		privdata->mp2_ops = &amd_sfh_ops;

base-commit: 47d0d5ce3cfca63a04eabcbeef7086d06240ff97
-- 
2.56.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-02 12:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-02 12:52 [PATCH] HID: amd_sfh: accept op_idx acks with sensor_id 13 on ROG Flow X16 GV601R Denis Benato
2026-12-02 12:53 ` Denis Benato

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®