Repository navigation
HID: dockchannel-hid: let a TP26 trackpad click wake the system - #3372
Conversation
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]>
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: FINISH, then merge, at b781812c9e86. The code is fine; the branch needs main.
Blockers:
- host-tests is red because of the branch's base, not the patch: it is based on
deb2df2a(the #3302 merge) without its revertfca33ed6, 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. - 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, sodchid_tp26_clicked(payload, shdr->length)stays inside the frame. In the helper,pos + 22 <= sizeis checked beforelen > 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] & 1as before. Any other multi-touch report reaches the TP26 check, which needs5a 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'smagicmouse_tp26_button_id,MAGICMOUSE_TP26_HEADER_SIZEandMAGICMOUSE_TP26_RECORD_HDRon main. - Build:
make W=1 drivers/hid/dockchannel-hid/at this head: 0 warnings. checkpatch --strict: 1 CHECK (alignment of thememcmpcontinuation line). - Row source vs head: dockchannel-hid at
a851ca0eplus 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.
Signed-off-by: Ryan Murray <[email protected]>
|
Merged main into the branch (normal push; head |
There was a problem hiding this comment.
Verdict: MERGE at 861d77f62fcb
Checked (tried to break the parser):
- Bounds: the caller only reaches
dchid_wake_report()whenhdr->length >= sizeof(subhdr) + shdr->length(dockchannel-hid.c around line 1748), sosizeis backed by the buffer. Indchid_tp26_clicked()the loop guardpos + 22 <= sizecovers the 16-byte id compare atpos+1and the length read atpos+20.len > size - pos - 22rejects an overrunning record before the le32 read, and that read needslen >= 4. - Progress and overflow:
len == 0still advances by 22 andsize_tcan'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).
|
@DjDeveloperr code-owner ping (6-point rule, point 6) at |
|
Regression row, J616s (M4 Pro, fleet89
Together with the K114s rows (TP26 click wake), this covers the regression-row point for two families. |
|
KREVIEW, regression condition closed at |
|
Merging under the 6-point rule (Ryan 09:29, permanent), at |
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.Tested: K114s, kernel 7.3.0-42 (linux a851ca0) with dockchannel-hid rebuilt from that source plus this patch,
systemctl suspendwith the lid open: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