[BUG] amd_sfh: ~10-second resume delay from accelerometer response timeout

From: lendev4

Date: Thu Sep 17 2026 - 18:25:36 EST


Hello,
I am reporting a reproducible ~10-second resume delay in amd_sfh associated with an accelerometer response timeout.

Hardware: HP ENVY x360 2-in-1 Laptop 15-ey0xxx, board 8A31, BIOS F.14 (2023-07-05); AMD sensor hub 1022:15e4 at 0000:04:00.7.
Software: Linux 7.2.5, s2idle suspend.

To reproduce, load amd_sfh with sensor_mask=-1 and suspend with systemctl suspend. After wake, the display shows a stale frame for about 8-10 seconds, including without locking. PM timing measured the sensor-hub resume callback at 10,011,884 us.

Unloading amd_sfh removes the delay; reloading it with default discovery restores it. Using sensor_mask=0x88002, excluding accelerometer ID 0 while retaining gyro 1, operating mode 15, and ALS 19, also removes the delay.

With the normal 500 us polling sleep parameter, kprobes show the accelerometer enable command 0xc8001011. On the failing resume, polling first reads 0x00130340 and then repeatedly reads 0x000a0340 (status 0, enabled, sensor ID 10) until the 10-second timeout. The other sensors subsequently receive matching acknowledgments.

Successful driver initialization and the failed resume use the same accelerometer command and DMA address.

As an experiment, I changed only the polling sleep parameter in amd_sfh_wait_response_v2() from 500 us to 20 us, leaving the 10-second timeout and all response checks unchanged. This eliminated the delay in two uninstrumented tests and one traced test. Accelerometer initialization and resume were confirmed enabled in both uninstrumented tests.

The successful traced resume shows:

+69 us: matching accelerometer acknowledgment 0x340 read
+71 us: driver reports success
+90 us: subsequent gyro wait reads 0xa0340 (sensor ID 10)

This suggests that the driver may be missing a short-lived matching acknowledgment before another sensor response replaces it. However, the failing traces do not establish that firmware actually published the correct accelerometer acknowledgment during those wakes, and I have tested only this laptop.

For the experiment, only amd_sfh was rebuilt against the installed headers from Linux 7.2.5 source, with a header-compatibility patch renaming platform-state enums. The rebuilt baseline .text matched the installed driver's .text byte for byte; srcversion metadata differed.

I have attached focused trace excerpts and the experimental polling change; I am not proposing the polling change as a final fix. Full traces and the kprobe script are available if useful.

The investigation and preparation of this report were AI-assisted; I verified the reported tests, measurements, and trace data. I currently use the accelerometer exclusion as a workaround.

Is the additional sensor ID 10 response expected here, and could it explain the accelerometer response timeout with the current polling sleep parameter?

Thank you.--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
@@ -48,7 +48,7 @@
if (!readl_poll_timeout(mp2->mmio + AMD_P2C_MSG(0), cmd_resp.resp,
(cmd_resp.response_v2.response == sensor_sts &&
cmd_resp.response_v2.status == 0 && (sid == 0xff ||
- cmd_resp.response_v2.sensor_id == sid)), 500, 10000000))
+ cmd_resp.response_v2.sensor_id == sid)), 20, 10000000))
return cmd_resp.response_v2.response;

return SENSOR_DISABLED;
Focused kprobe trace excerpts. Timestamps are seconds from the trace clock.
Original trace lines below are unchanged; unrelated/repeated lines are omitted.

Probe locations were verified by disassembling the installed and rebuilt modules:
start_command: amd_start_sensor_v2+0x5e, immediately before command write;
command=%r9:x32, dma=%r8:x64
poll: amd_sfh_wait_response_v2+0x67, immediately after response read;
raw=%dx:x32, sensor=%r14:u8, expected=%bp:u32
success: amd_sfh_wait_response_v2+0x89
timeout: amd_sfh_wait_response_v2+0x9e

Response decoding: status=raw & 3; state=(raw >> 4) & 15;
sensor ID=(raw >> 16) & 63. Enabled=4; disabled=5.
Offsets are specific to the verified driver binaries.

