Skip to content

J714s: keep the USB4 dock port's USB host in place through a deep sleep - #2072

Draft
DjDeveloperr wants to merge 2 commits into
mainfrom
j714s/usb4-dock-usb-in-place
Draft

DjDeveloperr wants to merge 2 commits into
mainfrom
j714s/usb4-dock-usb-in-place

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 16, 2026 •

Copy link
Copy Markdown

Follow-up to #2046 and #2057 (merged), based on integration/aurora.

This is still draft: the host restores successfully, but the dock's USB3 devices still disconnect during resume. Sustained deep-sleep qualification is also pending a separate wake/alarm investigation.

With the existing router sleep fixes, the J714s dock router returns in place but xHCI loses its saved state when its controller loses power. This change follows the controller hibernation sequence observed under macOS: request D3 after xHCI saves its state, wait for the power-control handshake, gate the PIPE clock on the tunnel producer, then restore D0 and the host globals before xHCI restores its state. It avoids the core soft reset that invalidates that restore.

The two commits add the J714s power-control mapping and PHY hibernation sequence, then the DWC3 host restore in place. They also suspend and restore the USB2 PHY, retain the PIPE producer, and handle return from a refused entry. The rest of the router sleep and display stack remains a dependency.

Validation:

  • The existing Fedora compile/link checks passed on the PR head and the PHY commit separately.
  • The November 16 hardware kit was built natively on J714s from integration 568c9e4cfc915, this PR's code, a refused-entry keep follow-up, an entry-refusal test switch, early port-controller S0, and an experimental PCIe readiness poll. Those additional changes are not in this PR head.
  • Three direct mem transitions and one systemctl suspend transition committed and returned. The corrected RTC estimates for the three direct transitions were approximately +0.50, −0.29, and +0.76 seconds, with ±1 second quantization uncertainty. They do not demonstrate the programmed 30-second hold. Earlier clean recovery counts likewise do not establish sustained sleep duration.
  • xHCI reported no restore error. The dock's USB2 devices remained in place. At each of the four committed wakes the dock's USB3 subtree still had five disconnects, five new enumerations and one USB reset. Early S0 completed in about 12 ms and did not remove this failure.
  • An intentional entry refusal returned safely with all dock USB devices present afterward, but five device numbers changed. Refusal recovery is therefore also not in place.
  • After the three direct transitions, all six tunnelled PCI functions were bound and dock Ethernet had carrier. GPU, camera, network and fault checks passed. A separate left-port USB3 hub was absent after one wake.
  • Panel lighting was about 2.10 seconds after CPUs were enabled. The last external sink returned about 9.5 seconds after the router. The experimental downstream vendor-ID poll exhausted its one-second timeout because root bus routing had not yet been restored.
  • The logind test's waiter missed successful service completion when systemd cleared an inactive service timestamp. The kernel/service journal records the return, but that fixture does not supply a valid return-duration measurement. The original sleep/suspend mask state was restored exactly.

Open work: identify the late USB3 disconnect, qualify sustained sleep after the alarm investigation, and reduce resume latency. No zero-reset or fast-resume qualification is claimed for this head.

… router's sleep

macOS keeps the USB host on the USB4 dock's port through the router's
sleep in place, and xHCI restores its state at the wake, so no device
behind the dock is reset. Linux parked the host's PIPE on its dummy
producer and stopped the USB2 PHY, and the controller lost its power
with nothing kept: the xHCI restore failed (USBSTS save/restore error)
and every dock device was reset at each wake.

