Repository navigation
usb: typec: tipd: debugfs commands and replug on every Mac - #4056
Conversation
A port without apple,debug-lock-key can be replugged too when the user asks for it: the key is then the board number of the machine's compatible. The property itself keeps marking a port that may carry a debug link, and one that the OS may replug on its own after a sleep. Signed-off-by: DjDeveloperr <hey@djdev.me>
The debugfs replug file was there only on a port whose DT gives the LOCK
key (apple,debug-lock-key) and whose host has a USB role switch: on the
J714s and on three of the J575C's four ports. The J700 has the key on one
port, but its host is fixed behind a hub.
Wherever the LOCK key is known, it is the board number reversed, and the
driver already derives it from the machine's compatible for two other uses.
Use that for a replug asked for through debugfs on an SN201202x or CD321x
whose DT gives no key, and take K boards ("apple,k114s" gives "411K") too.
A controller that does not take the key refuses the unlock, and is not sent
the disconnect. A replug needs no role switch, only a connector, which
MagSafe's controller does not have.
Not done with a key in every board's DT: the property also marks a port
that may carry a debug link (no HChk and no USBw at boot) and one that the
kernel may replug on its own after a sleep. Both stay with the boards that
have it. A CD321x that kept an attach over a reboot is replugged with the
same key as before, so its copy of the key goes away.
Signed-off-by: DjDeveloperr <hey@djdev.me>
tuxvdmtool reboots a hung Mac from another Mac on a USB-C cable. From an M3 or later Mac it does so through the debugfs command file, which a kernel has only with CONFIG_TYPEC_TPS6598X_DEBUG_COMMANDS. Distribution kernels were built without it, so their M3 to M5 Macs could not rescue another one. Default to y on Apple silicon, and set it in asahi.config, the fragment that the distributions merge and validate. The file stays root-only (0600), and kernel lockdown refuses to open it. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
RyanTheTide
left a comment
There was a problem hiding this comment.
The root-only debugfs path checks for a named connector and supported controller. The automatic role-switch path still requires the explicit DT key and an SN201202x. The list and removal paths keep queued work tied to the port lifetime. A hardware row is pending.
|
Hardware check on MacBook Pro 16" M3 Pro (J516s, T6030) at
|
|
Hardware check on MacBook Pro 14" M2 Pro (J414s, T6020, CD321x) at
|
|
J700 (MacBook Neo, T8140) boot rows for |
What: Any Mac on
maincan now reboot another Mac over USB-C withtuxvdmtool. The kernel option for the debugfscommandfile is on by default on Apple silicon, and thereplugfile appears on every USB-C port of every Mac that describes its port controllers. Until now distro kernels on M3 and later had onlyregs, andreplugneeded a device tree key that only the J714s, J575C and J700 have.Tested: J516s (SN201202x) at this head with #4057:
commandon by default,replugon all three USB-C ports and not on MagSafe (PASS). KUnit on UML passes (tipd-key2/2 new, the other tipd suites unchanged), the tipd directory builds atW=1on arm64 without a new warning, the binding passesdt-doc-validateandyamllint, and the host tests that build code from this driver pass.Risk: two-way · all Apple silicon Macs. Both files are root-only and nothing runs unless root writes to them. Boot, sleep and the kernel's own replug after a sleep keep their behaviour on every board.
Not yet: One CD321x Mac (M2 Pro J414s): both files, a
tuxvdmtoolnopand onereplug. J700 (the board without a role switch) shows the file. The K114 and K116 keys (411K,611K) are derived like the others and have not been tried.Details
The option.
CONFIG_TYPEC_TPS6598X_DEBUG_COMMANDSgetsdefault y if ARCH_APPLE, andasahi.configsets it, because that is the fragment the distributions merge and validate. The help text now says what kernel lockdown does: in integrity or confidentiality mode, openingcommand(0600) orreplug(0200) fails with EPERM, andregs(0400) can still be read.The key. The LOCK key is the board number reversed (
J516gives615J). The driver already had that code for the CD321x that kept an attach over a reboot and for the J716c's inherited connection. It is now one function,tipd_board_lock_key(), and a replug asked for through debugfs uses it when the device tree gives no key.tuxvdmtoolderives the same key from the same compatible string for its own commands. A controller that refuses the key is not sent the disconnect; the log line shows the unlock result.Why not
apple,debug-lock-keyin every device tree. The property does more than unlock:dwc3-applereplug a port by itself after a sleep (tipd_port_replug());Adding it everywhere would change boot and sleep on boards where none of that was tested. Those three uses still look at the property only.
Role switch.
replugalso required a USB role switch. The J700 has the key but no role switch (its host is fixed behind a hub), so it never had the file. A replug only needs a connector, so that is now the condition. MagSafe controllers have no connector and stay out.Ports. From the compiled device trees of this head:
replugports beforeJ575d, J804 and J833ct have no port controllers in their device trees on
main, so they get nothing yet (#2401 adds the J804 and J833ct ones).commandappears for every controller in the table, MagSafe included.Evidence
kunit.py runwith the tipd and SN201202x drivers: all suites pass (143/143 together with usb: typec: tipd: reset a controller through debugfs, and set the port up again #4057,cd321x-*andtipd-key). The SN201202x suite needs SUSPEND, which UML does not have, so it was only compiled. New suitetipd-key: the keys of eight boards (the three that the device trees give among them), and strings that are no board (SoCs, two-digit boards, other makers).W=1 drivers/usb/typec/tipd/with defconfig +asahi.config: the one warning is the existingi2c.c:21enum cast.sn201202x1/1,j613-mux6/6,hardware-defaults1/1,apple-dcp(it builds functions taken from this driver) passes.command,regsandreplugpresent on both connected ports,tuxvdmtool -c "USB-C Right" nopand-c "USB-C Left Back" noppassed. That module is not this head.