Skip to content

drm/apple: route a DP-alt port only once its display asserts HPD - #2835

Open
Ante042 wants to merge 1 commit into
aurora-silicon:mainfrom
Ante042:j314s-typec-dp-alt-hpd
Open

Ante042 wants to merge 1 commit into
aurora-silicon:mainfrom
Ante042:j314s-typec-dp-alt-hpd

Conversation

@Ante042

@Ante042 Ante042 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What: A port in DP alt mode takes a display pipeline as soon as it enters DP mode, even with nothing asserting HPD behind it, so a USB-C dock without a display takes a pipeline and a USB-C display then waits for as long as the dock stays plugged in. Which port enters DP mode first changes from boot to boot, and at a wake the port controller applies each port's state again, so the dock's port can also take a pipeline an HDMI display left free. Main now leaves such a port unrouted only on Desktop 26.x, T6041 and T8142; this makes that the rule on every machine. A port that owns a pipeline behaves as before on an HPD drop, so a display in standby keeps its pipeline, and the compositor-ordered path is unchanged.
Tested: J314s M1 Pro, main 24970e1 with this PR and three other small PRs (#4237, #4235, #4236) at 0a274fa, an empty USB-C dock (nothing behind it), an ASUS ROG monitor on USB-C and a VG278 on HDMI: 3 fresh boots, the dock's port took no pipeline in any (0 "waits for a free external display pipeline"), all three displays connected, 0 kernel warnings. On the T6000 deep sleep series, which carries this commit unchanged: 16 fresh boots with the same setup, the USB-C monitor on its pipeline and the dock's port unrouted in every one; HDMI pulled while awake, a deep sleep, HDMI plugged in after the wake: the dock's port took no pipeline and the HDMI display came up. The same series without this commit: at boot the empty dock's port got the Type-C pipeline and the USB-C monitor waited for the whole boot ("display on USB-C Left Front waits for a free external display pipeline").
Risk: Two-way door. Every Mac whose Type-C ports route DP alt mode through dcp_typec_route_apply(); for Desktop 26.x, T6041 and T8142 nothing changes. Run only on the J314s (T6000); a T8112 baseline in the comments shows the unpatched behaviour there too.
Not yet: Rows on other Macs (the J415 and J615 offers in the comments). The earlier "USB-C display stays dark after s2idle" item here was dcpext1 losing its power in s2idle, which is its own fix now: #4237 (for #3718).

Details

The same thing happens at boot, when the PD controllers report a DP state for ports with nothing behind them, which is how the LUKS prompt ends up on the internal panel of a closed laptop (omarchy-pkgs#1037). I wrote here before that other processors already keep such a port unrouted. That was wrong at least for the T8112 (see the baseline in the comments), and the change is in the common routing path.

An earlier version also let a port with HPD take over the pipeline of a port without it. As the review pointed out, that would also take the pipeline of a display in standby, so it is gone. The tipd -ENOSPC patch from the old pull request is already fixed here by 219a271 and 27285e5.

Moved from omacom/linux-aurora#186.

Evidence

At 861ff55 (rebased onto main 24970e1; main had gained the same rule for three machines, so the change is now the dropped gate): build (LLVM=1, W=1, arm64) drivers/gpu/drm/apple/dcp-fabric.o rc=0, 0 warnings; checkpatch --strict 0 errors, 0 warnings, 0 checks.

kernel boots dock's port routed USB-C monitor up warnings
main + this + three small PRs (0a274fa) 3 0 3 of 3 0
deep sleep series with this commit 10 + 6 0 16 of 16 0
deep sleep series without it 1 at boot no, waited all boot 0

Earlier version of this PR (edb4a5d):

  • Port disconnects: the port's PD controller told to drop the connection for 4 s (verify/pd-disc.sh 0x3f 4), three times, 16 s apart. Each time DP-2 came back at 2560x1440@200 10 bit, tps6598x/typec error lines 0, kernel WARNING splats 0.
  • Earlier rows on older bases (7.2.10, 7.2.11, a 22/11 integration tip): two displays and a dock on three ports, both displays up at boot and after replugs, the dock never got a pipeline and its USB worked; a display in standby kept its pipeline.
  • After the sleeps: dcp_dptx_connect: failed to validate DPTX target 0:1: -110 x6, Type-C DPTX reconnect failed after 6 retries, and on the next disconnect tps6598x 0-003f: cable revalidation failed after 3 attempts. The HDMI display came back.

Happy to run anything else on the J314s.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Review at b01c5de (non-author, draft). One question on the takeover; otherwise no blocker beyond the booted row.

  • Routing only once the sink asserts HPD (second patch) is the right default and matches what the other processors already do; a port that already owns a pipeline keeps it across an HPD drop, as before. applied_valid = true with no route makes the next HPD status a fresh update, so the port is routed then.
  • IS_ERR() from the takeover is propagated, and the "every pipeline busy" path now always goes to dcp_typec_port_busy(), which is only reached with HPD set.
  • Both commits merge cleanly on the current integration/aurora tip; the transaction selftest stub keeps it building.

Question (takeover, first patch): the comment says it takes a pipeline "from a direct DP-alt port whose sink never did" assert HPD, but the check is the port's current state (held->port->hpd || held->port->dp_hpd, both set from the latest status in dcp_typec_route_apply()). Many monitors drop HPD in standby, and the second patch deliberately lets such a port keep its pipeline. With every pipeline in use and one monitor asleep, plugging another display takes the sleeping monitor's pipeline, and that monitor finds none when it wakes. If the intent is "never asserted since it connected", a latched per-connection flag (cleared on disconnect/SAFE) would match the comment and leave sleeping monitors alone. A replug row with one monitor in standby would show which behaviour you get.

Small points, not blocking:

  • The -110 DPTX state you saw once after a hand-over is a reason to keep the takeover as narrow as possible; with the second patch in place, is the first one still needed for anything but ports routed before this change (boot-time state from the PD controllers)? If not, it could be limited to that case.
  • Both commits carry Assisted-by: LLM and no Signed-off-by: yet; they need the sign-off before landing.

Assisted-by: LLM (Claude:Opus 5.5)

@ericjuta

Copy link
Copy Markdown
Contributor

To address @RyanTheTide's review point about a sleeping monitor losing its pipeline on a second plug: I ported the idle-port reclaim patch onto 7.3 main with a latched per-plug dp_hpd_seen flag (set when HPD is asserted, cleared on Type-C disconnect) so dcp_typec_reclaim_idle() only reclaims a pipeline from a port whose sink never asserted HPD during the current plug.

If useful, feel free to cherry-pick or fold in commit 1a7c5aaff from ericjuta@1a7c5aaff (branch t8122/idle-port-pipeline-7.3, includes Signed-off-by, quiesce.py struct update, checkpatch clean, apple-dcp-* KUnit 163/163 pass).

@Ante042

Ante042 commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

The check is the port's current state, so with every pipeline in use a monitor in standby would lose its pipeline to a newly plugged display. That is not what the comment says and not what I meant.

With the second patch a port only gets a pipeline once its sink has asserted HPD, so as far as I can read it the only ports left for the takeover on this machine are the ones that had HPD and dropped it, which is exactly the case it should leave alone. That makes the choice either to drop the first patch or to keep it with a latched flag, the way @ericjuta did in 1a7c5aa (thanks for porting that with the latch!). Before I update the branch I'll check on the J314s whether anything is still routed without HPD at boot with the second patch alone, and run a replug row with one monitor in standby. That needs the laptop back at the desk with both monitors.

The sign-off will be on the commits before this leaves draft.

@Ante042
Ante042 force-pushed the j314s-typec-dp-alt-hpd branch from b01c5de to 9da4ccf Compare November 26, 2026 14:33
@ericjuta

Copy link
Copy Markdown
Contributor

Thanks. Either outcome works for me: if the second patch alone leaves nothing routed without HPD at boot on the J314s, dropping the first one is the simpler result, and 1a7c5aaff is there if you keep the takeover.

One limit on my side: 1a7c5aaff is build- and KUnit-tested only (apple-dcp-* 163/163). I have not booted it, and I have one external monitor on a J615, so I can't produce the standby row with every pipeline in use. I can run a single-monitor replug and lid row on a J615 at your updated head if that is useful.

@Ante042
Ante042 force-pushed the j314s-typec-dp-alt-hpd branch from 9da4ccf to fa8034a Compare November 26, 2026 19:54
@Ante042

Ante042 commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

I dropped the first patch, so the branch is now the second one alone, with the sentence about the hand-over taken out of its message.

Tested on the J314s with a test kernel built from the integration tip of the 22nd with this patch and without the takeover, two monitors over USB-C, one of them behind a USB-C KVM dock:

  • A monitor put in standby for 60 s drops HPD. Its port kept its pipeline, and the picture came back on the same DCP when it woke.
  • With the monitor's DP cable pulled from the dock, the dock stays in DP mode with nothing behind it and gets no pipeline. Plugging the monitor back in routed it to the free pipeline right away.
  • At boot with both monitors on, both are routed as before.

A port with HPD that finds every pipeline driving another display now waits, as it did before this PR. I could not set up that case here, it needs three displays.

@ericjuta, thanks for the latched version. With the takeover gone it isn't needed for this PR, but it would be the way to do it if the takeover comes back.

The sign-off will be back on the new commit shortly.

@sschuez

sschuez commented Nov 30, 2026

Copy link
Copy Markdown

Baseline from a J415 (MacBook Air 15" M2, T8112) for the case this PR targets. This is without the PR: packaged linux-aurora 7.3.0.aurora1-1 with aura 1.0.0b17 from the Omarchy rc channel.

Setup: an Anker USB-C hub with DP alt mode and no display attached, plugged in first. An Apple Studio Display (Thunderbolt) plugged into the other port 16 s later.

Result: the hub works (USB 2 and USB 3 trees, Ethernet, HID). The idle hub takes the external pipeline, and the Studio Display stays dark.

[ 1120.034238] apple-display-crossbar 50304c000.mux: Switched dpphy to dispext1,0
[ 1120.034433] apple-dcp 271c00000.dcp: allocated Type-C DPTX PHY 1
[ 1120.036190] xhci-hcd xhci-hcd.8.auto: new USB bus registered, assigned bus number 1
[ 1135.811253] thunderbolt 0-1: Apple Inc. Studio Display
[ 1136.152016] thunderbolt-apple-acio 381ac0000.cio: dpin0: no display pipeline free; waiting for one

The other order works on the same boot: display first, then the hub, gives a 5120x2880@60 picture and working hub USB, with no -28 or revalidation lines.

Not tested: whether the display lights up when the hub is unplugged afterwards, and this PR's head. I can re-test on this Mac when a build with it reaches the Omarchy rc channel.

@Ante042

Ante042 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

@sschuez, thanks for the baseline. That is exactly the case this PR is about, and I had only seen it on the J314s.

Your log also shows that my Risk line is wrong. It says T600x only, but the change is in the common Type-C routing path (dcp_typec_route_apply() in dcp-fabric.c), and the allocated Type-C DPTX PHY 1 line in your log comes from that path, so the T8112 takes it too. I'll correct the Risk line.

From reading the code, with this PR your hub should stay unrouted until a display behind it asserts HPD, and the Studio Display's tunnel picks from the same pipelines, so it should find one free. I have only run it on the J314s, so none of this is tested on your Air yet. If a build with it reaches the rc channel, your same two orders would be the row it is missing on a second chip, and an unplug of the hub afterwards would be a good third.

@Ante042

Ante042 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

@ericjuta, I never answered your offer of a single-monitor replug and lid row on your J615, sorry. If it still stands, it would help now. Reading main again, the change is not limited to T600x after all, and a row on a Mac other than my J314s is what it lacks. The head is still edb4a5db6ecf.

The most useful row with one monitor: a hub or dock in DP alt mode with no display behind it plugged in first and the monitor second, then a replug of the monitor, and a lid close and open with the monitor on. A pass would be the monitor lit each time, and no allocated Type-C DPTX PHY line when the hub is plugged in.

@sschuez

sschuez commented Dec 2, 2026

Copy link
Copy Markdown

Thanks. I'll run both orders and then a hub unplug once a build with this reaches the rc channel, and post the results here.

Outside compositor pairing order, a direct DP-alt port with no pipeline
takes the lowest free one as soon as it enters DP mode, whether or not a
display is behind it; only Desktop 26.x, T6041 and T8142 wait for HPD.
A USB-C dock without a monitor that enters DP mode before the port of a
USB-C display takes the pipeline that display needs, and the display
then waits for as long as the dock stays plugged in. Which port enters
DP mode first changes from boot to boot. At a wake the port controller
applies each port's state again, and the dock's port then takes a
pipeline an HDMI display left free.

Leave a port that owns no pipeline and has no HPD unrouted on every
machine, as those three already do. The port controller reports HPD as
a new status when a display appears, and the port is routed then. A port
that owns a pipeline behaves as before on an HPD drop, and the
compositor-ordered path is unchanged.

Signed-off-by: Andreas Fernandez <andreas.fernandez@hotmail.com>
@Ante042
Ante042 force-pushed the j314s-typec-dp-alt-hpd branch from edb4a5d to 861ff55 Compare December 3, 2026 22:00
@Ante042 Ante042 changed the title drm/apple: dcp: keep DP-alt ports without a display off the Type-C pipelines drm/apple: route a DP-alt port only once its display asserts HPD Dec 3, 2026
@Ante042
Ante042 marked this pull request as ready for review December 3, 2026 22:00
@Ante042
Ante042 requested review from a team as code owners December 3, 2026 22:00
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-12-03T22:01:03.891216Z
We couldn’t complete this review. Comment @codex review to try again.
861ff55 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

Merge readiness at 861ff550: not ready yet

Check Detail
CI at head ok 4 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head no no line with the head SHA 861ff550, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · . Every Mac whose Type-C ports route DP alt mode through dcptypecrouteapply(); for Desktop 26.x, T6041 and T8142 nothing changes. Run only on the J314s (T6000); a T8112 baseline in the comments shows the unpatched behaviour there too.

Areas: area:display

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 861ff55

Checked: An unowned direct DP-alt port with HPD low now exits without picking a pipeline. The cached status includes HPD, so a later assertion applies a fresh update. The existing HPD-drop path for an owned port, tunnel handling, and compositor ordering are preserved.

Checked: The exact routing block passed 25 local cases across the legacy and previously gated paths. They covered an empty dock with and without a free pipe, later HPD, an existing owner, ordered routing, and activation failure retry. Both legacy baseline controls reproduced the earlier behavior. The author reports three fresh J314s boots with the PR in the tested stack and 16 more in the deep-sleep series.

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

area:display Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants