Repository navigation
thunderbolt/typec: pick the T8122 USB4 router policy by capability, enable the J615 (on #1490) - #2649
RyanTheTide wants to merge 7 commits into
Conversation
Some USB4 routers must be stopped by the Type-C port driver, in a fixed order ahead of the USB role and the PHY, before tasks freeze and at shutdown. Others stop on their own. Let the provider say which it is in its switch description, and give port drivers typec_thunderbolt_switch_pd_ordered_stop() to ask, so they no longer have to guess from the machine they run on. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The T8122 router policy (MxWrap RUN, explicit LSTX, strict firmware-ready admission, witnessed power-off) was only taken on apple,j613. Every other T8122 Mac with the same router - the 15-inch MacBook Air (J615), the iMacs (J433/J434) and the MacBook Pro (J504) - fell back to the T8103 policy, which cannot start it. What the policy needs is the router's MxWrap CPU block, which the device tree names as the "cpu" resource. Take the T8122 policy whenever that resource is described and keep the T8103 fallback otherwise (for example an older loader's handoff tree without it). The strict power cycle has to be stopped by the PD driver ahead of the USB role and the PHY, so advertise that through the switch description instead of letting the PD driver infer it from the machine. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The CD321x session stop before tasks freeze and at shutdown (ACIO, then the USB role, then the PHY in safe mode) only ran on apple,j613. Run it for whichever port's USB4/Thunderbolt switch asks for a port-driver stop instead, and leave every other switch alone as before. The notifier is registered for every CD321x and asks the switch on each suspend, because the router may bind after the port. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The J615 (MacBook Air 15-inch, M3) has the J613's two ATC ports on the same T8122 routers. Give it the PCIe-C tunnel description and aliases the J613 already has, and drop its unused, disabled USB2 OTG node so older loaders do not prune the shared ATC0 suppliers. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Cover the suspend notifier with a router that stops on its own (nothing is sent to it) and with one that asks the port to stop it (SLEEP before the freeze, WAKE after it). Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
DjDeveloperr
left a comment
There was a problem hiding this comment.
The approach is right. The T8122 policy is chosen when the ACIO node's reg-names includes "cpu" (apple.c:4652-4654), and otherwise the driver falls back to the T8103 policy, which is today's behaviour on every T8122 board. Lock order is unchanged: the pd_ordered_stop read under tps->lock matches typec_thunderbolt_switch_set(). The J615 includes, aliases and /delete-node/ mirror the J613, and both DTBs compile.
Before this can land:
- The J615 inherits #1490's failing DT check.
scripts/dtc/apple-dart-pd-check.pyon the J615 DTBs reports 4 new DARTs with nopower-domains:/usb4-pcie-tunnel-{0,1}/iommu@{721008000,b21008000}, ont8122-j615and-25g83. It's the check that fails #1490 for the J613. This PR has no CI because it targets a stack branch, so it will fail once retargeted. Fix int8122-usb4.dtsi: give each tunnel DART its ATC CIO-PCIe power state. - The J615 would run with the J613's tunables. The tunnel DART
apple,tunable(t8122-usb4.dtsi:18,118) andapple,tunable-oe-fabric(:53,:153) are fixed values, and nothing re-reads them on the J615. The loader-copied aliases cover only the rc, fabric and debug tunables. Either have the loader fill these from each Mac's ADT, or confirm the J615's ADT matches. That's #1490's to fix, under checklist items 3 and 4. The header comment "J613 ADT PCIe-C windows" and the "m1n1 fills" comments also need updating. - One non-T8122 sleep row, please. The new PM notifier (
core.c:2649-2657) now registers on every CD321x and SN201202x, so it adds atps->lockacquisition toPM_SUSPEND_PREPAREon every Mac. Add a J714s (M5) deep-sleep row to the J616s/J713 s2idle rows already listed. - Nit:
tipd_shutdown()(core.c:3948) now doescontainer_of(tps, struct cd321x, tps)unconditionally. It's valid today, because the only caller issn201202x_shutdown(). But a plain TPS6598x caller of the exported function would read out of bounds, so a comment or a variant check would help.
Order: #1490, the base, isn't ready to land first:
- it's a draft and conflicts with integration;
- its dt-checks fail;
- its 8 commits carry
Assisted-bytrailers (checklist item 4); - its body describes 972cf33 rather than its head 154721f.
Folding this PR into #1490, as its body offers, is the clean path. The USB4 link row still waits on a Thunderbolt cable. J433, J434 and J504 also take the T8122 policy now; they'd log "PCIe-C tunnel disabled" and continue, but haven't booted it.
Assisted-by: LLM (Claude:Opus 5.5)
|
Blockers: 1 (in addition to the four points in the earlier review, which still stand on d93c785).
Nit: HW row: J615 with a Thunderbolt cable on this head: USB4 link up, thunderbolt-net ping, s2idle 3x with the link up (role/PHY quiesce lines in dmesg), then a poweroff and a reboot with the link up. Plus J613 regression and one I2C-PD T8122 Mac (J504 or J433) booting to a USB4 link and doing a clean shutdown. 0 AVC, 0 failed units, no new kernel errors. Assisted-by: LLM (Claude:Opus 5.5) |
pd_ordered_stop asks the Type-C port driver to stop the USB4 session before tasks freeze and at shutdown. Only the SPMI SN201202x driver had a .shutdown, so on the T8122 Macs whose CD321x sits on I2C (J433, J434, J504) the router took the strict power cycle at device_shutdown with the USB role and PHY still owned by the port. Give the I2C driver the same .shutdown. The I2C driver also binds plain TPS6598x parts, which have no struct cd321x around them, so tipd_shutdown() now returns early for a port whose variant does not embed one, and a KUnit case covers that. On a PREPARE that fails, the PM core skips our POST_SUSPEND: clear session_pm_armed on that path too so the state stays obvious. Macs that take the T8122 router policy (ACIO node names "cpu", shared t8122.dtsi): J433, J434, J504, J613, J615; their ports get the PD-ordered sleep and shutdown stop. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The PCIe-C tunnel DARTs probe as devices of their own and sit inside the ATC's CIO-PCIe block, which their tunnel's root port already names. Give each DART the same power state so it is never probed or read while that block is off. apple-dart-pd-check.py reported both as new findings on the J613 and J615 DTBs; it reports none now. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Thanks both. Pushed e690d19 (two commits on d93c785). Point by point: Dj's review
RyanTheTide's review
A separate finding from the same cable, not caused by this series and not fixed by it: if the peer changes the Type-C state while the J615 is in s2idle (peer reboot, or the peer unbinding its router), the J615 hangs. That happens on fleet78 without this series (2/2) and with it (1/1), even though here the session was already stopped before sleep. Plain s2idle with a stable link passes on both. I'm following that up on the J615's sleeping-port side. Row details
Assisted-by: LLM (Claude:Opus 5.5) |
|
Claude Opus 5.5 on @satchlj's behalf. Thanks: folded into #1490 as a fast-forward to e690d19, your commits unchanged. The J613 link+replug regression row will be reported on #1490; the replug part is on Satya's hands-on list (he is away until Nov 23). This PR can be closed in favour of #1490 if you agree. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Pre-PR checklist review (§1–§6) at e690d19c5b2eaa8755de03adf72fd17d4f0c1ea8: 0 code, policy, attribution, or naming blockers in these 7 commits; holding only for CI (none runs on stack branch stack/pr1490-154721f5) and §5 hardware evidence on the live head.
Verified
- §1 No model gating: Both
of_machine_is_compatible("apple,j613")gates are gone (drivers/thunderbolt/apple.c:4652-4654now selectsapple_cio_t8122_hwfrom the DT"cpu"reg-name;drivers/usb/typec/tipd/core.c:2630-2632,3962-3965now querytypec_thunderbolt_switch_pd_ordered_stop()). - Locking & lifetime:
typec_thunderbolt_switch_pd_ordered_stop()(drivers/usb/typec/mux.c:902-909) mirrorstypec_thunderbolt_switch_is_live()underrwsem_read(&sw->sw_dev->set_lock)and returnsfalseonce the provider unregisters.cd321x_session_pm()clearssession_pm_armedon both failedPM_SUSPEND_PREPAREandPM_POST_SUSPEND, andcd321x_stop_work()unregisters the PM notifier. - I2C shutdown & variant safety:
tps6598x_shutdown_i2c()(drivers/usb/typec/tipd/i2c.c:97-100) routes throughtipd_shutdown(), which guardscontainer_of(tps, struct cd321x, tps)withtps->data->tps_struct_size < sizeof(struct cd321x)(core.c:3958-3960) so plain TPS6598x/TPS25750/TPS66993 bindings return safely while CD321x and SN201202x proceed. Also verifiedapple_cio_tbt_switch_set()(apple.c:3986-3987) returns0forTYPEC_THUNDERBOLT_SWITCH_OFFeven ifapple_cio_shutdown()ran first and setacio->removing = true. - DTS & DART power domains:
t8122-j615.dtsmirrorst8122-j613.dts(andt8122-j615-25g83.dtsinherits it);t8122-usb4.dtsi:18,119addpower-domains = <&ps_atc{0,1}_cio_pcie>;to both tunnel DARTs. - §4 Attribution: All 7 commits carry human author/committer and human
Signed-off-by:only, with zero AI trailers.
Non-blocking notes (for #1490 where this series is folded)
- Since @satchlj has already fast-forward folded
e690d19cinto #1490, closing this PR in favour of #1490 once confirmed makes sense. - On #1490's base
arch/arm64/boot/dts/apple/t8122-usb4.dtsi: note thatusb4_1_pcieapple,tunable-oe-fabric(:157-158) lists<0xc 0x1 0x1>twice whereusb4_0_pcie(:56-57) has<0x8 0x1 0x1>then<0xc 0x1 0x1>— worth double-checking against the ADT, alongside cleaning up the pre-existingm1n1comments (:51,:152) and #1490's base commit trailers before #1490 merges.
Missing before approval (CI + §5 HW rows on live head e690d19c)
Existing J615 link rows were run on d93c785b (prior to dd986ff5 I2C .shutdown and e690d19c tunnel DART power-domains). Needed on e690d19c (or on #1490 after rebase onto integration/aurora with green CI):
- J615 (default cmdline, USB4 link up): s2idle x3 with active quiesce + clean poweroff + clean reboot; 0 SELinux denials, 0 failed units, 0 new kernel errors.
- J613 regression (USB4 link + suspend + shutdown).
- One I2C-PD T8122 Mac (J504 or J433/J434): USB4 link up + clean shutdown exercising the new
tps6598x_shutdown_i2c()->tipd_shutdown()path. - One non-T8122 Mac (e.g. J714s deep sleep) covering the
session_pmnotifier now registered on every CD321x/SN201202x.
Assisted-by: LLM (Gemini 4 Neon)
|
Folded into #1490, which now carries these commits unchanged. |
Stacked on #1490. The base branch
stack/pr1490-154721f5is #1490's head (154721f) copied unchanged, so this diff shows only the seven commits on top. Folding them into #1490 is fine with me if that is the cleaner path.Problem
#1490 brings up the T8122 USB4 router on the 13-inch M3 Air (J613), but it only takes the T8122 path on
apple,j613. Every other Mac with the same router falls back to the T8103 policy, which can't stop the router in the order the T8122 needs before sleep and shutdown.Change
typec_thunderbolt_switch_pd_ordered_stop().cpuresource, and keep the T8103 fallback for trees without it. Macs that take it (sharedt8122.dtsi): J433, J434, J504, J613, J615.tipd_shutdown()does nothing for a variant that has nostruct cd321x(plain TPS6598x on the I2C driver).Testing
--strictclean.apple-dart-pd-check.pyagainst the fleet78 DTBs as baseline: 0 new findings (2 before the DART fix).sn201202x 1-0a: USB4 session quiesced before freezer), the RTC wakes the system on time and the link is back 6 s after resume.t8122-usb4.dtsihard-codes (both ports).Still to run
Details for reviewers
strict_power_cycle), and that policy is chosen from the DTcpuresource.typec_thunderbolt_switch_pd_ordered_stop()reads under the switch'sset_lockand returns false once the provider unbinds, liketypec_thunderbolt_switch_is_live()..shutdown+ variant guard (dd986ff),session_pm_armedcleared when our own PREPARE fails, because the PM core skips our POST_SUSPEND then (dd986ff), tunnel DARTpower-domains(e690d19).t8122-usb4.dtsistay hard-coded here; having the loader fill them from each Mac's ADT is thunderbolt: apple: enable the J613 USB4 host-to-host path #1490's to decide. On the J615 they match its ADT.tps6598x_dr_set()is not part of this series.Assisted-by: LLM (Claude:Opus 5.5)