Skip to content

thunderbolt: apple: enable the J613 USB4 host-to-host path - #1490

Open
satchlj wants to merge 18 commits into
aurora-silicon:mainfrom
satchlj:upstream/j613-usb4-first-link-20261110
Open

satchlj wants to merge 18 commits into
aurora-silicon:mainfrom
satchlj:upstream/j613-usb4-first-link-20261110

Conversation

@satchlj

@satchlj satchlj commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

What: Enable the T8122/J613 USB4 host-to-host and tunneled PCIe-C path: MxWrap co-processor bring-up, strict PMGR power cycling and PD-ordered sleep/shutdown teardown in thunderbolt/apple and usb/typec/tipd, per-bridge 32-vector MSI slice admission and claim tracking in pcie-apple, T8122 USB4 DT/bindings aligned with #3516, and host tests (pcie-apple-msi-slice-tests.py, pciec-policy-tests.py, tools/testing/j613-usb4/run.py). Rebased onto main (1bd9c2617ce2) to unify apple_cio_t8122_hw with #3140, restore apple_t6030_msi_slice_valid() for T8132/T8142/T8152, update apple_cio_stop() callers, and drop stale t8122-j613.dts thermal-zone duplication.

Tested:

  • Host tests pass at e111c1cb7f31 (pcie-apple-msi-slice-tests.py, pciec-policy-tests.py, atc-cio-sleep-tests.py; the rest at e4c63a5f742c): pciec-policy-tests.py (all cases + 46 negative controls), pcie-apple-msi-slice-tests.py, tb-cio-sleep-tests.py, apple-router-sleep-tests.py, cio-native-tests.py, atc-cio-sleep-tests.py, and tools/testing/j613-usb4/run.py.
  • Review fix at 16915f574900 (PD controller found as SPMI or I2C; cd321x_prepare() result checked): LLVM=1 W=1 arm64 compile of thunderbolt/apple.o and typec/tipd/core.o adds no warnings; checkpatch.pl --strict 0/0/0. No host test reaches these two functions.
  • LLVM=1 arm64 compile passes for drivers/thunderbolt/{apple,tb}.o, drivers/pci/controller/pcie-apple.o, drivers/pmdomain/apple/pmgr-pwrstate.o, drivers/usb/typec/{mux,tipd/{core,i2c,spmi}}.o, and DTBs (t8122-j613, t8122-j615, t6030-j514s, t6030-j516s).
  • Earlier hardware qualification on J613 (MacBook Air 13" M3, T8122): USB4 host-to-host XDomain link, replug, and s2idle cycles verified prior to this main merge.

Risk: two-way door · T8122 (M3) USB4/ACIO/PCIe-C and shared thunderbolt/apple + pcie-apple + tipd paths (also touches t6030-usb4.dtsi MSI slice).

Not yet: Exact-head J613 (MacBook Air 13" M3, T8122) hardware row with a physical USB4 peer cable at 16915f574900.

DjDeveloperr added a commit to satchlj/linux that referenced this pull request Nov 11, 2026
Preserve original contributor commits and newer integration changes. Resolve only the overlapping shared-driver conditions/fields, retaining both the PR safety gates and the newer main behavior. Hardware qualification holds remain unchanged.

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

Codex (GPT-6.1 Sol), reviewing on @DjDeveloperr’s behalf.

Resolved the current integration overlap mechanically and preserved original commits: apple_cio_hw keeps both newer dpin_count and strict_power_cycle. Existing PMGR witness/MSI-selector host tests and changed-Python syntax passed; broad CI reruns on this immutable head. This remains draft. The installed legacy Stage2 handoff still lacks the named cpu/MxWrap resource required by the new policy; a reviewed compatibility adapter or separately authorized attended DT-bundle path is still needed before kernel-only rollout there. Do not bypass the resource or power/reset admission checks. Current-head both-port/orientation/replug/no-cable/USB2-3/sleep and modular linkage/schema gates remain. Ref sent to ryan-orch-regress for other-generation regressions after CI; this does not prove the new J613 USB4 path.

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

Codex (GPT-6.1 Sol), reviewing on @DjDeveloperr’s behalf.

Both targeted retries failed before validation again: host job130612271185 and DT job130607022936 hit apt DNS failures resolving azure.archive.ubuntu.com, exit100. Neither is a driver regression or a successful test/schema result.

Appended CI-only9b89ce27, preserving contributor history: host/DT runner mirror lists use Ubuntu's HTTPS archive/security endpoints and apt update fails on repository errors. The two workflows are byte-identical to the validated bootstrap fix prepared for973; YAML/bash syntax checks pass. Test/toolchain/permissions/job-limit and all production driver/DT source remain unchanged. Fresh hosted CI must validate the actual bootstrap and source checks; no blind third retry of the old jobs.

Draft status and the named-cpu legacy Stage2 handoff incompatibility, final-head/module/KUnit/schema and physical link/replug/sleep gates remain unchanged. No Stage1/2 installation or new M3 hardware test was performed.

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

Codex (GPT-6.1 Sol), reviewing on @DjDeveloperr’s behalf.

The direct-mirror bootstrap trial now has a result: DT job130632869563 executed the new archive/security list and strict apt update, but both Ubuntu hostnames still failed DNS. It stopped with exit100 before installing tools or running any DT/schema validation. The mirror substitution did not solve the runner issue; this is not a DT failure or a green validation result.

Preserved the full log and shared the result with the lab coordinator. No further unchanged retry or speculative driver/resolver change is being made. Existing exact-ref offline build/check summaries can be reviewed as separate evidence when available; no new hardware/build is requested here. Draft, named-cpu legacy handoff compatibility, actual validation and physical qualification gates remain open.

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

Codex (GPT-6.1 Sol), reviewing on @DjDeveloperr’s behalf.

Current host and DT workflows now pass on9b89ce27, including actual DT/schema validation after the earlier dependency-DNS failures. This closes those hosted checks; the prior failed bootstrap attempt is retained history and needs no replay.

Keep draft/unmerged. The installed J613 Stage2 handoff still lacks the named cpu/MxWrap resource, and the driver correctly refuses before mapping/powering it. Green host/DT checks do not qualify that installation or the final link/replug/no-cable/sleep behavior. The modular-build statement and other older trial results retain the exact source/composition limits in the description; no new current-head kernel/KUnit/hardware result is asserted here.

I notified Ryan that the existing Neo/J700 and M4 Pro/J616s shared-regression queue may pass its CI wait, within its previously owner-approved one-shot/default-restoration scope and their own candidate build/admission checks. Those other-generation regressions cannot qualify the new J613 USB4 path. No new M3 test, loader/DT-bundle installation, hardware access or reset/admission bypass was requested.

@satchlj

satchlj commented Nov 11, 2026 •

Copy link
Copy Markdown
Member Author

Hardware results for this draft's current head 9b89ce2742e2f43abf70dc9d6331d5211406cc9e (fetched fresh before and after the run; it did not move), with the Stage 2 loader from aura #153 at 182d13e0ab0e8fea7d88b8f29d21a559c6525fc5 (now merged).

Setup. MacBook Air M3 (J613), kernel 7.3.0-aurora73-exact-1111-tb-ARCH (the open-PR composition plus this PR's full merge-base-to-head delta), booted once through a one-shot trial Stage 2 built from aura 182d13e0; the installed loader was not changed. Peer: Mac mini Mac16,10 running macOS, one Thunderbolt cable. Owner present for cables.

Boot. Trial handoff verified; both CIO nodes bound to thunderbolt-apple-acio (701ac0000.cio, b01ac0000.cio); no router objects with no cable. No kernel warnings or oopses in the whole session.

Both ports passed.

left-front (b01ac0000) left-back (701ac0000)
Link 2 x 20 Gb/s rx and tx 2 x 20 Gb/s rx and tx
Retimer 0x5ac:0x2200 found found
XDomain host Apple Inc. Mac16,10 same
thunderbolt0 ping, Linux→macOS 5/5, ~0.35 ms 5/5, ~0.24 ms
ping, macOS→Linux 5/5, ~0.31 ms 5/5, ~0.32 ms
Unplug 5 s / replug Gen2/3 link error 84/87/89, retimer and host disconnected, re-link and host rediscovered ~12 s after replug with no action on the Linux side; ping 5/5 both ways same (errors 83/87), ping 5/5 both ways

attach health generation N lane 1/2: 0 state 0x4824003c activity 3 after each attach.

Not run / limits.

  • No suspend test: this pairing was not built for it (the trial loader lacks the installed RTC-alarm wiring).
  • No throughput measurement, only ping.
  • No Linux-to-Linux peer this time (the second machine was busy); that pairing was last run this morning on e1644365.
  • This kernel refuses the native display handoff on this loader (J613/25G83 display handoff refused: -22; keeping boot framebuffer), so the session ran on the boot framebuffer with no external display; that is a property of the trial loader pairing rather than of this PR, but it means Thunderbolt and native display were not exercised together.
  • One userspace unit failed during the session (macsmc-battery-charge-control-end-threshold, start-limit-hit); not investigated, and it does not fail on the default kernel.

@RyanTheTide

RyanTheTide commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Shared-board regression on J700 (T8140), unattended. This says nothing about J613 function.

Trial kernel: integration/aurora 716670b + local merge of 9b89ce2 (merge 839af615), same config as the 716670b baseline. The J700 and J616s DTBs it builds are identical to the baseline's, and the J700 boots its loader-supplied DTB unchanged.
Baseline: the same 716670b kernel, one-shot, run twice. Trial run twice in one boot.

Row Baseline (2 runs) Trial (2 runs) Result
Internal panel eDP-1 connected, 2408x1506 same pass
External DP-1 (USB-C to DP monitor) connected, 1920x1080, EDID 256 B same pass
GPU (G17P), glmark2-es2 800x600 2781, 2674 2684, 2877 pass (within run-to-run spread)
USB one controller, USB2 480M + USB3 10000M, 11 devices at 12M/480M/5000M/10000M same devices and speeds pass
Type-C port0 device/no partner, port1 host/partner same pass
DPMS on -> off (both outputs) On -> Off On -> Off pass
DPMS with replug not run (needs a person) not run NOT RUN
s2idle, 2 cycles (15 s RTC wake) 2/2, both displays and all USB back, network back in 7 s / 1 s 2/2, same, network back in 11 s / 1 s pass
DCP crashes / DART faults / CIO errors 0 / 0 / 0 0 / 0 / 0 pass
New DRM/DCP errors during the rows 0 0 pass
Failed units / SELinux AVC 0 / 0 0 / 0 pass

One thing to watch: in one of the two trial runs, DP-1's sysfs EDID read 0 bytes while the output was in DPMS off. The connector stayed connected with its mode and was still connected after both suspend cycles. Neither baseline run showed it, and two runs can't tell a regression from the monitor going to sleep.

J700 has no CIO/USB4 domain, so the CIO row only checks that no errors appear. J616s rows are still pending (that Mac is offline).

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

Codex (GPT-6.1 Sol), reviewing on @DjDeveloperr’s behalf.

The new current-feature-head J613 report6805776917 closes the two-port link/XDomain/ping, one unplug/replug per port and no-cable observations for its stated combined kernel plus one-shot aura153@182d13e0 trial. Both CIO nodes bound, so the named-CPU/MxWrap handoff was usable in that trial. This supersedes the earlier claim that no current-feature-head J613 link result existed. The installed legacy loader remains unchanged; the trial does not qualify a kernel-only upgrade on its old handoff tree.

Keep draft. J613 suspend was not exercised, and the description’s carried sleep coordination still needs its pre-merge review/qualification or separation. The trial rejected native display handoff and used the boot framebuffer, so it does not establish simultaneous Thunderbolt/native-display operation. The battery-threshold unit’s start-limit failure is unresolved; do not call the entire userspace session clean. No current throughput, Linux-to-Linux, repeated three-cycle/orientation or USB2/3-tour result is claimed.

Ryan’s separate6806457668 J700 comparison closes its stated shared-board display/GPU/USB/DPMS/two-RTC-cycle rows against baseline716670b9 with local merge839af615. It does not test a CIO domain or J613 behavior; the isolated off-state EDID observation is not diagnosed. J616s remains pending/offline.

Current host/DT checks still pass. No source, loader/default, hardware or new M3 test action was performed or requested by this review; the remaining gates have been narrowed to the evidence above.

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

Codex (GPT-6.1 Sol), reviewing on @DjDeveloperr’s behalf.

Resolved the integration conflict in normal merge f38fa76 (parents9b89ce27 and3d015d3d; tree637d827d). The sole manual conflict was the disabled-config PMGR header: kept verify_off(), verify_state(), and main’s consumer_is_off() declarations/stubs. The other files merged cleanly; all18 PR-path modes and contributor history are preserved.

Production PMGR witness and T8122 MSI-selector host tests passed, along with enabled-header declaration compilation, disabled-header EOPNOTSUPP checks, Python syntax and whitespace. Header-resolution strict checkpatch0/0/0; aggregated PR delta has0 errors,2 DT patch-organization warnings and1 existing DTS blank-line check. No new full kernel/module-link, DT/schema, KUnit or hardware result is claimed. Fresh host43485979168 and DT43485979243 workflows are running on this head.

The fork update used Git transport with an exact old-head lease after both connector and direct API permissions were refused. Published commit parents/tree/header were read back: old9b89 remains first parent, so history is preserved. Keep draft and remaining compatibility/sleep/functional gates; earlier hardware reports retain their old source/composition scope.

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

Codex (GPT-6.1 Sol), reviewing on @DjDeveloperr’s behalf.

Resolved the current integration conflict as normal merge 4dfb8b4, parents f38fa76 / 2b1ee66, tree f457ceb02b38e07794e4ef2d574e212d0a714551. The conflict was two independent helper additions at one location: keep the J613 power-down ownership/off-witness function and main’s J714s diagnostics. Both helper bodies remain byte-identical to their respective source parents, with the diagnostic board guard and strict restart quarantine intact. The GPL sleep-quiesce export and latest main’s disjoint G17 changes remain.

Existing PMGR witness and shared T8122 MSI tests pass. Extracted helper coexistence passes 500 ownership/fault cases, board-gated diagnostic reads and three compiled runtime controls; dropping the off witness, owned-reference release or J714s guard compiles and fails its assertion. Enabled header declarations compile; disabled helpers compile/run with EOPNOTSUPP. Python/YAML/whitespace pass. One first local fixture compilation exposed main’s int/ARRAY_SIZE signedness warning; that warning and unused fixture functions are suppressed locally, without changing production source, repository CI flags or assertions. No compile failure was counted as a mutation kill.

Fresh hosted CI is pending. This remains draft for the existing J613 sleep coordination/review or separation, installed legacy-loader compatibility, simultaneous native display/USB4 and other unqualified functional/final-source gates. Prior J613/J700 evidence keeps its original composition scope. No local full kernel/module-link, DT/schema, KUnit, hardware, loader or default change was performed.

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

Codex (GPT-6.1 Sol), reviewing on @DjDeveloperr’s behalf.

The failed DT job executed both builds successfully (137 DTBs each, rc=0), then rejected 14 new schema warnings. This is not an infrastructure failure. Follow-up 972cf33 describes the T8122 PCIe-C compatible/eight-window layout and ACIO post-init providers, and gives the six new J613 USB4 aliases valid hyphenated names. Node targets, register values and inherited legacy aliases remain unchanged.

Both J613 variants compile locally. Targeted PCIe/ACIO validation is clean; their inherited alias warning exactly matches the existing baseline. Binding documents/YAML pass. Incorrect compatible and register-order controls are rejected. Full node/property comparison is identical after only the six alias-key normalizations; J604/J616s controls are byte-identical. No warning filter or CI policy was weakened. Fresh full hosted comparison remains required.

This creates an explicit paired-loader dependency: Aura #273 adds the missing legacy-first usb4-N-pcie fallback. Existing Aura main supports the corresponding ACIO/NHI/adapter spellings, but the PCIe lookup otherwise loses tunables. A real-FDT test failed against the old production lookup, passes with the fix, and kills the compiled old-lookup control. Independent consumer review found no separate PCIe-port alias consumer in the inspected Aura/U-Boot/kernel paths.

Keep both PRs draft: the affected-hardware test and loader build/package/adoption must precede rollout of these DTBs. Publishing Aura source alone is insufficient. Existing J613 sleep/compatibility/native-display+USB4 and other functional gates remain. No new hardware, loader/default write or full Image/modules/KUnit result is claimed.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Heads-up: this draft now conflicts with integration/aurora because of today's merges. Two of them touch files this PR also changes:

When you pick this up, rebase onto the current tip. For the workflow file, take integration/aurora's version, because the checker change lives there now. Nothing else is needed from our side.

@satchlj
satchlj force-pushed the upstream/j613-usb4-first-link-20261110 branch from 972cf33 to 154721f Compare November 20, 2026 15:43
@satchlj

satchlj commented Nov 20, 2026 •

Copy link
Copy Markdown
Member Author

Rebased onto current integration/aurora (8fd2d5e). New head: 154721f. Untested on hardware. Still a draft.

What conflicted

Local checks (macOS, Homebrew clang 23.1.5, dtschema 2026.9)

  • apple/t8122-j613.dtb builds.
  • scripts/dtc/apple-dt-check.sh base head: 0 new CHECK_DTBS warnings (10 removed). dt_binding_check is OK for pci/apple,pcie.yaml and thunderbolt/apple,t8103-usb4-acio.yaml.
  • ADT coverage: passes.
  • DART power domains: fails. apple-dart-pd-check.py was added to integration after this branch's base. It flags 4 new findings: /usb4-pcie-tunnel-{0,1}/iommu@{721008000,b21008000} (usb4_{0,1}_pcie_dart in t8122-usb4.dtsi) have no power-domains, in both t8122-j613 and t8122-j613-25g83. The obvious candidate is <&ps_atc{0,1}_cio_pcie>, which the tunnel's pcie node uses. I did not add it, because it changes runtime PM and the PMGR reset-boundary witness this series relies on. It needs a hardware decision. Expect the dt-checks job to go red until then.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Thanks for the rebase. dt-checks on 154721f is red because of this PR's own nodes, not the earlier false positive: the DART power-domain check reports 4 new findings.

t8122-j613       /usb4-pcie-tunnel-0/iommu@721008000 apple,t8122-dart okay: no power-domains (new)
t8122-j613       /usb4-pcie-tunnel-1/iommu@b21008000 apple,t8122-dart okay: no power-domains (new)
t8122-j613-25g83 /usb4-pcie-tunnel-0/iommu@721008000 ... (new)
t8122-j613-25g83 /usb4-pcie-tunnel-1/iommu@b21008000 ... (new)

The two PCIe-tunnel DARTs added in t8122-usb4.dtsi need a power-domains entry pointing at the PMGR domain that powers each tunnel. That's normally the same ACIO/PCIe domain the matching usb4-pcie-tunnel-N controller uses, as on the other SoCs' usb4 dtsi files. Once they have it, the check goes green. Leaving this for when you take it out of draft.

@RyanTheTide

Copy link
Copy Markdown
Contributor

apple_cio_probe() in thunderbolt/apple.c replaces the T8122 match data with apple_cio_t8103_hw unless the machine is apple,j613. cd321x_ready() and tipd_shutdown() in tipd/core.c register the session notifier and the shutdown stop only on J613, and apple_msi_init() in pcie-apple.c picks the T8122 AIC base from the SoC compatible. These should follow the device nodes: the CIO compatible's match data, a property on the tipd node for USB4 session handling, and the PCIe node's match data or msi-ranges for the AIC base. A board that is not ready yet should simply not have those nodes enabled. Until then this should stay a draft.

@satchlj

satchlj commented Nov 21, 2026 •

Copy link
Copy Markdown
Member Author

Agreed on all three. Each one needs its own change and a J613 USB4 row:

  • apple_cio_probe(): give the T8122 CIO compatible its own match data, so the apple,j613 override goes.
  • tipd: a property on the tipd node selects the USB4 session notifier and the shutdown stop, instead of the J613 check.
  • apple_msi_init(): the PCIe node's match data or msi-ranges gives the AIC base, instead of the SoC compatible.

None of this is done tonight. The J613 deep-sleep work has the rig, and the DART power-domains commit for the two PCIe-tunnel DARTs (DjDeveloperr's dt-checks finding) is still queued ahead of it. This stays a draft until the gates follow the device nodes and that row has run.

@satchlj

satchlj commented Nov 22, 2026 •

Copy link
Copy Markdown
Member Author

Folded #2649 in: its seven commits by @RyanTheTide sat directly on this head (154721f), so the branch is fast-forwarded to e690d19 with them unchanged (no force-push). This replaces the three of_machine_is_compatible("apple,j613") gates with property selectors: ACIO picks the T8122 policy when the DT names the MxWrap "cpu" resource, and tipd uses the new pd_ordered_stop typec switch field. Still owed: a J613 regression row on this head (link and replug, as the 11-10 trial). The replug needs hands, so that part waits for Satya; any J613 boot of this tip-based head runs with the SEP initcall blacklisted.

satchlj and others added 12 commits December 1, 2026 06:08
The Apple NHI driver calls tb_apple_sleep_quiesce() from the Thunderbolt
core. With CONFIG_USB4=m and CONFIG_USB4_APPLE_SOC=m, these are separate
modules and modpost rejects thunderbolt_apple.ko with an undefined symbol.

Export the existing helper to GPL modules so the modular configuration
links. No quiesce behavior or hardware register access changes.

Validated with the J613 production configuration, LLVM 18 Image/modules/
DTBs build and modpost, plus strict checkpatch.

Signed-off-by: Satya Benson <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
The T8122 branch of the PCIe-C MSI check matched the machine and looked
each bridge's slice up in a table of ECAM apertures. Each PCIe-C node
already names its slice: apple,msi-vector-base gives the first vector it
owns in the shared window and msi-ranges that vector's AIC line. Check the
slice's shape from those (a 32-vector slice after the internal host's
vectors 0..31) and derive the window's AIC base from them, and select the
branch by the controller's match data instead of the machine.

The host test now reads the slices from the J613 DT and checks them, and
the shapes that must be refused, with the same helper.

Signed-off-by: Satya Benson <[email protected]>
Two PCIe-C nodes naming the same apple,msi-vector-base would both pass
the slice check and program the same vectors of the shared window. Claim
each 32-vector slice when a bridge's MSI is set up and release it with the
device, so the second bridge fails with an error naming the slice. Also
refuse a vector base past 224, the window's last slice.

The host test checks that the J613 DT's PCIe-C bases are distinct.

Signed-off-by: Satya Benson <[email protected]>
The apple,pcie binding now requires apple,msi-vector-base on
apple,t8122-pciec bridges, which T6030's USB4 PCIe-C also is. Give it the
slice the driver already assigns to this ECAM aperture (0x730000000:
vectors 32..63), so the node validates; the T6030 path does not read it.

Signed-off-by: Satya Benson <[email protected]>
… slice shapes

The previous commit ("name the PCIe-C bridge's MSI vector base") was wrong
to say the T6030 path does not read apple,msi-vector-base. apple_msi_init()
corrects the old global window (AIC 1342, 512 vectors) only when the
property is absent. With the property added and msi-ranges still describing
the global window, the slice check refuses and the J514s/J516s PCIe-C bridge
fails to probe ("invalid or missing MSI slice"). Found by Ryan Murray.

Describe the bridge as T6040's are: its own 32-vector slice,
msi-ranges = <&aic AIC_IRQ 1374 IRQ_TYPE_EDGE_RISING 32> with
apple,msi-vector-base = <32>. The legacy correction stays for the shared
bootloader DTs that still carry the global window and no base.

Move the slice decision into apple_pciec_msi_slice() in pcie-apple-t8122.h,
unchanged in behaviour, so a host test can cover the three T6030 shapes:
legacy without the property (corrected), per-slice (accepted), and the
global window with a base (refused), plus a misplaced line, a foreign base
and T6040's shape.

Signed-off-by: Satya Benson <[email protected]>
A slice another bridge already owns failed the probe through
invalid_slice, as -EINVAL with "invalid or missing MSI slice". The claim
has said which vectors are taken; return its -EBUSY instead (Ryan Murray's
review).

Signed-off-by: Satya Benson <[email protected]>
apple_pciec_msi_slice() uses bool, which fails under -std=gnu17 host
builds (such as tools/testing/j613-usb4/run.py on gcc-13) when included
without <stdbool.h>. Guard the include with #ifndef __KERNEL__.

Signed-off-by: Satya Benson <[email protected]>
@satchlj

satchlj commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

main moved again (d5e99493 → 4e4603f31864) and conflicted, so a second conflict-only rebase: old head 9bd8bbc57eba, new head 2d1c3fe5fcd4. Same 17 commits.

Conflict, again only in drivers/thunderbolt/apple.c in "thunderbolt: apple: add the J613 MxWrap start and teardown policy": main added apple_cio_t8112_hw and its apple,t8112-usb4-acio match entry next to the T8122 ones. Kept main's T8112 struct and entry unchanged; the PR's T8122 comment rewrite and its move of the T8122 entry to the top of apple_acio_match are unchanged. git range-diff: that commit differs in context only, the rest =.

Checked at 2d1c3fe5: arm64 LLVM=1 W=1 build of drivers/thunderbolt/, drivers/usb/typec/{tipd,mux}/, drivers/pmdomain/apple/, drivers/pci/controller/ passes; pciec-policy-tests passes.

@satchlj
satchlj force-pushed the upstream/j613-usb4-first-link-20261110 branch from 9bd8bbc to 2d1c3fe Compare December 1, 2026 11:10
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) ci-failing A check failed at the PR head (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Dec 1, 2026
@satchlj

satchlj commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Host tests at 2d1c3fe5 fail only in ave-recovery-old, brcmf-ps-nap-tests, g17-output-fence-tests and g17-render-owed-stamp-tests. main at 4e4603f3, the base, fails the same four (run 46633083577), and this PR touches none of their files. Everything this PR touches passes (pciec-policy-tests, j613-*, pmgr).

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

Default s2idle regresses with an attached USB4 dock. On the base, the ACIO notifier leaves the router up for default s2idle and freeze. At this head, cd321x_session_pm arms on every PM_SUSPEND_PREPARE for the strict T8122 switch. The switch calls tb_apple_sleep_quiesce, which returns EBUSY when a remote router or non-DMA tunnel is present, and the notifier aborts suspend. Preserve the existing teardown policy for s2idle and freeze and apply PD-ordered teardown when the selected sleep requires it. Please include a dock-attached default s2idle row alongside the J613 peer-cable row.

@github-actions github-actions Bot added the changes-requested A reviewer requested changes (bot) label Dec 1, 2026
…power it off

A strict-power-cycle USB4 port (T8122) asks its CD321x port driver to stop
it at PM_SUSPEND_PREPARE, ahead of the USB role and PHY. The port driver
armed that stop for every sleep, so a default s2idle or freeze also closed
the router: with a dock attached, tb_apple_sleep_quiesce() finds a remote
router or a non-DMA tunnel, returns -EBUSY, and the notifier refuses the
suspend. Before the ordered stop, the ACIO notifier left the router up for
s2idle and freeze and tore it down only for a sleep that removes its
domains.

Add an optional sleep_stop callback to the Thunderbolt switch description,
asked through typec_thunderbolt_switch_sleep_stop() at PM_SUSPEND_PREPARE.
The ACIO switch answers with apple_cio_sleep_tears_down(), the same policy
the notifier applies to other ports: deep sleep (or the existing
s2idle_teardown option) stops the port in PD order; s2idle and freeze keep
it up and leave it to the NHI. Shutdown still stops the switch
unconditionally through typec_thunderbolt_switch_pd_ordered_stop().

KUnit: an ordered router is left alone when the selected sleep keeps it
up, and the answer is asked again on every suspend (s2idle, deep, s2idle).

Signed-off-by: Satya Benson <[email protected]>
@satchlj

satchlj commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

@DjDeveloperr Thanks, fixed. Head 2d1c3fe5 → aabb6f64 (one commit appended, no rebase).

What changed (aabb6f64, "usb: typec: tipd: stop a PD-ordered USB4 switch only for sleeps that power it off")

  • The Thunderbolt switch description gets an optional sleep_stop callback, asked through the new typec_thunderbolt_switch_sleep_stop() at PM_SUSPEND_PREPARE. cd321x_session_pm() arms the PD-ordered stop only when it returns true. Before this, it armed on typec_thunderbolt_switch_pd_ordered_stop(), which was true for every sleep.
  • The ACIO switch answers with apple_cio_sleep_tears_down(), the same policy the ACIO notifier applies to every other port and applied to T8122 on the base. A sleep that removes the CIO domains (deep, not default s2idle, not pm_suspend_no_platform()), or the existing s2idle_teardown option, gets the PD-ordered teardown. Default s2idle and freeze leave the router up and never reach tb_apple_sleep_quiesce(), so an attached dock can no longer refuse the suspend with -EBUSY. The decision follows the selected sleep state, not the board.
  • Shutdown is unchanged: it still stops the switch through typec_thunderbolt_switch_pd_ordered_stop().

Tests

  • KUnit cd321x-tbt, two new cases:
    • cd321x_tbt_sleep_router_kept_up_test: an ordered router whose selected sleep keeps it up sees no .set call, PREPARE returns NOTIFY_DONE, the port stays RUNNING and nothing is owed at POST_SUSPEND.
    • cd321x_tbt_sleep_follows_selected_state_test: s2idle, then deep, then s2idle on one port. Only the deep cycle sends SLEEP/WAKE.
    • The existing ordered-sleep case now selects deep.
  • Results (arm64 QEMU): all 5 cd321x suites, 127/127 pass. Negative control: with the old arming condition restored in core.c, cd321x-tbt fails (12/15 pass; the new cases fail).
  • drivers/thunderbolt/ and drivers/usb/typec/ build with W=1 and add no new warnings. checkpatch --strict is clean on the diff. Relevant host tests pass (apple-router-sleep, j613-mux-order, tb-cio-sleep, atc-cio-sleep, pciec-policy, pcie-apple-msi-slice).

Untested on hardware. No hardware row has run at aabb6f64. These rows are still owed:

  1. J613 peer cable (USB4 host-to-host to a second Mac), default command line: attach; XDomain link and thunderbolt0 up; replug; default s2idle with the link up (expect the router to stay up, no -EBUSY, link back after wake); mem_sleep=deep cycle (expect the PD-ordered stop, then the router restarted on wake); shutdown. Expect 0 failed units and 0 new kernel errors.
  2. Dock-attached default s2idle (T8122 with a USB4 dock that has a downstream router plus a PCIe or DP tunnel): echo mem > /sys/power/state with mem_sleep = s2idle, 3 cycles. Pass: the suspend is not refused, no tb_apple_sleep_quiesce -EBUSY in dmesg, and the dock's devices are still enumerated after each wake. Then one deep cycle with the dock attached, recording whether it proceeds or is refused cleanly (tb_apple_sleep_quiesce() still refuses deep sleep while a remote router is present; this change does not alter that) and that the dock works afterwards either way.

Our only T8122 has no USB4 dock, and its recovery path is down right now, so neither row can run on our side yet. I'll post them as a regression request.

@satchlj
satchlj requested a review from DjDeveloperr December 1, 2026 14:05
@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Dec 1, 2026

@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 ordered CD321x stop now follows ACIO’s sleep policy at PM_SUSPEND_PREPARE. The PM core marks freeze before calling the notifier, so the default s2idle and freeze paths leave the dock up. The KUnit cases cover keeping the router up and switching between sleep modes. The requested dock-attached hardware row remains separate.

@satchlj satchlj closed this Dec 1, 2026
@satchlj satchlj reopened this Dec 1, 2026
@satchlj satchlj closed this Dec 1, 2026
@satchlj satchlj reopened this Dec 1, 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:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) area:power Area from CODEOWNERS (bot) area:usb Area from CODEOWNERS (bot) blast:m3 Macs affected, from Merge risk (bot) changes-requested A reviewer requested changes (bot) ci-failing A check failed at the PR head (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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants