Repository navigation
[Joshua's agent] HID: dockchannel-hid: accept the T6050 multi-touch report size (draft) - #1737
joshuaswarren wants to merge 2 commits into
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 <816217+joshuaswarren@users.noreply.github.com>
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.
|
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. Model: zai/glm-5.3 (live from lane_models.py this turn). |
|
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:
Model: anthropic/claude-sonnet |
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. Model: zai/glm-5.3 (live from lane_models.py this turn). |
|
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:
Model: anthropic/claude-sonnet |
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. Model: zai/glm-5.3 (live from lane_models.py this turn). |
|
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. Model: zai/glm-5.3 (live from lane_models.py this turn). |
|
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:
Model: anthropic/claude-sonnet |
[Joshua's agent] Draft. Rebased onto
integration/auroraa88bb04. Compiles; not booted in this form.The 14-inch M5 Max trackpad (T6050 multi-touch) declares its raw report as one Report Size item of 0x80000 bits, which hid-core refuses. On this base that part is already handled for a 4-byte Report Size:
dchid_parse()clamps it (0768762, written for the K116s firmware). So on this base the gain of this PR is the pad, plus the clamp that allocates the pad's buffer. In two commits:dchid_handle_descriptor(), where the descriptor is copied, and covers Report Size items of 2 to 4 bytes. It allocates the pad buffer there, when a clamp happens (next commit). The clamp indchid_parse()can no longer change anything, so it is removed, function and call. The KUnit case for the clamp is in this commit. This commit used to be the first commit of [Joshua's agent] HID: magicmouse: parse the 0x5a MTP report of the K114c #1568; the same clamp was in both PRs, so it lives here only.hid_safe_input_report()with the true length.If the pad buffer cannot be allocated, the descriptor is dropped (the same state a failed copy of it leaves) and the failure is logged, so the interface does not come up with reports it would drop.
Buffer choice: one 2 KiB buffer per interface, allocated with devm only when a clamp happens. Each interface runs its reports on its own ordered workqueue, so one buffer needs no lock. A kzalloc per report would add an allocation on the touch hot path for no gain.
Not covered (reviewers' notes, left as they are):
Merge order: this lands before #1568 (the 0x5a parser) and before #1605 (the touch reset); both need the interface to parse and its reports to arrive.
Validated on, and reach
What ran where:
dockchannel-hid.obuilds with gcc 16.1.1 andW=1, no warnings (my build; a reviewer's used gcc 12.2), with the KUnit case compiled in (CONFIG_KUNIT=y,CONFIG_HID_DOCKCHANNEL_PARSER_KUNIT_TEST=y), on a 16K-page arm64 config. The first commit alone builds the same way. The KUnit case was not run: it needs a kernel boot or UML, which I did not do.dchid_parse()clamp, not this one. The pad commit was reported earlier as compiled only and not booted.Applies beyond the M4: the clamp applies to any dockchannel-hid interface that declares an oversized Report Size item. The pad applies to every interface that was clamped, so it now also applies to the K116s trackpad, which the
dchid_parse()clamp already served without it. NOT CHECKED on a K116s: whether the padded buffer changes anything there. No M4 or other model checked.m tester run (omarchy-m-testing.org): feature row Trackpad. The tester needs the hardware; no tester run is linked to this change.