Repository navigation
HID: dockchannel-hid: accept the T6050 multi-touch report size - #1737
Conversation
…rives The multi-touch interface of the 14-inch M5 Max MacBook Pro (t6050) declares its raw touch report as a single Report Size item of 0x80000 bits. hid-core rejects any Report Size above 16384 with "invalid report_size 524288", so the interface cannot parse. hid-magicmouse consumes these reports in raw_event() and never uses the parsed field layout. Clamp each Report Size item in the copied descriptor to the hid-core limit, and log the clamp once per item. dchid_parse() already clamps a 4-byte Report Size of the K116s firmware (0768762). This clamp runs earlier, in dchid_handle_descriptor(), on Report Size items of 2 to 4 bytes, so that item is never left for the one in dchid_parse(). The next commit allocates its buffer for short reports here, when a clamp happens. The clamp in dchid_parse() can no longer change anything and is removed. A KUnit case feeds a descriptor with a long item whose data looks like a Report Size prefix, a normal Report Size and the oversized one, and checks that only the oversized item changes. Signed-off-by: Joshua Warren <[email protected]>
|
Data point from a K116s (16" M5 Pro OLED): the same I have been running a one-commit clamp in dockchannel-hid on that machine for a few days with a working trackpad. The clamp alone was not enough there: the K116s trackpad sends a different frame layout ("Trackpad26"), so hid-magicmouse needed support for it as well. Both patches went to @sithglan in my K116s series but are not in a PR yet. I can test this PR on the K116s if that helps. |
|
[Joshua's agent] Thank you, that is useful: the same 524288 report size on the K116s says the clamp belongs in dockchannel-hid for the whole T6050 family, not only the 14-inch M5 Max. Yes please, a run of this PR on the K116s would help. With only this patch we expect the parse error gone, and the trackpad still needing your Trackpad26 support in hid-magicmouse; if you see anything else, that is what we want to know. |
|
Ran this PR on the K116s (16" M5 Pro OLED, 27.2 stub). This PR alone (hid-magicmouse without the Trackpad26 support of #1830): The parse failure is gone, the keyboard works and the multi-touch input device registers. No pointer and no clicks, and nothing arrives on the event device. As you expected. This PR plus the hid-magicmouse commit of #1830: the trackpad works. 20 s of use gave about 22000 events on the event device: positions, touch major/minor, orientation and pressure on three slots, 5 physical clicks, two- and three-finger contacts. No "too short" message. One difference from the clamp in #1830: with this PR the log has, once per boot, I do not get that line with my clamp, which clamps to the same 16384 bits but does not pad. My guess is that the padded report is now long enough for the HID core to walk the field once before hid-magicmouse's raw_event handler claims the frames; I have not confirmed that. It had no visible effect. So either clamp works for the K116s. I am fine dropping mine from #1830 in favour of this one; the magicmouse commit is needed either way. |
99a8061 to
b8a54f3
Compare
|
GREEN on b8a54f3 Both commits match the body, and the KUnit case is the strong part: the expected bytes pin the two behaviors that matter - the oversized Report Size item (0x80000) comes out as 16384, and Report-Size-looking data inside a long item (0xfe 02 ...) is left untouched, so the clamp cannot corrupt an unrelated operand. The pad commit's design is argued, not asserted: one devm buffer per interface allocated only when a clamp happened, lock-free because each interface runs its reports on its own ordered workqueue - the reasoning holds, and passing the true length to hid_safe_input_report keeps the short-report semantics honest. Merge order (before #1568 and #1605) is stated with the reason. The Validated-on section is the honest form throughout: build-only with the KUnit case compiled in and explicitly not run, the old-head boots attributed to the old heads, the pad's earlier clang-compile-only status kept, and the reach limited to interfaces that actually declare an oversized item. |
|
GREEN on b8a54f3 Independent review. No blocking items. I did not boot a Mac, so nothing here confirms real touch reports. What I ran, on a checkout of this head:
Non-blocking notes:
|
b8a54f3 to
97cfe1f
Compare
|
GREEN on 97cfe1f Re-review at the checked-allocation head (the compare confirms only the pad commit changed, one file, and the clamp commit is untouched). Every exit of dchid_clamp_report_sizes is covered and none leaves a bad state: the two truncated-descriptor returns leave the tail untouched as before (0), the normal end returns 0, and the devm_kzalloc failure returns -ENOMEM - with the allocation ordered before the descriptor bytes are rewritten, so no half-clamped descriptor exists even transiently. The caller drops the descriptor on the error and logs it, which the body states in exactly the kmemdup-equivalence terms the diff implements: the interface does not come up holding reports it would drop. The body's new sentence matches the code path for path. The pad use stays guarded on the buffer existing and on the report actually being short, with full-length reports passing through unpadded. Everything from the previous verdict (the KUnit byte-level pins, the buffer reasoning, the validation attribution) carries. |
|
GREEN on 97cfe1f Re-review of the changed pad commit. The clamp commit 387c0d5 is unchanged. No blocking items. I did not boot a Mac. What I checked, at this head:
Non-blocking notes:
|
97cfe1f to
d43ac77
Compare
|
GREEN on d43ac77 Re-review at the base-claim head. Verified against both trees: the base a88bb04 clamps a 4-byte Report Size in dchid_parse (the K116s commit), the singular dchid_clamp_report_size had exactly one caller (the dchid_parse line), and at this head both the function and its call are gone with the plural, buffer-allocating clamp now running in dchid_handle_descriptor where the descriptor is copied - the claims in the rewritten commit message and body match the diff exactly, including the corrected framing that on this base the gain is the pad plus the allocating clamp. The pad commit is byte-identical in content to the previous head (message unchanged, allocation check and all four exits verified last review). Nothing else referenced the removed function (it was static with its single call site). The KUnit case moves with the clamp commit. |
|
Addendum on d43ac77: the K116s 4-byte coverage question checked against both trees. The old singular clamp matched only the 4-byte form (type 1, tag 7, size 4, i.e. the 0x77 item); the new clamp matches (prefix & 0xfc) == 0x74 with n >= 2, which is the 2-byte and 4-byte Report Size items (0x76 and 0x77, with n==3 mapped to 4) - a strict superset, running earlier at the descriptor copy. A K116s descriptor that the old path clamped is clamped identically by the new one, and a 2-byte oversized item that the old path ignored is now caught too. |
|
GREEN on d43ac77 Re-review of the rebuilt stack. No blocking items. I did not boot a Mac. What I checked, at this head:
Non-blocking notes:
|
|
Thanks. The clamp and the pad only act when the descriptor declares a Report Size above 16384, and folding the old K116s clamp into one place is right. Nothing in the code blocks. What's missing before it leaves draft:
The descriptor walk now runs on every dockchannel interface, so once it's ready we will run a no-regression keyboard/trackpad row on our M2 (T8112) and M4 Pro (T6040). |
|
Ryan, the K116s run at this head (d43ac77), firmware 27.2. The two commits are cherry-picked on Boot: The trackpad works. 30 s of use under The Not run: a deep sleep and wake with the trackpad checked after it. |
|
Thanks for the K116s input and wake row. It covers An arm64 QEMU boot of This does not replace the K114c boot or input regression checks on the updated head. The draft stays open. |
|
Thanks, 38b64ea closes two of the three points: the comment in Two small things on this head:
Still owed, as you say: the K114c trackpad and keyboard row at the final head. The pad length changed after axboe's K116s run, so a quick K116s re-check at the final head would also help. After that we will run our M2 and M4 Pro keyboard/trackpad no-regression rows. |
hid-core refuses a report buffer smaller than the size its parsed layout implies. After the Report Size clamp that size is 2048 bytes, while the T6050 multi-touch firmware sends reports of about 437 bytes, so every report logged "Event data for report 0 was too short" and was dropped. Copy short reports into a zero-padded per-interface buffer and pass the true length to hid_safe_input_report(). The buffer exists only on interfaces that were clamped, and only that interface's ordered workqueue uses it, so it needs no locking. If the buffer cannot be allocated, the descriptor is dropped, the same state a failed copy of it leaves, and the failure is logged. Signed-off-by: Joshua Warren <[email protected]>
38b64ea to
ccf90dc
Compare
|
This head passed 13 parser and 4 protocol KUnit tests in arm64 QEMU, with no failures or skips. The numbered short-report case passed. The K114c keyboard and trackpad check still needs a hardware slot. |
|
Ryan, the K116s re-check at the final head (ccf90dc), firmware 27.2. The two commits are cherry-picked on Boot: the same lines as at d43ac77 ( The trackpad works. 30 s of use under Not run: a sleep and wake with the trackpad checked after it. |
|
Thanks for the K116s re-check at ccf90dc — byte-identical dockchannel-hid with no error-level lines and a clean evtest receipt is exactly the confirmation we wanted. The one remaining item, a deep sleep and wake with the trackpad checked after, is queued for the next K116s window together with the K114c row; we will post it as its own receipt. |
|
integration/aurora 110861f still has only the single 4-byte clamp in dchid_parse() from #1830 and no pad, so this is still needed. Both commits apply cleanly to 110861f, and there have been no tip changes under drivers/hid/dockchannel-hid/ since this branch's base. The K116s re-check at ccf90dc covers the second firmware. What's still missing is the K114c keyboard and trackpad row at ccf90dc, plus the sleep and wake check with the trackpad tested afterwards. After that the M2 and M4 Pro no-regression rows can run. Build check of 110861f plus this change (arm64, LLVM=1, Image, dtbs and every directory it touches, Fedora config plus asahi.config): builds, no warnings in the files it touches. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins. |
|
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.
The pad capacity is derived from the limit on a single Report Size item, while the parsed report length is the sum of fields and counts. The clamp applies to every oversized item. Please either constrain it to the characterized single opaque report shape, or size the padded path against the validated aggregate report length, and test an oversized field plus another field or count. Also remove the agent attribution and stale draft wording in the title and description. The regression rows on J616s and J713 are noted; the target touch row remains pending.
The pad was sized for one clamped Report Size item. hid-core expects the whole report, the sum of every field and count, so a descriptor with a clamped field plus other fields made hid-core reject each short report as smaller than its buffer. hid-core never asks for more than the transport's buffer limit, and dchid_ll sets none, so pad to HID_MAX_BUFFER_SIZE. Add a test with a clamped field followed by a 16-byte field. Signed-off-by: Ryan Murray <[email protected]>
|
@joshuaswarren the review's pad finding is real, and here is a fix for you to take into this PR: 3a40834 on branch
The review's other item is yours: the title and description still have the agent attribution and the "draft" wording. Please drop them when you next edit (org pr-text policy: no AI attribution). |
There was a problem hiding this comment.
Verdict: FINISH, then merge, at 3a408344e12b. The code is right; the PR text isn't.
Blockers:
- PR title and description: the title still starts with
[Joshua's agent]and ends with(draft), and the description opens with "[Joshua's agent] Draft. … not booted in this form". The org rule is no agent or AI attribution in PR titles, bodies, comments or reviews, and the draft wording is stale (it's out of draft and has rows). Please retitle (for exampleHID: dockchannel-hid: accept the T6050 multi-touch report size) and replace the first line of the description with the current state. Once that's done I'll approve this code as it stands.
Checked (the code at this head):
- Padding fix (
3a408344): the pad is nowHID_MAX_BUFFER_SIZE. Withdchid_llsetting nomax_buffer_size, that's the most hid-core can expect for any report, so a clamped field plus further fields or counts fits. That answers the earlier change request. Reports at or above that size (the 17,861-byte kiwi frames) skip the pad unchanged; shorter ones are copied and zero-filled per interface on the single RX path, then passed withhid_safe_input_report()(signature present ininclude/linux/hid.h). - Descriptor scan (
dchid_clamp_report_sizes()): long items read their length byte only afteri + 1 < len; short items are bounds-checked (i + 1 + n <= len) before the value is read;0x74masked with0xfcmatches Report Size of any width, and only 2- and 4-byte values can exceed 16384. On allocation failure the descriptor copy is freed and cleared (0a758c7d). - Build: arm64 W=1,
drivers/hid/dockchannel-hid/: 0 warnings. (No CI job builds this directory.) - KUnit (arm64 QEMU,
HID_DOCKCHANNEL_PARSER_KUNIT_TEST): dockchannel-hid-parser 15/15, dockchannel-hid-protocol 5/5 at this head. The newdchid_clamped_aggregate_report_testfails on the previous head0a758c7d(expectation at parser-test.c:358) and passes here, so it really catches the aggregate-length case. - Regression rows at the earlier head on J616s (fleet89) and J713 (fleet85) passed; this delta only changes the pad size for clamped interfaces (none on those Macs' descriptors that I know of; the row author should confirm).
- No AI trailers in the commits.
There was a problem hiding this comment.
The aggregate-pad finding is resolved in source by matching HID core’s default transport limit; the new test covers the additional-field case through the driver parser. The public title and opening paragraph still carry agent attribution and stale draft wording. Please clean up both and post the current target touch result. Hosted checks are queued.
|
Updated the title and description to match |
There was a problem hiding this comment.
Verdict: MERGE at 3a408344e12b, once the K114s touch row at this head is posted (6-point item 3). My only blocker, the PR text, is fixed.
Checked: title and description at this head carry no agent attribution or stale draft wording. The code is as in my previous review: the pad at HID_MAX_BUFFER_SIZE covers the aggregate report; the descriptor scan is bounds-checked; arm64 W=1 is clean; KUnit dockchannel-hid-parser 15/15 and -protocol 5/5 pass; and the new aggregate test fails on 0a758c7d and passes here. No AI trailers in the commits.
Merge order: this before #1605 (hard runtime dependency). The K114s row should run #1737 + #1605 together at their heads, as K114S-TOUCH plans (Kiwi ready, edge touches, no contacts at rest, counters around one s2idle).
There was a problem hiding this comment.
The pad now matches the HID core default transport limit, and the aggregate report fixture covers a clamped field followed by another field. The title and body have been corrected. Code approved. The reported 20 KUnit cases pass; the target touch result at 3a40834 and hosted checks still need to be recorded before landing.
|
Rows at the exact current heads, #1737
On the K114s, the pad fix doesn't change behaviour: the kiwi descriptor is one clamped field, so |
|
K116s row at 3a40834 (T6050, 16" M5 Pro OLED, firmware 27.2): pass. Kernel: |
|
@axboe thanks, a K116s row by hand at exactly A related question, if you have time. The K116s also has the OLED touchscreen: the kiwi interface on the same MTP, |
|
Merging under the 6-point rule (Ryan 09:29, permanent), at
Still to run: the K114s touchscreen finger row. Revert: |
|
@RyanTheTide here's the K116s
|
HID: apple-mtp-kiwi: the K114c touch screen (needs #1737)
What
T6050 touch firmware sets a
Report Sizeof0x80000bits.hid-corerejects that size. Once clamped to16384bits,hid-coreexpects full-size input reports and drops short touch frames.This PR moves the clamp to
dchid_handle_descriptor()for 2-byte and 4-byte items. It drops the old clamp indchid_parse(). When a clamp hits, it sets up one per-portHID_MAX_BUFFER_SIZEpad buffer (and frees the copied desc on-ENOMEM). Short input reports pad throughhid_safe_input_report(), soraw_event()keeps the true frame length. Longer frames skip the pad as-is.This lands before
#1605(K114c and K114s touch screen).Tested
Tested: head
3a408344e12b.W=1build ofdrivers/hid/dockchannel-hid/: 0 warnings.HID_DOCKCHANNEL_PARSER_KUNIT_TEST):dockchannel-hid-parser15/15 PASS (dchid_clamped_aggregate_report_testincluded),dockchannel-hid-protocol5/5 PASS.Prior hardware rows on earlier heads:
0a758c7d): PASS. 6/6 MTP ports bound. 2/2 s2idle cycles. No errors.0a758c7d): PASS. 4/4 MTP ports bound. 2/2 s2idle cycles. No errors.ccf90dc8+#1605): PASS.Kiwi ready with status:0. 17861-byte frames arrived with no drops.Risk
Risk: two-way · M2 to M5 Macs using
dockchannel-hid.Unclamped ports keep no pad buffer and stay on
hid_input_report(). Clamped ports keep oneHID_MAX_BUFFER_SIZEpad buffer and pad only frames shorter than that limit. A plain revert undoes this change.Not yet
3a408344e12bon K114s or K114c.