Skip to content

HID: dockchannel-hid: let a TP26 trackpad click wake the system - #3372

Merged
RyanTheTide merged 2 commits into
mainfrom
fix/dockchannel-hid-tp26-click-wakes
Nov 28, 2026
Merged

RyanTheTide merged 2 commits into
mainfrom
fix/dockchannel-hid-tp26-click-wakes

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Problem

On the 14" M5 Pro MacBook Pro (K114s), a trackpad click does not wake the system from suspend-to-idle; only the keyboard does. dockchannel-hid decides what wakes the system, and it recognises a click only in the MTP report (ID 0x75, button at byte 23). This trackpad's firmware ("SensingAlgsTrackpad26C", hid-magicmouse's TP26 frames) sends no report ID: its data frames are stream records, and the click comes as a 32-bit word in the button stream.

Change

  • dchid_tp26_clicked() (dockchannel-hid-protocol.h) walks a TP26 data frame's records, as hid-magicmouse does, and returns the button stream's bit 0.
  • dchid_wake_report() uses it for multi-touch reports that aren't the MTP report.
  • Touches, the accelerometer and other interfaces still don't wake the system.

Tested: K114s, kernel 7.3.0-42 (linux a851ca0) with dockchannel-hid rebuilt from that source plus this patch, systemctl suspend with the lid open:

  • stock dockchannel-hid: a trackpad click does not wake it (the owner tried at 19:09); a key does.
  • patched: one trackpad click wakes it (19:57), no key needed; it stays asleep until the click (no spurious wake over 30 s).
  • KUnit (arm64, qemu): dockchannel-hid-protocol 6/6 pass, including the new dchid_tp26_clicked_test (click, no click, another stream, overrunning record, non-data frame, non-TP26 frame, short frame).

Risk: two-way · Macs whose trackpad firmware sends TP26 frames (M5 MacBook Pros) gain click-to-wake; the MTP-report path is unchanged.

Still to run

  • K116s (Axboe), the other TP26 board in the lab's view.
  • A haptic click during sleep is a separate question: in host-controlled actuator mode the firmware doesn't pulse. Switching the actuator to device mode in suspend gave a felt click, but it also woke the system within milliseconds, so that change is not part of this PR.

dockchannel-hid wakes the system on a keyboard report or on a multi-touch
report with the trackpad clicked, and recognises the click only in the
MTP report (ID 0x75, button at byte 23). Newer trackpad firmware
("SensingAlgsTrackpad26C", the frames hid-magicmouse calls TP26, on the
M5 MacBook Pros) sends no report ID: its data frames are a list of
stream records, and the click comes as a 32-bit word in the button
stream. Such a click never woke the system; only the keyboard did.

Recognise the TP26 button stream too. dchid_tp26_clicked() walks the
records of a data frame as hid-magicmouse does and reports the button
word's bit 0. Touches still do not wake the system.

Add KUnit cases for the helper: a click, no click, another stream with
the bit set, a record that runs past the frame, a non-data frame, a
non-TP26 frame and a short frame.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide
RyanTheTide requested review from a team as code owners November 27, 2026 09:02
@github-actions github-actions Bot added blast:m5 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Merge readiness at 861d77f6: not ready yet

Check Detail
CI at head ok 2 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at 861d77f6
Conflicts ok not computed yet
PR text ok Risk: two-way · Macs whose trackpad firmware sends TP26 frames (M5 MacBook Pros) gain click-to-wake; the MTP-report path is unchanged. Still to run - K116s (Axboe), the other TP26 board in the lab's view. - A haptic click during sleep is a separate question: in host-controlled actuator mode the firmware doesn't pulse. Switching the actuator to device mode in suspend gave a felt click, but it also woke the system within milliseconds, so that change is not part of this PR.

Areas: none matched in CODEOWNERS

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: FINISH, then merge, at b781812c9e86. The code is fine; the branch needs main.