Do as macOS does on J714s:

 - At the PIPE's park for the router's sleep (xHCI has saved its state
   by then; macOS does this right after the save), take the controller
   into hibernation through its power control ("pwrctl", the
   controller's window beside the PIPE handler, as on T8140): D3 asked
   for, VDD_OFF awaited and cleared, the wake events armed, SLEEP in the
   status. Without the region, or if the hibernation fails, the PIPE is
   parked on its dummy producer as before.
 - Keep the USB3 PIPE on the tunnel producer with its clock gated
   instead of moving it to the dummy producer, and take the core's
   reset after the CIO shutdown.
 - Suspend the USB2 PHY instead of stopping it, and give it back before
   the PHY's restart at the wake.
 - At the host's resume, give the PIPE its clock back on the tunnel,
   disarm the wake events, ask for D0, release the core's reset and
   wait for D0_ON (about 1 ms). A new RETAINED step reports whether the
   controller's bank kept the sleep's state, for the glue to resume the
   host in place. A refused sleep, the reset's release and a failed
   hibernation ask for D0 too.

A power control that reads all zeros after the sleep lost its state:
the host starts over, as before. A controller that gives no D0_ON and
still reports SLEEP may be unpowered: the PHY is marked faulted and the
glue keeps away from its core. The region is described for the J714s
display layout of the right port's PHY and mapped only there.

Signed-off-by: Diljit Singh <hey@djdev.me>
… deep sleep

With the dock port's controller kept through the USB4 router's sleep in
hibernation, its core still comes back without its registers (GUID at
its reset value), but the controller's state is kept: macOS writes back
only a few globals (the ADT's host tunables, the CIO timers and the DRD
configuration), with no core soft reset, and xHCI then restores its
saved state.

Do the same on J714s: mark GUID before the sleep; after the wake, when
the PHY reports the controller's bank kept the sleep's state, resume in
place if the core kept the mark, otherwise write back the globals and
the host's GCTL hibernation setup and let xHCI restore its state. After
a sleep refused behind the hibernation the core is set up the same way.
The J714s's T6050 controllers now get the same GCTL hibernation enable
and power-down scale as T8140 at every start, as macOS's controller start
sets them on the dock's port.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Author

First hardware run of this exact code on integration/aurora (d5a8a25 + this PR + the refused-sleep follow-up, J714s with the TB5 dock, 3 real deep sleeps and 1 forced .enter refusal):

  • At every entry and wake the controller's hibernation ran as macOS's does, and xHCI's state restore succeeded every time: no xHC error in resume. The dock's USB2 devices stayed in place.
  • At every wake the dock's USB3 devices behind the router's USB3 tunnel were still disconnected and enumerated again. It happened 25 to 80 ms after the dock port's controller (sn201202x) went back to S0 in its .resume, which now runs about 0.6 s after xHCI's restore. On the test stack, which puts that controller back in S0 in the noirq resume, before the router's wake (as macOS does right after the wake), there were 0 disconnects. That change is the next commit for this PR; it is being built and tested now.
  • With the refused-sleep follow-up the host is no longer stopped and started after a refusal (result "kept"). Its USB3 devices disconnected the same way, after the same late S0.
  • The other wake checks (four displays, Wi-Fi/BT, camera, GPU, faults) passed. The only other failure is a USB3 hub on the left port missing after 2 of the 3 wakes. That port is not part of this PR, and the same miss is in the default candidate's own runs.

🤖 Generated with Claude Code

@RyanTheTide

Copy link
Copy Markdown

atc_sleep_macos_usb() in atc-t6050-dp.c, the pwrctl mapping in combo_setup() and the GBLHIBERNATIONEN setup in dwc3-apple.c are all keyed on of_machine_is_compatible("apple,j714s"). The behaviour is a property of the T6050 ATC PHY and its dwc3 instance, not of one board, so every other T6050 machine silently keeps the old path. Select it from the device nodes: map pwrctl when the PHY node has it, use the apple,t6050-dwc3 compatible (or a DT property) for hibernation, and drop the board checks. Until then this should stay a draft.

@RyanTheTide

Copy link
Copy Markdown

The controller hibernation sequence is not on 110861f. Both commits apply cleanly on 110861f, even though dwc3-apple.c and the T6050 PHY gained several sleep commits since this branch's base. @DjDeveloperr, the review point is still open: select the pwrctl mapping, atc_sleep_macos_usb() and the GBLHIBERNATIONEN setup from the PHY and dwc3 nodes instead of the apple,j714s machine compatible. #2441 is doing the same for the existing T6050 sleep paths. The dock's USB3 devices still re-enumerate after each wake, which the body also says.

Build check of 110861f plus this change (arm64, LLVM=1, Image, dtbs and every directory it touches, Fedora config plus asahi.config): builds, no warnings in the files it touches; CHECK_DTBS over every Apple DTB: no new warnings against the tip.

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