From f1effbd17a55f3ed3f95d18846963c4718d4a7af Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Tue, 24 Nov 2026 14:17:34 +1100 Subject: [PATCH 1/2] phy: apple: atc: keep a CIO link when its USB host stops, on every generation The PHY returns to its off mode when the dwc3 host or device on the port stops, except in a CIO mode (USB4 or Thunderbolt) on T8132, where the Type-C mux owns the mode and takes it down when the connection ends. Other generations power the PHY off under a live CIO link instead. dwc3 stops for every data role swap, not only for a cable change. On the M2 Mac mini (J473) with a host-to-host USB4 peer, a partner that leaves and comes back during s2idle can come back with the data roles swapped. At resume dwc3 goes from device to host, which takes the PHY off and back to USB4 within the same millisecond, while the peer is still training the link. The peer times out, the link never trains again, and the XDomain is gone until the next replug or sleep. A partner event in the next s2idle then stops the J473 for good (5 of 6 such sleeps hung on the bench). Nothing about this is specific to T8132: the router owns the lanes in a CIO mode on every generation, and the PIPE is parked before the check either way. Drop the generation from the condition. The Type-C mux still takes a CIO mode down on a real disconnect, an ordinary USB mode still ends with its host, and a CIO mode whose last transition failed is still taken down. Extend the USB3 host model: the CIO cases now run on the T8103 sequence (which T8112 and T600x use) as well as on T8132, and a mutation that restores the T8132-only condition is caught. Signed-off-by: Ryan Murray --- drivers/phy/apple/atc.c | 16 +++++++++------- tools/asahi/atc-usb3-tests.py | 29 +++++++++++++++++------------ 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/drivers/phy/apple/atc.c b/drivers/phy/apple/atc.c index 34d3aa12b8f4..a2ca45a8e8b9 100644 --- a/drivers/phy/apple/atc.c +++ b/drivers/phy/apple/atc.c @@ -4638,14 +4638,16 @@ static int atcphy_usb3_power_off(struct phy *phy) return ret; atcphy->t8103_usb3_retry = false; /* - * T8132 keeps DWC3 on the dummy PIPE while USB4/Thunderbolt owns the - * lanes. Stopping that USB host must not take the dock's PCIe and DP - * tunnels down before their drivers suspend. The Type-C mux owns the - * CIO mode and releases it when the connection ends. A CIO mode whose - * last transition failed is still taken down, as before. + * In USB4/Thunderbolt the router owns the lanes: dwc3 only had its PIPE + * on the router's USB3 adapter (or on the dummy backend), and that is + * parked above. Stopping the USB host, for a cable change or only for a + * data role swap, must not take the router's link down with it: that + * drops a host-to-host link, and a dock's PCIe and DP tunnels, before + * their drivers know. The Type-C mux owns the CIO mode and releases it + * when the connection ends. A CIO mode whose last transition failed is + * still taken down, as before. */ - if (atcphy->hw->gen == ATCPHY_GENERATION_T8132 && atcphy_mode_is_cio(atcphy->mode) && - !atcphy->mode_dirty) + if (atcphy_mode_is_cio(atcphy->mode) && !atcphy->mode_dirty) return 0; /* * dwc3 can tear its host down while a DisplayPort alt mode link is up, diff --git a/tools/asahi/atc-usb3-tests.py b/tools/asahi/atc-usb3-tests.py index 3a7955197c9f..2894ca2bd5e8 100644 --- a/tools/asahi/atc-usb3-tests.py +++ b/tools/asahi/atc-usb3-tests.py @@ -9,7 +9,7 @@ T600x/T8112/T602x still match the T8103 PHY fallback but keep their previous single-poll/BIST/role behavior. OF compatible lookup is a modeled boundary. The DT-to-driver match contract is checked from the actual sources. -T8132 cases cover CIO ownership during USB host shutdown; its lane setup +CIO ownership during USB host shutdown is covered on T8103 and T8132; T8132 lane setup and electrical behavior are not modeled. Hardware qualification remains necessary. Run --mutations for sensitivity checks. """ @@ -398,14 +398,17 @@ def block(source, marker): assert(atcphy_usb3_power_off(&phy)==-ETIMEDOUT);assert(!configure_calls); unlock_ret=0;assert(!atcphy_usb3_power_off(&phy));assert(p.mode==APPLE_ATCPHY_MODE_USB3_DP&&!configure_calls&&!p.t8103_usb3_retry&&!p.t8103_dummy_pending); } -static void t8132_usb_stop_keeps_cio_until_mux_disconnect(void) { +static void usb_stop_keeps_cio_until_mux_disconnect(void) { const enum atcphy_mode modes[] = { APPLE_ATCPHY_MODE_TBT, APPLE_ATCPHY_MODE_USB4 }; - for (unsigned i=0;i<2;i++) { - reset(ATCPHY_GENERATION_T8132,false);p.mode=modes[i];p.typec_mode=modes[i];p.host_active=true; + /* Every generation: T8112 and T600x run the T8103 PHY sequence. */ + const enum atcphy_generation gens[] = { ATCPHY_GENERATION_T8103, ATCPHY_GENERATION_T8132 }; + for (unsigned g=0;g<2;g++) for (unsigned i=0;i<2;i++) { + reset(gens[g],false);p.mode=modes[i];p.typec_mode=modes[i];p.host_active=true; assert(!atcphy_usb3_power_off(&phy)); assert(!p.host_active&&p.mode==modes[i]&&!configure_calls&&atcphy_rpm_busy(&p)); assert(!atcphy_dwc3_reset_assert(&p.rcdev,0)); assert(p.mode==modes[i]&&!configure_calls&&atcphy_rpm_busy(&p)&&usb2_power_off_calls==1); + if (gens[g]!=ATCPHY_GENERATION_T8132) continue; /* the OFF lane setup is modeled for T8132 only */ model_t8132_off=true; assert(!atcphy_mux_switch(&p,APPLE_ATCPHY_MODE_OFF)); assert(p.mode==APPLE_ATCPHY_MODE_OFF&&configure_calls==1&&!atcphy_rpm_busy(&p)); @@ -614,7 +617,7 @@ def block(source, marker): TEST(usb4_and_dead_parking_single_poll);TEST(early_host_and_device);TEST(early_admission_and_failure);TEST(later_off_and_bist_unchanged);TEST(success_only_all_generations); TEST(live_lock_failure_restores_masks);TEST(live_park_then_pending_completion);TEST(legacy_live_dispatch_and_generation);TEST(pending_blocks_lane_and_backend); TEST(canceled_lane_change_reconnects);TEST(role_finishes_pending);TEST(target_failure_preserves_reconnect);TEST(nonusb_commit_clears_retry);TEST(dp_assignment_d_retains_usb3);TEST(modern_safe_refusal_retained); - TEST(fixed_hub_host_dispatch);TEST(reset_release_retries_before_writes);TEST(reset_assert_failure_and_stop);TEST(power_off_preserves_dp_and_finishes_pending);TEST(t8132_usb_stop_keeps_cio_until_mux_disconnect);TEST(setup_known_reset_clears_obligations);TEST(target_mode_table_and_dirty); + TEST(fixed_hub_host_dispatch);TEST(reset_release_retries_before_writes);TEST(reset_assert_failure_and_stop);TEST(power_off_preserves_dp_and_finishes_pending);TEST(usb_stop_keeps_cio_until_mux_disconnect);TEST(setup_known_reset_clears_obligations);TEST(target_mode_table_and_dirty); TEST(lock_timeout_left_to_caller); printf("%u ATCPHY USB3 host cases passed\n",tests); } @@ -731,13 +734,15 @@ def harness(source): return PRELUDE + defines + "\n" + "\n".join(usb_defines) + "\n" + types + "\n" + table + stubs + functions + scope_c + TESTS -MUTATIONS = {'t8132-usb-stop-keeps-dirty-cio': ('atcphy_usb3_power_off', - '&&\n\t !atcphy->mode_dirty)', ')'), - 't8132-usb-stop-drops-cio': ('atcphy_usb3_power_off', - 'atcphy->hw->gen == ATCPHY_GENERATION_T8132 && atcphy_mode_is_cio(atcphy->mode)', 'false'), - 't8132-usb-stop-keeps-usb-too': ('atcphy_usb3_power_off', - 'atcphy->hw->gen == ATCPHY_GENERATION_T8132 && atcphy_mode_is_cio(atcphy->mode)', - 'atcphy->hw->gen == ATCPHY_GENERATION_T8132'), +MUTATIONS = {'usb-stop-keeps-dirty-cio': ('atcphy_usb3_power_off', + 'atcphy_mode_is_cio(atcphy->mode) && !atcphy->mode_dirty)', 'atcphy_mode_is_cio(atcphy->mode))'), + 'usb-stop-drops-cio': ('atcphy_usb3_power_off', + 'atcphy_mode_is_cio(atcphy->mode) && !atcphy->mode_dirty', 'false'), + 'usb-stop-keeps-usb-too': ('atcphy_usb3_power_off', + 'atcphy_mode_is_cio(atcphy->mode) && !atcphy->mode_dirty', '!atcphy->mode_dirty'), + 'usb-stop-keeps-cio-t8132-only': ('atcphy_usb3_power_off', + 'atcphy_mode_is_cio(atcphy->mode) && !atcphy->mode_dirty', + 'atcphy->hw->gen == ATCPHY_GENERATION_T8132 && atcphy_mode_is_cio(atcphy->mode) && !atcphy->mode_dirty'), 'no-live-retry': ('atcphy_pipehandler_lock_live', '? 10 : 1;', '? 1 : 1;'), 'retry-later-generations': ('atcphy_pipehandler_lock_live', '? 10 : 1;', '? 10 : 10;'), 'sleep-after-last': ('atcphy_pipehandler_lock_live', 'if (attempt + 1 < attempts)', 'if (true)'), From a9654421c21282bc4d092fa9d7b1bf04514c00c2 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Mon, 23 Nov 2026 11:32:56 +1100 Subject: [PATCH 2/2] drm/apple: dcp: disable the Type-C routes of a processor whose firmware is refused A display processor whose firmware-compat is not supported fails its probe with -ENODEV and never registers the Type-C display routes under its node. The USB-C port controllers that name such a route as their mode switch then wait for it for good: fwnode_typec_mux_get() keeps returning -EPROBE_DEFER, so the port is never registered and USB2, USB3, USB4 and the role switch stay down on every port the processor routes, not only DP alt mode. On the M2 Mac mini (J473) the routes of both USB-C ports sit on the primary DCP, which refuses the 27.2 firmware: both CD321x stay in "deferred probe pending" and neither USB-C port works at all. The firmware cannot change before the next boot, so disable the routes in the device tree on this refusal, as the processor failure paths that already give up for good do (dcp_native_routes_error(), dcp_ext_give_up(), dcp_platform_probe_t8132_ext()). The connector's graph lookup then skips the disabled route endpoints (fwnode_graph_devcon_matches()), the port takes the PHY mode switch alone, and the ports come up without DP alt mode on that processor. The routes stay disabled for the rest of the boot: a driver that would accept the firmware gets them back after a reboot, not by loading a newer module in the same boot. Selected by what the device tree describes (a typec-routes child of the refusing processor); a processor without one is unchanged. Signed-off-by: Ryan Murray --- drivers/gpu/drm/apple/dcp.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 0666748f436d..b6b5fe71c253 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -7197,8 +7197,16 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev) } fw_compat = dcp_check_firmware_version(dev); - if (fw_compat == DCP_FIRMWARE_UNKNOWN) + if (fw_compat == DCP_FIRMWARE_UNKNOWN) { + /* + * The firmware does not change until the next boot, so this + * processor never registers its Type-C display routes: disable + * them, so that the port controllers that name them as their + * mode switch do not wait for them, and USB on the ports goes on. + */ + dcp_typec_routes_disable_dev(dev); return -ENODEV; + } if (fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP || (fw_compat == DCP_FIRMWARE_V_27_0 && of_device_is_compatible(dev->of_node, "apple,t6041-dcp"))) {