Skip to content

drm/apple: support independent dual dock DP streams on J414s - #46

Closed
DjDeveloperr wants to merge 29 commits into
review/pr14-basefrom
fix/j414s-dual-dock-dp
Closed

DjDeveloperr wants to merge 29 commits into
review/pr14-basefrom
fix/j414s-dual-dock-dp

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Summary

Stacked on #14 (oliverlukschander:j416s-usb4-dp-tunnel-pr,
currently e9e52e6dc932). Because that head lives in a fork, this PR targets
review/pr14-base, an unchanged copy of that exact commit in this repository.
Retarget to aurora-wip after #14 merges; do not merge this base branch as a
substitute for reviewing #14.
This PR contains only the local Thunderbolt/Type-C display follow-up fixes;
it does not include SEP/Neo, AVD, haptics, userspace compositor changes, or
the ongoing bandwidth-allocation experiments.

The main change is to give J414s two independent display streams through
one USB4/Thunderbolt dock instead of sharing one connector, DCP ownership
slot, or pixel-clock state between both DP IN adapters.

Changes

  • Preserve an available Type-C port's previous DCP route. Avoid retraining
    unrelated displays during the immediate DP-to-USB4 detach sequence.
  • Keep synthetic DPMS disconnects distinct from physical unplug events;
    allow a positive hotplug through after a replug. Do not equate a clear-swap
    timeout during power-off with an RTKit crash.
  • Enable the existing T6020 tunnel path on J414s and rearm the route after
    teardown. Prefer the Type-C-only DCP for direct displays, leaving the
    hybrid DCP available for a dock stream.
  • Add independent primary/secondary dock connectors and route ownership.
    Preselect the DCP source before AUX probing; fix the T602x DPIN1 crossbar
    fields and preserve the other stream's gates.
  • Track ATC tunnel-clock users and rates per DP IN, preserving the shared
    PCLK1 prerequisite and the PLL descriptor across DPMS. Wait for IOMFB HPD
    readiness on wake before powering the display pipeline.
  • On Apple hosts without USB3 bandwidth-allocation writes, read consumed
    bandwidth from the downstream USB3 UP adapter rather than treating the
    software maximum as permanently occupied. Preserve conservative fallback
    on read failure and the 900 Mb/s minimum before PCIe weighting. This is
    admission accounting, not a USB bulk-transfer rate cap.
  • Preserve the tested J414/J416 USB4 firmware aliases and enable the USB4
    connection manager / Apple NHI modules in the Asahi configuration.

Validation

Hardware evidence comes from these fixes in the combined m2fix48 development
tree on a J414s M2 Pro with a Winstars WL-UTD59 dock. The user visually
confirmed both dock displays working together. Recorded checks also cover
cold boots, individual/all-display DPMS cycles, natural idle/wake, and
controlled dock-controller re-enumeration. Later remote tests reported both
Dell S2725QC and Samsung Odyssey G81SF at 3840x2160@120 after a manual mode
change; that report is not an independent optical validation of those modes.

For this isolated PR branch:

  • Compiled appledrm, thunderbolt, thunderbolt_apple, phy-apple-atc,
    and mux-apple-display-crossbar as external modules against the warm
    m2fix48 build output and its Module.symvers, using Clang on ARM64.
  • Compiled the J414s DTB and checked the USB4 controller aliases. The direct
    DTC invocation emits warnings, including existing reserved-memory and
    bus-node naming warnings; this is not a clean DT-schema validation.
  • Buffered/direct-read SHA-256 comparisons matched for all five modules
    and the DTB (the build guest has an unresolved page-cache issue).
  • git diff --check and checkpatch.pl --no-tree --no-signoff pass.

The isolated branch has not been booted as a complete kernel. The test
machine is left unchanged by this PR preparation.

Known limitations / review focus

  • This does not resolve connection-order-dependent DP bandwidth
    allocation. Samsung-first attachment can still constrain the second
    display's available modes. General dual-4K120 hotplug reliability remains
    under investigation.
  • The deployed development image also has an opt-in dock-specific pairing
    delay and bandwidth tracing; neither is included here. Do not attribute
    all results from that image to this clean patch stack alone.
  • No bandwidth splitting, forced link-rate cap, eager-HPD ordering,
    automatic retraining experiment, raw packet counters, or speculative
    firmware-reply modifications are included.
  • USB3 admission accounting needs broader testing with demanding
    isochronous devices joining after display allocation; no claim of
    exhaustive USB3/PCIe contention testing is made.
  • J416s dual-stream behavior and other docks are not validated. Controlled
    controller re-enumeration is not equivalent to every physical cable-pull
    sequence.
  • drm/apple: keep a Type-C display connected while its CRTC is off #44 overlaps the DPMS guard, but is not merged here. This stack preserves
    positive replug notifications and the IOMFB readiness wait. Userspace
    route-mask refresh and layer-position fixes used on the test system are
    outside this kernel PR.

Please review/merge after #14, or retarget once #14 lands. The six commits
are intentionally separate from the combined development branch.

Retain the last available DCP route and avoid retraining unrelated outputs during the immediate DP-to-USB4 teardown sequence. Keep synthetic DPMS disconnects separate from physical cable removal, while allowing positive hotplug events through after a replug. Let the RTKit crash callback, rather than a power-off clear-swap timeout, establish a fatal firmware crash.
Extend the T6020 ATC tunnel clock gate and dcpext0 preference to J414s. Re-establish the DCP route when a new dock tunnel appears after a controller detach without a prior teardown callback.

