Repository navigation
Conversation
2d903fd to
3464d30
Compare
bfae172 to
071e41e
Compare
DjDeveloperr
left a comment
There was a problem hiding this comment.
[4/7] phy: apple: atc: review at 3464d30
Gating: the sleep transaction only acts while cio_sleep.prepared. Only #1419's J713 NHI sets it, with thunderbolt_apple.cio_s2r=1, and atcphy_from_cio_phy() limits the API to T8132.
The one unconditional change is the early return in atcphy_usb3_power_off(). It applies on every T8132 board (J604, J623/J624, J713/J715, J773g) whatever cio_s2r says. The behaviour looks right, and it's now its own commit (6ca9291); its message should say it applies on every T8132 board, outside the opt-in. No M5 impact: T6050 uses atc-t6050-*, and atc.c merges cleanly.
Findings
- That early return also skips the old
mode_dirtycleanup (mode != OFF || mode_dirtyreconfigured to OFF). A failed transition in a CIO mode now stays dirty after DWC3 stops. Suggest&& !atcphy->mode_dirty. apple_atcphy_cio_prepare()gates onpm_suspend_via_firmware(), whileapple_nhi_cio_prepare()gates onpm_suspend_target_state == PM_SUSPEND_MEM. A MEM sleep without the firmware flag makes the NHI's prepare fail with-EOPNOTSUPP, which refuses the sleep instead of falling back to the stock path. Use one predicate in both.- If
atc_t8122_tunnel_stop()fails incio_off(), it setst8132_failed,cio_on()then returns-EUCLEAN, and #1419's unwind panics. A tunnel-clock stop timeout shouldn't cost the machine. Fail beforechanged = true, or letcio_on()restore power and only refuse the clock restart. - Nit:
dev_infoin tunnel stop/start on every CIO sleep.
Verdict: OK with minor changes.
Review only: read at the head commit, not built or run (no J713 here). Written with Claude Code.
| * tunnels down before their drivers suspend. The Type-C mux owns the | ||
| * CIO mode and releases it when the connection ends. | ||
| */ | ||
| if (atcphy->hw->gen == ATCPHY_GENERATION_T8132 && atcphy_mode_is_cio(atcphy->mode)) |
There was a problem hiding this comment.
This is unconditional on T8132, outside the cio_s2r opt-in, which deserves a line in the commit message. It also skips the mode_dirty recovery below. Before, a dirty mode was always reconfigured to OFF here; now a CIO mode whose last transition failed stays dirty after DWC3 stops. Suggest atcphy_mode_is_cio(atcphy->mode) && !atcphy->mode_dirty.
| struct apple_atcphy *atcphy = atcphy_from_cio_phy(phy); | ||
| struct atcphy_cio_sleep *s; | ||
|
|
||
| if (!atcphy || !pm_suspend_via_firmware()) |
There was a problem hiding this comment.
The NHI decides whether to run this transaction from pm_suspend_target_state == PM_SUSPEND_MEM (apple_nhi_cio_prepare()), but this checks pm_suspend_via_firmware(). If they ever disagree, the NHI's .prepare fails with -EOPNOTSUPP and refuses the sleep instead of taking the stock path. Suggest one shared predicate.
| } | ||
| s->changed = true; | ||
| /* This PLL belongs to the saved DP streams, not to the CIO link. */ | ||
| ret = atc_t8122_tunnel_stop(atcphy); |
There was a problem hiding this comment.
If this fails, t8132_failed is set after s->changed = true. The NHI unwind's apple_atcphy_cio_on() then returns -EUCLEAN, and apple_nhi_cio_suspend() panics (suspend %d, recovery %d). Nothing has been powered down yet at this point, so failing before changed = true (or not marking the PHY failed for this step) would let the sleep be refused cleanly.
| if (stale_ack) { | ||
| /* The same release a clock stop ends with, so the start sees a real ACK. */ | ||
| ret = atc_t8122_tunnel_apb(atcphy, 0x10000018, false); | ||
| dev_info(atcphy->dev, "CIO tunnel clock ACK release: %d (APB %#x)\n", ret, |
There was a problem hiding this comment.
Nit: this and the stop-side dev_info print on every CIO sleep; dev_dbg would do.
On T8132 the PHY returns to its off mode when the DWC3 host on the port stops. With a USB4 or Thunderbolt link up that also drops the CIO lanes and with them every tunnel through the dock, although the cable is still connected and only the USB host went away, as it does for a system sleep. Leave a PHY that is in a CIO mode as it is when its USB host stops, and keep it busy for runtime PM. The Type-C mux still takes it down on a real disconnect, an ordinary USB mode still ends with its host, and a CIO mode whose last transition failed is still taken down. This applies on every T8132 board (J604, J623/J624, J713/J715, J773g), outside the J713 deep-sleep opt-in. Extend the USB3 host model with the T8132 cases and three mutations. Signed-off-by: Erik Bourget <erik@ebourget.net>
A deep sleep with a USB4 link up has to power the PHY down and bring it back in CIO mode with the same lane configuration. The system suspend callback refuses a deep sleep while the common block is in use, and only the ACIO host knows when the link's users are stopped. Add an interface for that host: prepare records the mode and orientation and lets the system suspend through, off stops the DP tunnel clock, saves the lane mode and crossbar and powers the PHY down, on powers it up and restores them, and finish ends the transaction. The tunnel clock is started again for the DP inputs that were using it. prepare takes part in the same sleeps as its host (a suspend to RAM). A tunnel clock that does not stop refuses the sleep before anything is powered down, and the DP inputs using it get their clocks back. After the power cycle the tunnel clock's command register reads with its acknowledge bit set and no request pending. The first clock start after it, in the restore or whenever a DP tunnel next asks for the clock, accepts that and issues the release command a stop ends with before it starts the clock, so the start's own acknowledge is real. Add a host-side model of the transaction with negative controls. Signed-off-by: Erik Bourget <erik@ebourget.net>
071e41e to
8178a9f
Compare
3464d30 to
280330c
Compare
Two changes to the T8132 Type-C PHY for a deep sleep with a USB4 link up.
Part 4/7 of J713 docked S2R, stacked on the native radio series (#1384), which is stacked on #1314.
Series order: #1414 → #1415 → #1416 → #1417 → #1418 → #1419 → #1420.
Depends on #1416.
Validation of the series on this base:
Based-on-work-by:trailers and style in thetools/asahifixtures.The changes since that version (the DT-selected DART owners and memory-only updates while closed, the unplug handling, the failure unwinds, the stock tb.c resume restored, the PMGR and RTKit hardening) are built and covered by the host suites, but have not run on the J713 yet.
Not covered: repeated sleeps on one boot, wake sources other than the RTC, the desktop's own sleep path (lid, logind), a dock unplugged during the sleep on hardware, and docks other than the TS5. Both native parameters (
pcie_apple.cio_s2r,thunderbolt_apple.cio_s2r) default to off.This series was developed and tested by Claude (Anthropic), working with me on the J713.