Skip to content

j873, kboot_atc: bring up all rear USB hosts and export T8152 USB3 tunables - #565

Merged
RyanTheTide merged 4 commits into
aurora-silicon:mainfrom
sithglan:feat/j873-rear-usb
Nov 30, 2026
Merged

RyanTheTide merged 4 commits into
aurora-silicon:mainfrom
sithglan:feat/j873-rear-usb

Conversation

@sithglan

@sithglan sithglan commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

What: Bring up all three rear USB host controllers on J873g (usb-drd0, usb-drd1, usb-drd3) in USB2 host mode and export apple,tunable-lane0-usb and apple,tunable-lane1-usb on non-fixed-USB3 T8152 ATC PHYs so Linux can switch rear Type-C ports between USB3 SuperSpeed (normal and reversed orientations) and USB4/CIO.
Tested: J873g M6 Mac mini (mini6) at exact head d1d7ca31 (Stage 2 ESP_STAGE2=1, paired with aurora-silicon/linux#3617 at 460f8ea4bda8): all 4 USB hosts active (Bus 001..008), live DT exports common-a/common-b/lane0-cio/lane1-cio/lane0-usb/lane1-usb on all three rear PHYs (phy@{403000000,40b000000,413000000}) plus front phy@383000000, Pin D 5000M SuperSpeed USB3 (Bus 008) + 480M USB2 (Bus 007) active alongside 2-lane 2560x1440 DP on ATC3 (phy-apple-atc 413000000.phy: USB3 SuperSpeed active alongside 2-lane DP (lane 1)), 0 failed units, 0 kernel warnings, 0 DART faults; pytest tests/python/test_t8152_atc_usb3.py 8/8 PASS, make format-check clean, Stage 1 gcc headroom 11,480 B. (Earlier at 265e443c: VL817 10000M SSD 331-347 MB/s and VIA+RTL8153 5000M GbE normal/reversed hot-swap verified.)
Risk: two-way door · T8152 (J873g)
Not yet: Other T8152 boards if any.

j873_usb_prep() previously powered and initialized only usb-drd1 (back-
left) and usb-drd2 (front internal hub), leaving the back-middle (usb-
drd0, hpm0) and back-right (usb-drd3, hpm3) ports unconfigured for USB2
host mode.

Add usb-drd3 (ATC3_USB_AON 0x3082901c0, PSD 74 0x303a14a00, ATC3_USB
0x3082901e0, DWC3 0x412430000, hpm3) to j873_usb[], and bring up usb-
drd0 (ATC0_USB_AON 0x308290100, PSD 71 0x303a14700, ATC0_USB
0x308290120, DWC3 0x402430000, hpm0) in kboot_boot_t8152() so the USB
CDC proxy still finds usb-drd0 cold if entered. Also allow ATCn_USB_AON
to already be on (0x3ff) in j873_usb_power() in case display_init()
already powered ATC3_USB_AON.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Non-fixed-USB3 T8152 ATC PHYs (the rear Type-C ports on J873g)
previously
received only the common and CIO (USB4) lane tunable lists. Export
apple,tunable-lane0-usb and apple,tunable-lane1-usb alongside the CIO
lists so Linux can switch those ports between USB3 SuperSpeed (in either
plug orientation) and USB4/CIO.

Place tunable_ACIOPHY_USBC0_DFLT and tunable_ACIOPHY_USBC0_USB at the
front of each lane's USB3 list rather than in apple,tunable-common-b so
CIO/USB4 mode never writes USBC0 registers and older kernels that only
consume the CIO lists keep identical behaviour.

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

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 265e443c (once queued CI checks pass)

Blockers: none

Checked:

  • Audited both commits (42d50fa7, 265e443c) across all 4 touched files (src/j873.c, src/j873.h, src/kboot.c, src/kboot_atc.c, +144/-36); zero code blockers found.
  • Verified j873_usb0 (usb-drd0) and usb-drd3 MMIO/PMGR/PSD/DART/HPM tables follow the exact T8152 ATC stride (0x40 PMGR, 0x100 PSD bank, 0x8000000 ATC block), and j873_usb_prep_host0() is called only in kboot_boot_t8152() right before Linux handoff so the USB CDC proxy still receives usb-drd0 cold when entered.
  • Verified j873_usb_is_up(&j873_usb0) checks aon == 1023, !(psd & 7), and gate == 1023 before reading u->dwc + 0xc110, so j873_usb_wake_hpms() cannot fault on a cold usb-drd0, and j873_usb_power() safely accepts already-powered AON (0x3ff) from display_init() while still validating cold PSD and gate.
  • Verified all 24 apple,tunable-lane0-usb and 24 apple,tunable-lane1-usb entries in src/kboot_atc.c: every lane 1 offset equals lane0 + 0x9000 (with shared USBC0 0x15c00 placed at the front of each lane's USB3 list so CIO/USB4 mode never writes USBC0 registers and older kernels remain unaffected).
  • Verified exact-head J873g (mini6) hardware row at 265e443c (paired with linux#3566 74b7061e): all 4 USB hosts active, VL817 SSD at 10000M (339-347 MB/s), VIA hub + RTL8153 GbE at 5000M (IPv4/IPv6 + ping 3/3 0% loss), front VL822 hub at 10000M, 0 failed units, 0 DART faults, plus PR text (What/Tested/Risk two-way door).
Evidence
  • src/j873.c: j873_usb_prep_one() deduplicates bring-up across j873_usb[] (id 1, 2, 3) and j873_usb0 (id 0).
  • src/kboot.c: j873_usb_prep_host0() runs in kboot_boot_t8152() after kboot_move_to_exec_window(), gated by chip_id == T8152 && board_id == 0x24.
  • src/kboot_atc.c: atc_tunables_t8152_cio[] adds apple,tunable-lane0-usb and apple,tunable-lane1-usb without altering apple,tunable-common-a/b or apple,tunable-lane0/1-cio.

@github-actions github-actions Bot added blast:m5 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Merge readiness at d1d7ca31: not ready yet

Check Detail
CI at head ok 27 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at d1d7ca31
Conflicts ok none
PR text ok Risk: two-way · T8152 (J873g)

Areas: none matched in CODEOWNERS

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

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

Verdict: Changes requested at 265e443c995e.

Blocker: On a rear T8152 PHY, the new required USB3 lane groups share the common/CIO export's failure path. If a USB3 group is absent or malformed after common and CIO calibration has been read successfully, that path deletes the valid common and CIO properties and drops existing USB4 support. Please publish the two USB3 lane lists together and clear only those two lists when the USB3 calibration is incomplete. Keep the existing common/CIO cleanup for errors in that calibration.

Checked: Compared the old and new export tables and followed dt_append_atc_tunable() through the cleanup. The J873g row verifies the complete group set. Please cover both complete and incomplete USB3 calibration in validation of the fix.

Export apple,tunable-lane0-usb and apple,tunable-lane1-usb for T8152
Type-C ports via a dedicated dt_copy_t8152_cio_usb3_tunables() helper
that reuses atc_tunables_t8152_usb3[] instead of duplicating 48 static
table entries in atc_tunables_t8152_cio[].

If any USB3 ADT group is missing or malformed after common/CIO export
succeeded, cleanup now deletes only the two USB3 lane properties and
preserves valid common and CIO calibration. Reusing the existing table
also removes 48 PIE relocations from Stage 1, bringing gcc Stage 1
headroom back from 3664 B to 11480 B.

Add a host test covering complete export (USBC0 at 0x15c00, lane 1 at
+0x9000) and isolated cleanup on missing or malformed USB3 groups.

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

Copy link
Copy Markdown
Contributor Author

Addressed in 45455f8:

  • Moved T8152 Type-C USB3 lane tunable export into dt_copy_t8152_cio_usb3_tunables(), reusing atc_tunables_t8152_usb3[] instead of duplicating 48 entries in atc_tunables_t8152_cio[]. Missing or malformed USB3 groups now delete only apple,tunable-lane0-usb and apple,tunable-lane1-usb while preserving valid common/CIO calibration.
  • Added host test tests/python/test_t8152_atc_usb3.py covering complete export and isolated cleanup on missing/malformed USB3 groups (pytest: 18/18 ATC tests PASS).
  • Removing the 48 duplicate table entries + PIE relocations restored tools/stage1_size.sh gcc headroom to 11480 B (stage1) / 11656 B (stage1-secure-audit, stage1-secure-enforce); make format-check clean.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: HOLD at 45455f8c — dt_copy_t8152_cio_usb3_tunables() and test_t8152_atc_usb3.py cleanly resolve the common/CIO cleanup isolation blocker and restore Stage 1 headroom; awaiting queued CI completion and exact-head hardware confirmation at 45455f8c.
Blockers:

  1. Wait for queued CI checks (build, ESP stage 2 vital size, all 5 stage1-size toolchains, all 5 Pytest jobs, format-check, policy, pr-text) at 45455f8c to pass.
  2. Post a J873g boot verification row at exact head 45455f8c confirming apple,tunable-lane0-usb / apple,tunable-lane1-usb export and rear-port USB2/USB3 bring-up match the prior 265e443c result.
    Checked: src/kboot_atc.c (dt_copy_t8152_cio_usb3_tunables(), atc_tunables_t8152_usb3[], dt_copy_atc_tunables()), tests/python/test_t8152_atc_usb3.py, src/j873.c, src/j873.h, src/kboot.c, and DCO sign-off at 45455f8c.
Evidence
  • Blocker fix verification (45455f8c):
    • dt_copy_t8152_cio_usb3_tunables() runs only after common/CIO export succeeds on non-apple,fixed-usb3 atc-phy,t8152 nodes, clears stale apple,tunable-lane0-usb / apple,tunable-lane1-usb first, and reuses atc_tunables_t8152_usb3[] (verified lines 296–297 are the only two 0x15c00 USBC0 entries, followed by the 22 apple,tunable-lane0-usb entries, biased by +0x9000 for lane 1).
    • On any missing or malformed USB3 group, cleanup: deletes only apple,tunable-lane0-usb and apple,tunable-lane1-usb, keeping valid common/CIO calibration intact for USB4.
    • Reusing atc_tunables_t8152_usb3[] drops 48 duplicate entries and their PIE relocations from Stage 1 (restoring local GCC Stage 1 headroom to 11,480 B).
    • tests/python/test_t8152_atc_usb3.py verifies complete 24-triple export per lane (0x15c04 USBC0 prefix + +0x9000 lane 1 stride) and isolated cleanup on both missing and malformed USB3 groups.
  • Note (non-blocking): @DjDeveloperr has a pending CHANGES_REQUESTED review from 265e443c that will also need dismissal/re-review once CI and the 45455f8c row land.

@github-actions github-actions Bot added changes-requested A reviewer requested changes (bot) needs-hw-row No hardware row at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 29, 2026
In dt_copy_t8152_cio_usb3_tunables(), require each required ADT USB3
tunable group to be both present and non-empty before calling
dt_append_atc_tunable(), taking the USB3-only cleanup path on a
present-but-empty group while preserving common/CIO calibration.

Extend tests/python/test_t8152_atc_usb3.py to cover the empty-group
case alongside complete, missing, and malformed groups.

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

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: HOLD at d1d7ca31 — the empty required-group guard and host test extension are clean and code-ready; awaiting queued CI completion, exact-head J873g hardware confirmation, and @DjDeveloperr's re-review.

Blockers:

  1. Wait for queued CI checks at d1d7ca31 (build, ESP stage 2 vital size, all stage1-size toolchains, Pytest, pr-text, readiness) to complete green.
  2. Post exact-head d1d7ca31 J873g hardware confirmation showing rear Type-C USB3 lane tunables exported and common/CIO calibration intact.

Checked:

  • Audited commit d1d7ca31 (src/kboot_atc.c L937–940, tests/python/test_t8152_atc_usb3.py, DCO Signed-off-by: present):
    • dt_copy_t8152_cio_usb3_tunables() checks adt_getprop(adt, adt_node, entry.adt_name, &len) and jumps to cleanup when entry.required && (!raw || !len), rejecting present-but-empty required USB3 ADT groups while clearing only apple,tunable-lane0-usb/apple,tunable-lane1-usb and preserving common/CIO tunables.
    • tests/python/test_t8152_atc_usb3.py adds a present-but-empty tunable_ACIOPHY_USBC0_USB case verifying both USB3 properties are removed and common/CIO properties remain intact.
Evidence
  • src/kboot_atc.c (L913–951): verified !raw short-circuits before !len and cleanup deletes only lane_names[].
  • tests/python/test_t8152_atc_usb3.py (L28–45, L113–127): verified empty hook returns non-NULL pointer with *len = 0, exercising the new guard after re-population.

@sithglan

Copy link
Copy Markdown
Contributor Author

Addressed in d1d7ca31:

  • Added the adt_getprop() NULL/zero-length guard in dt_copy_t8152_cio_usb3_tunables() for required entries before dt_append_atc_tunable() so present-but-empty USB3 groups take the USB3-only cleanup path while preserving common/CIO calibration.
  • Expanded tests/python/test_t8152_atc_usb3.py to cover complete, missing, malformed, and empty groups (pytest PASS, make format-check clean).

@DjDeveloperr
DjDeveloperr dismissed their stale review November 29, 2026 14:01

Verified at d1d7ca3 that an empty required USB3 group clears both USB3 lane lists and preserves common/CIO. Exact-head CI and J873g hardware confirmation remain outstanding.

@sithglan

Copy link
Copy Markdown
Contributor Author

Exact-head Stage 2 hardware verification on Mac mini M6 (J873g, T8152, FW 27.2) at d1d7ca31 (paired with aurora-silicon/linux#3617 at 460f8ea4bda8):

  • Built Stage 2 (ESP_STAGE2=1, build/aura.bin with existing boot trailer) and booted cleanly on J873g (0 failed systemd units, 0 kernel warnings/Call traces, 0 DART/IOMMU faults).
  • Live /proc/device-tree/soc/phy@* tunables exported by Stage 2 d1d7ca31:
    • phy@383000000 (front USB-C hub): common=924B common-a=96B common-b=924B lane0-usb=660B
    • phy@403000000 (ATC0): common=912B common-a=96B common-b=912B lane0-cio=756B lane0-usb=696B lane1-cio=756B lane1-usb=696B
    • phy@40b000000 (ATC1): common=912B common-a=96B common-b=912B lane0-cio=756B lane0-usb=696B lane1-cio=756B lane1-usb=696B
    • phy@413000000 (ATC3): common=912B common-a=96B common-b=912B lane0-cio=756B lane0-usb=696B lane1-cio=756B lane1-usb=696B
  • End-to-end rear USB3 + 2-lane DP bring-up consuming these tunables:
    • phy-apple-atc 413000000.phy: USB3 SuperSpeed active alongside 2-lane DP (lane 1)
    • Bus 001..008 all 4 xHCI controllers up (382430000, 402430000, 40a430000, 412430000); Eizo EV2780 on ATC3 enumerated Bus 007 480M Hub + EIZO HID + Billboard and Bus 008 5000M SuperSpeed Hub alongside 2560x1440 DP (card1-DP-2) and 2560x1440 HDMI (card0-DP-1).
  • Local automated checks at d1d7ca31: pytest tests/python/test_t8152_atc_usb3.py 8/8 PASS, make format-check clean, tools/stage1_size.sh gcc Stage 1 headroom 11,480 B.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed changes-requested A reviewer requested changes (bot) labels Nov 29, 2026
@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 29, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at d1d7ca31

Blockers: none

Checked:

  • Upgrading prior HOLD at d1d7ca31: all build, format, policy, Stage 1 headroom, Pytest (Linux gcc/llvm, macOS 15/26, ARM native), selftest, clang-macos, and distro (fedora, alarm, nix) CI checks are green (0 failures; only queued pr-text and readiness remaining).
  • Exact-head d1d7ca31 Stage 2 J873g (T8152, FW 27.2) hardware row posted: clean boot (0 failed units, 0 kernel warnings/Call traces, 0 DART/IOMMU faults), live /proc/device-tree/soc/phy@* tunables verified across front hub and ATC0/ATC1/ATC3, end-to-end rear USB3 SuperSpeed + 2-lane DP bring-up on ATC3, test_t8152_atc_usb3.py 8/8 PASS, Stage 1 gcc headroom 11,480 B.
  • Prior 265e443c review is dismissed and both the USB3-only cleanup isolation (45455f8c) and present-but-empty required-group guard (d1d7ca31) are cleanly in place.
Evidence
  • d1d7ca31095df9000238ab85d4ddad45e05f2c8f (MERGEABLE on main, DCO-signed): dt_copy_t8152_cio_usb3_tunables() rejects missing or zero-length required USB3 groups via the USB3-only cleanup path without deleting common/CIO calibration.
  • Wait for queued pr-text and readiness checks to finish green before merging.

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Nov 30, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at d1d7ca31. App approved (NEON-PR-REVIEW2), hosted CI green, rows in the body. Merges under the 6-point rule 1 h from now unless you object.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging under the 6-point rule at d1d7ca31. (1) The review App approved at this head. (2) CI is green. (3/4) Rows: App+CI Tested: J873g M6 Mac mini (mini6) at exact head d1d7c. (5) No blocking review. (6) Dj was pinged 61 min ago with no objection. Revert: git revert -m 1 `.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (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