Tested on J414s m2fix42: dock DP tunnel enabled USB-3 at 1920x1280@60, direct USB-2 at 3840x2160@120 and eDP at 3024x1964@120 with active CRTCs and zero failed units. Controller-detach disconnect reporting remains under investigation.
Route an available direct Type-C DP-alt-mode display to dcpext1 first so dcpext0 remains available for a dock DP tunnel. The tunnel still prefers dcpext0, which is the pipeline that completes link training on T6020.

m2fix45 cold-booted with both displays attached: direct 3840x2160@120 on dcpext1 and dock 1920x1280@60 on dcpext0 came up without port resets, alongside eDP. SEP identity, haptic FF ioctl, and AVD H.264 decode remained functional.
Route DPIN1 through the native T602x crossbar fields and source selector, give the two tunnel streams separate DCP connector/route ownership, and keep both ATC pixel clocks alive at independent link rates. Wait for Type-C IOMFB hotplug after a display power-on.

The dual-dock path was exercised on J414s/m2fix48 with Dell 3840x2160@120 and JTG 1920x1280@60, per-output DPMS and idle/wake; the user confirmed the displayed image. This commit removes a frame-complete callback that had no register side effect. The cleaned tree builds with the Asahi profile; the cleaned commit itself is not yet deployed.
Apple host USB3 adapters do not acknowledge bandwidth-allocation writes, so their software-only initial allocation should not be treated as consumed USB3 bandwidth when admitting DP tunnels. Read the downstream router USB3 UP adapter consumed-bandwidth counters instead, retaining 900 Mb/s minimum headroom for isochronous traffic. If those counters cannot be read, keep the existing conservative allocation estimate. The change does not cap USB3 bulk traffic or write the unsupported host registers.

The m2fix48 dock test reached Dell 4K120 and JTG 60 with USB devices enumerated; a standalone throughput or isochronous stress test has not been performed.
Preserve the underscore-form USB4 controller aliases used by the tested m1n1 handoff, and build the USB4 connection manager and Apple NHI with the Asahi profile. Keep unrelated SEP and host configuration out of this stack.
@rryan

rryan commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Amazing work! Any chance this will also work on M2 Max? Claude wrote this tiny patch to support it, but I'm not sure it's right that that is all that is needed: https://paste.debian.net/hidden/3273dbee

@rryan

rryan commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Amazing work! Any chance this will also work on M2 Max? Claude wrote this tiny patch to support it, but I'm not sure it's right that that is all that is needed: https://paste.debian.net/hidden/3273dbee

Just tried it out and my CalDigit USB Pro (Thunderbolt 3) hub works great with 2 4k@60 32" LCDs. Summary from Claude:

