Skip to content

drm: apple: dcp: take no device lock for a mode set without a peer - #2454

Open
techmore wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
techmore:m4/dcp-peerless-modeset
Open

techmore wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
techmore:m4/dcp-peerless-modeset

Conversation

@techmore

@techmore techmore commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What fails

dcp_peer_modeset_v27() tries the DCP's device lock before it looks whether the display has a reserved peer, and returns -EBUSY when the lock is held. Without a peer the function has nothing to do: its answer is -EOPNOTSUPP, "set the mode on this engine alone".

The DCP's own probe holds that lock while the DRM device is bound and registered. If the sink's hot-plug arrives before the registration, the fbdev client's first mode set runs inside the registration, under the probe's lock, and is refused before anything is sent to the firmware:

apple-dcp 30ae00000.dcp: paired mode set failed: -16

The requested mode is already recorded as the current one at that point, so nothing retries it, and the pipe stays on the boot loader's mode until the next real mode change.

The change

Seven lines: under dcp_peer_lock, a display with no reserved peer gets -EOPNOTSUPP before the device lock is tried.

Who it reaches

The only caller is iomfb_template.c:4297: every firmware 27.0+ mode set that does not inherit the boot mode. Every such display without a peer takes the new return; it is the value the old code returned whenever its trylock succeeded. A display with a reserved peer is unchanged line for line, and that includes the remaining window: it still gets -EBUSY while its device lock is held, with the mode already recorded.

Testing

Hardware: a J773g (Mac mini M4) on a macOS 27.2 stub, as part of our firmware-27 display test stack (not on the base alone, where this unit has no display path).

  • One boot with the failing order (hot-plug 0.36 ms before the registration): no paired mode set failed line, and the firmware's Modeset requested at 1.49 s.
  • An earlier boot of the same stack without the fix, with the hot-plug 0.3 ms before the registration: the line twice, and no mode set reaching the firmware until a mode change at 96.8 s.
  • Four boots without the fix had the hot-plug 3 to 7 ms after the registration and no failure.

Not tested: any display with a peer (T6050), any other machine.

Checks, on base 6ae9c3c and on the commit:

  • The CI host-tests job's command (python3 -I tools/asahi/run-host-tests.py, clang 18, rustc 1.96.0; gcc 15.2 where the job pins 13), run locally: 426 of 427 on both. The one failure on each is a mutant run of tbnet-refill-tests (Thunderbolt networking), which is timing-dependent on this shared host: run again by itself, all five of its runs pass on the commit, and on the base three of five failed while another job was running. Everything else passes on both, the apple-dcp suite included.
  • checkpatch --strict: no errors, warnings or checks.
  • W=1 build of drivers/gpu/drm/apple/: builds; the two kernel-doc notices it prints are for dcp.c:774, which this commit does not touch.

The commit adds no board, SoC or firmware gate. Its one new test is whether a peer engine is reserved for the display, the state the function already reads a few lines further down.

On integration base 5746ef8a5, the rebased patch compiled for ARM64 with Rust enabled. Both dcp.o and iomfb_v27.o built without warnings. The five connected-HDMI J773g cold boots and the J575c/T6050 peer boot are still pending.

Assisted-by: LLM (OpenAI:GPT-6.2-Astra)

@chatgpt-codex-connector

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-11-19T19:29:55.769327Z
We couldn’t complete this review. Comment @codex review to try again.
23044cd PR opened
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Blockers: 1.

The change is correct. In drivers/gpu/drm/apple/dcp-peer-runtime-v27.inc:127-129, peer_reserved is read under dcp_peer_lock, as the existing check after the trylock does (:137-140). The no-peer case now returns the same -EOPNOTSUPP the old code returned whenever its trylock succeeded, and the peer path is unchanged. dcp_peer_limited_pair_locked() already returns false without a peer (:87), so nothing it checked is lost.

  1. Commit 23044cd carries Assisted-by: LLM. Keep only the human Signed-off-by in the commit, and put Assisted-by: LLM (<Vendor>:<Model>) as the PR body's last line (it is missing).

HW row: J773g on this commit, default command line, 5 cold boots with the HDMI sink connected. Each needs no paired mode set failed line and a firmware mode set within the first 2 s, with the hot-plug/registration order logged for each. Add one boot on a Mac that has a peer (J575c/T6050) to show the paired path is unchanged, plus 0 failed units, 0 AVC and 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pre-PR checklist review against 23044cd5ecd4e0c20c75b3c0453c2ad57449cf16 (host-tests: SUCCESS).

Code Review

The kernel change itself (drivers/gpu/drm/apple/dcp-peer-runtime-v27.inc:127-133) is sound:

  • dcp->peer_reserved is protected by dcp_peer_lock (dcp-internal.h:462-464, dcp-peer-v27.inc:148-237), matching the existing read under dcp_peer_lock after device_trylock(dcp->dev) at :137-140.
  • dcp_peer_limited_pair_locked() (:84-94) already returns false when !dcp->peer_reserved, so returning -EOPNOTSUPP early for a peerless display skips no peer-limit logic and avoids taking device_trylock(dcp->dev) against DCP probe's lock.
  • Sole caller iomfb_modeset() (iomfb_template.c:4297-4310) still rejects any timing requiring a pair via dcp_peer_needs_pair_v27() (:4305), and the paired path is unchanged.

Blockers

  1. §4 Attribution violation (hard):
    • Commit 23044cd5ecd4e0c20c75b3c0453c2ad57449cf16 includes Assisted-by: LLM in the commit message. Commits must carry human identity and human Signed-off-by: only, with no Assisted-by: or AI trailers in commits.
    • Remove Assisted-by: from the commit message and disclose agent assistance with a plain Assisted-by: line at the end of the PR body (currently missing).

Checklist (§1–§6)

  • §1–§3, §6: Pass (no chip/board/firmware gate added — checks runtime dcp->peer_reserved state; default cmdline, no hacks/params, no safety/naming violations).
  • §4 Attribution: FAIL (blocker #1 above).
  • §5 Evidence: Incomplete — currently only 1 stacked J773g boot with the fix is reported, no Mac with a reserved peer (T6050) has been tested (Not tested: any display with a peer (T6050), any other machine), and the §5 regression tuple (0 SELinux denials, 0 failed units, 0 new kernel errors) is missing. Please add multi-boot J773g confirmation (cold boots with HDMI sink connected, hot-plug/registration order, no paired mode set failed, firmware mode set completed), a peer-path boot on T6050 confirming no regression, and the §5 regression counts on the updated head.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Applies cleanly onto integration/aurora (4a17f73). dcp-peer-runtime-v27.inc has not changed since this was opened, so dcp_peer_modeset_v27() on the tip still tries the device lock before it looks for a peer, and the fix is still needed. Both reviews found the change correct; what is open is the commit-message point they raised and the rows: five J773g cold boots with the HDMI sink connected, and one boot on a machine that has a peer.

dcp_peer_modeset_v27() takes the DCP's device lock with a trylock
before it looks whether the display has a reserved peer at all, and
returns -EBUSY when the lock is held. Without a peer the answer is
-EOPNOTSUPP, "set the mode on this engine alone", and needs no lock.

The lock is held by the DCP's own probe while the DRM device is bound
and registered from it. A display that is already connected at that
moment gets its first mode set from the fbdev client inside the
registration, so under that lock: the mode set is refused before
anything is sent to the firmware,

  apple-dcp 30ae00000.dcp: paired mode set failed: -16

while the requested mode is already recorded as the current one. The
pipe then runs on whatever mode the boot loader left until the next
real mode change.

Whether it happens depends on the order of the sink's hot-plug and the
registration, a few milliseconds apart on the J773g's fixed HDMI
output on firmware 27.2: four boots had the hot-plug after the
registration, one had it 0.3 ms before and logged the line twice, with
no mode set reaching the firmware until a mode change 95 s later.

Answer for a display without a reserved peer under the peer lock
alone, before the device lock is tried. A display with a peer is
handled as before.

A display with a reserved peer still gets -EBUSY while its device lock
is held, with the mode already recorded; that is unchanged. Every
firmware 27 display without a peer takes the new return. Not tested:
any display with a peer.

Signed-off-by: Sean Dolbec <sdolbec1@gmail.com>
@techmore
techmore force-pushed the m4/dcp-peerless-modeset branch from 23044cd to 7ba8b93 Compare November 24, 2026 02:59

Copy link
Copy Markdown
Contributor Author

We can schedule the five connected-HDMI J773g cold boots locally. Could an owner with a peer-equipped J575c/T6050 claim the paired-display boot at 7ba8b9396 and share the modeset result, failed-unit count, AVCs and new kernel errors?

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.

3 participants