Repository navigation
thunderbolt: apple: request USB4 Gen4 wherever the host router has it (T6040/T6041 TB5) - #2301
Draft
RyanTheTide wants to merge 1 commit into
Draft
RyanTheTide wants to merge 1 commit into
RyanTheTide wants to merge 1 commit into
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 <ryan@aurorasilicon.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.Assisted-by: LLM (Claude:Opus 5.5)