Skip to content

Enable native rear-port USB4 and PCIe storage on J813 - #2142

Open
sithglan wants to merge 4 commits into
aurora-silicon:integration/aurorafrom
sithglan:thomas/j813-usb4-native
Open

sithglan wants to merge 4 commits into
aurora-silicon:integration/aurorafrom
sithglan:thomas/j813-usb4-native

Conversation

@sithglan

@sithglan sithglan commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

The J813 rear USB-C port can enumerate a USB4 storage enclosure, but the existing T8142 match data follows the wrong router startup sequence and has no native PCIe-C MSI setup. This enables the rear port with the MxWrap/RTKit/LSTX sequence verified on hardware, native PCIe-C match data and validated 32-vector MSI slices, and the corresponding device tree and bindings.

Deep sleep releases idle NVMe tunnels before the shared USB PHY shuts down, then requests fresh cable state after wake. An open disk or an unsupported endpoint driver refuses sleep. The notifier runs before DWC3: the initial default-priority version exposed a link-loss race during refusal, reproduced and covered by a production-registration test and negative control.

Hardware: J813 / T8142, rear port, UGREEN enclosure (vendor 0x00b8, device 0x2463), Samsung 980 PRO 2 TB, firmware 5B2QGXA7. The clean series is based on integration/aurora at dcce0e7. Runtime qualification used the same changes on the full J813 stack from #2135, retaining its display, GPU, radio, audio, media and sleep work.

Validation:

  • Full arm64 LLVM 22 kernel/modules/DTB build; no configuration features removed.
  • PCIe admission tests, including native T8142 and missing-DART/compatibility negative controls; PM notifier-order test and reversed-order negative control; five CIO host suites.
  • Changed binding schemas and examples pass. Board DT validation adds no new warning: the PCIe-C tunable alias is usb4-1-pcie (as in t6040-usb4.dtsi), which aura looks up since kboot: accept the hyphenated usb4-N-pcie alias for PCIe-C tunables aura#302.
  • The T8132/T8142 MSI slice is checked against the device tree alone (msi-ranges minus apple,msi-vector-base gives the window base; 32 vectors, 32-aligned, above vector 31, inside the 8-bit map): no AIC constant and no ECAM table in the driver. The T8132 trees give 1506 and every J813 PCIe node 1741, as before.
  • Boot of this exact DTB with aura 8b9c92ea + aura#302 (chainloaded, 19 Nov): the PCIe-C tunables are present under both pcie-tunnel-N/pcie@... nodes, the rear link comes up at 20 Gb/s x 2, NVMe gets its MSI-X queues, and a 4 GiB direct read runs at 2.9 GB/s. With the enrolled aura (no drm/apple: dcp: let a Type-C port with HPD take over a pipeline held without it #302) the same DTB gives "PCIe-C tunnel disabled: not initialized by m1n1 or the kernel" and the enclosure falls back to USB.
  • Boot with the enclosure attached: authorized USB4 link at 20 Gb/s x 2 lanes, IOMMU protection enabled, NVMe MSI-X queues working.
  • Open-disk suspend refusal preserves the link and read checksums.
  • Actual 8- and 20-second deep sleeps with the idle enclosure attached: automatic reconnection, repeated 64 MiB direct-read checksums at 0, 1 GiB and 1 TiB; 4 GiB direct read after resume at about 2.9 GB/s.
  • SMART media/error-log counts stay zero, unsafe shutdown count and host-write-command count unchanged across those two sleeps/read tests.
  • Normal default reboot with the trial marker spent: matching kernel/DTB, automatic deep-sleep service, enclosure enumeration and the health checks pass.
  • After each wake: all ten CPUs, internal display, GPU clear/readback, factory Bluetooth identity and LE discovery, Wi-Fi traffic and internal-storage checksum pass.

Scope: rear port only. USB4 DisplayPort tunnels stay disabled; the existing DP alternate-mode graph remains separate on connector port 3. Other enclosures, front-port USB4, write workloads, mounted-storage suspend, external-display combinations and long-duration sleep remain unqualified. The final clean build's physical replug matrix is still pending; the preceding bring-up build was tested through physical unplug/replug. Existing firmware/property and IRQ-affinity messages remain, so this is a functional qualification rather than a clean-dmesg claim. Raw logs, per-unit identities and firmware remain private.

Allow the five ACIO register windows, LSTX GPIO and router firmware
tunables used by T8142. Describe its native PCIe-C compatible and
require the shared MSI vector base. Include the T8142 pinctrl fallback
chain used by the AOP LSTX pin.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
@sithglan

Copy link
Copy Markdown
Contributor Author

