Skip to content

phy: apple: atc, mux: display-crossbar: select tunnel clocks and crossbar flows by compatible, retry only an owed SuperSpeed power-on - #2457

Draft
RyanTheTide wants to merge 12 commits into
mainfrom
hack/round3-a
Draft

RyanTheTide wants to merge 12 commits into
mainfrom
hack/round3-a

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What: phy: apple: atc, mux: display-crossbar: select tunnel clocks and crossbar flows by compatible, retry only an owed SuperSpeed power-on. This PR now carries these drafts as one feature (merge commits, the commits themselves unchanged):

Tested: each part as tested on its own PR (folded bodies below; no hardware row on this head yet). Combined with current main (ba29027) together with the other folds of 11-25: full arm64 build (Image, modules, dtbs; fleet89 config, clang 22, rustc 1.97.1) clean.

Risk: two-way · M1/M2 Pro/Max, M3 Pro, Neo (ATC, display crossbar)

Not yet: dock/USB-C display rows on M1 Pro (J316s) and M2 (J413) and a Neo crossbar row on this head.

#2457 original description

Stacked on #2415 (hack/drm-board-gates2-b), whose apple,t6020-atcphy match entry this uses; review only the top commit. Merge #2415 first.

Problem

The T602X (M2 Pro/Max) DP tunnel pixel clock in drivers/phy/apple/atc.c was admitted by checks in drivers/phy/apple/atc-tunnel.h that do not describe the hardware:

  • apple_atc_t602x_qualified() (atc-tunnel.h:9) read the root (machine) compatible, apple,t6020 or apple,t6021, at probe (apple_atc_tunnel_wiring()).
  • apple_atc_t602x_core_valid() (atc-tunnel.h:15) accepted only PHYs whose core registers start at 0x703000000, 0xb03000000 or 0xf03000000, and were at least 0x7048 bytes long.

Both came in with Oliver Lukschander's first T602X tunnel clock (14f86a8, "a recognized Type-C core address", then gated to apple,j416s) and were kept by Chris Kearney's c30adcc, which added the real qualification: the PHY's Type-C connector must be wired to both DP IN adapters of its router (apple_dp_tunnel_dual_stream()). The address list stood for "atcphy0-2 of J414/J416, not atcphy3", because on those boards atcphy3 drives the HDMI port. The connector wiring already says that: atcphy3 has no Type-C connector there. The list was kept only so that atcphy3 answered -EINVAL instead of -EOPNOTSUPP. The root check stood for "this PHY has a clock per DP IN adapter", which is a property of the PHY block.

