From: Kenhou Iijima <kenhou@kenhou.net>
To: "Derek J. Clark" <derekjohn.clark@gmail.com>
Cc: Kenhou Iijima <kenhou@kenhou.net>,
linux-input@vger.kernel.org, Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>,
Ana Veto <green.koala2979@fastmail.com>
Subject: Re: [PATCH v3] HID: hid-msi: Ignore unexpected 0x06 ACKs outside WRITE_PROFILE_DATA
Date: Wed, 2 Dec 2026 01:49:21 +0900 [thread overview]
Message-ID: <20261201164921.12907-1-kenhou@kenhou.net> (raw)
In-Reply-To: <20261201012506.2313913-1-derekjohn.clark@gmail.com>
Hi Derek,
Thanks for spotting the WRITE_PROFILE_DATA window race — that scenario is real
on firmware 2.30, and testing it on my Claw 8 AI+ (fw 2.30, with all userspace
daemons stopped) also showed why modeling it with a `late_acks` packet counter
breaks on this MCU.
The core issue is that the hazard is time-bounded rather than a fixed packet
debt. Testing `late_acks` on hardware hit -EBUSY for two distinct reasons:
1. Normal back-to-back writes get their own immediate 0x06 eaten:
With `rumble_intensity_left` followed 10 ms later by
`rumble_intensity_right`:
left store: 0x21 -> 0x06 (3 ms) -> SYNC_TO_ROM (0x22), late_acks = 1
0x06 (3 ms, consumed by orphan_ack_pending)
+10 ms right: 0x21 sent (waiting_cmd = 0x21)
+3 ms later: 0x06 arrives (the new write's own ACK, well before +560 ms)
-> "Dropped a counted MCU ACK" (late_acks -> 0)
-> "Remaining timeout: 0" (-EBUSY)
The same -EBUSY reproduces on `gamepad_mode` -> immediate write (47.97 ms,
-EBUSY) and `SYNC_TO_ROM` + 560 ms -> write (34.79 ms, -EBUSY).
2. The MCU emits a variable number of 0x06 ACKs (1 or 2), stranding `late_acks`:
- Issuing READ_GAMEPAD_MODE (0x26) right after SWITCH_MODE (0x24) suppresses
SWITCH_MODE's second 0x06 ACK. `late_acks` stays 1 and breaks the next
WRITE_PROFILE_DATA even 1.0 s later (-EBUSY).
- SYNC_TO_ROM (0x22) also frequently emits only the single ~515-565 ms
commit 0x06 with no immediate +4 ms ACK; once the 25 ms orphan wait
expires (or orphan_ack_pending eats that single commit ACK), `late_acks`
again drifts out of sync. Conversely, zeroing `late_acks` on `err:` drops
pending state on an unrelated failure or signal interruption, re-opening
the premature-completion race.
Separately, testing concurrent commands revealed another MCU behavior that also
calls for a time/completion window rather than a counter: while SYNC_TO_ROM is
committing to flash, the MCU answers reads immediately (~4-9 ms) but queues
SWITCH_MODE (0x24) behind the commit and emits a ~16 ms 3-packet 0x06 burst
(+0/+8/+16 ms) right when the flash commit completes.
For v4, I switched to tracking time/completion windows instead of counting ACKs:
- Keep the waiting_cmd == WRITE_PROFILE_DATA guard and dev_dbg downgrade for
leftover 0x06 packets.
- Track a unified 35 ms 0x06 quiet window (`ack_quiet_until`, inside cfg_mutex)
for non-SYNC_TO_ROM timeout-0 commands and track the SYNC_TO_ROM commit
window (700 ms fallback / 100 ms min threshold, outside cfg_mutex via
rom_sync_complete), clearing both on remove and suspend.
- Wait on active windows only before WRITE_PROFILE_DATA so reads and
SWITCH_MODE stay unblocked. When a commit-window 0x06 arrives outside an
active TX quiet window, complete rom_sync_complete early and open a 35 ms
quiet window to absorb any queued post-commit 0x06 burst.
With v4 on the same daemon-free suite (including readback verification,
concurrent reads + SWITCH_MODE during SYNC_TO_ROM, and SIGALRM interruption),
every case passes with zero timeouts or lost commits.
I'll send v4 shortly with Reported-by/Closes crediting your report.
Regards,
Kenhou
prev parent reply other threads:[~2026-12-01 16:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 10:10 [PATCH] HID: hid-msi: Drain orphan MCU ACKs by issuing a query Kenhou Iijima
2026-11-14 10:29 ` sashiko-bot
2026-11-14 12:50 ` [PATCH v2] " Kenhou Iijima
2026-11-16 13:46 ` [PATCH v3] HID: hid-msi: Ignore unexpected 0x06 ACKs outside WRITE_PROFILE_DATA Kenhou Iijima
2026-12-01 1:25 ` Derek J. Clark
2026-12-01 16:49 ` Kenhou Iijima [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201164921.12907-1-kenhou@kenhou.net \
--to=kenhou@kenhou.net \
--cc=bentiss@kernel.org \
--cc=derekjohn.clark@gmail.com \
--cc=green.koala2979@fastmail.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox