Repository navigation
pcie: set up each root port's DBI at its own device - #405
Conversation
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>
RyanTheTide
left a comment
There was a problem hiding this comment.
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.
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 (itsreg, 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
left a comment
There was a problem hiding this comment.
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:
- CI on 6e799cb. The runs are approved and queued.
- 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,0andpci@2,0), J704 (T8142, the same pair) and the T8132 desktops (t8132-desktop.dtsiaddspci@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 ADTmaximum-link-speedand lane count, and every device behind the controller enumerates. - The no-gap rows Ryan listed (M1 Pro, M2):
lspci -vvroot-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.
|
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. |
|
The device number vs. port index check is in #423 (log only, merges on its own). |
|
M1 Pro (J316s, T6000) no-gap row on 6e799cb merged with main a752152 (Stage 2
Assisted-by: LLM (Claude:Opus 5.5) |
|
M2 (J413, T8112) no-gap row on 6e799cb merged with main a752152 (Stage 2
Assisted-by: LLM (Claude:Opus 5.5) |
|
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. |
Split out of #266 as asked there.
The port loop skips a port whose
pci-bridgenode 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-bridge0for the radio,pci-bridge2for the SD card reader, and nopci-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-speed1, the reader'sexpected-link-speed2).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:
makebuilds with no new warnings,clang-format20.1.8 reports nothing forsrc/pcie.c, andtest_pcie_sequence.py,test_pcie_fdt_disable.pyandtest_m4_pcie_power_fdt.pypass. 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.