Skip to content

thunderbolt: apple: request USB4 Gen4 wherever the host router has it (T6040/T6041 TB5) - #2301

Draft
RyanTheTide wants to merge 1 commit into
integration/aurorafrom
m4fam/t604x-usb4-gen4
Draft

RyanTheTide wants to merge 1 commit into
integration/aurorafrom
m4fam/t604x-usb4-gen4

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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_recovery in 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).

  • The Type-C switch records a Gen4 cable as Gen4 for every router.
  • Every place the cable word is written (first start and the two wake paths in apple-cio-sleep.c) goes through apple_nhi_cable_info(): a router without the Gen4 bit gets the 20 Gb/s word, exactly as before.
  • Gen4 link recovery is requested on every Apple host; the core (tb_switch_gen4_link_recovery()) returns early unless the link trained at Gen4.
  • gen4_cable and gen4_link_recovery are removed from apple_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_ASYM for its documented mid-transition drop; T6040 gets one only if a Gen4 row shows the same.

Testing

Still to run

  1. J616s USB4 partner row (needs the Thunderbolt cable to the M2 plugged back in): the lab cable to the M2 is a Gen4 (80G passive) cable and the M2 is Gen3, so this row checks the fallback directly. Expect cable word 0x801 in the debug log, the M2 XDomain still at 2 x 20.0 Gb/s each way, iperf3 >= 18 Gbit/s both ways, no new Dead End / link state / config timeout lines, across 3 partner hotplugs and one s2idle cycle. A drop to 10 Gb/s would mean the T6040 firmware reads the Gen4 word differently from T6050.
  2. Gen4 row (community): an M4 Pro/Max with a Thunderbolt 5 dock or a second M4 Pro/Max or M5 Pro/Max Mac and an 80 Gb/s cable. Expect rx_speed/tx_speed 40.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 from LANE_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)

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

1 participant