Skip to content

usb: typec: tipd: debugfs commands and replug on every Mac - #4056

Open
DjDeveloperr wants to merge 3 commits into
mainfrom
feat/tipd-debug-commands-default
Open

DjDeveloperr wants to merge 3 commits into
mainfrom
feat/tipd-debug-commands-default

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

What: Any Mac on main can now reboot another Mac over USB-C with tuxvdmtool. The kernel option for the debugfs command file is on by default on Apple silicon, and the replug file appears on every USB-C port of every Mac that describes its port controllers. Until now distro kernels on M3 and later had only regs, and replug needed a device tree key that only the J714s, J575C and J700 have.

Tested: J516s (SN201202x) at this head with #4057: command on by default, replug on all three USB-C ports and not on MagSafe (PASS). KUnit on UML passes (tipd-key 2/2 new, the other tipd suites unchanged), the tipd directory builds at W=1 on arm64 without a new warning, the binding passes dt-doc-validate and yamllint, 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 tuxvdmtool nop and one replug. 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_COMMANDS gets default y if ARCH_APPLE, and asahi.config sets 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, opening command (0600) or replug (0200) fails with EPERM, and regs (0400) can still be read.

The key. The LOCK key is the board number reversed (J516 gives 615J). 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. tuxvdmtool derives 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-key in every device tree. The property does more than unlock:

  • it marks a port that may carry a debug link, and the probe then skips HChk and USBw at boot;
  • it lets dwc3-apple replug a port by itself after a sleep (tipd_port_replug());
  • it makes a failed renegotiation of an inherited connection harmless, where the J716c fails the probe.

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. replug also 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:

Macs Controller replug ports before after
J714s SN201202x 2 2
J575C SN201202x 3 4
J700 SN201202x 0 2
J514s J516s, J514c J516c, J514m J516m SN201202x 0 3
J614s J616s J773s, J614c J616c SN201202x 0 3
J714c J716c J716s, K114s K114c K116s K116c SN201202x 0 3
J775c / J775d / J873s / J873g SN201202x 0 4 / 5 / 2 / 3
J604, J773g / J624 / J623, J713, J715 SN201202x 0 3 / 4 / 2
J704 / J813, J815 SN201202x 0 3 / 2
J613, J615 SN201202x 0 2
J433, J434, J504 CD321x 0 2
J274, J293, J313, J456, J457, J413, J415, J473, J493 CD321x 0 2
J314s/c, J316s/c, J414s/c, J416s/c CD321x 0 3
J375c, J474s, J475c / J375d, J475d / J180d CD321x 0 4 / 6 / 8

J575d, 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). command appears for every controller in the table, MagSafe included.

Evidence
  • KUnit, UML, clang: kunit.py run with 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-* and tipd-key). The SN201202x suite needs SUSPEND, which UML does not have, so it was only compiled. New suite tipd-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).
  • arm64 W=1 drivers/usb/typec/tipd/ with defconfig + asahi.config: the one warning is the existing i2c.c:21 enum cast.
  • Host tests (ubuntu 24.04 image): sn201202x 1/1, j613-mux 6/6, hardware-defaults 1/1, apple-dcp (it builds functions taken from this driver) passes.
  • Seen today on a J516s with a module built for its running kernel and the same key derivation: command, regs and replug present on both connected ports, tuxvdmtool -c "USB-C Right" nop and -c "USB-C Left Back" nop passed. That module is not this head.

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>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners December 3, 2026 04:40
@github-actions github-actions Bot added area:usb Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Merge readiness at 1c71d486: ready to merge

Check Detail
CI at head ok 13 checks passed
Review ok approved by RyanTheTide
Requested changes ok none
Hardware row at head ok comment at 1c71d486
Conflicts ok none
PR text ok 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.

Areas: area:usb
Merge: gh pr merge 4056 --merge (Owners and Core through the bypass: add --admin).

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@RyanTheTide RyanTheTide 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 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.

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Dec 3, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Hardware check on MacBook Pro 16" M3 Pro (J516s, T6030) at 1c71d486f2f5 (merged with main cff875630c61 and #4057 ca3ddc7f4568): PASS

  • CONFIG_TYPEC_TPS6598X_DEBUG_COMMANDS=y is enabled by default without a custom kernel config override.
  • Every Type-C controller exposes the expected debugfs nodes under /sys/kernel/debug/usb/tipd/:
    • 1-0a (USB-C Left Front): command regs replug
    • 1-0c (USB-C Left Back): command regs replug
    • 2-08 (USB-C Right): command regs replug
    • 1-06 (MagSafe 3 controller): command regs

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-hw-row No hardware row at the PR head (bot) ready-to-merge Meets the merge policy: merge it (bot) labels Dec 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:usb Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants