HID: amd_sfh: accept op_idx acks with sensor_id 13 on ROG Flow X16 GV601R
Subsystems (2)
PATCH 1/1 HID: amd_sfh: accept op_idx acks with sensor_id 13 on ROG Flow X16 GV601R
From: ratcashdev <[email protected]>
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.
---
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(+)
drivers/hid/amd-sfh-hid/amd_sfh_common.h +2 -0
@@ -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; };
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +20 -0
@@ -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
Signature · 1 line
2.56.1
Quoted 22 lines · Denis Benato
From: ratcashdev <[email protected]>
The MP2 v2 firmware of the ASUS ROG Flow X16 2022 (GV601R) acks ENABLE/DISABLE of the operating-mode sensor (
op_idx, 15) withsensor_id13 inP2C_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()requiressensor_id== sid, so sensor setup at probe stalls for the 10 s ack timeout andop_idxstaysSENSOR_DISABLED. The "tabletmode" auxiliary device is then not created and noSW_TABLET_MODEswitch is reported.Add a DMI quirk with the
sensor_idthis firmware uses inop_idxacks and matchop_idxacks 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_devhas notm_auxdevandmp2_select_ops()does not setmp2_ver.
Quoted 5 lines
Fixes 3a807f3ff9ea ("HID: amd_sfh: Enable operating mode")Signed-off-by Denis Benato <[email protected]>Signed-off-by ratcashdev <[email protected]>---
Notes:
Hi all,
I am sending this patch on behalf of the user that has created and tested it.
Best regards,
Denis Benato
Quoted 94 lines
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_MODEtoggles 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_MODEcomes fromamd_sfh_tabletmodeinstead.Tool use: the root-cause analysis (a debug build logging
P2C_MSG0after theop_idxcommands), 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(+)drivers/hid/amd-sfh-hid/amd_sfh_common.h +2
-0@@ -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; };drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +20
-0@@ -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
Quoted 11 lines · Denis Benato
Quoted 9 lines · Denis Benato
From: ratcashdev <[email protected]>
The MP2 v2 firmware of the ASUS ROG Flow X16 2022 (GV601R) acks ENABLE/DISABLE of the operating-mode sensor (
op_idx, 15) withsensor_id13 inP2C_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
Quoted 7 lines
Quoted 7 lines
amd_sfh_wait_response_v2()requiressensor_id== sid, so sensor setup at probe stalls for the 10 s ack timeout andop_idxstaysSENSOR_DISABLED. The "tabletmode" auxiliary device is then not created and noSW_TABLET_MODEswitch is reported.Add a DMI quirk with the
sensor_idthis firmware uses inop_idxacks and matchop_idxacks against it.
I tend to think this is a generic problem in the driver with handling of these sensor IDs; this shouldn't be a quirk.
Let's let Basavaraj comment though to confirm.
Quoted 6 lines
Quoted 6 lines
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_devhas notm_auxdevandmp2_select_ops()does not setmp2_ver.
I don't understand why this is in the commit message. It should be below the cutlist, or in the cover letter.
Quoted 6 lines
Quoted 5 lines
Fixes 3a807f3ff9ea ("HID: amd_sfh: Enable operating mode")Signed-off-by Denis Benato <[email protected]>Signed-off-by ratcashdev <[email protected]>---
Notes:
Quoted 7 lines
Hi all,
I am sending this patch on behalf of the user that has created and tested it.
Best regards,
Denis Benato
I think you got the order of S-o-b wrong, it's a chain of custody. It should have been
Quoted 24 lines
Quoted 24 lines
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_MODEtoggles 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_MODEcomes fromamd_sfh_tabletmodeinstead.
Quoted 4 lines
Quoted 4 lines
Tool use: the root-cause analysis (a debug build logging
P2C_MSG0after theop_idxcommands), 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.
Please ask the agent to follow correct style while writing commit messages.
Quoted 67 lines
Quoted 67 lines
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(+)drivers/hid/amd-sfh-hid/amd_sfh_common.h +2
-0@@ -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; };drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +20
-0@@ -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