Skip to content

HID: spi-hid-apple: validate replies and retry transient GET failures - #842

Merged
RyanTheTide merged 3 commits into
integration/aurorafrom
fix/spi-hid-get-report-resync-2
Nov 10, 2026
Merged

RyanTheTide merged 3 commits into
integration/aurorafrom
fix/spi-hid-get-report-resync-2

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Supersedes #782. This branch starts at aurora-wip commit e1524e6135e9, includes fcc170020a1c, and preserves the original #782 branch. The update is a fast-forward from f3f555427e9a.

A valid trackpad dimensions GET can receive status 9c 17 e5 f8 after probe. In the supplied M1 Pro run, 19/20 boots were clean with baseline-identical axes; one boot failed at 4.849 seconds with report 0xd9, interface 2, sequence ID 11, followed by get report d9 failed: -71 and magicmouse unable to request dimensions (-71). Returning immediately on every bad status makes that transient condition fatal to the input open.

The call path explains the timing:

  • magicmouse_input_configured() calls the SPI input setup, which sets query_dimensions = true. The 1.6-second messages report input registration and haptic setup, not a successful dimensions GET.
  • magicmouse_open() calls hid_hw_open(), sends the multitouch SET { 0x02, 0x01 }, then reads feature report 0xd9 while query_dimensions is set. This is the first input-open geometry query, consistent with the userspace device discovery occurring around the failure. The log does not identify the opening process or establish an earlier successful 0xd9 GET.
  • A successful query validates and publishes the axes, then clears query_dimensions. Subsequent opens reuse them. A failed query leaves the flag set for another open, but that does not prevent the original error. The resume callbacks restore multitouch mode but do not re-arm the dimensions query. Dropping this read would leave the initial input geometry at its placeholder values.

Writes already hold tx_lock; the write and its status read are in one SPI message, serialized by the SPI core against the IRQ read message. Synchronous GETs also hold get_report_lock, and replies match interface, report and sequence under reply_lock. The supplied log does not establish a host transfer interleaving. Firmware work after the preceding MT SET, or its own input traffic, could still affect acceptance, but that is not proven by this trace.

The firmware meaning of 9c 17 e5 f8 is not documented by this code. It also occurs for an unsupported actuator request fixed by fcc170020a1c, so it cannot safely be called a busy-only or unsupported-only answer. Here it accompanies a report that succeeds on other boots. Use bounded GET recovery without inventing a firmware status definition.

The final change:

  • Validate status and return -EPROTO if all bad-status attempts fail. Keep each status mismatch visible as a warning with interface, command, report and sequence.
  • Retry bad-status GETs and acknowledged GETs whose replies time out, sharing one maximum of three total attempts. Each attempt retires its pending reply and obtains a fresh sequence ID. There is no new settling delay or receive-assembly reset.
  • Distinguish a controller status mismatch explicitly from a spi_sync() error, including SPI -EPROTO. SPI errors and interrupted waits are not retried. SET/OUTPUT remain single attempts with their existing best-effort status behavior.
  • Preserve serialized GETs, pre-send reply arming, reply matching and the min(len, reply_len) copy bound from the original PR commit. Preserve the power, LED and resume fixes from fcc170020a1c.

Validation at c48d1d05ae0f3d638cfdb3cc14390601ffae3375:

  • Controller buildbox ARM64 LLVM W=1 -j8 drivers/hid/spi-hid/ drivers/hid/hid-magicmouse.o: passed, zero warning/error diagnostics. The core, OF transport and magicmouse objects were compiled, including the SPI HID KUnit code.
  • UML KUnit with the committed .kunitconfig, W=1: all nine cases passed, zero failures/skips. The cold UML build emits warnings in unchanged code outside this driver.
  • Negative control: retaining the new fault case and restoring the previous retry decision reproduces status message mismatch: 9c 17 e5 f8 (device 2 request 32 report d9 id 11) and -71. The fixed decision passes the same case.
  • Source SHA-256 values match the two committed files; the build script restores the fixed source after the negative control and verifies it again. Whitespace checks and strict checkpatch pass with zero errors, warnings or checks.

The build command returned rc=0. Separate artifact retrieval was refused by the controller's local free-space guard, so configuration files, objects and raw TAP were not retrieved. The complete 19,402-byte streamed build/test log is preserved, SHA-256 d30cc05f1578f77893554d39e19b06a2d111274db8c883009080d924ee0660d2. This artifact collection failure is recorded separately from the successful compilation and tests.

