Repository navigation
HID: let hid-generic take Apple internal interfaces no driver wants - #2262
RyanTheTide wants to merge 1 commit into
Conversation
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>
|
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.
Not covered: physical key, Fn and force-click presses. |
|
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)
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). |
DjDeveloperr
left a comment
There was a problem hiding this comment.
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.
|
@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 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):
A script that collects all three: https://gist.github.com/RyanTheTide/c881b2f6d8061e8603d42a81d1133668. As root, run |
|
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. |
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_IDand return-ENODEVfrom 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):
0019:05AC:0351.0005 "Apple MTP tp_accel"has no driver. dmesg shows hid-generic binding it at 2.54 s ashidraw4. It loses the binding when hid_apple/hid_magicmouse load and the bus reprobes it.0019:05AC:035A.0005 "tp-accel"and.0006 "mtp"never bind.Change
__check_hid_generic()now asks a driver's.matchcallback, if it has one, before handing a device over to it..matchcallbacks. 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:
tp_accelgoes from no driver to hid-generic (hidraw4, no input device); keyboard, multi-touch,actuator and stm keep their drivers; same input device list.
tp-accelandmtpbind to hid-generic, the other three are unchanged.Still to run
Details
hid_check_device_match()already callshdrv->matchwhen 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.matchare hid-generic and hid-apple-mtp-haptic, plus the two added here.hid_ignore_special_drivers/HID_QUIRK_IGNORE_SPECIAL_DRIVERbehaviour, because a driver's.matchreplaces that check inhid_check_device_match().BUS_HOSTApple withHID_ANY_ID. Once it lands it would claim these interfaces again unless it gets a.matchlike the two above.__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)