NORMAL POLLING (500 us): SUCCESSFUL REINITIALIZATION AND FAILED RESUME
# entries-in-buffer/entries-written: 20111/20111 #P:12
bash-7327 [002] ...1. 1189.987245: tracing_mark_write: BEGIN_BIND
kworker/2:2-828 [002] ..Zff 1189.987837: start_command: (amd_start_sensor_v2+0x5e/0x80 [amd_sfh]) command=0xc8001011 dma=0xfffeb000
kworker/2:2-828 [002] ..Zff 1189.987841: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0x350 sensor=0 expected=4
kworker/2:2-828 [002] ..Zff 1189.988354: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0x340 sensor=0 expected=4
kworker/2:2-828 [002] ..Zff 1189.988356: success: (amd_sfh_wait_response_v2+0x89/0xc0 [amd_sfh]) sensor=0 expected=4
kworker/2:2-828 [002] ..Zff 1189.988367: start_command: (amd_start_sensor_v2+0x5e/0x80 [amd_sfh]) command=0xc8011011 dma=0xfffea000
kworker/2:2-828 [002] ..Zff 1189.988370: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0x340 sensor=1 expected=4
kworker/2:2-828 [002] ..Zff 1189.988748: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0xa0340 sensor=1 expected=4
kworker/2:2-828 [002] ..Zff 1189.989264: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0x10340 sensor=1 expected=4
kworker/2:2-828 [002] ..Zff 1189.989266: success: (amd_sfh_wait_response_v2+0x89/0xc0 [amd_sfh]) sensor=1 expected=4
kworker/2:2-828 [002] ..Zff 1189.989274: start_command: (amd_start_sensor_v2+0x5e/0x80 [amd_sfh]) command=0xc80f1011 dma=0xffffa000
kworker/2:2-828 [002] ..Zff 1189.991304: success: (amd_sfh_wait_response_v2+0x89/0xc0 [amd_sfh]) sensor=15 expected=4
kworker/2:2-828 [002] ..Zff 1189.991318: start_command: (amd_start_sensor_v2+0x5e/0x80 [amd_sfh]) command=0xc8139011 dma=0xffff9000
kworker/2:2-828 [002] ..Zff 1189.998572: success: (amd_sfh_wait_response_v2+0x89/0xc0 [amd_sfh]) sensor=19 expected=4
bash-7327 [006] ...1. 1219.985142: tracing_mark_write: INITIALIZATION_CAPTURED_BEFORE_SUSPEND
kworker/u48:12-584 [005] ..... 1233.104300: start_command: (amd_start_sensor_v2+0x5e/0x80 [amd_sfh]) command=0xc8001011 dma=0xfffeb000
kworker/u48:12-584 [005] ..... 1233.104307: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0x130340 sensor=0 expected=4
kworker/u48:12-584 [005] ..... 1233.104822: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0xa0340 sensor=0 expected=4
kworker/u48:12-584 [002] ..... 1243.100580: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0xa0340 sensor=0 expected=4
kworker/u48:12-584 [002] ..... 1243.101029: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0xa0340 sensor=0 expected=4
kworker/u48:12-584 [002] ..... 1243.101574: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0xa0340 sensor=0 expected=4
kworker/u48:12-584 [002] ..... 1243.101578: timeout: (amd_sfh_wait_response_v2+0x9e/0xc0 [amd_sfh]) sensor=0 expected=4
kworker/u48:12-584 [002] ..... 1243.101592: start_command: (amd_start_sensor_v2+0x5e/0x80 [amd_sfh]) command=0xc8011011 dma=0xfffea000
kworker/u48:12-584 [002] ..... 1243.101595: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0xa0340 sensor=1 expected=4
kworker/u48:12-584 [002] ..... 1243.102029: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0xa0340 sensor=1 expected=4
kworker/u48:12-584 [002] ..... 1243.102574: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0xa0340 sensor=1 expected=4
kworker/u48:12-584 [002] ..... 1243.103028: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0x10340 sensor=1 expected=4
kworker/u48:12-584 [002] ..... 1243.103032: success: (amd_sfh_wait_response_v2+0x89/0xc0 [amd_sfh]) sensor=1 expected=4
kworker/u48:12-584 [002] ..... 1243.103044: start_command: (amd_start_sensor_v2+0x5e/0x80 [amd_sfh]) command=0xc80f1011 dma=0xffffa000
kworker/u48:12-584 [002] ..... 1243.107029: success: (amd_sfh_wait_response_v2+0x89/0xc0 [amd_sfh]) sensor=15 expected=4
kworker/u48:12-584 [002] ..... 1243.107042: start_command: (amd_start_sensor_v2+0x5e/0x80 [amd_sfh]) command=0xc8139011 dma=0xffff9000
kworker/u48:12-584 [002] ..... 1243.112565: success: (amd_sfh_wait_response_v2+0x89/0xc0 [amd_sfh]) sensor=19 expected=4

FAST POLLING (20 us): SUCCESSFUL RESUME
# entries-in-buffer/entries-written: 391/391 #P:12
kworker/u48:9-9515 [005] ..... 1800.700195: start_command: (amd_start_sensor_v2+0x5e/0x80 [amd_sfh]) command=0xc8001011 dma=0xfffe2000
kworker/u48:9-9515 [005] ..... 1800.700202: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0x130340 sensor=0 expected=4
kworker/u48:9-9515 [005] ..... 1800.700236: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0x130340 sensor=0 expected=4
kworker/u48:9-9515 [005] ..... 1800.700264: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0x340 sensor=0 expected=4
kworker/u48:9-9515 [005] ..... 1800.700266: success: (amd_sfh_wait_response_v2+0x89/0xc0 [amd_sfh]) sensor=0 expected=4
kworker/u48:9-9515 [005] ..... 1800.700282: start_command: (amd_start_sensor_v2+0x5e/0x80 [amd_sfh]) command=0xc8011011 dma=0xfffe1000
kworker/u48:9-9515 [005] ..... 1800.700285: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0xa0340 sensor=1 expected=4
kworker/u48:9-9515 [005] ..... 1800.700323: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0xa0340 sensor=1 expected=4
kworker/u48:9-9515 [008] ..... 1800.700355: poll: (amd_sfh_wait_response_v2+0x67/0xc0 [amd_sfh]) raw=0x10340 sensor=1 expected=4
kworker/u48:9-9515 [008] ..... 1800.700358: success: (amd_sfh_wait_response_v2+0x89/0xc0 [amd_sfh]) sensor=1 expected=4
kworker/u48:9-9515 [008] ..... 1800.700375: start_command: (amd_start_sensor_v2+0x5e/0x80 [amd_sfh]) command=0xc80f1011 dma=0xfffe0000
kworker/u48:9-9515 [008] ..... 1800.701936: success: (amd_sfh_wait_response_v2+0x89/0xc0 [amd_sfh]) sensor=15 expected=4
kworker/u48:9-9515 [008] ..... 1800.701941: start_command: (amd_start_sensor_v2+0x5e/0x80 [amd_sfh]) command=0xc8139011 dma=0xfffdf000
kworker/u48:9-9515 [000] ..... 1800.708450: success: (amd_sfh_wait_response_v2+0x89/0xc0 [amd_sfh]) sensor=19 expected=4

Both full trace buffers retained every written entry. Probe-profile counters
reported zero missed probes. Fast-polling capture reported zero timeouts.