M1 Pro retest plan, for lane 4:

  1. Build the fleet14m (a7a8a258) candidate with the exact updated HID: spi-hid-apple: validate replies and retry transient GET failures #842 commits. Record both the PR head and resulting candidate commit/kernel identifier. Keep the known-good kernel and bootguard fallback for every one-shot boot.
  2. Run 30 boots. Save the boot ID, running candidate identity, full kernel log and input enumeration for each boot. Exercise the first userspace trackpad open on every boot, including the later geometry query after probe. Confirm that the open succeeds; then close and reopen to check that cached geometry remains stable.
  3. Record minima, maxima and resolutions of ABS_X, ABS_Y, ABS_MT_POSITION_X and ABS_MT_POSITION_Y after first open. Require valid ranges identical to this M1 Pro's fleet14m baseline on all 30 boots.
  4. Require zero err-level or more severe spi-hid/magicmouse lines on every boot, including no dimensions-request failure, GET exhaustion or timeout. Retain and count warning-level status mismatches and their request IDs separately, even if recovered. Check for CRC mismatches, incomplete reports and unrelated kernel error deltas without hiding them.
  5. Any failed boot fails qualification. Preserve its logs and axis/open results before rollback through the known-good bootguard fallback. Publish only a sanitized result summary. Lane 7 merges only after a clean 30/30 result and review.

This task runs synthetic tests and builds only. Hardware retesting is pending, and this PR stays a draft.

An invalid GET write status still looks successful after fcc1700
("HID: spi-hid-apple: stop status mismatches on boot and suspend").
Return -EPROTO immediately instead of waiting for an unacknowledged GET.
Keep the existing best-effort SET/OUTPUT behavior without replaying it.

Serialize synchronous GETs, arm their reply state before transmission,
and accept only the requested interface, report and sequence ID. Bound
copies and the returned length to the caller's destination buffer.

Keep at most three attempts only when an acknowledged GET's reply wait
times out: receive CRC validation still discards consumed replies, a
path untouched by fcc1700. Do not retry bad status or SPI errors.
Drop the previous speculative framing reset and settling delays.

Adapt the six fake-controller KUnit cases to the new power state and
exercise invalid status, CRC-discarded replies, stale/wrong-interface
replies, timeout exhaustion, copy bounds and non-replayed SETs.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
The M1 Pro can return status 9c 17 e5 f8 for a valid dimensions GET
several seconds after probe. magicmouse_open() enables multitouch and
then reads report 0xd9 on the first input open. Probe does not read
those dimensions, and a successful open already caches them. Removing
the query would leave the input axes unconfigured.

The write and status transfers form one SPI message, writes hold
tx_lock, and synchronous GETs hold get_report_lock. The available
trace does not establish an interleaved host transfer or the firmware
meaning of this status. The same report works on the other boots, so
recover a transient rejection without assuming that it means busy.

Retry a bad-status GET within the existing three-attempt budget shared
with reply timeouts. Retire the pending reply on every failure and use
a fresh ID on retry. Report status mismatches as warnings and keep the
final error on exhaustion. Distinguish bad status from spi_sync()
errors explicitly, including an SPI -EPROTO, rather than replaying on
an errno alone. SET and OUTPUT remain single attempts.

Keep the existing KUnit cases and add a successful earlier GET followed
by the MT SET, a dimensions GET rejected at ID 11, and a successful
retry that discards stale replies. Cover mixed-failure exhaustion and
non-replayed SPI errors as well.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide RyanTheTide changed the title HID: spi-hid-apple: validate GET replies after boot/suspend fixes HID: spi-hid-apple: validate replies and retry transient GET failures Nov 2, 2026
@RyanTheTide
RyanTheTide changed the base branch from aurora-wip to integration/aurora November 2, 2026 23:15
Picks up the tools/aurora-sep source-check fix (c60537c) and the
current release branch, so CI runs against today's base.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
RyanTheTide added a commit that referenced this pull request Nov 7, 2026
…ck-20261107

Merge train 11-08. Test kernel 7.3.0-aurora-mtrl1 (integration 43c790f + this check + #842/#1088/#1091) one-shot on the Neo: AV1 1080p 747 fps and 4K 189 fps decode bit-exact against software (fleet23 base 747/189), VP9/H.264 bit-exact, GStreamer v4l2slav1dec 1080p/4K clean, 0 tile refusals on valid streams, 0 AVD errors, 0 AVC, CTXR boot verify PASS. Build warnings = fleet22, W=1 avd 0, run-host-tests --only avd 12/12, CI green. M4 Max evidence: AxxzyWasTaken's J616C (Chromium 8-tile/1-entry case).
@RyanTheTide
RyanTheTide marked this pull request as ready for review November 10, 2026 17:23
@RyanTheTide
RyanTheTide merged commit a4e27ca into integration/aurora Nov 10, 2026
1 check passed
@RyanTheTide
RyanTheTide deleted the fix/spi-hid-get-report-resync-2 branch November 16, 2026 05:07
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