Skip to content

HID: let hid-generic take Apple internal interfaces no driver wants - #2262

Open
RyanTheTide wants to merge 1 commit into
integration/aurorafrom
drvgap/hid-generic-special-match
Open

RyanTheTide wants to merge 1 commit into
integration/aurorafrom
drvgap/hid-generic-special-match

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The internal keyboard controllers on Apple laptops (SPI and DockChannel) give every interface the controller's vendor and product ID. hid-apple, hid-magicmouse and hid-apple-mtp-haptic list that ID with HID_ANY_ID and return -ENODEV from probe for the interfaces they don't drive. hid-generic refuses those interfaces as well, because __check_hid_generic() only checks the other drivers' ID tables. Those interfaces end up with no driver.

Seen on current fleet kernels (read-only sysfs and dmesg):

  • M2 MacBook Air (J413, 7.3.0-aurora-fleet74): 0019:05AC:0351.0005 "Apple MTP tp_accel" has no driver. dmesg shows hid-generic binding it at 2.54 s as hidraw4. It loses the binding when hid_apple/hid_magicmouse load and the bus reprobes it.
  • M4 Pro MacBook Pro (J616s, 7.3.0-aurora-fleet75): 0019:05AC:035A.0005 "tp-accel" and .0006 "mtp" never bind.

Change

  • __check_hid_generic() now asks a driver's .match callback, if it has one, before handing a device over to it.
  • hid-apple and hid-magicmouse get .match callbacks. For Apple SPI/host-bus devices they accept only the keyboard and trackpad interface types (HID_TYPE_SPI_KEYBOARD / HID_TYPE_SPI_MOUSE, set by spi-hid-apple and dockchannel-hid). Every other device matches as before. hid-apple-mtp-haptic already has a .match.

The extra interfaces then bind to hid-generic as hidraw nodes. That is the state the M2 already reaches during boot before the reprobe drops it.

Testing

  • Compile check (arm64, LLVM, W=1) of hid-generic.o, hid-apple.o, hid-magicmouse.o and hid-apple-mtp-haptic.o on integration 0abc2f3: no warnings. checkpatch: clean.

  • Hardware, one-shot test kernel vs production fleet74 on the same Mac, 2/2 s2idle each:

    • M2 (J413): tp_accel goes from no driver to hid-generic (hidraw4, no input device); keyboard, multi-touch,
      actuator and stm keep their drivers; same input device list.
    • J616s (M4 Pro): tp-accel and mtp bind to hid-generic, the other three are unchanged.
    • M1 Pro (SPI HID): no change in bindings.
    • Enforcing, 0 failed units, 0 AVC on all three. Rows in the PR comments.

Still to run

  • Physical key, Fn and force-click presses (the lab Macs are headless).