Blockers:

  1. host-tests is red because of the branch's base, not the patch: it is based on deb2df2a (the #3302 merge) without its revert fca33ed6, and its four failures (apple-dcp, dcpext26-startup-tests, hardware-defaults-tests, backlight-coldboot-tests) are exactly #3302's. Merge main into the branch (normal push), and host-tests should go green.
  2. Second-Mac row: J714s (also an M5 MacBook Pro, which very likely sends TP26 frames too) with the new head: a trackpad click wakes from s2idle, a key wakes, and no spurious wake in about a minute asleep. Plus the K114s rows restated for the new head (the dockchannel-hid source is unchanged; see Evidence).

Checked: read the whole diff and the wake caller; built with W=1; ran the PR's KUnit cases on the host plus extra cases and a fuzz run under ASan/UBSan; checked that the stream ID and frame layout match hid-magicmouse; the old MTP path behaves exactly as before; no gates, no params, no attribution.

Evidence
  • Bounds: the caller only classifies frames with hdr->length >= sizeof(subhdr) + shdr->length, so dchid_tp26_clicked(payload, shdr->length) stays inside the frame. In the helper, pos + 22 <= size is checked before len > size - pos - 22, so the subtraction can't wrap.
  • Host harness (the header compiled for x86-64 with -fsanitize=address,undefined): the 7 PR cases pass, plus a contacts-then-button frame (click found; one byte short = no click). 2,000,000 random frames, half with a valid header and button record and random lengths, in exactly-sized heap buffers: no ASan or UBSan report.
  • MTP path: a report with ID 0x75 and enough length returns payload[23] & 1 as before. Any other multi-touch report reaches the TP26 check, which needs 5a 01 02, the record markers and the 16-byte button ID, so old-firmware Macs see no change.
  • Constants: dchid_tp26_button_id, the 31-byte header and the 22-byte record header are identical to hid-magicmouse's magicmouse_tp26_button_id, MAGICMOUSE_TP26_HEADER_SIZE and MAGICMOUSE_TP26_RECORD_HDR on main.
  • Build: make W=1 drivers/hid/dockchannel-hid/ at this head: 0 warnings. checkpatch --strict: 1 CHECK (alignment of the memcmp continuation line).
  • Row source vs head: dockchannel-hid at a851ca0e plus this patch equals this head and main's dockchannel-hid. The K114s rows (stock: no click wake; patched: click wake 19:57, no spurious wake over 30 s) apply.
  • Nits, not blocking: (a) no CI job runs this KUnit suite, because drivers/hid/dockchannel-hid/** isn't in apple-build-kunit's paths; worth adding in a follow-up. (b) The button ID now exists in two places (dockchannel-hid and hid-magicmouse); a shared header later would keep them from drifting.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merged main into the branch (normal push; head 861d77f62fcb) to pick up the #3302 revert that the old base lacked. Nothing under drivers/hid/dockchannel-hid/ changed against b781812c9e86, the head the K114s rows were taken on, so those rows carry over: stock dockchannel-hid, a trackpad click doesn't wake from s2idle (19:09 GNOME idle sleep, 19:47 ssh systemctl suspend); patched, one click wakes after about a minute asleep with no spurious wake (19:57). KUnit at the new head, arm64 QEMU: dockchannel-hid-protocol 6/6 and dockchannel-hid-parser 12/12 pass (22 run, 21 passed, 1 unrelated skip).

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Nov 27, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: MERGE at 861d77f62fcb

Checked (tried to break the parser):

  • Bounds: the caller only reaches dchid_wake_report() when hdr->length >= sizeof(subhdr) + shdr->length (dockchannel-hid.c around line 1748), so size is backed by the buffer. In dchid_tp26_clicked() the loop guard pos + 22 <= size covers the 16-byte id compare at pos+1 and the length read at pos+20. len > size - pos - 22 rejects an overrunning record before the le32 read, and that read needs len >= 4.
  • Progress and overflow: len == 0 still advances by 22 and size_t can't wrap, so the loop can't spin or underflow.
  • Old path unchanged: an MTP report (id 0x75, length > button offset) takes the old path byte for byte. A short or odd multi-touch report falls through to the TP26 check and needs 0x5a 0x01 0x02, so random data doesn't wake.
  • Interfaces: only "multi-touch" can wake through this path. The keyboard path is unchanged.
  • Constants: the stream id is a protocol identifier, the same one hid-magicmouse uses for TP26, not a tuning value. Nothing is gated per board: any Mac whose trackpad firmware sends TP26 frames gets click-to-wake.
  • Tests: the KUnit case covers click, no-click, other stream, overrun, non-data frame, non-TP26 frame and short frame. I also built it clean in the K114s bridge tree (main 4ac70df + K PRs, -42 config).
  • Hardware: the PR's K114s A/B shows stock does not wake on a click, while the patched build wakes on one click with no spurious wake over 30 s.

Not covered: no second TP26 Mac in the lab, and no row on a non-TP26 Mac yet showing the MTP path unchanged (any J6xx s2idle trackpad-click row would do).

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

@DjDeveloperr code-owner ping (6-point rule, point 6) at 861d77f6: App-approved and CI green, with the K114s row(s) in. Merge earliest 13:50 AEDT if there's no objection and the regression-row point is settled (see lanes: ORCH5 decides whether the J714s row is waived for T6050-only code). Revert: git revert -m 1 <merge>.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Regression row, J616s (M4 Pro, fleet89 645f7cd3): PASS. Not a TP26 Mac, so this covers the MTP path that this change must leave alone.

  • Module. drivers/hid/dockchannel-hid from this PR's head 861d77f6 merged onto current main 635a52df (so it includes the merged HID: dockchannel-hid: accept the T6050 multi-touch report size #1737/HID: apple-mtp-kiwi: the K114c touch screen (needs #1737) #1605 base), built against the J616s's own fleet89 source and config. Every undefined symbol resolves in its System.map or in its apple-dockchannel/apple-rtkit-helper modules, and the vermagic matches.
  • Method. Same as the HID: dockchannel-hid: accept the T6050 multi-touch report size #1737 rows: the module sits in updates/ behind a separate initramfs and a one-shot GRUB entry. Live swaps don't work for this driver, so it's a real boot.
  • Result. All 6 MTP interfaces bind to the same drivers as stock (keyboard → apple, multi-touch → magicmouse, actuator → hid-apple-mtp-haptic, stm → hid-generic, plus mtp and tp-accel). The keyboard and multi-touch input devices are present. 2/2 rtcwake -m freeze cycles leave everything bound. No dockchannel/MTP errors. power/wakeup on the dockchannel-hid device reads enabled both with this change and with the stock module afterwards, so wake policy on MTP Macs doesn't change.
  • Restored. Back on the saved fleet89 default with stock modules, next_entry empty, boot_success=1, Enforcing, 0 failed units.

Together with the K114s rows (TP26 click wake), this covers the regression-row point for two families.

@aurora-silicon-review

Copy link
Copy Markdown

KREVIEW, regression condition closed at 861d77f6: the J616s row (#3372 (comment)) is the in-lab substitute I asked for in place of the J714s row. It's a non-TP26 MTP Mac, this head's module built on current main against fleet89, and a real boot. All 6 MTP interfaces bind to the stock drivers, 2/2 s2idle cycles keep everything bound, and power/wakeup is unchanged (enabled with and without this change), so MTP wake policy doesn't move. With the K114s TP26 click-wake rows, that makes two families. My App approval at this head stands; merge per the 6-point rule.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merging under the 6-point rule (Ryan 09:29, permanent), at 861d77f6. (1) The review App approved at this head. (2) Full CI is green. (3/4) Rows: K114s-TP26+J616s-dchid-regression. (5) There's no blocking review. (6) Dj was pinged here 432 min ago with no objection. Revert: git revert -m 1 <merge>.

@RyanTheTide
RyanTheTide merged commit cf20444 into main Nov 28, 2026
4 checks passed
@RyanTheTide
RyanTheTide deleted the fix/dockchannel-hid-tp26-click-wakes branch November 28, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant