Repository navigation
thunderbolt: apple: request USB4 Gen4 wherever the host router has it (T6040/T6041 TB5) - #2301
Conversation
The M4 Pro and M4 Max (T6040, T6041) ports are Thunderbolt 5 / USB4 v2 ports, but only the T6050 description asked its router for Gen4: the cable word for a Gen4 cable said Gen4 (0x801) on T6050 and 20 Gb/s (0x11) everywhere else, so T6040 links never got past Gen3, whatever the cable and the partner. Whether a host router can run Gen4 is in its own config space: USB4 v2 lane adapters report Gen4 in the Supported Link Speeds field of LANE_ADP_CS_0, USB4 v1 routers leave that bit clear. The J616s (T6040) host router reports it: its lane adapter target speed is 0xe (Gen2, Gen3 and Gen4) where the M2's is 0xc. Select Gen4 by that bit instead of by SoC: - The Type-C switch records a Gen4 cable as Gen4 for every router. - When the cable word is written (first start, and the wakes in apple-cio-sleep.c), a router whose lane adapters do not report Gen4 gets the 20 Gb/s word it got before. - Gen4 link recovery is requested on every Apple host. The core only touches links that trained at Gen4, so nothing changes on Gen2/Gen3 links. T6050 keeps the word it had. USB4 v1 routers keep the 20 Gb/s word (0x11). T6040/T6041 now send 0x801 on a Gen4 cable. The speed itself is still negotiated by the two routers: a Gen3 partner on a Gen4 cable is expected to train Gen3. Asymmetric links are left as they were: allowed by the core capability checks, and only reached through DP tunnels, which are off on T6040; T6050 keeps QUIRK_NO_ASYM for its documented link drop. Signed-off-by: Ryan Murray <[email protected]>
|
Blockers: 2. Selecting the cable word from the router's own Supported Link Speeds is the right direction. QUIRK_GEN4_LINK_RECOVERY on every host is safe: tb_switch_gen4_link_recovery() returns early when
HW row: on head: J616s plus the M2 over the 80G passive cable. The debug log shows CS_0 with Gen4, cable word 0x801, XDomain 2 x 20 Gb/s, iperf3 >= 18 Gbit/s both ways, 3 hotplugs and 1 s2idle with no link-state, config-timeout or Dead End lines. The M2 end of the same run logs 0x11 written. One T6050 owner row with a TB5 partner still at 40 Gb/s x 2. 0 AVC, 0 failed units. Assisted-by: LLM (Claude:Opus 5.5) |
|
J616s row: an RX 7900 XTX in a Thunderbolt 5 eGPU enclosure works over PCIe-C on the M4 Pro (left front port) Kernel:
Not yet: s2idle and a bound hot-unplug with the eGPU on this Mac. The GL per-frame latency floor needs a look (Vulkan is unaffected). Stopping GDM while mutter drove the eGPU outputs left DMUB failing ( EvidenceLab trace |
There was a problem hiding this comment.
Verdict: FINISH, then merge at fab82c82
Blockers:
drivers/thunderbolt/apple.c:2583-2598: the prior review blocker remains unaddressed atfab82c82.apple_nhi_host_gen4()still re-readsLANE_ADP_CS_0across every wake (drivers/thunderbolt/apple-cio-sleep.c:64,:297) and returnsfalseon read failure, silently downgrading a Gen4 host router to the 20 Gb/s cable word (0x11). Cache the host router's Gen4 capability once instruct apple_nhiduringapple_nhi_probe(), use the cached flag inapple_nhi_cable_info(), and warn if no lane adapter could be read at probe.- PR description is missing
Tested:andRisk:(two-way/one-way) lines, which will fail the queuedpr-text / pr-textcheck. Update the PR body to include both. - Wait for
pr-text / pr-textandreadiness / readinessCI to finish green after updating, and record a Gen3-partner / T6050 regression check once the cached probe path is in place (the 2026-11-28 J616s TB5 eGPU row already provedLANE_ADP_CS_00xe, cable word0x803, and 2 x 40 Gb/s Gen4 link bring-up on T6040).
Checked: no Apple material, no AI attribution, human DCO Signed-off-by, removes the SoC-gated gen4_cable and gen4_link_recovery fields from apple_cio_hw in favor of LANE_ADP_CS_0_SUPPORTED_SPEED_GEN4 capability probing, QUIRK_GEN4_LINK_RECOVERY is safe on non-Gen4 routers (core returns early when link generation < 4), branch is MERGEABLE against main.
Evidence
- Full diff (
+68/-19across 3 files:drivers/thunderbolt/apple.c,drivers/thunderbolt/apple-cio-sleep.c,drivers/thunderbolt/tb_regs.h) is unchanged atfab82c82since the 2026-11-21 review comment. - The 2026-11-28 J616s row (AOOSTAR EG02 JHL9480 TB5 + RX 7900 XTX) confirmed
LANE_ADP_CS_0advertises Gen4 (0xe) on T6040 and that cable word0x803brings up a 2 x 40 Gb/s TB5 PCIe-C tunnel (48.2 / 49.6 Gb/sSDMA), answering the T6040 firmware question; cachinghost_gen4at probe and updating the PR body (Tested:/Risk:) are the remaining items. - Non-blocking nit:
dev_dbginapple_cio_tbt_switch_set()logs the requestedtarget_cable_info(0x801) even on Gen3 hosts whereapple_nhi_cable_info()later downgrades it to0x11.
apple_nhi_host_gen4() read LANE_ADP_CS_0 of the host lane adapters every time a cable word was written, which includes both wake paths, and took a failed read for "no Gen4". A read that fails around a wake then hands a Gen4 cable on a Gen4 router the 20 Gb/s word, and the link comes back at Gen3 with nothing in the log. Supported Link Speeds is a property of the router silicon, so read it once at probe, right before the first cable word, keep it in struct apple_nhi and use the kept value from then on. Warn when none of the host lane adapters could be read at probe, since Gen4 cables are then limited to the 20 Gb/s word. Also say "requested" in the USB4 cable debug line: the word logged there is the one asked for, apple_nhi_cable_info() may still lower it. Signed-off-by: Ryan Murray <[email protected]>
There was a problem hiding this comment.
The probe reads capability after lane unlock and before the first cable write. Both wake paths use the cached result. Unreadable adapters warn and fall back without a SoC gate. Source blocker resolved. Keep exact-head Gen4, Gen3 partner and T6050 rows and hosted CI before landing.
|
J616s row at 2791740 (cache-at-probe head): PASS.
HowOne-shot of the same kernel and DT as the 11-28 row (main 844781f + #2069 + #3512 DT), with |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
T6050 regression row (K114s, M5 Pro) at exact head 2791740: PASS.
Unrelated to this PR, found in the same window: with the enclosure attached at boot, its internal PCIe link (JHL9480 downstream port to the GPU) trains at 8 GT/s and caps tunnel DMA at ~24-26 Gb/s; a hot-plug or a USB4 port restart retrains it at 16 GT/s (48-50 Gb/s). Tracked separately. |
|
Closing and reopening to retrigger CI on the new aurora-buildbox runners (linux#3572 merged); no code change. Same head 2791740. |
|
Merging at |
What
M4 Pro/Max (T6040/T6041) Thunderbolt 5 ports never got past Gen3: the driver asked only the T6050 router for Gen4. This picks the Gen4 cable word from the host router's own Supported Link Speeds (
LANE_ADP_CS_0) instead of a SoC flag. The router capability is read once at probe and cached instruct apple_nhi, so a failed read around a wake can no longer silently drop a Gen4 router to the 20 Gb/s word.Tested
Training TO HL0, Gen4), and the link comes up at Gen3,current link speed 20.0 Gb/s, as before.drivers/thunderbolt/apple.o, no new warnings; checkpatch clean. On a successful probe read the result is the same as at fab82c8.Risk
two-way: shared Apple USB4 code. T6050 should be unchanged (it reports Gen4 in
LANE_ADP_CS_0and keeps 0x801). USB4 v1 routers (M1/M2/M3) keep 0x11. Revert = back to the SoC flag.Not yet
Original description (problem, change, follow-up rows)
Problem
The M4 Pro and M4 Max (T6040/T6041) Thunderbolt ports are Thunderbolt 5 / USB4 v2 ports, but the driver only asked the T6050 router for Gen4. On T6040 a Gen4 (80 Gb/s) cable was always described to the router as a 20 Gb/s cable (cable word 0x11), so no T6040 link could get past Gen3, whatever the partner. The choice was made by SoC (
gen4_cable/gen4_link_recoveryin the T6050 description only).Change
Gen4 is now selected by what the host router reports about itself: USB4 v2 lane adapters set the Gen4 bit in the Supported Link Speeds field of
LANE_ADP_CS_0; USB4 v1 routers leave it clear. The J616s (T6040) router reports it (its lane adapter target speed is 0xe = Gen2|Gen3|Gen4; the M2's is 0xc).apple-cio-sleep.c) goes throughapple_nhi_cable_info(): a router without the Gen4 bit gets the 20 Gb/s word, exactly as before.tb_switch_gen4_link_recovery()) returns early unless the link trained at Gen4.gen4_cableandgen4_link_recoveryare removed fromapple_cio_hw. No chip list is left.Net effect: T6050 unchanged (0x801), USB4 v1 routers unchanged (0x11), T6040/T6041 send 0x801 on a Gen4 cable.
Asymmetric 120/40 is not forced: the core already gates it on the lane adapters' asym capability and a Gen4 link, and only DP tunnel bandwidth triggers it, which is off on T6040 today. T6050 keeps
QUIRK_NO_ASYMfor its documented mid-transition drop; T6040 gets one only if a Gen4 row shows the same.Testing
drivers/thunderbolt/builds with W=1 (arm64, gcc), no new warnings.thunderbolt_apple.ko. No USB4 partner was cabled during this boot, so the NHI never probed and the Gen4 cable-word path did not run. This shows no boot or probe regression only.Still to run
rx_speed/tx_speed40.0 Gb/s x 2 lanes.Why the speed cannot be forced past what the link supports
The cable word only tells the router firmware what the cable carries. Link speed is negotiated by the two routers in lane initialisation from each end's supported speeds; Linux never sets a target speed (
tb_xdomain_link_state_change()keeps the current target speed and only changes width) and reads the result back fromLANE_ADP_CS_1(tb_port_get_link_generation()). A Gen4 cable carries Gen3. The open question is only how the T6040 firmware reads the vendor Gen4 cable bit, which row 1 answers on the existing lab link.