Details
  • hid_check_device_match() already calls hdrv->match when it decides whether a driver may probe. This patch only brings the hid-generic veto in line with it. The only drivers in the tree with a .match are hid-generic and hid-apple-mtp-haptic, plus the two added here.
  • The new callbacks keep the old hid_ignore_special_drivers / HID_QUIRK_IGNORE_SPECIAL_DRIVER behaviour, because a driver's .match replaces that check in hid_check_device_match().
  • Open HID: apple-mtp-kiwi: the K114c touch screen (needs #1568) #1605 (hid-apple-mtp-kiwi) also lists BUS_HOST Apple with HID_ANY_ID. Once it lands it would claim these interfaces again unless it gets a .match like the two above.
  • Why the M2 binding is lost: when a HID driver registers, __hid_bus_reprobe_drivers() reprobes every device that hid-generic holds but no longer matches. The new driver then turns the device down, and it is left with nothing.

Assisted-by: LLM (Claude:Opus 5.5)

The internal keyboard controllers on Apple laptops (SPI and DockChannel)
give every interface the same vendor and product ID. hid-apple,
hid-magicmouse and hid-apple-mtp-haptic list that ID with HID_ANY_ID,
and each probe returns -ENODEV for the interfaces it does not drive.
hid-generic then refuses them too, because __check_hid_generic() only
looks at the other drivers' ID tables.

So the extra interfaces stay unbound. On the M2 MacBook Air the
DockChannel "tp_accel" interface binds to hid-generic during boot
(hidraw4) and is unbound again once hid_apple and hid_magicmouse load
and the bus reprobes it. On the M4 Pro MacBook Pro "tp-accel" and "mtp"
never bind at all.

Make __check_hid_generic() ask a driver's match callback, so a driver
can decline a device its table covers. Give hid-apple and hid-magicmouse
callbacks that keep only the keyboard and trackpad interface types of
these controllers; hid-apple-mtp-haptic already has one. Every other
device matches as before.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J616s row (MacBook Pro 16" M4 Pro). One-shot test kernel: integration 2c35f50 + fabc6f2, fleet75 config, production device tree. Compared against production fleet75 on the same Mac.

interface fleet75 with this PR
Apple MTP tp-accel (0019:05AC:035A.0005) no driver hid-generic, hidraw4, no input device
Apple MTP mtp (.0006) no driver hid-generic, hidraw5, no input device
keyboard / multi-touch / actuator apple / magicmouse / hid-apple-mtp-haptic same
  • The /proc/bus/input/devices list is identical on both kernels. The magicmouse "initialised MTP haptics" and actuator click-handoff lines appear on both.
  • After 2/2 s2idle cycles (rtcwake on the apple-pmu-rtc, rc=0), all six bindings are unchanged.
  • Gate: 0 failed units, 0 AVC denials. The only kernel error lines are the dwc3-apple genpd_prepare returns -11 lines production prints on each suspend.

Not covered: physical key, Fn and force-click presses.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

M2 and M1 Pro rows. Both are one-shot boots of a test kernel: this PR (fabc6f2) on integration 6ae9c3c plus the linux#2468 GPU commits (drm/asahi only, no HID code), fleet74 config. Each Mac's production fleet74 kernel is the baseline.

M2 MacBook Air (J413)

interface fleet74 with this PR
Apple MTP tp_accel (0019:05AC:0351.0005) no driver hid-generic, hidraw4, no input device
Apple MTP keyboard / multi-touch / actuator apple / magicmouse / hid-apple-mtp-haptic same
Apple MTP stm (0019:0000:0000.0001) hid-generic same
  • /proc/bus/input/devices lists the same devices on both kernels.
  • During boot, hid-generic briefly takes keyboard, actuator and tp_accel, then apple and hid-apple-mtp-haptic take their two over. tp_accel stays on hid-generic.
  • After 2/2 s2idle cycles (rtcwake -d rtc1 -m freeze, rc=0), all five bindings are unchanged.
  • Gate: Enforcing, 0 failed units, 0 AVC denials, no kernel error lines.

M1 Pro (J316, SPI HID): no change. Keyboard, trackpad and actuator bind to apple, magicmouse and hid-apple-mtp-haptic, the same as on fleet74. The input device list is identical, and it is unchanged after 2/2 s2idle cycles. Gate is the same as on the M2.

Not covered: physical key, Fn and force-click presses (the Macs are headless).

@RyanTheTide
RyanTheTide marked this pull request as ready for review November 20, 2026 10:24

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The approach is right: the controller-ID drivers decline interfaces that aren't theirs, and hid-generic asks a driver's match callback before deciding nobody wants the device. External Magic devices (not SPI/HOST) are unaffected.

One machine isn't covered by the rows: the K114c. dockchannel-hid types only "multi-touch" (SPI_MOUSE) and "keyboard" (SPI_KEYBOARD); every other interface is HID_TYPE_OTHER (dockchannel-hid.c:1008-1014). That includes the K114c's "touch screen", the only touchscreen in the fleet. Before this PR it matched magicmouse's ID table. After it, it falls to hid-generic or hid-multitouch. That is probably better, but it is a behaviour change on the one device we can't test here. Please get a K114c row before merge: which driver binds the touch screen interface, evtest touches on the panel, and keyboard and trackpad unchanged. With that, approve.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

@joshuaswarren, could you run a K114c row for this one? The K114c touch screen is the only interface here we can't test: it's a DockChannel HID_TYPE_OTHER interface that used to match hid-magicmouse's ID table, and with this PR it should go to hid-generic or hid-multitouch.

What's needed, on your current K114c kernel and on the same kernel with this PR applied (head fabc6f2, https://github.com/aurora-silicon/linux/pull/2262.diff; hid-generic is built in, so it needs a full kernel build):

  • which driver binds the touch screen interface;
  • evtest touches on the panel (tap and drag);
  • keyboard and trackpad still on their drivers.

A script that collects all three: https://gist.github.com/RyanTheTide/c881b2f6d8061e8603d42a81d1133668. As root, run bash hidrow.sh base on the current kernel and bash hidrow.sh pr2262 on the patched one (it asks you to tap the panel for 15 s), then paste both hidrow-*.txt files here. It only reads sysfs and the kernel log.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Rows pass on three Macs; still needed before merge is a K114c row (which driver binds the touch screen, evtest taps and drags, keyboard and trackpad unchanged), plus one check with physical key, Fn and force-click presses.

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.

2 participants