Skip to content

PCI: apple: t6050: write the gen5 shadow tunables into the 32 GT/s bank - #2794

Draft
RyanTheTide wants to merge 1 commit into
mainfrom
isw/t6050-shadow-sel-v2
Draft

RyanTheTide wants to merge 1 commit into
mainfrom
isw/t6050-shadow-sel-v2

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Replaces #2270 (same changes, commit trailers fixed).

Fixes #1379.

apple_pcie_t6050_port_configure() picks each rate's shadow bank in GEN3_RELATED.RATE_SHADOW_SEL (bits 25:24) before it writes that rate's tunables. The table it used, { 0, BIT(24), 0 }, selected bank 0 again for apple,pcie-rc-gen5-shadow-tunables. The gen5 values overwrote the gen3 ones, and since the link trains at 8 GT/s, the bank in use ran with gen5's values.

Change. The loop writes FIELD_PREP(RC_T6050_RATE_SHADOW_SEL, i), so the gen3, gen4 and gen5 lists go to banks 0, 1 and 2. That is DesignWare's encoding: pcie-qcom-common.c writes speed - PCIE_SPEED_8_0GT into the same field. It also matches the J716s boot-loader trace cited in the issue (gen3 = 0, gen4 = 1, gen5 = 2). The field is left at 2, as the boot loader leaves it. Nothing else in the driver reads or depends on the field.

Reach. Every T6050 board whose DT carries the shadow tunables (J714s, K116s) runs this function at port configure, adopt and restart. No other SoC uses it.

Evidence.

  • checkpatch --strict: 0 errors, 0 warnings.
  • Build: compiles with the fleet release config on 0abc2f3: 0 warnings, 0 errors. In the disassembly of apple_pcie_t6050_port_configure(), the third select now writes 2 (orr #0x2000000 after the field clear). Before, it wrote 0 again.
  • Hardware: not run, as we have no T6050 machine. A useful row from anyone with a J714s or K116s: lspci -vv -s <N1 root port> LnkSta and dmesg | grep -iE 'aer|pcie' before and after, plus a few minutes of Wi-Fi ping and throughput. The link should still train at 8 GT/s x1, with no new AER errors.

Reported by @RINNECODER in #1379, including the fix.

apple_pcie_t6050_port_configure() selects a rate's shadow bank in
GEN3_RELATED.RATE_SHADOW_SEL (bits 25:24) before it writes that rate's
tunables. The table it used, { 0, BIT(24), 0 }, selected bank 0 again
for the gen5 tunables. They overwrote the gen3 values, and the link
trains at 8 GT/s, so the bank in use ended up with gen5's values.

The field is DesignWare's: 0 selects the 8 GT/s bank, 1 the 16 GT/s
bank, 2 the 32 GT/s bank. pcie-qcom-common.c uses the same encoding
(speed - PCIE_SPEED_8_0GT). The J716s boot loader trace in the report
shows gen3 = 0, gen4 = 1, gen5 = 2, with the field left at 2.

Write the loop index into the field with FIELD_PREP(), which gives 0, 1
and 2 for the three tunable lists. The field is left at 2 as the boot
loader leaves it, and no other code here depends on its value.

Every T6050 board with these tunables in its DT is affected (J714s,
K116s). Nothing else uses this function.

Fixes: 847c749 ("PCI: apple: Add the T6050 port reset, enable, configure and train sequences")
Reported-by: RINNECODER <[email protected]>
Closes: #1379
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at 3cb28cf (non-author, draft). The code change is correct, but the commit message describes an effect that the in-tree device trees do not have; please correct the message (and reconsider the Fixes tag) before this leaves draft.

  • Merges cleanly onto integration/aurora 6748d83. One commit, human sign-off only. PCI: apple: t6050: write the gen5 shadow tunables into the 32 GT/s bank #2270 is closed.

  • FIELD_PREP(RC_T6050_RATE_SHADOW_SEL, i) with RC_T6050_RATE_SHADOW_SEL = GENMASK(25, 24) writes 0, 1, 2 for the gen3, gen4 and gen5 lists. That is the DesignWare encoding, and the function is reached only through the T6050 port ops.

  • What the message says happened did not happen on J714s or K116s. Both device trees carry the bank select inside each shadow list, ahead of the only shadowed register in it:

    • apple,pcie-rc-gen3-shadow-tunables: <0x154 ...>, <0x890 4 0x3000000 0x0>, <0x8a8 ...>
    • apple,pcie-rc-gen4-shadow-tunables: <0x178 ...>, <0x890 4 0x3000000 0x1000000>, <0x8a8 ...>
    • apple,pcie-rc-gen5-shadow-tunables: <0x1ac ...>, <0x890 4 0x3000000 0x2000000>, <0x8a8 ...>

    apple_pcie_t6050_tune() applies the records in order, so the 0x890 record sets bank 2 before the gen5 0x8a8 write, whatever the driver selected just before. The first record of each list (0x154, 0x178, 0x1ac) is a different register per rate, in the extended capability area, so it does not depend on the bank select (please confirm against the DesignWare register list). So with these DTs the gen5 values already went to bank 2, the gen3 bank was not overwritten, and the field was already left at 2. The three 0x8a8 records are also identical (mask 0xffff0f, value 0x1).

  • Consequence: on J714s and K116s this change writes the same register values in the same order as before, except that the driver's own pre-select for the third list is now 2 instead of 0, immediately overwritten by the same value from the list. A before/after lspci/AER row cannot show a difference.

What I would change:

  • Commit message and description: say that the driver's pre-select for the gen5 list was wrong and is now the DesignWare value, and that the in-tree DTs were not affected because their lists select the bank themselves. Drop "They overwrote the gen3 values ... the bank in use ended up with gen5's values" and "Every T6050 board with these tunables in its DT is affected (J714s, K116s)".
  • Fixes: implies a behaviour fix to backport; with no affected DT it reads better as a cleanup.
  • Optional: since the lists carry their own 0x890 record, the driver pre-select is redundant. Either keep it (as here) with a comment that it covers a list without the record, or drop the pre-select and require the record in the binding text.

Assisted-by: LLM (Claude:Opus 5.5)

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t6050: gen5 PCIe shadow tunables are written into the gen3 bank (shadow_sel)

1 participant