Rebased onto integration/aurora 0abc2f3. It is now 963d155 (was 9736db6); the old branch no longer merged.

  • The only conflict was in t8142-j813.dts. Integration added J813 nodes at the end of the board file (arm64: dts: apple: t8142: lid angle sensor on J815 and J813 (on #1532) #1805 and the J813 alignment). They are kept, and the USB4 include stays last.
  • The binding commit lost its apple,pinctrl.yaml hunk. Integration already has the T8142 pinctrl compatible, so git dropped it as already applied. The other commits are unchanged (git range-diff).
  • The dt-checks failure is fixed. The PCIe-C tunable alias is now usb4-1-pcie, as in t6040-usb4.dtsi, so the board adds no new warning. aura only looked up the underscored usb4_N_pcie for these tunables; kboot: accept the hyphenated usb4-N-pcie alias for PCIe-C tunables aura#302 adds the hyphenated fallback that its other USB4 lookups already have. Until that is in, an older aura copies no PCIe-C tunables for this port.
  • Re-checked locally:
    • scripts/dtc/apple-dt-check.sh against 0abc2f3: 137 DTBs, 0 new and 0 removed warnings, both changed bindings OK;
    • run-host-tests.py: 427/427;
    • full build of Image, modules and DTBs (LLVM 22).

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for the J813 rear-port USB4 work. The sleep handling, and the hardware-reason comments on it, are good to have.

One small thing: drivers/pci/controller/pcie-apple.c:3441-3443 picks the AIC MSI base with of_machine_is_compatible("apple,t8142") ? 1741 : 1506, right after the PR adds t8142_pciec_hw match data for this controller. We select by the IP block's compatible or match data, or by the DT, rather than by the SoC name. Could the AIC base become a field in hw_info (1506 for T8132, 1741 for T8142), or be checked against the node's msi-ranges? Then the branch can test pcie->hw as the line above it does.

Happy to run a no-regression row on our other Macs once it's updated.

@sithglan

Copy link
Copy Markdown
Contributor Author

Done. It is now 4ed06b3 (was 963d155). Only "PCI: apple: support T8142 PCIe-C MSI slices" changed (now adee45b); the other three commits are identical (git range-diff).

  • struct hw_info has a new msi_aic_base field: 1506 in t8132_pciec_hw, 1741 in t8142_pciec_hw.
  • The slice check selects that branch by pcie->hw == &t8132_pciec_hw || pcie->hw == &t8142_pciec_hw, like the line above it, and takes aic_base from the match data. No machine check is left in that branch.
  • apple,t8132-pciec appears only in t8132-usb4.dtsi, so the T8132 boards reach the same branch with the same base as before.

Checked: pcie-apple.o builds with LLVM 22 and W=1 with no warnings, and checkpatch is clean. This is compile-tested only; the running path on the J813 is unchanged (same branch, same 1741).

#2238 is restacked on this head (6113f94, content unchanged). #2178 (T8152, 1879) has the same pattern and gets the same treatment in its rework.

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

Thanks for the quick rework. At 4ed06b3 the machine check is gone (pcie-apple.c:3446-3447). I'd still like the AIC base out of the driver, because the DT already says it. msi-ranges names the AIC input of global vector apple,msi-vector-base, and the window is linear, so args[1] - apple,msi-vector-base is the base. On J813 every node gives 1741 (internal 1741 at 0, front 1837 at 96, rear 1869 at 128). msi_aic_base and the ECAM-keyed expected_base switch only re-derive that from a table, and #2178 is about to add a third constant.

Concretely, for the T8132/T8142 branch:

  1. Read apple,msi-vector-base first.
  2. Check the slice structurally: 32 vectors, 32-aligned, above the internal port's vectors, within FIELD_MAX(PORT_MSIMAP_TARGET) + 1, edge-rising SPI, args[1] >= base.
  3. Drop msi_aic_base and the ECAM table.

No binding change is needed: both properties are already required for t8142 PCIe-C. If you want the cross-node check, "all PCIe nodes agree on msi-ranges[1] - apple,msi-vector-base and the slices are disjoint" fits apple-dt-check better than the driver. T6030/T6040/T6050 can follow in a separate PR.

Two merge gates besides that:

  • Rerun CI: both runs on 4ed06b3 were cancelled by the runner, not failed.
  • The usb4-1-pcie alias needs aura#302, which is still open, and the qualified boot used the underscored alias with an older aura. Please post one boot of this exact DTB with an aura that has #302: link up, and the PCIe-C tunables present under the apciec1 node.

Minor, non-blocking: thunderbolt/apple.c keys three behaviours on acio->hw == &apple_cio_t8142_hw (4011, 4257, 4742). Named flags in apple_cio_t8142_hw would carry to the next SoC more easily.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for adee45b. Taking the AIC base from the match data and selecting the branch by pcie->hw covers the point we raised.

T8142 uses the Intr2AXI controller layout but its three-cell AIC
interrupt specifier and MSI window differ from T6050. Match it natively.
This allows a tunnelled NVMe controller to allocate working MSI-X
interrupts.

For T8132 and T8142 the slice is checked against the device tree alone.
msi-ranges names the AIC input of global vector apple,msi-vector-base in
a linear window, so the window's AIC base is msi-ranges minus
apple,msi-vector-base, and the slice is checked by its shape: an
edge-rising SPI, 32 vectors, 32-aligned, above the internal port's
vectors and inside the 8-bit map target. This replaces T8132's table of
ECAM apertures and its AIC base 1506 behind a machine check. The T8132
trees give 1602 - 0x60 = 1634 - 0x80 = 1506, and every J813 PCIe node
gives 1741.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Use the qualified MxWrap startup sequence: CIO reset leaves the CPU
running, then RTKit readiness precedes the LSTX handoff. Admit native
T8142 PCIe-C hosts without a T6050 fallback. Keep DP IN disabled.

Deep sleep removes CIO power. Remove idle NVMe hierarchies before
stopping the router and request fresh cable state on resume. Refuse
sleep when a disk is open or another endpoint driver cannot be removed
safely. Extend the production-C admission tests with native T8142 and a
negative control.

The T8142 behaviours are named flags of its match data
(sleep_removes_domains, restart_on_wake, phy_shared_with_dwc3), so a later
SoC that behaves the same sets them instead of extending a comparison.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Describe ACIO1, its mailbox and LSTX pin, and the PCIe-C tunnel.
Populate both DARTs under their powered parents. Use connector port 4 so
the existing DisplayPort alternate-mode route can retain port 3. Name the
PCIe-C tunable alias usb4-1-pcie, as t6040-usb4.dtsi does; aura looks it
up under that spelling since aurora-silicon/aura#302.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
@sithglan
sithglan force-pushed the thomas/j813-usb4-native branch from 4ed06b3 to 13483df Compare November 19, 2026 19:48
@sithglan

Copy link
Copy Markdown
Contributor Author

Thanks. All three points are done. The head is now 13483df0aa7f.

AIC base from the DT (56cecd6de922). T8132 and T8142 now have their own branch in apple_msi_init():

  1. It reads apple,msi-vector-base first.
  2. It checks the slice by shape alone: a three-cell edge-rising SPI, args[1] >= base, then apple_t6030_msi_slice_valid() with args[1] - base as the window base. That means 32 vectors, 32-aligned, at or above 0x20, and base + count <= 256.

msi_aic_base and the ECAM table are gone. That also removes T8132's old of_machine_is_compatible("apple,t8132") table and its 1506. Its two trees still pass: 1602 − 0x60 = 1634 − 0x80 = 1506. T6030/T6040 keep their branch, for a separate PR. #2178 now uses the same branch for T8152 instead of adding a third constant.

Named flags (caf9ba025e07). apple_cio_t8142_hw now sets sleep_removes_domains, restart_on_wake and phy_shared_with_dwc3, and the three acio->hw == &apple_cio_t8142_hw comparisons test those instead. The PM-order host test models the flag, and its reversed-priority negative control still fails as it should.

CI and the aura#302 boot.

  • The push re-triggered CI. Locally, run-host-tests.py passes 427/427, and apple-dt-check.sh against the base gives 0 new warnings with both changed bindings OK.
  • Boot of this DTB on the J813 with aura 8b9c92ea (the enrolled build) + aura#302 a38b80cbd6, chainloaded in place (1.0.0b12-g2074ae7e in /chosen). The kernel is the arm64: dts: apple: enable the J813 front USB4 port #2238 head, whose rear-port DT is this PR's. Enclosure on the rear port:
    • apple,tunable-rc, apple,tunable-fabric and apple,tunable-debug are present under /pcie-tunnel-1/pcie@1c60000000, and under /pcie-tunnel-0/... too.
    • The router links at 20 Gb/s × 2, then pcie-apple 1c60000000.pcie: Link up. nvme1n1 (Samsung 980 PRO) comes up with 10 MSI-X queues through the new slice check.
    • A 4 GiB O_DIRECT read runs at 2.9 GB/s, and the 64 MiB checksum at offset 0 matches the qualified one (b12e3997…).
  • Control with the enrolled aura (no drm/apple: dcp: let a Type-C port with HPD take over a pipeline held without it #302), same kernel and DTB: PCIe-C tunnel disabled: not initialized by m1n1 or the kernel on both routers, and the enclosure enumerates as a 10G USB disk. So the hyphenated alias really does need drm/apple: dcp: let a Type-C port with HPD take over a pipeline held without it #302.

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.

3 participants