Tested on J416c (16" M2 Max): two independent 4K60 dock streams working

With a 4-line patch that adds apple,j416c to the J414s gates, this PR drives two independent extended displays through one Thunderbolt 3 dock on a 16" M2 Max.

Setup

Machine MacBook Pro 16" M2 Max 2023 (apple,j416c, T6021)
Base tree this PR's head 3075f5503a32c44e29e7a1e6b9244038e8e28569 + patch below
Kernel config Aurora edge config (CONFIG_USB4=m, CONFIG_USB4_APPLE_SOC=m), built with the asahi-alarm PKGBUILD as 7.1.12-dualdock-1-ARCH
Bootloader stock m1n1 1.6.1 (asahi-alarm), U-Boot 2026.07.asahi2, DTBs from this build
Userspace Arch Linux ARM (asahi-alarm), Hyprland 0.56.2, Mesa 26.2.3
Dock CalDigit USB-C Pro Dock (Intel Titan Ridge, Thunderbolt 3, not USB4), included 40Gb/s TB3 cable
Displays Lenovo T32p-20 and ASUS PA329CRV, both 3840x2160@60 over the dock's two DP 1.2 outputs, plus the internal panel

Patch (J416c enablement)

--- a/drivers/gpu/drm/apple/apple_drv.c
+++ b/drivers/gpu/drm/apple/apple_drv.c
@@ -438,7 +438,8 @@
 	for (idx = 0; idx < nr_ports *
-	     (of_machine_is_compatible("apple,j414s") ? 2 : 1); idx++) {
+	     ((of_machine_is_compatible("apple,j414s") ||
+	       of_machine_is_compatible("apple,j416c")) ? 2 : 1); idx++) {
--- a/drivers/gpu/drm/apple/dcp.c
+++ b/drivers/gpu/drm/apple/dcp.c
@@ -607,7 +607,8 @@
-		if (of_machine_is_compatible("apple,j414s")) {
+		if (of_machine_is_compatible("apple,j414s") ||
+		    of_machine_is_compatible("apple,j416c")) {
@@ -781,7 +782,8 @@
-				if (of_machine_is_compatible("apple,j414s") &&
+				if ((of_machine_is_compatible("apple,j414s") ||
+				     of_machine_is_compatible("apple,j416c")) &&
 				    candidate->dcp->fixed_phy)
--- a/drivers/phy/apple/atc.c
+++ b/drivers/phy/apple/atc.c
@@ -2370,7 +2370,8 @@
 	    (!of_machine_is_compatible("apple,j414s") &&
-	     !of_machine_is_compatible("apple,j416s")))
+	     !of_machine_is_compatible("apple,j416s") &&
+	     !of_machine_is_compatible("apple,j416c")))

J416c shares the apple,t6020-{atcphy,display-crossbar,usb4-nhi,dcpext} blocks and t602x-j414-j416.dtsi with J414s/J416s, so nothing else needed changing. J414c (14" M2 Max) probably needs the same patch (not tested).

What works

  • Dock enumerates over TB3: 0-1 CalDigit, Inc. USB-C Pro Dock, gen 3, 2x20 Gb/s. The typec mux shows svid=8087 ... tbt=1.
  • Both DP IN adapters tunnel and route as intended: 0:5 <-> 1:10 → dpin0 → dcpext0, 0:6 <-> 1:11 → dpin1 → dcpext1. So dcpext1 does complete link training for a tunnel target on T6021.
  • Both monitors run at 3840x2160@60 simultaneously (10-bit on dcpext0, 8-bit on dcpext1), alongside eDP 3456x2234@120, with no link faults after setup:
    apple-dcp 289c00000.dcp: set_digital_out_mode(color:102 timing:48) "3840x2160": 60 533250 ...
    apple-dcp 315c00000.dcp: set_digital_out_mode(color:109 timing:63) "3840x2160": 60 594000 ...
    
  • The dock charges the laptop over the TB3 cable (it didn't on stock linux-asahi).
  • dpin_mode_value=8 (default) and dprx_timeout=12000 worked unchanged on T6021.
  • One suspend/resume cycle with the dock attached (displays not active at the time) completed without errors.

Issues seen

1. A tunnel that goes idle is not re-established on the next modeset.
On a cold boot with the dock attached, both tunnels came up at ~14 s and read EDID, but no compositor modeset them (see issue 2). About 30 s later both went down:

[44.32] thunderbolt-apple-acio f01ac0000.cio: dpin0: inactive handshake=0
[44.32] apple-display-crossbar f0304c000.mux: dpin0: crossbar link down (dispext=0 atc=0x1)
[44.32] apple-dcp 289c00000.dcp: DPTXPort: SET_LINK_RATE 0x0
[44.56] thunderbolt-apple-acio f01ac0000.cio: dpin1: inactive handshake=0

The next modeset (fbcon on VT switch, ~63 s) then failed on both pipes, and both connectors were marked disconnected:

apple-dcp 289c00000.dcp: DPTXPort: firmware reports link fault 22 on target 0:2
apple-dcp 289c00000.dcp: RTKit: syslog message: ... IOAVVideoInterface prepareLink() failed with 0xe00002ed
apple-dcp 289c00000.dcp: RTKit: syslog message: ... set_digital_out_mode returned 80000104
apple-dcp 289c00000.dcp: cb_hotplug() connected:0, valid_mode:1 nr_modes:26

(identical sequence on 315c00000.dcp / dpin1). Unplugging and replugging the TB cable with the compositor running brought both displays up immediately. The route/crossbar isn't re-armed for a modeset after the idle deactivate.

2. Boot race with autologin compositors (probably not specific to this PR, but made worse).
With dcpext2/dcpext3 enabled on J416c, apple-drm initializes as card2 at 12.5 s (five DCPs booting ~1 s each). SDDM autologin started Hyprland at 10.8 s on simpledrm (card0). When card0 was removed and card2 appeared, aquamarine failed to set up a renderer (initMgpu: no renderer, Failed to update renderer state for eDP-1), which left a black screen with a frozen cursor. Restarting the display manager after card2 existed fixed it. Not a kernel bug as such, but users on J416c with this tree will hit it on every boot, and it also triggers issue 1.

Not tested

  • HDMI as a third output at the same time (dcpext0 is taken by dpin0)
  • Hot-unplug of a single monitor from the dock
  • Long-term DPMS/idle/wake cycles
  • USB3 throughput on the dock while both streams run

Happy to run more tests or collect traces.

@oliverlukschander

Copy link
Copy Markdown
Contributor

Nice work. One finding from j416s that overlaps the ATC tunnel-clock part here, so I'd rather coordinate than open a competing PR.

Same observation as your "PLL retains lock" comment. On #14/#25, a compositor off/on went through atc_tunnel_restore(). Clearing the output drivers and replaying the saved registers left ACIOPHY_AUSPLL_LOCK set (+7044=00000008, "AUSPLL_LOCK did not clear after teardown"). The next atc_tunnel_start() preflight then refused its own stale lock with -EBUSY, and the display stayed in standby until a replug.

Your DPMS path avoids that by never tearing the PLL down on DPMS, so it covers the off/on case. The full teardown in atc_tunnel_restore() (mode change, failed start) still leaves the PLL running, though, so a restore followed by a new start can still hit the same refusal.

What powers it down: clearing AUSPLL_CLKOUT_MASTER bits 2, 4 and 6 one at a time, then sending APB command 3 through the same command/ACK handshake as the 0/0x2000 start commands. The lock then drops, and the next preflight reads +7044=00000000. Tested on j416s (M2 Pro, USB4 hub, BenQ 1440p) on the #25 base, with no warning and result=0 on every re-enable.

Proposal: once #14/#46 settle, I send a small follow-up on top of #46 that adds only this power-down to atc_tunnel_restore(), keeping your PCLK2 clear. I'd retest it on a replug/mode change, since your DPMS path no longer goes through restore.

Also a heads-up: #25 carries a newer version of #14's tunnel commit that polls for the lock to clear in atc_tunnel_restore(), while #46 is based on #14's older head. They'll conflict there whichever lands second. With the power-down, that poll becomes a real check instead of a 10 ms timeout.

(Found and written with Claude's help, per the project's LLM policy.)

J416c (16" M2 Max, T6021) shares the T602x ATC PHY, display crossbar,
USB4 NHI and the dcpext0/dcpext1 layout with J414s; only the board
gates differ. Treat J416c like J414s: two connectors per Type-C port,
DPIN0 -> dcpext0 and DPIN1 -> dcpext1, direct DP-alt displays prefer
dcpext1 so dcpext0 stays free for a dock tunnel, and allow the ATC
tunnel clock.

Tested on J416c with a CalDigit USB-C Pro Dock (Thunderbolt 3): two
3840x2160@60 displays through the dock plus the internal panel at
120 Hz, on hotplug and with the dock connected at boot.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RJ Skerry-Ryan <[email protected]>
The per-port Type-C connectors carry DisplayPort (DP alt mode or a
Thunderbolt/USB4 DP tunnel), but were registered as
DRM_MODE_CONNECTOR_USB, which DRM reserves for USB display adapters
(gud, appletbdrm). Userspace keys on the type: systemd-logind only
counts VGA/DVI/DP/HDMI/TV connectors as external displays, so a
docked lid close suspended the machine instead of honoring
HandleLidSwitchDocked=ignore.

Register them as DisplayPort. The driver's internal "is Type-C" checks
use dcp->connector_type / fixed_connector_type and are unaffected.
Connectors are now named DP-N instead of USB-N.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RJ Skerry-Ryan <[email protected]>
PCIe-C root ports behind a USB4 router must be cold-initialized before
use. Today the kernel only accepts ports the bootloader initialized and
reported through "apple,pciec-preinit-status", which no m1n1 does.

Add a boolean for PCIe-C nodes that tells the OS to do the cold init
itself when the USB4 PCIe tunnel comes up.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RJ Skerry-Ryan <[email protected]>
PCIe-C tunnel support requires m1n1 to cold-initialize the port and
report "apple,pciec-preinit-status" = 1, but no m1n1 does so. On
J414/J416 the tunnel is therefore always disabled and PCIe devices
behind Thunderbolt 3 docks (whose USB is an xHCI behind the tunnel)
never appear.

m1n1 already copies the PCIe-C tunables into the DT and the driver has
the port enable sequence. For ports marked "apple,pciec-kernel-init",
let the kernel do the cold init, as #8 does for
t8103:

- apple_pcie_tunnel_cold_init() follows the enablePortHardware()
  baseline of apple_pcie_tunnel_start(): debug/fabric tunables, port
  reset table and tunables, PERST off and APPCLK on, wait for RUN, and
  only then the root-complex (config space) tunables. Touching config
  space while APPCLK is still off hard-resets a J416c.
- apple_pcie_tunnel_prepare() runs it on transient mappings before the
  tunnel children are populated, since the DART never completes an
  invalidation while APPCLK is gated. A port that is already running is
  left alone.
- The Thunderbolt glue and the host bridge accept kernel-init ports in
  place of the m1n1 handoff.

As the sequence is new on T602x, it is gated behind
pcie_apple.tunnel_kernel_init (default off), checked before the first
PCIe-C MMIO access. pcie_apple.tunnel_kernel_init_trace_ms logs each
step and pauses after it, for locating failures with a persistent log.

Tested on J416c with a CalDigit USB-C Pro Dock (Thunderbolt 3, Titan
Ridge xHCI 8086:15f0): the dock's hubs, keyboard, audio, SD reader,
webcam and Ethernet work, including after unplug and replug.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RJ Skerry-Ryan <[email protected]>
No m1n1 performs the PCIe-C preinit handoff on these machines. Mark
apciec0-2 "apple,pciec-kernel-init" so the kernel cold-initializes the
Thunderbolt PCIe tunnel ports itself.

The tunneled DART driver also requires "apple,tunable", but iBoot adds
the corresponding "dart-tunables-instance-0" to the ADT only at boot and
m1n1 does not copy it for dart-apciec*. Without it the DART fails to
probe and devices behind the tunnel time out. Add the values from the
live J416c ADT (macOS ioreg), identical for all three ports; the same
decoding reproduces entry for entry the apciec tunables m1n1 already
copies into the DT.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RJ Skerry-Ryan <[email protected]>
A Type-C port's encoder spans every pipeline that can drive the port, and
routing narrows its possible_crtcs to the pipeline actually chosen,
relying on userspace to re-read them on the following hotplug.
Compositors that read possible_crtcs once when the connector appears
(aquamarine, used by Hyprland) never see that. With a USB4 dock carrying
two streams, whichever connector connects first takes the lowest free
CRTC. When that is the DPIN1 connector, it gets dcpext0's CRTC while the
stream is routed to dcpext1, every modeset fails the atomic check with
-EINVAL, and both dock displays stay dark until the dock is replugged
and happens to connect in the other order.

possible_crtcs is meant to be static. On the dual-stream machines
(J414s, J416c):

- Fix the DPIN1 connector to the lowest-indexed Type-C-only pipeline
  (dcpext1), where DPIN1 is always routed, and route DPIN1 only within
  the connector's possible_crtcs.
- Leave the primary connector spanning all its pipelines and stop
  narrowing or restoring possible_crtcs at runtime.
- Route direct DP-alt displays to the lowest free CRTC, which is what a
  compositor picks from the port's fixed possible_crtcs, instead of
  steering them away from dcpext0.

A direct DP-alt display now takes dcpext0 when it is free, so a
single-stream dock on another port lands on the next free pipeline.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RJ Skerry-Ryan <[email protected]>
PCIe-C is populated from delayed work queued when the PCIe tunnel is
activated. If the cable bounces, the tunnel can be deactivated before
that work runs; pcie_tunnel_requested stays set, so the work then
cold-initializes and starts PCIe-C against a tunnel that no longer
exists. On J416c the port then never links again ("link didn't come
up") until reboot, even after replugging or power-cycling the dock.

Clear the request and cancel the pending work on tunnel deactivation.
The work already re-checks the request under pcie_tunnel_lock, so a run
that is in progress either completes before the teardown takes the
lock, and is quiesced by it, or does nothing.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RJ Skerry-Ryan <[email protected]>
When the USB4 router disappears during suspend (e.g. a Thunderbolt 3
dock under s2idle), the NHI's resume tears the PCIe tunnel down and
quiesces this host before PCIe-C's own resume_noirq runs. That resume
then starts the ports anyway, training against a tunnel that no longer
exists; on J416c the port is afterwards unable to link on every later
connect until reboot.

Skip restarting the ports when the host has been quiesced. They are
started again by apple_pcie_tunnel_restore(), or cold-initialized by a
fresh populate, once a new tunnel is up.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RJ Skerry-Ryan <[email protected]>
oegv and others added 7 commits September 30, 2026 22:57
DCP tears its EPIC services down when an external display disconnects
and announces them again on fresh channels when it reconnects; it never
reuses a channel. On the j416s DPAVSERV endpoint (0x28), every
compositor off/on or replug of the display tears down
dcpav-service-epic (the service EDID is read through) and
dcpdp-service-epic, and announces both again: channels 1/3 at boot, then
5/7, 9/11 and so on. afk_recv_handle_init() handed out slots append-only
(ch_idx = num_channels++), and teardown only disables a service, so its
slot was never given back. After boot plus seven reconnects all
AFK_MAX_CHANNEL (16) slots were used, and the next reconnect failed:

  AFK[ep:28]: too many enabled services!
  AFK[ep:28]: expected announce but got 0xc0 on channel 33

The re-announced dcpav-service-epic then had no slot, so dcpavserv
stayed disabled and dcp_get_modes() skipped the EDID read without
logging anything. The connector's EDID stayed empty for the rest of the
boot, and a physical replug did not bring it back, since the endpoint is
never restarted.

Reuse a slot whose service was torn down, is disabled and has no
command pending. Pending commands keep their buffers in the slot until
the firmware acks them, so such a slot is left alone. The slot lock is
initialised once, when the slot is first used. Add debug messages for
teardown and slot reuse, since a normal teardown was not logged at all.

Confirmed on hardware: M2 Pro (j416s), BenQ 1440p through a USB4 hub,
fresh boot, 10 compositor off/on toggles. Each cycle logs teardown of
dcpdp-service-epic and dcpav-service-epic, then "reusing slot 0" and
"reusing slot 1" as the two services come back, with channels reaching
43 and no "too many enabled services". The EDID read back as 256
bytes after every toggle and Hyprland kept identifying the display.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Signed-off-by: Oliver Lukschander <[email protected]>
(cherry picked from commit 6fdc8fe)
Signed-off-by: RJ Skerry-Ryan <[email protected]>
The send-empty interrupt is requested with IRQF_NO_AUTOEN.
apple_mbox_send() enables it when the A2I FIFO is full and it has to
wait, and the interrupt handler disables it again when it fires. When
the wait times out or is interrupted by a signal, apple_mbox_send()
returns with the interrupt still enabled, so the next send that has to
wait calls enable_irq() on a line that is already enabled. The IRQ core
warns about the unbalanced enable, and from then on the enable state no
longer tracks whether a sender is waiting. On T8140 this shows up as
"Unbalanced enable for IRQ" warnings from the SEP hwrng thread, whose
sends can wait longer than the 500 ms timeout.

Track whether the interrupt is unmasked in struct apple_mbox, protected
by tx_lock. The sender enables it only while it is masked, the handler
disables it only while it is unmasked, and a sender whose wait failed
disables it unless a late interrupt already has. Disabling it
unconditionally on the error path would not work: the handler may
already be waiting for tx_lock and would then disable it a second time.

Fixes: 6e1457f ("soc: apple: mailbox: Add ASC/M3 mailbox driver")
Assisted-by: LLM checkpatch sparse
Co-authored-by: Claude Fable 5.1 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
(cherry picked from commit 7a155e3)
Signed-off-by: RJ Skerry-Ryan <[email protected]>
apple_rtkit_free() and apple_rtkit_reinit() stopped the mailbox and
destroyed or flushed the workqueue, but left the mailbox's rx callback
and cookie pointing at the instance the whole time. A message popped by
a concurrent apple_rtkit_poll() or a work item queued just before the
stop could still reach the consumer's callbacks while its state was
being torn down, and apple_rtkit_init() left a dangling receiver behind
when the workqueue allocation failed.

Make the receiver an explicit ownership: claim the mailbox rx callback
under rx_lock once the workqueue exists, detach it (with the interrupt
already disabled by apple_mbox_stop()) before draining the queue, drop
messages that arrive or were queued once teardown has started, and
release the cookie only after all host state is gone.
apple_rtkit_reinit() re-arms the receiver under the lock and detaches
again if the mailbox fails to start. A mailbox poll with no receiver
attached returns without touching the FIFO; the entries are drained
once a receiver is attached again.

Claiming a mailbox that already has a receiver keeps the previous
behaviour of taking it over, now with a warning, so existing consumers
that never free their instance can still rebind.

Assisted-by: LLM checkpatch sparse
Co-authored-by: Claude Fable 5.1 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
(cherry picked from commit 692a3c6)
Signed-off-by: RJ Skerry-Ryan <[email protected]>
apple_dart_hw_map_locked_ttbr() maps the L1 table of a locked DART
stream with devm_memremap() and checks the result for NULL, but
devm_memremap() never returns NULL: it returns ERR_PTR(-ENOMEM) or
ERR_PTR(-ENXIO) on failure. A failed mapping was therefore stored as
the table pointer, and apple_dart_hw_sync_locked() then wrote the
page-table entries through it and apple_dart_hw_unmap_locked_ttbr()
passed it to memset().

The NULL check was added together with the locked-DART page-table code
by commit 0d4ec07 ("iommu/dart: Add iommu_ops for locked DARTs"),
and became reachable once locked DARTs were allowed to probe.

Check the result with IS_ERR() and return the error, so that no error
pointer is ever stored.

Fixes: 85322eb ("iommu/dart: Support locked DARTs")
Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
(cherry picked from commit 162b646)
Signed-off-by: RJ Skerry-Ryan <[email protected]>
commit d87cb88 upstream.

apple_soc_cpufreq_init() adds OPP tables from firmware, but
some failure paths do not remove them. The driver also uses
dev_pm_opp_remove_all_dynamic(), which is not the right cleanup
helper for OPP tables loaded from firmware.

Use the cpumask OPP helper after the policy CPU mask has been
populated. Pair it with the matching cpumask remove helper on
failure paths and in apple_soc_cpufreq_exit(). This also removes
the separate dev_pm_opp_set_sharing_cpus() call, as the cpumask
helper loads the DT OPP tables for all CPUs in the policy.

Fixes: 6286bbb ("cpufreq: apple-soc: Add new driver to control Apple SoC CPU P-states")
Cc: [email protected]
Signed-off-by: Haoxiang Li <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
(cherry picked from commit eb346c1)
Signed-off-by: RJ Skerry-Ryan <[email protected]>
apple_soc_cpufreq_exit() drops the static OPP tables with
dev_pm_opp_of_cpumask_remove_table(policy->cpus), but policy->cpus is
always empty by then. __cpufreq_offline() clears the outgoing CPU from
the mask first and calls ->exit() only once the last CPU of the policy
has gone, and unbinding the driver takes the same path. The call
removes nothing, so every time a cluster goes fully offline and comes
back, or the driver is rebound, the OPP table of each of its CPUs is
left with one more reference and is never freed.

Remove the tables of policy->related_cpus instead, which still lists
every CPU the policy covered, as qcom-cpufreq-hw does. The error path
of apple_soc_cpufreq_init() keeps using policy->cpus, because the core
fills in related_cpus only after ->init() has succeeded.

Fixes: d87cb88 ("cpufreq: apple-soc: Fix OPP table cleanup")
Assisted-by: LLM checkpatch sparse
Co-authored-by: Claude Fable 5.1 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
(cherry picked from commit 6559da7)
Signed-off-by: RJ Skerry-Ryan <[email protected]>
commit f61c934 upstream.

apple_nvme_init_queue() initializes queue state and then marks the queue
enabled. The interrupt and request paths check enabled before using that
queue state.

The old wmb() after WRITE_ONCE(enabled, true) does not publish the
earlier initialization before enabled becomes visible. Use a release store
when enabling the queue and acquire loads when testing it.

Although the shutdown-side enabled accesses are not used for publishing
queue initialization, use helpers for them as well for consistency.

Fixes: 5bd2927 ("nvme-apple: Add initial Apple SoC NVMe driver")
Signed-off-by: Gui-Dong Han <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Keith Busch <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
(cherry picked from commit 8d4657c)
Signed-off-by: RJ Skerry-Ryan <[email protected]>
oliverlukschander and others added 3 commits September 30, 2026 22:57
apple_pmp_report_probe() allocates the report with devm_kzalloc() but
never initializes rep->lock. The first apple_pmp_report_set_state() from
a child entry's probe then takes an uninitialized spinlock; with lockdep
this is reported as a non-static key and lockdep turns itself off for the
rest of the boot:

  INFO: trying to register non-static key.
  ...
   _raw_spin_lock_irqsave
   apple_pmp_report_set_state
   apple_pmp_report_entry_probe

Initialize the lock before of_platform_populate() creates the entries.

Tested on j416s (M2 Pro) with PROVE_LOCKING: the report is gone and
lockdep stays enabled.

Fixes: e5f8c27 ("pmdomain: apple: Add PMP reporting interface")
Signed-off-by: Oliver Lukschander <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 583b9fa)
Signed-off-by: RJ Skerry-Ryan <[email protected]>
Commit c300d1b ("soc: apple: pmgr: Add force-disable/force-reset")
changed the transition poll in apple_pmgr_ps_set() to read into cur,
but left the timeout message printing reg, which now holds the value
that was written. Since then the "now:" field shows what was requested
rather than the state the domain is stuck in.

Print both the value written and the last value read back. On T8140,
audio_leap_mca occasionally misses the 100 us poll window, and the
read-back value (0xa4f: BUSY set, ACTUAL clock-gated, TARGET active) is
what tells a slow transition from a failed one.

Fixes: c300d1b ("soc: apple: pmgr: Add force-disable/force-reset")
Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
(cherry picked from commit 2768025)
Signed-off-by: RJ Skerry-Ryan <[email protected]>
apple_pmgr_ps_set() builds the words it writes from a read of the power
state register. It clears the WAS_CLKGATED and WAS_PWRGATED flags but
not BUSY (bit 11), which the hardware reports while a transition is
still in progress: on T8140 audio_leap_mca reads back 0xa4f, with BUSY
set, after missing the 100 us poll window. A value read in that state
was written back with BUSY set. Clear BUSY in the DEV_DISABLE/PS_RESET
write that precedes a power-down and in the target state write, which
the auto-enable write reuses. This changes the value written on every
SoC that uses this driver.
No failure attributable to writing BUSY back was observed; the change
is precautionary, as the bit is hardware-owned.

The error messages in apple_pmgr_ps_set() and in the reset assert and
deassert paths are printed from genpd and reset callbacks that
consumers retry, so a domain that keeps missing its poll window, as
audio_leap_mca does on T8140, repeats the same message on every
attempt. Ratelimit them; their text is unchanged.

Assisted-by: LLM checkpatch sparse
Co-authored-by: Claude Fable 5.1 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
(cherry picked from commit afe19ef)
Signed-off-by: RJ Skerry-Ryan <[email protected]>
@oliverlukschander

Copy link
Copy Markdown
Contributor

Tested on j416s (16" M2 Pro): two displays behind one dock work.

Setup: 3075f5503a32 plus your three apple,j414s gates extended to apple,j416s
(atc.c already covers j416s). OWC Thunderbolt 5 Hub on the right-hand port, two BenQs,
both attached at boot:

DP IN tunnel routing: tunnel 0:5 <-> 1:19   apple-dcp 289c00000.dcp: display routed to Thunderbolt DP tunnel dpin0
DP IN tunnel routing: tunnel 0:6 <-> 1:11   apple-dcp 315c00000.dcp: display routed to Thunderbolt DP tunnel dpin1
Switched dpin0 to dispext0,0  /  Switched dpin1 to dispext1,0
289c00000.dcp: set_digital_out_mode finished  /  315c00000.dcp: set_digital_out_mode finished

There was no not enough bandwidth, no WARN and no oops. For comparison, #8 without this series
fails the second tunnel with 0:6 <-> 1:11 (DP): not enough bandwidth and never feeds
315c00000. So the second J416s pipeline you held back validates, and J416s can take the J414s
rule.

Gate change used for the test
diff --git a/drivers/gpu/drm/apple/apple_drv.c b/drivers/gpu/drm/apple/apple_drv.c
index 4fcfac0f695d..3245c089d38c 100644
--- a/drivers/gpu/drm/apple/apple_drv.c
+++ b/drivers/gpu/drm/apple/apple_drv.c
@@ -438,7 +438,8 @@ static int apple_probe_typec_ports(struct drm_device *drm,
 	 * append one more connector per port for a second USB4 DP tunnel.
 	 */
 	for (idx = 0; idx < nr_ports *
-	     (of_machine_is_compatible("apple,j414s") ? 2 : 1); idx++) {
+	     ((of_machine_is_compatible("apple,j414s") ||
+	       of_machine_is_compatible("apple,j416s")) ? 2 : 1); idx++) {
 		struct apple_connector *connector;
 		struct apple_encoder *enc;
 		unsigned int port_idx = idx % nr_ports;
diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c
index 9578e688b0f1..a35a28376af5 100644
--- a/drivers/gpu/drm/apple/dcp.c
+++ b/drivers/gpu/drm/apple/dcp.c
@@ -607,7 +607,8 @@ int apple_dcp_tb_dp_tunnel(struct device_node *connector_np, unsigned int dpin,
 		 * streams through one dock. Retain J416s' existing preference
 		 * until its second pipeline has been validated separately.
 		 */
-		if (of_machine_is_compatible("apple,j414s")) {
+		if (of_machine_is_compatible("apple,j414s") ||
+		    of_machine_is_compatible("apple,j416s")) {
 			if ((dpin == 0 && !candidate->dcp->fixed_phy) ||
 			    (dpin == 1 && candidate->dcp->fixed_phy))
 				score += 100;
@@ -781,7 +782,8 @@ static int dcp_typec_route_set(struct typec_mux_dev *mux,
 				 * tunnel when a direct DP-alt-mode display can use
 				 * the Type-C-only dcpext1 pipeline.
 				 */
-				if (of_machine_is_compatible("apple,j414s") &&
+				if ((of_machine_is_compatible("apple,j414s") ||
+				     of_machine_is_compatible("apple,j416s")) &&
 				    candidate->dcp->fixed_phy)
 					score += 100;
 				if (score < best_score) {

Not yet covered with two displays: replug, DPMS and suspend. This test kernel is on #14's base,
without #25 and the AUSPLL fix, so those are better tested once this is on top of #8.

Also, c5653cb2e0b7 ("…rather than a power-off clear-swap timeout, establish a fatal firmware
crash") looks like it covers the DCP unplug wedge I reported on #8 (the 50 ms clear-swap timeout
in iomfb_poweroff() setting crashed). Worth lining up with Chris, who planned a separate PR
for it.

@oliverlukschander

Copy link
Copy Markdown
Contributor

Follow-up with the same two displays on j416s:

@chriskearney

Copy link
Copy Markdown
Contributor

@DjDeveloperr I've ported this series onto #8 (947026902232), since #8 now carries #14 and #25. Your six commits keep you as author, and each has a note on what changed. The j414s gates go through #8's apple_dp_tunnel_t602x(), so all four M2 Pro/Max laptops get two streams; Oliver ran two displays on j416s with the same gates. The DPMS part was already in aurora-wip as ab7cad0652d5, and the clear-swap change is superseded by #64's version, which carries on with the power-off. Happy to adjust anything. If it looks right to you, this PR could close in favour of #8.

chriskearney added a commit to chriskearney/aurora-linux that referenced this pull request Oct 2, 2026
On a 16" M2 Pro (j416s) the built-in screen stayed black on 11.17/11.18
while the session ran. apple-drm registered about 30 s into boot, after
the desktop had started on the boot framebuffer (simpledrm), and the
session was left without its screen; restarting the display manager
brought it back (same symptom reported on a j416c in
aurora-silicon/linux#46). An sddm drop-in now waits for a DRM card
bound to apple-drm before the display manager starts. It only waits on
a Mac whose device tree enables an Apple display subsystem, gives up
after 30 s and never fails the start, so where apple-drm is already up
(3.9 s on an M1 Air) it costs nothing.

Signed-off-by: Chris Kearney <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FwdG63dRaMrRbYrUBkSa1i
The shared TIPD core can be built in for the SPMI transport while the I2C
transport is a module. Descending with the I2C setting then omits the
built-in core from the parent archive, leaving the I2C module with
unresolved TIPD references at modpost and omitting the SPMI driver from
vmlinux.

Use TYPEC_TPS6598X_CORE for directory traversal, as in the current
aurora-wip Makefile. The child Makefile already selects the core and both
transports independently.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
RyanTheTide and others added 4 commits October 8, 2026 18:51
The board property permits experimental kernel cold initialization, but
must not reject an existing successful m1n1 handoff. Admit the explicit
preinit certificate in both the population gate and preparation helper
without touching cold-init registers.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Keep receiver ownership reserved until teardown finishes. A competing
initialization must return EBUSY instead of overwriting the callback and
cookie, and must not stop the mailbox owned by the existing receiver.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
usb: typec: tipd: descend according to the shared core
[follow-up to #50] PCI: apple: retain preinitialized tunnels when cold init is disabled
RyanTheTide added a commit that referenced this pull request Oct 8, 2026
drm/apple: support independent dual dock DP streams on J414s

Original contributor commits are preserved. Conflict resolutions retain the audited shared driver APIs and their integrated review fixes.

Contributor credit; Signed-off-by outstanding:
- 2530a2c: Ryan <[email protected]>
- 9e93cac: Ryan <[email protected]>
- 3075f55: DjDeveloperr <[email protected]>
- a9aa605: DjDeveloperr <[email protected]>
- 0cd936d: DjDeveloperr <[email protected]>
- aff9d4e: DjDeveloperr <[email protected]>
- a044eab: DjDeveloperr <[email protected]>
- c5653cb: DjDeveloperr <[email protected]>
- e9e52e6: Oliver Lukschander <[email protected]>
- 0c16b38: Oliver Lukschander <[email protected]>
- e83f46d: Oliver Lukschander <[email protected]>
- 2b5254a: Oliver Lukschander <[email protected]>
- cc895f2: Oliver Lukschander <[email protected]>
- f8cec39: Oliver Lukschander <[email protected]>
- 81eee7b: Oliver Lukschander <[email protected]>
- 45c34d5: Oliver Lukschander <[email protected]>
- 6f0468f: Oliver Lukschander <[email protected]>
Ryan integrates these contributions under DCO (b); no author signature is forged.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
@DjDeveloperr
DjDeveloperr deleted the fix/j414s-dual-dock-dp branch October 12, 2026 19:14
DjDeveloperr pushed a commit that referenced this pull request Oct 16, 2026
drm/apple: support independent dual dock DP streams on J414s

Original contributor commits are preserved. Conflict resolutions retain the audited shared driver APIs and their integrated review fixes.

Contributor credit; Signed-off-by outstanding:
- 2530a2c: Ryan <[email protected]>
- 9e93cac: Ryan <[email protected]>
- 3075f55: DjDeveloperr <[email protected]>
- a9aa605: DjDeveloperr <[email protected]>
- 0cd936d: DjDeveloperr <[email protected]>
- aff9d4e: DjDeveloperr <[email protected]>
- a044eab: DjDeveloperr <[email protected]>
- c5653cb: DjDeveloperr <[email protected]>
- e9e52e6: Oliver Lukschander <[email protected]>
- 0c16b38: Oliver Lukschander <[email protected]>
- e83f46d: Oliver Lukschander <[email protected]>
- 2b5254a: Oliver Lukschander <[email protected]>
- cc895f2: Oliver Lukschander <[email protected]>
- f8cec39: Oliver Lukschander <[email protected]>
- 81eee7b: Oliver Lukschander <[email protected]>
- 45c34d5: Oliver Lukschander <[email protected]>
- 6f0468f: Oliver Lukschander <[email protected]>
Ryan integrates these contributions under DCO (b); no author signature is forged.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
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.

7 participants