Change

  • A tunnel_dpin_clocks flag in the match data of apple,t6020-atcphy (the entry from phy: apple: atc: select the T8103 and T600x tunnel clocks by PHY compatible #2415) says the PHY has the per-DP IN clock (atc_tunnel_set_t602x()). Probe reads it instead of the root compatible.
  • apple_atc_dp_tunnel_rate() admits a T602X-style rate only if the PHY has that flag and its connector has the dual-stream wiring (apple_atc_dpin_clock_gate()). Otherwise it returns -EOPNOTSUPP.
  • The address list, the scan of the other connectors and tunnel_routes_present are removed. The size check is removed too. Every atcphy core is 0x4c000 bytes. The lane setup of every mode change (atcphy_configure_lanes()) already writes LN1_AUSPMA_RX_TOP at 0x10000, beyond the highest tunnel clock register (ACIOPHY_DP_PCLK_STAT, 0x7044).

No device tree or binding change is needed. The distinguishing property (the typecN-dpin0/typecN-dpin1 crossbar controls plus two port@3 endpoints, or the legacy typecN-usb4 names) is already in apple,dcp-typec-routes.yaml and in t602x-j414-j416.dtsi.

Every SoC this reaches gets the same tunnel clock decision as before:

SoC / board PHY compatible Before After
T6020/T6021 J414s/J414c/J416s/J416c atcphy0-2 apple,t6020-atcphy, dual-stream connector admitted admitted
same boards, atcphy3 (HDMI) apple,t6020-atcphy, no connector -EINVAL -EOPNOTSUPP (no caller routes a tunnel to it)
T6020/T6021 J474s/J475c apple,t6020-atcphy, no DP IN wiring -EOPNOTSUPP -EOPNOTSUPP
T6022 J180d/J475d apple,t6020-atcphy, no DP IN wiring -EOPNOTSUPP (root) -EOPNOTSUPP (wiring)
T8103, T8112, T600x t8103/t6000-atcphy T8103 sequence unchanged
T6030, T8132 t6030/t8132-atcphy T8122 clock unchanged
T8122, T6031, T8140, others no flag -EOPNOTSUPP -EOPNOTSUPP

Testing

  • Built for arm64 (LLVM, W=1, release config, CONFIG_PHY_APPLE_ATC_KUNIT_TEST=y): drivers/phy/apple/atc.o built with no compiler warnings. The kernel-doc warnings for struct apple_atcphy are identical before and after.
  • checkpatch --strict: clean, apart from the unknown-commit-id warnings that --no-tree always gives.
  • KUnit apple-atc-tunnel: the old root/address cases are replaced by atc_tunnel_dpin_clock_gate (the gate) and atc_tunnel_clock_by_compatible (which tunnel clock each PHY compatible's match data selects). Ran on arm64 QEMU with kunit.py run --arch=arm64 --kunitconfig=drivers/phy/apple/.kunitconfig.apple-atc 'apple-atc-tunnel': 6/6 passed.
  • Host tests (tools/asahi/run-host-tests.py --only ...): atc-usb3 (with mutations), atc-cio-sleep, t6030-clock, tunnel-route and hardware-defaults: all passed.

Still to run

No lab Mac has a T602X PHY. The paths the lab Macs run (T8103-style on M1 Pro and M2, and the T8140 PHY on Neo, which gets -EOPNOTSUPP as before) are unchanged. Regression rows:

  • M1 Pro (J316s, T6000): a display behind a Thunderbolt dock lights as before. dmesg | grep -i 'tunnel' shows no new refusals.
  • M2 (J413, T8112), Neo (J700, T8140), J616s (T6040): boot. USB-C storage enumerates. dmesg | grep -iE 'atcphy|tunnel' matches the base kernel.

Owner row (J414s/J416s/J414c/J416c, M2 Pro/Max laptop): with echo 'file atc.c +p' > /sys/kernel/debug/dynamic_debug/control, connect a display through a Thunderbolt dock to each of the three USB-C ports in turn. Each should light, with DP tunnel clock rate 0x..: 0 in dmesg and no no DP tunnel pixel clock on dpin warning, the same as on the base kernel. The HDMI port should behave as before.

Why the address list is equivalent to the connector wiring

t602x-dieX.dtsi declares atcphy0-3 identically (apple,t6020-atcphy, core 0x4c000 bytes at 0x703000000, 0xb03000000, 0xf03000000, 0x1303000000; die 1 adds 0x2000000000). On J414/J416, t602x-j414-j416.dtsi gives atcphy3 only port@2 (the dcpext0 HDMI output), so of_graph_get_remote_node(np, 0, -1) is NULL and apple_dp_tunnel_dual_stream() is false. typec0-2 (atcphy0-2) have two port@3 endpoints whose routes name typecN-dpin0/typecN-dpin1. On J474/J475, T6021 display2 and T6022, no route names DP IN controls, so no connector is dual-stream. Before this change, those PHYs got -EOPNOTSUPP because tunnel_routes_present was false, and they still do.

Original T602X tunnel clock by Oliver Lukschander. Connector wiring qualification by Chris Kearney.

Hardware rows (combined test kernel, 2026-11-20)

This change was booted in a combined test kernel: integration/aurora 0abc2f3 plus the open gate-sweep drafts plus this and the related drafts (7.3.0-aurora-hk2/pwr1/hk3). It ran once on each lab Mac (M1 Pro J316s, M2 J413, J616s, Neo J700) and was compared against the production kernel on the same Mac, using the same silent row script:

  • kernel errors, failed units and SELinux denials;
  • microphone capture byte counts;
  • camera frame counts;
  • USB speeds;
  • panel brightness steps;
  • every retry/refusal message these drafts touch;
  • 2 s2idle cycles on M1 Pro, M2 and J616s.

M1 Pro, M2 and J616s matched production on every row, apart from the new counters and lines the drafts add. The Neo row found the old-DTB display regression that #2358's follow-up commit fixes.

This PR: No lab Mac has a T602x; boot-clean regression rows only.

#2409 original description

Problem

drivers/phy/apple/atc.c retries the power-on of a fixed-hub controller's SuperSpeed root port that a Type-C mux update still owes (atcphy_usb3_port_retry(), added in 5f5dc5f, "phy: apple: atc: Retry a SuperSpeed port power-on that a mux update owes"). It is reached only on a fixed-hub PHY with the T8140 DisplayPort path, which is the J700 rear port today.

atcphy_mux_update_to() hands every USB-side failure to the retry, also a failure to look up the root hub or to take the port down. When no port was held off there is nothing to power on: the retry work still takes the controller, xHCI and root hub locks up to five times over about three seconds, which waits for any enumeration in progress, and if the lookup keeps failing it warns "SuperSpeed port left off" about a port that was never off. The same happens for a port held off once its host or root hub is gone (-ENODEV, -ESHUTDOWN). No retry can bring that port back. The next host powers its root hub ports itself as it starts, and atcphy_usb3_set_mode() drops the debt then.

After a sleep in place, atcphy_common_restore() falls back to USB2 when it cannot set a USB3 mode up again, and warns "USB2 for now". The second attempt that this message promises is atcphy_sleep_ss_up(), which logged its result at debug level only. If that attempt failed as well, the port stayed at USB2 until the next Type-C event, and the log said nothing beyond the first warning.

Change

  1. atcphy_usb3_port_retry() now schedules a retry only for a port that is still held off (usb3_port_off), and not after -ENODEV or -ESHUTDOWN. The case the retry was added for is unchanged: a power-on request to a running root hub that failed for want of memory, after a failed runtime resume, or while a controller or hub driver was not bound yet. Nothing signals when such a request would succeed, so the bounded backoff (100 ms doubling, five tries, about 3 s, then a warning) stays. Each failed power-on is still logged by atcphy_usb3_port_on() as it happens. The comment now says what is retried and why.
  2. atcphy_sleep_ss_up() warns when applying the mode again fails. The fallback's comment and message name the path that applies the mode again, and say that after a power cycle outside a sleep in place only the next Type-C event does. Why the set-up can fail after a sleep is not known yet. That is tracked in phy: apple: atc: USB3 mode not set up again after a sleep falls back to USB2, cause unknown #2314.

Both changes only affect the error paths of the fixed-hub T8140 PHY. On every other ATC PHY atcphy_usb3_pm_get() returns 0 without a root hub, usb3_port_off is never set, and the retry was not reachable before either. The sleep-in-place path exists only on fixed-hub T8140. No register access changes.

The sleep path is Diljit Singh's, from d9b438c ("arm64: apple: support coordinated suspend-to-RAM on T8140").

Testing

  • arm64 LLVM W=1 build of atc.o (with the KUnit tests compiled in) at both commits, release config: 0 warnings. checkpatch --strict is clean.
  • New KUnit case (compiled, not run, see below) atcphy_test_update_port_unowed. With no port held off, a root hub that is not bound yet leaves no retry queued. A held-off port behind such a hub is retried, until the host is gone (-ENODEV). A dead controller that fails the power-on with -ESHUTDOWN queues no retry. The existing retry cases (-ENOMEM power-on retried, given up after five tries, host gone) are unchanged.
KUnit and build

Objects built against an O= dir prepared from base 0abc2f3 with the release config (CONFIG_PHY_APPLE_ATC=m, CONFIG_PHY_APPLE_ATC_KUNIT_TEST=y, so the tests are compiled into atc.o): make ARCH=arm64 LLVM=1 W=1 atc.o, run at each of the two commits. Both builds: rc 0, 0 warnings. checkpatch --strict: 0 errors, 0 warnings, 0 checks on both patches.

The KUnit suite was compiled but not run. Running it needs a full arm64 kernel and modules for QEMU, which was not built for this change. Run with: ./tools/testing/kunit/kunit.py run --arch=arm64 --kconfig_add CONFIG_PHY_APPLE_ATC=y --kconfig_add CONFIG_PHY_APPLE_ATC_KUNIT_TEST=y 'phy-apple-atc*' (or load phy-apple-atc.ko on any arm64 kernel with KUnit and read /sys/kernel/debug/kunit/*/results).

Still to run

  • KUnit phy-apple-atc on arm64 (command below).

On J700 (T8140), with a USB3 device on the rear port:

  • Boot, then lsusb -t: the device is at 5000M, and dmesg | grep -c 'SuperSpeed port left off' is 0. It was also expected to be 0 before this change, so the row checks for regressions.
  • DisplayPort and USB3 through a dock, with a pin assignment change (replug the DP sink): USB3 comes back at 5000M, and there is no "SuperSpeed port left off" line.
  • s2idle and the deep sleep, where the lab allows it (rtcwake -m freeze -s 15, then the deep sleep path): after resume lsusb -t shows 5000M again, and the log has neither "not set up again after the sleep" nor "not applied again after the sleep". If either line shows up, it goes to phy: apple: atc: USB3 mode not set up again after a sleep falls back to USB2, cause unknown #2314 with the error code.
Hardware rows (combined test kernel, 2026-11-20)

This change was booted in a combined test kernel: integration/aurora 0abc2f3 plus the open gate-sweep drafts plus this and the related drafts (7.3.0-aurora-hk2/pwr1/hk3). It ran once on each lab Mac (M1 Pro J316s, M2 J413, J616s, Neo J700) and was compared against the production kernel on the same Mac, using the same silent row script:

  • kernel errors, failed units and SELinux denials;
  • microphone capture byte counts;
  • camera frame counts;
  • USB speeds;
  • panel brightness steps;
  • every retry/refusal message these drafts touch;
  • 2 s2idle cycles on M1 Pro, M2 and J616s.

M1 Pro, M2 and J616s matched production on every row, apart from the new counters and lines the drafts add. The Neo row found the old-DTB display regression that #2358's follow-up commit fixes.

This PR: "SuperSpeed port left off" and "not set up again after the sleep": 0 on all four Macs, including after 2 s2idle cycles on J616s, M1 Pro and M2.

#2414 original description

Problem

The Apple display crossbar driver (drivers/mux/apple-display-crossbar.c) chose two behaviours by the machine's root compatible instead of by the crossbar block:

  • apple_dpxbar_probe() (~1325) turned on the T6030 flow, where selecting an output only routes it and its link-up starts its clocks, when of_machine_is_compatible("apple,t6030"). This came from 6a6ee2a ("thunderbolt, phy, soc: apple: T6030 USB4/Thunderbolt, Type-C and DP tunnel support").
  • apple_dpxbar_set_t602x() (~381) kept the original T602x gate sequence on the physical DP output when of_machine_is_compatible("apple,j700"). In that sequence CROSSBAR_ATC_EN and CROSSBAR_DISPEXT_EN are not written, and teardown restores the read reset in FIFO_RD_PCLK1_EN. This came from aa41619 ("mux: apple: retain the physical J700 crossbar gate sequence").

Both are properties of the crossbar IP. The T6030 crossbars already carry "apple,t6030-display-crossbar", "apple,t6020-display-crossbar" in t6030.dtsi and the binding, but the driver only matched the fallback. The J700 crossbar is the T8140's, which t8140.dtsi described with the T6020 compatible alone.

Change

  • New match entry apple,t6030-display-crossbar: the T6020 data plus t6030_flow, which the T6041 and T8132 entries already use.
  • New match entry apple,t8140-display-crossbar: the T6020 data plus a new dpphy_t602x_gates flag. A comment on the struct says what the flag does.
  • The binding lists apple,t8140-display-crossbar with the T6020 fallback, and t8140.dtsi gives dpxbar0 that compatible.
  • Neither machine check is left in the driver.

Why every SoC is safe: the T6030 crossbars (J514s, J516s) and the one T8140 crossbar (J700) get the flows they had. Every other crossbar node matches the same entry as before: T8103, T8112, T6000, T6020, T6031, T8122, T6041, T8132, T8142 and T6050. The other users of the T6020 compatible in drm/apple, display-gate and the J613 gate check of_device_is_compatible() on the fallback, which is still there. A J700 booted with an older DTB that lacks the new compatible gets the T6020 sequence on its DP output. The DTB ships with the kernel.

Original work: Chris Kearney (T6030 flow) and the J700 gate sequence commit; this only changes how each is selected.

Testing

  • arm64 LLVM W=1 build of drivers/mux/apple-display-crossbar.o: no warnings.
  • t8140-j700.dtb and t6030-j514s.dtb build. The J700 dtb has compatible = "apple,t8140-display-crossbar", "apple,t6020-display-crossbar" on display-crossbar@40b04c000.
  • Host tests dcpext26-crossbar-union, tiled-split and t6030-wiring pass.
  • No KUnit suite covers this driver.

Still to run

  • Neo (T8140 J700): plug a DP/HDMI display into the physical DP output (DPPHY). Expect apple-display-crossbar 40b04c000.display-crossbar: Switched dpphy to dispext... and a picture, the same as on the base kernel. A/B against the base kernel: picture on 5/5 hotplugs on both.
  • M3 Pro (J514s/J516s, if one is available): a Thunderbolt dock display comes up as on the base kernel (t6030_dpin path).
  • J616s, M1 Pro and M2 are not affected.
Hardware rows (combined test kernel, 2026-11-20)

This change was booted in a combined test kernel: integration/aurora 0abc2f3 plus the open gate-sweep drafts plus this and the related drafts (7.3.0-aurora-hk2/pwr1/hk3). It ran once on each lab Mac (M1 Pro J316s, M2 J413, J616s, Neo J700) and was compared against the production kernel on the same Mac, using the same silent row script:

  • kernel errors, failed units and SELinux denials;
  • microphone capture byte counts;
  • camera frame counts;
  • USB speeds;
  • panel brightness steps;
  • every retry/refusal message these drafts touch;
  • 2 s2idle cycles on M1 Pro, M2 and J616s.

M1 Pro, M2 and J616s matched production on every row, apart from the new counters and lines the drafts add. The Neo row found the old-DTB display regression that #2358's follow-up commit fixes.

This PR: Neo (hk3, production DTB without the new crossbar compatible): boot-clean, internal panel up, 0 kernel errors. The physical DP output row with an attached display is still to run.

…owed

atcphy_mux_update_to() hands every USB-side failure to
atcphy_usb3_port_retry(), also a failure to look up the root hub or to
take the port down. When no port was held off, nothing is owed: the
retry work only takes the controller, xHCI and root hub locks five
times over about three seconds, which waits for any enumeration in
progress, and if the lookup keeps failing it ends in "SuperSpeed port
left off" for a port that was never off. The same happens for a port
held off once its host or root hub is gone (-ENODEV, -ESHUTDOWN): no
retry can bring that port back, and the next host powers the ports of
its root hubs itself as it starts, where atcphy_usb3_set_mode() drops
the debt.

Schedule a retry only for a port that is still held off, and not for
a host that is gone. What is left is the case the retry was added for:
a power-on request to a running root hub that failed for want of
memory, a failed runtime resume, or a controller or hub driver not
bound yet. Nothing signals when such a request would succeed, so the
bounded backoff stays, and each failed power-on is still logged as it
happens. Document what is retried and why.

Fixes: 5f5dc5f ("phy: apple: atc: Retry a SuperSpeed port power-on that a mux update owes")
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
… compatibles

The T6030 display paths were selected by the root compatible
(of_machine_is_compatible("apple,t6030")):

 - dcp-fabric.c: the tunnel pixel clock sources a route may use
   (dcp_route_tunnel_clock_blocked(), dcp_route_clock_rate(),
   dcp_tunnel_set_rate()) and the explicit crossbar link-up of a direct
   output (dcp_direct_crossbar_link());
 - atc.c: the T8122-generation tunnel clock (apple_atc_tunnel_t8122_clock())
   and the matching stop before a mode change (atcphy_configure()).

What these follow is hardware: the T6030 display crossbars, where a
selected output is only routed until its link is brought up and only
external sources 0 and 2 reach the ATC PHY's tunnel pixel clocks, and
the T6030 ATC PHY, which clocks both DP IN outputs from its own AUSPLL
tunnel clock. Every display processor behind those crossbars is an
apple,t6030-dcp or apple,t6030-dcpext, and every such PHY an
apple,t6030-atcphy.

Select them by those compatibles, through match data: a t6030_fabric
flag for the two T6030 processors, read by dcp_is_t6030_fabric(), and a
t8122_tunnel_clock flag for the PHY, set in a new apple,t6030-atcphy
entry (the T8122 PHY data plus the flag) and in the T8132 PHY data. The
PHY's mode change reads the same flag; a T8132 PHY never reaches that
path (atcphy_configure_t8132()), so it is the condition it had.

No functional change on any in-tree device tree: the T6030 machines
(J514s, J516s) carry exactly these compatibles, and no other SoC does
(T6031/T6034 use apple,t6031-*, T8122 apple,t8122-*). Whether the T8122
and T6031 PHYs, of the same generation, want the same tunnel clock
sequence is not known and is not changed here.

The host fixtures that replay these functions model the match data the
way they modelled the machine check, and the ATC USB3 host test now
resolves the new apple,t6030-atcphy entry.

Fixes: 6a6ee2a ("thunderbolt, phy, soc: apple: T6030 USB4/Thunderbolt, Type-C and DP tunnel support")
Fixes: 9e03c19 ("drm/apple: reserve the T6030 HDMI processor with source-aware tunnel clocks")
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…s unused

The PHY host fixtures in phy.py define of_machine_is_compatible() for
the ATC functions they extract. Since the T6030 tunnel clock stop in
atcphy_configure() reads the PHY's match data instead of the machine,
no extracted function calls the mock any more, and the units fail to
build under -Werror=unused-function. Mark the two mocks unused, as the
fixtures do for other optional stubs.

Fixes: 6cb4c3e ("drm/apple, phy: apple: atc: select the T6030 display fabric by its IP compatibles")
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…patible

Two crossbar behaviours were selected by the root compatible:

 - the T6030 flow, where selecting an output only routes it and its
   link-up starts its clocks, by of_machine_is_compatible("apple,t6030")
   in apple_dpxbar_probe();
 - the original T602x gate sequence of the physical DP output (no
   CROSSBAR_ATC_EN/CROSSBAR_DISPEXT_EN writes, read reset restored in
   FIFO_RD_PCLK1_EN), by of_machine_is_compatible("apple,j700") in
   apple_dpxbar_set_t602x().

Both follow the crossbar block, not the board. The T6030 crossbars are
already "apple,t6030-display-crossbar", "apple,t6020-display-crossbar"
in t6030.dtsi and the binding, but the driver only matched the fallback.
The J700 crossbar is the T8140's, which t8140.dtsi described with the
T6020 compatible alone.

Add match entries for both: apple,t6030-display-crossbar (the T6020 data
with t6030_flow, as the T6041 and T8132 entries already set it) and
apple,t8140-display-crossbar (the T6020 data with a new
dpphy_t602x_gates flag), list the T8140 compatible in the binding with
the T6020 fallback, and give the T8140 node its own compatible.

No functional change on the in-tree device trees: the T6030 crossbars
and the one T8140 (J700) crossbar get the flows they had; every other
crossbar matches the same entry as before. A J700 booted with an older
DTB, which lacks the T8140 compatible, gets the T6020 sequence on its
DP output; the DTB ships with the kernel.

Fixes: aa41619 ("mux: apple: retain the physical J700 crossbar gate sequence")
Fixes: 6a6ee2a ("thunderbolt, phy, soc: apple: T6030 USB4/Thunderbolt, Type-C and DP tunnel support")
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…atible

The DP tunnel pixel clock sequence of a T8103-generation PHY was picked
by the root compatible: apple_atc_tunnel_is_t600x() (apple,t6000 or
apple,t6001) and apple_atc_tunnel_is_t8103_style() (apple,t8103,
apple,t8112 or T600x). A T8103-style PHY feeds both DP IN adapters from
one AUSPLL pixel clock; a T600x one also runs PCLK2 and the DPRX clock
and is opened before the first rate request; every other PHY took the
per-DP IN T602x sequence.

Which of these a PHY needs is a property of the PHY: the T8103 and
T8112 PHYs ("apple,t8103-atcphy", the T8112 one through its fallback),
the T600x PHY ("apple,t6000-atcphy") and the T602x PHY
("apple,t6020-atcphy") all share the T8103 register generation and match
data today. Give the T600x and T602x PHYs their own match entries (the
T8103 data, which they get now through the fallback) and say in the
match data which tunnel clock they have: tunnel_t8103_clock for the
T8103 entry and T600x, tunnel_dprx_clock for T600x only.
apple_atc_dp_tunnel_open() now answers -EOPNOTSUPP for a PHY of another
driver before it looks at the match data, as it did on every machine
but T6000/T6001.

No functional change on T8103, T8112, T6000, T6001 and T602x. T6002
(M1 Ultra), whose PHYs are the same apple,t6000-atcphy blocks
(t600x-dieX.dtsi) but whose root compatible was not in the list, now
gets the T600x sequence instead of the T602x one; there the T602x path
refused every rate with -EOPNOTSUPP, as T6002 has no T602x tunnel
wiring (apple_atc_t602x_qualified()).

The ATC USB3 host test resolves the two new entries.

Fixes: 49fa065 ("phy: apple: atc: run the t8103 tunnel clock sequence on t600x")
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
When atcphy_common_restore() cannot set a USB3 mode up again after a
sleep in place, it falls back to USB2 and warns "USB2 for now", saying
that the mux update after the wake tries the mode again. That second
attempt is atcphy_sleep_ss_up(), which logs its result at debug level
only: if it fails too, the port stays at USB2 until the next Type-C
event, and the log has nothing beyond the first warning to say so.

Warn when atcphy_sleep_ss_up() fails, and say in the fallback's comment
and message which path applies the mode again, and that after a power
cycle outside a sleep in place only the next Type-C event does. Why the
set-up can fail after the sleep is not known yet; that is tracked in
#2314.

The sleep path is Diljit Singh's, from commit d9b438c ("arm64:
apple: support coordinated suspend-to-RAM on T8140").

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…nnector wiring

The per-DP IN tunnel pixel clock of the T602X PHY
(atc_tunnel_set_t602x()) was admitted by three checks in atc-tunnel.h:

 - apple_atc_t602x_qualified(): the root compatible is apple,t6020 or
   apple,t6021, read in apple_atc_tunnel_wiring() at probe;
 - apple_atc_t602x_core_valid(): the PHY is an apple,t6020-atcphy whose
   core registers start at 0x703000000, 0xb03000000 or 0xf03000000 and
   are at least 0x7048 bytes long;
 - the PHY's connector is wired to both DP IN adapters of its router
   (apple_dp_tunnel_dual_stream()), or -EINVAL instead of -EOPNOTSUPP
   if some other connector is.

The address list comes from Oliver Lukschander's first T602X tunnel
clock, commit 14f86a8 ("phy: apple: atc: add DisplayPort tunnel
clock support for USB4/TBT"), as "a recognized Type-C core address".
On J414/J416, the only T602X boards whose display routes reach the DP
IN adapters, atcphy0-2 (those three addresses) serve the Type-C ports
and atcphy3 (0x1303000000) drives the HDMI port. Chris Kearney's
commit c30adcc ("thunderbolt: apple: Qualify display tunnels by
connector wiring") then added the connector wiring, which says the
same from the device tree: atcphy3 there has no Type-C connector, so
it has no dual-stream wiring, and neither has any connector of the
T602X desktops (J474/J475, T6022). The address list was kept only to
keep the -EINVAL. The root check stood for "this PHY has a clock per
DP IN", which is a property of the PHY: every apple,t6020-atcphy
(atcphy0-3 of every T602X die) has it, and the PHYs of other SoCs that
reach this path (T8122, T6031, T8140 and later) do not; they reached
it only because they are neither T8103- nor T6030-style.

Say it in the match data: a tunnel_dpin_clocks flag in the
apple,t6020-atcphy entry added by commit e583b4e ("phy: apple:
atc: select the T8103 and T600x tunnel clocks by PHY compatible"),
read at probe instead of the root compatible, and admit a rate only
for such a PHY whose connector has the dual-stream wiring. The address
list, the scan of the other connectors and tunnel_routes_present go.
So does the core size check: every atcphy core is 0x4c000 bytes, and
the lane setup of every mode change (atcphy_configure_lanes()) already
writes LN1_AUSPMA_RX_TOP at 0x10000, past the highest tunnel clock
register (ACIOPHY_DP_PCLK_STAT at 0x7044), so a PHY in the USB4 mode
the clock requires has that much.

No change in which PHYs get a tunnel clock on any in-tree device tree:
atcphy0-2 of J414s/J414c/J416s/J416c as before, nothing elsewhere. The
J414/J416 atcphy3, to which no caller routes a tunnel, now answers
-EOPNOTSUPP instead of -EINVAL. KUnit checks the gate and which tunnel
clock each PHY compatible selects.

Fixes: c30adcc ("thunderbolt: apple: Qualify display tunnels by connector wiring")
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Looks good; approve once #2415 has landed, this is rebased onto it, and the M2 Pro/Max owner row has run.

What I checked in the top commit (71e7424):

  • apple_atc_dp_tunnel_rate() (drivers/phy/apple/atc.c:5136-5141) and apple_atc_tunnel_wiring() (atc.c:6830-6838) now gate on atcphy_hw_t6020.tunnel_dpin_clocks (atc.c:7967) plus the connector's dual-stream wiring. That is block match data, not the machine. Every other PHY on the non-T8103, non-T6030 path (T8122, T6031, T6040, T8140) has no flag and still gets -EOPNOTSUPP, as it did through tunnel_routes_present.
  • DP IN routes appear only in t602x-j414-j416.dtsi. None of the J474s, J475c, J180d or J475d peripheral files names typecN-dpin* or typecN-usb4 mux controls. So apple_dp_tunnel_dual_stream() (include/linux/soc/apple/dp-tunnel.h:281) is false on every T602X desktop PHY and on the J414/J416 atcphy3. That matches the table in the description. The only behaviour change is -EINVAL to -EOPNOTSUPP on atcphy3. The DCP caller (dcp-fabric.c:512-520) passes the error straight up; no caller routes a tunnel to atcphy3.
  • Dropping the size check is safe: atcphy_configure_lanes() already writes past 0x7044 on every mode change.
  • Commits carry only a human Signed-off-by, and host-tests pass.
  1. The PR doesn't merge into integration/aurora as it stands. The conflicts are in drivers/gpu/drm/apple/dcp-fabric.c and tools/asahi/dcpext26-crossbar-union-tests.py, both from the phy: apple: atc: select the T8103 and T600x tunnel clocks by PHY compatible #2415 commits under it, not from 71e7424. Rebase once phy: apple: atc: select the T8103 and T600x tunnel clocks by PHY compatible #2415 lands, or resolve them in phy: apple: atc: select the T8103 and T600x tunnel clocks by PHY compatible #2415.

Nit: atc_tunnel_clock_by_compatible (drivers/phy/apple/atc-tunnel-test.c:37-43) covers only one no-flag PHY, apple,t8122-atcphy. Adding apple,t6040-atcphy or apple,t8140-atcphy would pin the "no per-DP IN clock on later SoCs" claim, and so would the fact that apple,t8112-atcphy resolves through its fallback.

HW row: on an M2 Pro/Max laptop (J414s/J416s/J414c/J416c), on this head, put a display behind a Thunderbolt dock on each of the three USB-C ports. Each should light with DP tunnel clock rate ...: 0 and no pixel-clock warning, and HDMI should be unchanged. Also boot regression rows on M1 Pro, M2, J616s and Neo on the rebased head. 0 AVC, 0 failed units, no new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

Conflicts: dcp-fabric.c (dcp_direct_crossbar_link: keep dcp_is_t6030_fabric() plus integration's dcp_t6041_ext_v27()), dcpext26-crossbar-union-tests.py (extract both dcp_t6041_ext_v27 and dcp_is_t6030_fabric).

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
No conflicts: integration/aurora comes in through the updated hack/drm-board-gates-b (81af464), merged cleanly.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
No conflicts: integration/aurora comes in through the updated hack/drm-board-gates2-b (10ccffe), merged cleanly.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merged integration/aurora (f5f023b, through the updated #2415 head 10ccffe); no conflicts on this branch, drivers/phy/apple/ incl. the ATC KUnit test (arm64 fleet config, LLVM) builds; atc-usb3 host test and apple-dcp selftests (92/92) pass.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Still needed: #2359 and #2415 to land first, then an M2 Pro/Max row on this head (a display behind a Thunderbolt dock on each of the three USB-C ports, HDMI unchanged) plus boot regression rows on M1 Pro, M2, J616s and Neo.

…d port power-on, warn on a failed post-sleep mode

Folds #2409 into this PR unchanged.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…0 and T8140 flows by compatible

Folds #2414 into this PR unchanged.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide RyanTheTide changed the title phy: apple: atc: gate the T602X tunnel clock by PHY compatible and connector wiring phy: apple: atc, mux: display-crossbar: select tunnel clocks and crossbar flows by compatible, retry only an owed SuperSpeed power-on Nov 25, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Status 12-05: parked. A merge of main (f02bd68) conflicts in 9 files: dcp-fabric.c, dcp.c, apple-display-crossbar.c (3 hunks), atc.c (3), atc-tunnel.h, atc-tunnel-test.c and three host tests. Main reworked the same paths since this branch: dcp_direct_crossbar_link() gained an on_link argument; the crossbar select moved its MUX_MAX/runtime-PM/T6030 dispatch out of apple_dpxbar_t602x_select(); main added a T8122 crossbar entry and T8142 control domains, still sets t6030_dpin from the machine compatible, and grew the T6030 DCP match data (handoff, s2r layout, 27.2 flags); and the tunnel clock moved to dcp_phy_clocks_tunnel()/dcp_phy_tunnel_rate(). Resolving these means re-deriving the compatible-keyed selection against main's new structure, not picking sides, so it needs the owner's rebase rather than a mechanical merge. After that: the M2 Pro/Max dock row plus boot rows on M1 Pro, M2, J616s and Neo.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Second-pass assessment 12-05 against main @ef8a1bf8 (merge-base d1b022d, 11-22). Stays PARKED; nothing pushed. The goal (select by compatible/match data, not the machine) still stands: main still has every machine gate this PR removes, and added more. Mapping onto main:

  • atc.c tunnel clocks (e583b4e, 71e7424, 6cb4c3e's PHY half): main already selects the PHY by compatible (atcphy_hw_t6030 for apple,t6030-atcphy, atcphy_hw_t8103, ... in the match table ~9868), but the tunnel helpers still ask the machine: apple_atc_tunnel_is_t600x() (~3435, apple,t6000/t6001), apple_atc_tunnel_t8122_clock() (~4117, apple,t6030 && gen T8122), the of_machine_is_compatible("apple,t6030") at ~4763, and apple_atc_tunnel_is_t8103_style() (~5710, apple,t8103/t8112 + t600x). Redo: add the PR's t8122_tunnel_clock (and a t8103-style tunnel flag) to struct atcphy_hw and set them in atcphy_hw_t6030/_t8132 and atcphy_hw_t8103/_t6000-class entries; the helpers become atcphy->hw->.... Main's newer dcp_phy_clocks_tunnel()/dcp_phy_tunnel_rate() callers stay as they are.
  • display crossbar (99989ba): main has match data for t8103/t8112/t6000/t8122/t6020/t6041/t8132/t8142/t6050 but none for apple,t6030-display-crossbar (t6030.dtsi uses it with the t6020 fallback) or t8140; probe still does dpxbar->t6030_dpin = hw->t6030_flow || of_machine_is_compatible("apple,t6030") (~1490), and j700_physical (~413) still asks for apple,j700. Redo: add apple_dpxbar_hw_t6030 (.t6030_flow = true, t6020 ops) and apple_dpxbar_hw_t8140 entries with the PR's DPPHY gate flag, drop the machine terms. Binding: apple,t6030-display-crossbar / apple,t8140-display-crossbar enum entries in display-crossbar.yaml.
  • DCP fabric (6cb4c3e's DRM half): main still calls of_machine_is_compatible("apple,t6030") in dcp-fabric.c at ~290 (dcp_route_tunnel_clock_blocked()), ~385 (dcp_typec_ordered_dual_stream()), ~551, ~2903 (now inside main's dcp_direct_crossbar_link(..., on_link)), ~2982. Redo: the PR's dcp_is_t6030_fabric(dcp) from the T6030 dcp/dcpext match data (main grew those entries with handoff, s2r layout and 27.2 flags; add one bool there), used at each site; the global dcp_typec_ordered_dual_stream(void) needs a dcp or a probe-time latch, since it has none today.
  • b7d2f4c (retry only an owed SuperSpeed power-on) and 5ae30dc (warn when the mode is not reapplied after sleep): need re-checking against main's reworked atc.c sleep path; they conflict in the same 3 atc.c hunks.
  • Out of this PR's scope but the same class on main: dcp-fabric.c apple,t6050 (~429, ~529) and apple,j714s (~3668); dcp.c apple,t6050 (~2835), apple,j613 (~7041), apple,j700 (~9562). Worth a follow-up issue rather than growing this PR.

So this is a rewrite of ~330 lines across atc.c, the crossbar, dcp-fabric.c and dcp.c, touching M1 Pro/M2/M3 Pro/Neo display routing; not small enough to do blind. Rows after the redo: M3 Pro (J514s/J516s) dock display on each of the 3 USB-C ports (HDMI unchanged), boot regression on M1 Pro, M2, J616s and Neo.

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.

1 participant