Skip to content

pcie: set up each root port's DBI at its own device - #405

Merged
RyanTheTide merged 1 commit into
aurora-silicon:mainfrom
IronsideXXVI:j604-pcie-dbi-per-port
Nov 21, 2026
Merged

RyanTheTide merged 1 commit into
aurora-silicon:mainfrom
IronsideXXVI:j604-pcie-dbi-per-port

Conversation

@IronsideXXVI

Copy link
Copy Markdown
Contributor

Split out of #266 as asked there.

The port loop skips a port whose pci-bridge node is absent, but it moves the DBI window on by one device only for the ports it sets up. On a controller with a gap, port N's tunables, speed cap and width go to the config space of the device before it, and port N keeps its reset defaults.

The J604 (M4 MacBook Pro 14") has such a gap: pci-bridge0 for the radio, pci-bridge2 for the SD card reader, and no pci-bridge1. Port 2's RC tunables, gen3/gen4 shadow tunables, speed cap and width went to device 1. Linux then read the reader's root port maximum link speed as 16 GT/s, where the ADT has it at 5 GT/s (maximum-link-speed 1, the reader's expected-link-speed 2).

The fix takes each port's DBI from its port number, the same number its bridge's unit address uses. Controllers with no gap are unchanged.

Checked on main 3efa4a8: make builds with no new warnings, clang-format 20.1.8 reports nothing for src/pcie.c, and test_pcie_sequence.py, test_pcie_fdt_disable.py and test_m4_pcie_power_fdt.py pass. This is the same change our J604 aura build carries.

The no-regression rows on controllers without a gap would be very welcome, as offered in #266.

The port loop skips a port whose pci-bridge node is absent, but moves
the DBI window on by one device only for the ports it sets up. On a
controller with a gap, such as the J604's (pci-bridge0 for the radio,
pci-bridge2 for the SD card reader, no pci-bridge1), port 2's RC
tunables, gen3/gen4 shadow tunables, speed cap and width went to
device 1's config space, and port 2 kept its reset defaults: Linux
reads its root port's maximum link speed as 16 GT/s, where the ADT
(maximum-link-speed 1, the reader's expected-link-speed 2) has it at
5 GT/s.

Take each port's DBI from its port number, as its bridge's unit address
has it. Controllers with no gap are unchanged.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Local run of the workflow commands on 6e799cb (Linux, current main 3efa4a8 as base): clang-format clean, gcc and clang builds, stage1-size and the PMP boot-data test pass, pytest 829 passed / 26 skipped. macOS Pytest I can't run here. The fork run is waiting for approval; could someone approve it?

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

No blockers. Taking each port's DBI from its own port number fixes the shift for ports after a missing pci-bridgeN. Controllers with no gap get the same addresses as before, since the old running config_base equalled config_base + (port << 15) there. Nothing after the loop used the advanced config_base. The GE0/GE1 controllers use port 0 only, so they are unchanged.

  1. src/pcie.c:996: this assumes device number == port index, which the PR checks against the unit address by hand. If the ADT bridge node gives its device number (its reg, or the unit address in the node name), use that, or at least check the two agree and log the port and device. A future layout where they differ would then fail visibly instead of tuning another port.

Hardware rows. J616s (M4 Pro MacBook Pro 16, T6040, which also has an SD reader): before and after, list the pci-bridgeN nodes in the ADT and capture lspci -vv LnkCap/LnkSta for every root port. Pass: each root port's max speed and width match that port's ADT maximum-link-speed and lane count, and Wi-Fi and the SD reader both enumerate. M1 Pro (T6000) and M2 (T8112), no-gap regression: the same lspci -vv root port fields are identical before and after, and Wi-Fi and NVMe work.

Assisted-by: LLM (Claude:Opus 5.5)

@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 Dylan. The code is right. Taking each port's DBI from its port number fixes the shift after a missing pci-bridgeN. The only continue in the port loop is the absent-bridge one (src/pcie.c:804); every other failure returns. So on a controller whose bridges run 0..n with no gap, every port gets the address the running config_base gave it before.

Before this merges:

  1. CI on 6e799cb. The runs are approved and queued.
  2. A row from a second board with a gap, because this changes Stage 1 there too. Going by the Linux DTS, J773s (T6040 Mac mini, pci@0,0 and pci@2,0), J704 (T8142, the same pair) and the T8132 desktops (t8132-desktop.dtsi adds pci@2,0) have the same layout, and all of them run this port loop. J616s, from Ryan's list, has ports 0 and 1 in its DTS, so it would be a no-gap row, not the gap row. Pass is what Ryan described: each root port's LnkCap/LnkSta matches its own ADT maximum-link-speed and lane count, and every device behind the controller enumerates.
  3. The no-gap rows Ryan listed (M1 Pro, M2): lspci -vv root-port fields identical before and after.

Ryan's suggestion to check the bridge's device number against the port index and log a mismatch is still worth doing, but it doesn't block.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Thanks for the review and for approving the runs. I'll add the bridge device number vs. port index mismatch log Ryan suggested as a small follow-up so it doesn't hold this one.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

The device number vs. port index check is in #423 (log only, merges on its own).

@RyanTheTide

Copy link
Copy Markdown
Contributor

M1 Pro (J316s, T6000) no-gap row on 6e799cb merged with main a752152 (Stage 2 1.0.0b14-g86bacff5). It ran as an aura-try one-shot behind the installed Stage 1, with the configured Stage 2's DTB, U-Boot and config kept byte for byte, on the fleet kernel.

  • lspci -nn device list identical to the production boot (5 functions).
  • Both root ports (00:00.0, 00:01.0): LnkCap, LnkSta, LnkCtl2 and LnkSta2 identical to production (5 GT/s, x1, ASPM L1).
  • Enforcing, 0 failed units, 0 AVCs, 0 kernel errors, 10/10 CPUs, NVMe and Wi-Fi up, 0 DART faults.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

M2 (J413, T8112) no-gap row on 6e799cb merged with main a752152 (Stage 2 1.0.0b14-g86bacff5). It ran as an aura-try one-shot behind the installed Stage 1, with the configured Stage 2's DTB, U-Boot and config kept byte for byte, on the fleet kernel.

  • lspci -nn device list identical to the production boot (3 functions).
  • Root port: LnkCap, LnkSta, LnkCtl2 and LnkSta2 identical to production (5 GT/s, x1, ASPM L1).
  • Enforcing, 0 failed units, 0 AVCs, 0 kernel errors, 8/8 CPUs, NVMe and Wi-Fi up, 0 DART faults.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide
RyanTheTide merged commit 529e87e into aurora-silicon:main Nov 21, 2026
15 checks passed
@RyanTheTide

Copy link
Copy Markdown
Contributor

Merged. Thanks, @IronsideXXVI. Rows: no-gap controllers on the M1 Pro (T6000, 2 ports) and M2 (T8112) are identical to production (device list, LnkCap/LnkSta/LnkCtl2/LnkSta2), and the J604 gap case is covered by your measurement in the description. It also merges cleanly with #416, which touches the same file. The device-number check follows in #423.

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