Skip to content

HID: spi-hid-apple: resync and retry failed get reports - #782

Closed
RyanTheTide wants to merge 2 commits into
aurora-wipfrom
fix/spi-hid-get-report-resync
Closed

RyanTheTide wants to merge 2 commits into
aurora-wipfrom
fix/spi-hid-get-report-resync

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

A bad SPI write status currently logs a warning but reports success. The synchronous get then waits for a reply that may never arrive, and the trackpad's first open can fail before its dimensions are installed.

Retry GET_REPORT up to three times after a bad status or lost reply, with a CS-inactive settling interval and receive reassembly reset. Serialize gets, arm reply matching before transmission, and reject stale request IDs/report numbers. Bound response copies to the caller's buffer. SET/OUTPUT commands retain their existing behavior and are never replayed.

Adds six KUnit cases using a fake SPI controller: bad-status recovery, dropped replies, stale replies, exhausted retries, short destination buffers, and non-replayed sets.

Validation at 1f1973ab0417345df13d81ff76754901a1933952:

  • ARM64 LLVM W=1 -j8 drivers/hid/spi-hid/ drivers/hid/hid-magicmouse.o with both drivers enabled: passed, zero warning/error diagnostics.
  • Full ARM64 LLVM W=1 -j8 Image modules: passed; warnings remain in unchanged code outside the affected files.
  • UML KUnit using the committed drivers/hid/spi-hid/.kunitconfig, built with W=1: all six tests passed, zero failures or skips. The build reports warnings in unchanged code outside this driver.
  • git diff --check: passed. Prior strict checkpatch of the code diff passed apart from the generic new-file MAINTAINERS reminder.

The 20-boot hardware soak and measured axis-range checks remain pending in the hardware lane. No candidate has been installed or booted for this validation. Keep this PR as a draft. The original wire-level cause of the malformed acknowledgement remains unproven; this patch addresses the missing transport recovery path. Synthetic tests do not establish real firmware resynchronization.

A bad write status is currently only logged, so GET_REPORT waits for a
reply to an unacknowledged command and eventually fails the trackpad's
dimensions query. Treat that status as a failed get, allow the completed
SPI transaction to settle with CS inactive, and invalidate incomplete
receive assembly before retrying. Retry lost replies as well, with at
most three attempts, and report an error only after recovery fails.

Serialize synchronous gets and match responses by interface, report and
request ID, arming the waiter before transmitting. This prevents delayed
responses from satisfying a subsequent attempt. Bound the reply copy to
the caller's buffer. Preserve best-effort SET/OUTPUT behavior and never
replay commands that may have side effects.

Add KUnit fault injection using a fake SPI controller for bad status,
lost and stale replies, retry limits, reply bounds and non-replayed sets.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Include the interface, command, report and sequence ID in the existing warning so a malformed acknowledgement can be associated with its request during recovery verification.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Superseded by #842, which rebases onto fcc1700 (the boot-time status mismatch fix already in aurora-wip) and keeps only the parts that are still defects there.

@RyanTheTide RyanTheTide closed this Nov 2, 2026
@RyanTheTide
RyanTheTide deleted the fix/spi-hid-get-report-resync branch November 27, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant