Skip to content

HID: spi-hid-apple: stop status mismatches on boot and suspend - #222

Merged
chriskearney merged 1 commit into
omacom:integration/aurorafrom
ludagoo:fix/spi-hid-apple-status-wake
Oct 30, 2026
Merged

chriskearney merged 1 commit into
omacom:integration/aurorafrom
ludagoo:fix/spi-hid-apple-status-wake

Conversation

@ludagoo

@ludagoo ludagoo commented Oct 25, 2026 •

Copy link
Copy Markdown

Stop two SPI HID status mismatches on the MacBook Air M1 2020 (J313).

The keyboard, trackpad, and actuator share one controller, so each mismatch is one transfer. At boot, actuator probe sends feature report 0x21, which this descriptor does not have (input 0x3f and output 0x53 only). The controller answers 9c 17 e5 f8. Skip that report when it is absent. The part already powers up device-controlled.

On suspend, NumLock-off is queued on the non-freezable system workqueue and races controller power-off, so the late write reads 00 00 00 00. Flush the keyboard and trackpad LED workers while the controller is still up, refuse new transfers once it is down, and on resume wait for boot packet a0 80 00 00 before returning.

spi-hid-apple-of.c is unchanged. Any other bad status word still warns.

Session build, Monday 26 Oct 2026 05:02 PM -03: linux-aurora 7.2.11-6-2-ARCH (package 7.2.11.aurora6-2), branch local/j313-test at 7638df0. makepkg exited 0. rustc 1.85.0, LLVM/clang 18.1.8. This machine is running that kernel. The stacked commit compiled in was 6d535f9. This pull request's head is cb0f94f, which is not the commit that was built.

Two real s2idle cycles on this kernel showed no spi-hid status mismatch. malik-na's J313 runs of an earlier identical diff (38d4f0804ceb) logged neither the boot mismatch 9c 17 e5 f8 (0 of 8 boots) nor the suspend mismatch 00 00 00 00 (0 of 3). A real lid-close sleep had working keyboard, pointer, and trackpad click. The rebased head cb0f94f8429f was not re-tested.

@ludagoo
ludagoo force-pushed the fix/spi-hid-apple-status-wake branch from 38d4f08 to cb0f94f Compare October 26, 2026 18:15
@malik-na

Copy link
Copy Markdown
Member

Tested on a J313 (M1 Air): removes both status mismatches, at boot and around suspend, and input works straight after a real wake. No regressions found.

kernels without this PR this PR
boots logging spi-hid-apple-of spi2.0: status message mismatch: 9c 17 e5 f8 14 of 30 (installed 7.2.11-6-1-ARCH and the other test kernels) 0 of 8
status message mismatch: 00 00 00 00 around suspend (devices + s2idle cycles) 7 of 16 boots that ran both cycles (baseline 1 of 4; the other PR kernels 6 of 12) 0 of 3
SPI HID controller resume incomplete / boot-packet timeout – none
device suspend phase, omarchy-m-test pass pass, 0 regressions

Real lid-close sleep (70 s, keypress wake): keyboard, pointer and trackpad click with haptic feedback all worked straight away. No mismatch or resume warnings were logged.

How this was tested
  • MacBook Air (M1, 2020), J313, DCP 13.5, BCM4378, booted through U-Boot → Limine.
  • This PR's head and its parent 19f4965180f4 (the baseline), built with the Air's own /proc/config.gz and booted as one-shot test entries. The Mac returns to its installed 7.2.11-6-1-ARCH after every run.
  • Automated boots: device-phase suspend (pm_test=devices), omarchy-m-test, and a check script (dmesg counters, keyboard and panel backlight writes, ALS channels, two nmcli con up re-associations, one pm_test=platform s2idle cycle).
  • Hands-on boots: a person at the Mac doing a real lid-close sleep and keypress wake, using the brightness keys, and covering or lighting the ALS, while the kernel's state was logged every 2 s.
  • Tested commit: 38d4f0804ceb on 19f4965180f4. The PR has since been rebased to cb0f94f8429f on 937b727ef9a3 with an identical diff; the new base wasn't re-tested.

@ludagoo
ludagoo marked this pull request as ready for review October 26, 2026 23:06
@ludagoo
ludagoo force-pushed the fix/spi-hid-apple-status-wake branch from cb0f94f to be9b631 Compare October 28, 2026 15:40
The shared SPI HID controller logs "status message mismatch" once at
boot and once on every s2idle cycle. The keyboard, the trackpad, and
actuator 001C:05AC:0281 share that transport, so each line is one
transfer.

At boot the actuator probe sends feature report 0x21. The J313 SPI
actuator descriptor has input 0x3f and output 0x53 only, and the
controller answers 9c 17 e5 f8. Report 0x21 is the MTP host-mode
switch. Skip it when the device has no such report. The SPI actuator
powers up device-controlled, which is the state probe asks for.

On suspend, input core turns lit LEDs off. NumLock is on, so that
queues one output report on the non-freezable system workqueue. The
SPI parent then cuts controller power and the late write reads
00 00 00 00. Flush the keyboard and trackpad LED workers while the
controller is still up, refuse new transfers once it is down, and on
resume wait for boot packet a0 80 00 00 before returning.

spi-hid-apple-of.c is unchanged. Any other bad status word still warns.

Signed-off-by: Lucas Goossen <lucas.goossen@hey.com>
@ludagoo
ludagoo force-pushed the fix/spi-hid-apple-status-wake branch from be9b631 to ca049aa Compare October 30, 2026 10:14

@chriskearney chriskearney left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head ca049aab7efe23908179be0d701026613f160e59, both changed files and current HID/IRQ/probe/suspend/remove callers. Source/host PASS subject to required CI and full MQ. The existing J313 physical-test driver area is byte-identical to the effective merge; this is component binding, not a new full-cohort hardware run.

Exact power-gate/wait/wake controls pass six scenarios across three runs, including a pending boot IRQ, BOOT waiters, timeout releasing waiters, OFF refusal and an in-flight transfer. Four semantic mutants are caught. The unsupported 0x21 report is skipped without changing the old successful caller return; LED work is flushed before power-off, and resume waits for the existing probe boot packet before admitting writes. CI/QEMU is not input or suspend qualification.

Nonblocking details remain explicit: use HID_CLAIMED_INPUT rather than the numerically identical HID_CONNECT_HIDINPUT for the claimed-bit test. OFF-before-destroy also refuses child teardown mode-switch writes; with opt-in host haptics on an actuator supporting 0x21, device mode is not restored until the next probe. All SPI-HID boards gain the resume boot wait; an absent packet logs and costs up to one second, then admits writes rather than leaving BOOT waiters stuck. The existing public identical-code J313 and author suspend results support merging without a new dedicated sleep campaign.

@chriskearney chriskearney reopened this Oct 30, 2026
@chriskearney chriskearney reopened this Oct 30, 2026
@chriskearney
chriskearney added this pull request to the merge queue Oct 30, 2026
Merged via the queue into omacom:integration/aurora with commit aa64d8f Oct 30, 2026
16 checks passed
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.

3 participants