Repository navigation
j416s: DisplayPort over Thunderbolt (T602X USB4 DP tunnel) - #14
Closed
oliverlukschander wants to merge 11 commits into
Closed
oliverlukschander wants to merge 11 commits into
oliverlukschander wants to merge 11 commits into
Conversation
Apple CD321x reports DP_CONNECTION together with USB4_CONNECTION on USB4 docks that also advertise DP Alt Mode (OWC Thunderbolt 5 Hub is one). cd321x_typec_update_mode() handled DP first and forced the thunderbolt switch OFF, so the Apple ACIO block never started and tunneled USB 3.x never appeared. Check USB4, then Thunderbolt, then native DP. Tested on MacBook Pro 16-inch M2 Pro (apple,j416s) with an OWC Thunderbolt 5 Hub; a Keychron Q4 on the hub USB-A port enumerates. Signed-off-by: Oliver Lukschander <[email protected]>
m1n1 v1.6.1 copies ACIO tunables and the USB4 DROM using aliases named usb4_%d_rc and usb4_%d_nhi (underscores). The DT only provided usb4-%d-acio (hyphens). On that m1n1 the tunable copy is skipped, so thunderbolt-apple-acio fails with "Unable to load rc tunable" and the Type-C ports that wait on ACIO never come up. Newer m1n1 falls back to the hyphen names. Ship both so v1.6.1 and current m1n1 work. t602x J414/J416 include this file. Tested on MacBook Pro 16-inch M2 Pro (apple,j416s). Signed-off-by: Oliver Lukschander <[email protected]>
Add a second mux-control entry (index 1) per Type-C PHY crossbar to both dcpext0's and dcpext1's mux-controls/mux-control-names, named "typecN-usb4" alongside the existing "typecN" (direct alt-mode) entry. These are the devicetree handles the display crossbar driver resolves by name to select a USB4/Thunderbolt DP tunnel route (dpin0/dpin1) rather than a direct Type-C alt-mode route, on T602X (M2 Pro) j414/j416 machines. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Add the shared header that lets the Thunderbolt/ACIO driver, the DCP display driver, the ATC PHY and the display crossbar mux driver cooperate on routing a DisplayPort tunnel over USB4/Thunderbolt on Apple Silicon (starting with T602X/j416s). The four declared entry points cover the full path a tunneled DP stream takes: apple_dcp_tb_dp_tunnel() lets Thunderbolt hand a DP IN adapter's crossbar output to DCP (or take it back) and runs DCP's DPTX_INACTIVE handshake via a callback; apple_atc_dp_tunnel_rate() starts or stops the PHY's pixel clock at a given DP link rate once the PHY is in USB4 mode; and apple_dpxbar_link_down()/apple_dpxbar_link_up() let an already-selected crossbar output be quiesced and restored around a link reconfiguration without disturbing the mux selection. None of the four providers is a build-time dependency of the others: each caller resolves its counterpart with symbol_get()/symbol_put(), so the four drivers can each be loaded independently. This header keeps those calls type-checked against a single declaration. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Give struct tb_nhi_ops three new optional callbacks -- dp_tunnel_pre_activate, dp_tunnel_post_activate and dp_tunnel_deactivate -- mirroring the existing pci_tunnel_* hooks, so a platform NHI driver can observe and participate in DP tunnel bring-up and teardown: pre_activate runs after DP hops are programmed but before VE/AE are enabled, post_activate runs once the adapters are enabled, and deactivate runs when the tunnel comes down. Export tb_cfg_read() into the USB4 symbol namespace alongside the already-exported tb_cfg_write(), since an out-of-tree platform NHI driver implementing these hooks needs tb_port_read()/tb_port_write(). Fix tb_dp_activate() to not abort the rest of its teardown sequence when disabling one adapter fails: once a port is marked unplugged, tb_port_read()/tb_port_write() short-circuit to -ENODEV, so a departing DP OUT adapter always makes the disable call "fail" during a hot-unplug teardown. Only bail out early when actually activating; keep going on deactivate regardless of an individual adapter's error, since tb_tunnel_deactivate() already discards this function's return value and callers rely on the rest of the teardown running. Add Apple silicon host DP IN/OUT adapter support, gated on the NHI being compatible with "apple,t8103-usb4-nhi" (the family also used by T6020/M2 Pro) so it has no effect on non-Apple hardware. Apple hosts need several deviations from the standard USB4 DP tunnel sequence: the DP IN adapter has no physical connector wired to its own hotplug-detect line, so pulse ADP_DP_CS_3_HPD_PROPAGATE after activation to make it propagate HPD itself; the sink is trained by the host's DPTX through the tunnel rather than by the DP OUT adapter's own link training, so hold ADP_DP_CS_3_NO_AUTO_LT set on DP OUT for the tunnel's lifetime; the host-side DP IN adapter needs a fixed 5 NFC credits on the video path rather than the standard credit-allocation formula; on some ports the DP IN adapter never raises a bandwidth-allocation request notification as the spec expects, so grant its already-computed non-reduced bandwidth immediately once capped at what the connection manager reserved; and because Apple's DPTX negotiates AUX capability through the DP IN adapter only after the tunnel's paths already exist, treat the tunnel as active as soon as its paths are programmed and keep it up across a DPRX capability-read timeout rather than tearing it down. Add an off-by-default dp_video_counter module parameter that turns on hardware packet counters on the DP video path for debugging, readable through the existing debugfs port counter files. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Wire up the tb_nhi_ops dp_tunnel_pre_activate/post_activate/deactivate hooks so a DisplayPort tunnel programmed by the Thunderbolt connection manager -- whether the monitor hangs off the host router directly or off a Thunderbolt/USB4 hub -- gets a real display pipeline attached, instead of only working through direct HDMI or a USB-C alt-mode adapter as before. Add a small, self-contained helper (apple-dpin-handshake.h) that drives the ACIO DP IN adapter's DPTX_INACTIVE register handshake: HPD/CONTROL/ ACK plus the two link-rate mode fields that must be programmed before the adapter's crossbar output will pass a real display signal. The link-rate value is an empirically-determined estimate rather than a value confirmed against any spec or reference implementation; it is exposed as a module parameter (dpin_mode_value, default matching the value confirmed working on T602X/M2 Pro hardware) rather than hardcoded, in case other Apple silicon generations need a different value. apple_cio gains the Type-C connector node this router is wired to (found via the port@1 OF-graph endpoint to the PD controller) and a per-adapter context with its own lock, mapped-register pointer and lifetime flags, driven from a dedicated ordered workqueue so tunnel up/down events are serialized and never lost. When a tunnel activates, the driver maps the relevant DPIN handshake register block and calls into the DCP display driver's apple_dcp_tb_dp_tunnel() (resolved via symbol_get()/symbol_put(), so neither module hard-depends on the other being loaded) with a callback that runs the DPTX_INACTIVE handshake at the point DCP itself decides to bring the link up or down; a bounded retry loop covers DCP still probing when a dock is already present at boot. Deactivation reverses this in mirror order once the Thunderbolt core has already disabled both tunnel adapters. Give apple_cio's RTKit ops a recv_message callback that logs any message the ACIO M3 coprocessor sends unprompted, for visibility into ACIO's own asynchronous notifications. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Add afk_send_command_timeout()/afk_service_call_timeout(), which take an explicit reply timeout instead of the existing functions' hardcoded one second, and rework afk_send_command()/afk_service_call() as thin wrappers over them at the previous default. A Thunderbolt DP tunnel's AUX proxying round-trip for an HPD-assert reply can take longer than a direct-PHY connection's one-second budget, and the caller needs to widen just that one call rather than every AFK command in the driver. Add dev_warn() logging on the failure paths (handler error, timeout, non-zero retcode, reply magic/group/command mismatch) and a dev_dbg() on success, so a failed AFK round trip is diagnosable without needing to instrument individual call sites. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Add core routing support for a USB4/Thunderbolt DisplayPort tunnel arriving behind a Thunderbolt hub, as opposed to a direct Type-C DP alt-mode connection. struct apple_dcp_typec_route grows a tunnel flag, an active_xbar pointer distinct from the route's own crossbar control, a tunnel_dpin index and an xbar_up flag, so dcp_typec_route_activate()/ deactivate() can be handed the crossbar control to actually use: for a tunnel this is a dpin0/dpin1 controller resolved at tunnel-creation time rather than the route's own dpphy control, and the mux selection for it is deferred until the tunnel pixel clock is confirmed running rather than issued immediately. Add apple_dcp_tb_dp_tunnel(), the entry point Thunderbolt calls once it has stood up a DP IN tunnel: it finds a free Type-C route on the target port and activates it as a tunnel. A Type-C-only pipeline (no fixed output of its own) never completes link training for a tunneled target on this hardware -- DCP firmware accepts request_display but never issues the follow-up apcall, despite byte-identical connect parameters, a firmware-internal decision on that coprocessor instance with no driver-source asymmetry to explain it. A pipeline with a fixed output of its own reliably reaches a full AUX/DPCD link, so route scoring prefers it unconditionally for a tunnel route on this hardware. Add dcp_tunnel_crossbar_up()/down()/set_rate()/dpin_activate(), the hooks the DPTX endpoint uses to keep the crossbar clocks and the DP IN adapter's active state in step with DCP's link (re)configuration, serialized by a new per-DCP tb_lock. Make the Type-C alt-mode mux callback leave a tunnel-owned port alone -- a tunnel is torn down by apple_dcp_tb_dp_tunnel() itself, not by an alt-mode notification, and reapplying a stale alt-mode state on top of one would fight it. Thread the DFP port selected by route activation through dcp_dptx_connect() into the DPTX validate/connect calls, which previously always targeted DFP port 0 -- this is what makes a tunneled connection train against the Thunderbolt DP IN adapter DCP was actually told to use, rather than the direct PHY. Widen DPTX_CONNECT_TIMEOUT from 2s to 8s and the Type-C HPD-assert wait to 8s, and drop DPTX_RECONNECT_RETRIES from 5 to 1: a tunneled connection's handshake round-trip through the DP IN adapter can outlast a direct-PHY connection's budget. Co-Authored-By: Claude Sonnet 5 <[email protected]>
A Thunderbolt/USB4 DisplayPort tunnel reaches the same DCP DPTX AFK/EPIC endpoint as a direct HDMI or USB-C alt-mode PHY, but several request/reply shapes and side effects differ: the endpoint has no local ATC DisplayPort PHY to configure, the pixel clock and display crossbar connection are owned by the Thunderbolt tunnel infrastructure instead of being driven directly, and firmware's link-training sequencing includes calls (INACTIVE_SINK_DETECTED, FORCE_HOTPLUG_DETECT, GET_ACTIVE_LANE_COUNT) that the direct-PHY path never exercises. Factor VALIDATE_CONNECTION/CONNECT's remote-port target computation into dptxport_remote_target(), and add a tunnel "role" attribute bit that lets firmware distinguish a Thunderbolt DP-IN route from a direct PHY; tolerate the resulting difference in firmware's attrs reply only for a tunnel route, still rejecting a mismatch for the direct-PHY case. Treat a NULL dptx->atcphy (the USB4 DP-IN service has no ATC PHY of its own) as "report a fixed 4 lanes, skip phy_configure()" in GET_MAX_LANE_COUNT/SET_ACTIVE_LANE_COUNT. Route SET_LINK_RATE, ACTIVATE and DEACTIVATE through the dp-tunnel.h API for a tunnel connection instead of touching the ATC PHY's DP mode or rate registers directly -- the PHY must stay in USB4/Thunderbolt mode for the life of the tunnel. Bring the tunnel's display crossbar connection down before a re-link and back up once it completes, and handle GET_ACTIVE_LANE_COUNT, FORCE_HOTPLUG_DETECT and INACTIVE_SINK_DETECTED explicitly rather than relying on the generic unhandled-call ACK. Add dptxport_set_hpd_timeout() so a caller can widen the AFK reply timeout for the HPD-assert call, since a tunnel's AUX proxying round-trip can be slower than a direct PHY's. dcp_hotplug()'s forced link-status retrain recovers a connector that reports connected without a valid mode set yet, for a Type-C route switch that can drop the active mode without changing HPD state. A USB4 tunnel connector's link comes up through the DPTX endpoint's own crossbar/clock sequencing rather than a Type-C route switch, so restrict that recovery path to non-tunnel connectors. Trace the read_edt_data and property-dictionary DCP callbacks' key, size and result for any connector other than the fixed eDP panel, and include the firmware-reported mode count in the existing hotplug log line, to make the boot-property and mode-list exchange with firmware observable for a tunnel connector. Co-Authored-By: Claude Sonnet 5 <[email protected]>
apple_dpxbar_set_t602x() only ever programmed the DPPHY fields of the mux control register and its ATC bit, regardless of which of the three physical outputs (dpphy, dpin0, dpin1) was actually selected. Selecting dpin0 or dpin1 therefore only updated driver-internal bookkeeping without ever routing analog onto the ACIO DP IN pins, and the enable/disable paths never touched the enable bits the generic (non-T602X) crossbar path does. Add helpers to resolve the correct ATC bit and mux-select field for the index actually being switched, and use them in both the enable and disable sequences, including the enable-bit sequencing that was previously only done for the generic crossbar. Reject an out-of-range index up front rather than proceeding with an unresolved mux mask. Add apple_dpxbar_link_up()/apple_dpxbar_link_down(), exported for the DCP driver to reach through symbol_get()/symbol_put() so the crossbar driver does not need to be a hard module dependency of the display driver. A Thunderbolt DP tunnel re-link needs to bounce the crossbar's clock/FIFO gates on an output that is already selected, without reselecting the mux or dropping the enable bits -- a full teardown/ re-enable would drop the route entirely. Both functions operate on whichever output the mux already has recorded as selected. DPIN0's field masks and ATC bit are hardware-confirmed on T602X/M2 Pro; DPIN1's are filled in by the same per-index resolution by symmetry with DPPHY/DPIN0's layout, not by independent confirmation on real hardware -- flagging this here since getting a field encoding wrong on this hardware is silent (no error, just no picture). Co-Authored-By: Claude Sonnet 5 <[email protected]>
On T602X (M2 Pro, j416s) Type-C PHYs, a monitor connected directly via DP alt-mode or a USB-C-to-HDMI adapter already works, because that path drives the AUSPLL through the PHY's normal per-mode configuration table. A monitor connected through a USB4/Thunderbolt hub instead carries DisplayPort as a tunneled stream over the USB4 link, and the DCP display coprocessor firmware expects the PHY driver to hand it a dedicated tunnel pixel clock on request, outside the normal mode-configure path. Nothing implements that request today, so a tunneled display never gets a clock and stays dark even though the USB4 link itself comes up. Add the tunnel clock state machine: atc_tunnel_start() brings up the fixed AUSPLL frequency descriptor and PCLK1 output for one of the four standard DisplayPort link rates, after a preflight read of the gate/output/lock registers confirms the PHY is in the specific idle state this sequence expects (refusing with -EBUSY otherwise rather than clobbering live state). Before touching anything it snapshots the registers it is about to modify; atc_tunnel_restore() replays that snapshot in reverse to undo the sequence, and is called unconditionally at the top of atcphy_configure() so any mode change, power-down, or unplug leaves the tunnel registers exactly as it found them instead of stuck mid-sequence, and clears the request-guard state so a later tunnel request is not permanently refused by a stale in-progress flag. Expose this through a new exported apple_atc_dp_tunnel_rate(phy, rate) -- the exact symbol name drivers/gpu/drm/apple/dcp.c resolves via symbol_get() to ask a PHY for a tunnel clock. It is gated to apple,j416s machines and to ATC cores that are both a t6020-atcphy and a recognized Type-C core address, so it is a correctly-typed no-op everywhere else, and only proceeds while the PHY is already in USB4 or TBT mode. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
Author
cb2206
pushed a commit
to cb2206/linux
that referenced
this pull request
Oct 5, 2026
…ompute-batch drm/asahi: allow bounded runtime compute batch tuning
DjDeveloperr
pushed a commit
that referenced
this pull request
Oct 15, 2026
…14) Signed-off-by: Chris Kearney <[email protected]>
This was referenced Nov 9, 2026
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.
DisplayPort over Thunderbolt for M2 Pro (T602X/j416s)
Extends #8's Thunderbolt DisplayPort tunnel work (t8103/M1) to T602X
(M2 Pro, j416s). Stacked on #6 (
j416s-usb4-hub), which this branchalready contains.
Lets an external monitor work when connected through a USB4/Thunderbolt
hub, on top of the two DP-alt-mode paths that already worked (direct
HDMI, and a USB-C-to-HDMI adapter).
Tested on an M2 Pro (j416s):
Also covered:
DPIN1 (the second tunnel-capable port on this crossbar) was not
independently tested -- only DPIN0 (the port used above) was exercised
on real hardware. Its register field encodings are filled in by
symmetry with DPIN0's confirmed layout, called out explicitly in the
mux commit's message and in a comment at the one field whose 2-bit
encoding for a second index was inferred rather than confirmed.
The DPIN0 link-rate handshake value (
dpin_mode_value) is anempirically-determined estimate rather than a value confirmed against
any spec or reference implementation -- also called out in its own
commit message and comment, and left as a module parameter rather than
hardcoded in case a different Apple Silicon generation needs a
different value.