Skip to content

drm/apple: stop the DCPLink when a start or swap ends the session - #2460

Merged
RyanTheTide merged 7 commits into
mainfrom
hack/round3-c
Nov 29, 2026
Merged

RyanTheTide merged 7 commits into
mainfrom
hack/round3-c

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What: A failed panel start or refused swap now stops the DCPLink, so a failed session stops queueing firmware notifications that are never freed.
Tested: head 307675b = 47cf16e (hardware rows) + a clean main merge (794c43b) + a KUnit-only commit (the backlight test fixture now runs dcp_v14_link_init(), plus the internal/external refusal cases). Hardware at 47cf16e in the combined one-shot kernel 7.3.0-aurora-dsw1: J615 (v26_6 client) and J473 (external DCPs) start and swap normally, displays connected, no new DCP error lines against the fleet kernel, s2idle rc 0, 0 WARN/BUG. iomfb_v14_7.c/iomfb_v26_6*.c are byte-identical at 307675b. KUnit at 307675b (local run of the CI recipe, drivers/gpu/drm/apple/tests/display.kunitconfig, arm64 QEMU): 169 run, 168 passed, 1 skipped; v14_bl_failed_submit_unknown and v14_bl_external_refusal_keeps_link pass. The hosted kunit check failed at 794c43b, before the fixture fix.
Risk: two-way · Macs on the v14_7 and v26_6 DCP clients (T6030/T6031, J613/J615, externals)
Not yet: a failed start or refused swap on real hardware (none reproduced); the failure paths are covered by reading the code only

Evidence
Original description

Problem

A failed panel start and a swap that the firmware refuses on the internal panel mark the DCP session failed, but leave the DCPLink running. Nothing pumps a failed session, so the link keeps queueing the firmware's notifications as kmalloc'd events that are never freed before reboot. The failed-call path (#2386) and the notification-error path (#2458) already stop the link in this case. These five paths did not.

Change

On these paths dcp_v14_link_fail() / dcp_v26_link_fail() is now called right after the session is marked failed, in both copies of the client:

  • the fail: label of the v14_7 panel start (T6030/T6031 internal panel);
  • an internal-panel swap refused in dcp_v14_swap_locked();
  • the fail: label of the v26_6 start (J613/J615);
  • a swap with a nonzero status in dcp_v26_swap();
  • (second commit) a refused external open (A401/A455 answered with an unexpected status: dcp_v14_simple_call() returns -EPROTO with the link still running).

link_fail() frees the queued events and refuses new ones. It takes only the link lock, which none of these paths hold: the session lock is taken first, the same order as the idle work. It is also harmless on a link that never started; it then only logs "DCP link stopped" once.

This is stacked on #2458 (and #2386 under it). Those must merge first, and their commits show up in this diff until then.

Third commit: both v14_7 DCP starts reboot RTKit up to four times when apple_rtkit_wake() times out, and a retry that worked left no trace. The bounded retry stays, because nothing records why the first handshake times out. It is now commented where the bound is defined and warns with the number of extra boots whenever one was needed (#2461).

Testing

  • arm64 LLVM W=1 build of iomfb_v14_7.o and iomfb_v26_6.o on the combined tree: no warnings.
  • Every failed = true site in both files was checked. A call that fails once submitted already stops the link in the link layer (dcp_v1[4]/v26_link_call()); RTKit wake and link-start failures happen before the link carries events; the idle-work path is drm/apple: stop the DCPLink when a notification fails #2458. The five paths above were the remaining ones.

Still to run

  • None of the lab Macs reaches these files. They run only on T6030/T6031 (J514/J516 family) and J613/J615.
  • Owner row: the panel starts as before, and dmesg | grep -E 'display not started|DCP link stopped' is empty. If a start or swap does fail, "DCP link stopped" follows straight after it, and /sys/kernel/debug/kmemleak (where enabled) shows no dcp_v1[4]_event/dcp_v26_event growth over 10 minutes.

Credit: the start, swap and external-open paths are from Chris Kearney (98d767e, b7b1076) and Satya Benson (aa504d6).

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

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

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

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

This PR: No lab Mac reaches these paths; boot-clean regression rows only.

dcp_v26_link_call() was copied from the T6030 14.7 DCPLink client
before two fixes landed there, and the 26.6 copy kept the old exits.
When a call times out, fails its reply check, or a callback handler
fails, it returns with the link still running and calls[nested].active
still set. dcp_v26_call() then marks the session failed and nothing
pumps the link again, but dcp_v26_link_receive() keeps accepting the
late reply and every later callback and queues a kmalloc'd copy of
each, up to the 32-event limit. The same happens when a queued
notification fails while draining before an outer call, and when a
nested call finds no callback to answer. link_fail() woke the waiters
but left the queued copies on a list nothing would dequeue again.

Port Chris Kearney's 14.7 fixes, commit d203ba4 ("drm/apple: stop
the T6030 DCPLink when a call is abandoned") and commit 90139dc
("drm/apple: stop the T6030 DCPLink when a call fails before submit"):
stop the link on every return that gives up on a call, clear the
abandoned call's active flag so the receive path drops whatever arrives
for it, and free the queued events in link_fail() under the lock. An
event a caller has already dequeued is no longer on the list.

The callers already treat any failed call as the end of the session
(dcp_v26_call() latches v26->failed, "recovery requires a reboot"), so
nothing that worked before stops working. The firmware buffers and the
RPC memory are still kept until reboot. This code runs only with the
J613 (apple,t8122-dcp) 25G83 DCP firmware.

The -EBUSY retry before submit is unchanged: it re-drains a callback
that arrived between the drain and the submit, bounded by the call
deadline.

Fixes: aa504d6 ("drm: apple: add the J613 v26 display backend and guarded coldplug")
Signed-off-by: Ryan Murray <[email protected]>
dcp_v14_idle() and dcp_v26_idle() handle the firmware callbacks that
arrive while no call is in progress. When one of them fails (a callback
handler error, a malformed callback, a reply nobody asked for, or a
failed reply), they mark the session failed, "recovery requires a
reboot", and return with the link still running. From then on the loop
condition (!failed) means nothing pumps the link again, but
dcp_vNN_link_receive() keeps accepting every later firmware callback and
queues a kmalloc'd copy of each, up to the 32-event limit, and queues
the idle work for each, which then does nothing. The copies stay on the
list until reboot unless a 33rd event arrives: the link state outlives
the device and nothing else frees them.

This is the leak Chris Kearney fixed for abandoned calls in the 14.7
client, commit d203ba4 ("drm/apple: stop the T6030 DCPLink when a
call is abandoned"), and commit adbab6a ("drm/apple: stop the J613
DCPLink when a call is abandoned") in the 26.6 copy; the notification
path of both was left out. Stop the link there the same way: call
dcp_vNN_link_fail(), which frees the queued events under the link lock,
wakes any waiter, and makes the receive path drop whatever arrives
next. The two idle functions stay identical.

Nothing that worked before stops working: every later call already
returns -EIO on the failed session (dcp_v14_call_guarded(),
dcp_v26_call()), and the firmware buffers and RPC memory are still kept
until reboot. If the link had already failed (the pump returned -EIO
for that reason), link_fail() is idempotent.

The 14.7 code runs on T6030 (J514s/J516s panel and external
processors), T6031 (J514c/J516c) and T8122 (J613/J615) with the 14.7
DCP image; the 26.6 code only on J613/J615 with the 25G83 image.

Fixes: 98d767e ("drm/apple, media: apple: avd: T6030 internal panel, external display and AVD fixes")
Fixes: aa504d6 ("drm: apple: add the J613 v26 display backend and guarded coldplug")
Signed-off-by: Ryan Murray <[email protected]>
A failed panel start (the fail: label of dcp_v14_start()/dcp_v26_start())
and a swap the firmware refuses on the internal panel mark the session
failed but leave the DCPLink running. Nothing pumps a failed session, so
the link keeps queueing the firmware's notifications as kmalloc'd events
that nothing frees until reboot. This is the leak the failed-call and
notification-error paths already close with dcp_v14_link_fail() and
dcp_v26_link_fail().

Stop the link on these four paths as well, in both copies of the client.
dcp_v*_link_fail() frees the queued events and refuses new ones; it takes
only the link lock, which these paths never hold (the session lock is
taken first, as in the idle work), and it is harmless on a link that
never started.

Fixes: 98d767e ("drm/apple, media: apple: avd: T6030 internal panel, external display and AVD fixes")
Fixes: aa504d6 ("drm: apple: add the J613 v26 display backend and guarded coldplug")
Signed-off-by: Ryan Murray <[email protected]>
…fused

When the external display processor answers A401 or A455 with an
unexpected status, dcp_v14_simple_call() returns -EPROTO with the link
still running. The open path then marks the session failed, and the link
keeps queueing notifications that nothing pumps or frees, the same leak as
the start and swap paths fixed in the previous commit.

Stop the link there as well, before reporting the session stopped.

Fixes: b7b1076 ("drm/apple: t6030: start an external display processor on first use")
Signed-off-by: Ryan Murray <[email protected]>
Both DCP starts (dcpext and the internal panel) boot RTKit up to four more
times when apple_rtkit_wake() times out, and a retry that worked left no
trace. Nothing records why the first handshake times out, so the loop
cannot be replaced by a wait on the right event yet.

Keep the bounded retry, say so where the bound is defined, and warn with
the number of extra boots whenever one was needed, so owners of T6030
and T6031 Macs can tell whether it ever fires (tracked in
#2461).

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

No blockers.

This is stacked on #2458, not a replacement for it. I checked the three new commits at 47cf16e.

  • The start fail: labels (iomfb_v14_7.c:2685, iomfb_v26_6.c:1469) can be reached before the link has started, but the link is initialised at bind (iomfb_v14_7.c:2234/2417, iomfb_v26_6.c:1165), so link_fail() there just sets failed and logs once.
  • dcp_v14_swap_locked() (iomfb_v14_7.c:2880) and dcp_v26_swap() (iomfb_v26_6.c:1622) hold the session lock and take only the link lock, the same order as the idle work.
  • The internal-panel swap cannot be vetoed: dcp_v14_swap_admit() returns true when !v14->external. So the new stop only follows a real firmware or link failure.
  • The external-open path (iomfb_v14_7.c:2358) stops the link before dcp_v14_external_stopped(), which is correct. A late hotplug submit then returns -EIO from link_submit().
  1. Nit: the third commit (RTKit retry warning) is a separate concern from the DCPLink leak. It also prints int n with %u (iomfb_v14_7.c:2254, 2440); use %d. The bounded four-boot retry over an unexplained wake timeout is still a workaround. The new warning is what will show whether it ever fires, so keep drm/apple: iomfb_v14_7: RTKit boot retried up to 4 times on -ETIME with no recorded cause #2461 open until a wait on the real event replaces it.

Merge order: #2386, then #2458, then this. #2464 also edits dcp_v26_swap(). The two trees merge cleanly, but rerun display26 after the second one lands.

HW row (owner Mac): J514s/J516s (T6030) and J613 (25G83) on this head. Panel and external display up. No display not started, DCP link stopped or RTKit wake timed out lines in a default boot. 0 AVC, 0 failed units, no new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

#2458 is now folded in here, and #2386's commit (adbab6a) is carried too, so #2386 should be folded the same way or land first. Still needed: %d for the int retry count in the RTKit retry warning (iomfb_v14_7.c:2254 and :2440), and J514s/J516s and J613 rows with panel and external display up and no DCP link stopped or RTKit wake timeout lines, then it can be marked ready.

@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.

Reviewed the fatal paths for both sessions and the v26 queue drain and slot release under the link mutex. The combined boots only cover successful startup. Please exercise a submitted RPC that times out with a late reply and queued callback, verifying that the waiter exits, queue stays empty, and subsequent work sees a failed session. Also cover the internal-swap versus external-refusal behavior before landing.

The backlight fixture zero-allocated the v14 session and never initialised
its link. Now that a refused internal swap stops the link, the
v14_bl_failed_submit_unknown case walked an uninitialised event list and
faulted (CI KUnit, display suites). Initialise the link with
dcp_v14_link_init() as iomfb_v14_7_bind() does, with no RTKit behind it.

Check the new behaviour too: the refused internal swap now leaves the link
stopped, and a new case shows that an external display refusing a swap
ends neither the session nor its link.

Reported by the aurora-silicon review of #2460.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Pushed 307675b (one commit, no force push):

  • CI KUnit failure fixed. v14_bl_failed_submit_unknown faulted because the backlight test fixture never initialised the session's link. With this PR the refused internal swap calls dcp_v14_link_fail(), which walked an uninitialised event list. The fixture now runs dcp_v14_link_init() as iomfb_v14_7_bind() does (no RTKit behind it).
  • Internal swap vs external refusal, as asked. v14_bl_failed_submit_unknown now also checks that the refused internal swap leaves the link stopped (dcp_v14_link_failed()). The new case v14_bl_external_refusal_keeps_link refuses the same swap with external set and checks -EIO, the session not failed, the link not failed, and exactly one submit.
  • Local run of the CI recipe (kunit.py run --arch=arm64 --make_options LLVM=1 --kunitconfig=drivers/gpu/drm/apple/tests/display.kunitconfig) at this head: 169 tests, 168 passed, 1 skipped (apple_g17_rx_util_min_test, needs CONFIG_UCLAMP_TASK). Both cases above passed.

Still open from your review: the v26 timed-out RPC with a late reply and a queued callback (waiter exits, queue stays empty, later work sees a failed session). That needs a link-level harness, which I'm writing next. I'll post here when it's in.

@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: FINISH, then merge at 307675b6

Blockers:

  1. Wait for the 21 queued CI checks at 307675b6 (specifically kunit / display suites confirming v14_bl_fixture passes after failing on 794c43b5).
  2. Update Tested: in the PR description to cite head SHA 307675b6 (noting runtime files remain byte-identical to 47cf16efe55c / 794c43b50e9a and KUnit passes at 307675b6).

Checked:

  • All 5 files (iomfb_v14_7.c, iomfb_v14_7_backlight_lifetime_test.c, iomfb_v14_7_backlight_test.c, iomfb_v26_6.c, iomfb_v26_6_link.c): 0 code blockers.
    • iomfb_v26_6_link.c: verified link_fail() drains link->events, resets event_count = 0, and wakes link->wait under link->lock, and dcp_v26_link_call() clears calls[nested].active = false and stops the link on pre-send pump failure, missing-callback -EPROTO, IS_ERR(e), bad reply, callback error, and -ETIMEDOUT, matching iomfb_v14_7_link.c.
    • iomfb_v14_7.c and iomfb_v26_6.c: verified every remaining fatal failed = true site calls dcp_v14_link_fail() / dcp_v26_link_fail(), and RTKit retry logging (#2461) warns only when extra boots occurred.
    • Commit 307675b6: verified dcp_v14_link_init(&f.v14->link, dev, NULL) initializes the link list before dcp_v14_link_fail() runs in v14_bl_failed_submit_unknown, and v14_bl_external_refusal_keeps_link exercises the internal-swap vs external-refusal distinction requested at 794c43b5.
Evidence
  • Head: 307675b6 (+75/-5 across 5 files, MERGEABLE on main).
  • CI at review time: 21 checks QUEUED/PENDING (kunit, apple-build, host-tests, pr-text, readiness, 16 KUnit suites).
  • Note: the prior 794c43b5 review also asked for unit coverage of a submitted v26 RPC timeout with a late reply and queued callback verifying queue drain and subsequent session failure; 307675b6 covers the internal-vs-external swap part only.

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

Copy link
Copy Markdown
Contributor Author

Per the review at 307675b: (1) noted, hosted CI is still queued. The local run of the same display KUnit recipe at 307675b passes, including the fixture case that failed at 794c43b. (2) Tested now names head 307675b and says what it adds over the 47cf16e hardware rows (a clean main merge plus a KUnit-only commit; the changed driver files are byte-identical).

@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 307675b6

Blockers: none (await the 20 queued CI checks at 307675b6 before merging)

Checked:

  • PR description updated to cite exact head 307675b6 with local arm64 QEMU KUnit (drivers/gpu/drm/apple/tests/display.kunitconfig: 169 run, 168 passed, 1 skipped — confirming v14_bl_failed_submit_unknown and v14_bl_external_refusal_keeps_link PASS) and runtime files (iomfb_v14_7.c, iomfb_v26_6*.c) byte-identical to the 47cf16ef J615 & J473 hardware rows.
  • Code across all 5 files previously audited clean at 307675b6 (iomfb_v26_6_link.c queue drain and abandon paths match iomfb_v14_7_link.c, every remaining fatal failed = true site stops the link, and v14_bl_fixture initializes the link).
Evidence
  • Head: 307675b6 (MERGEABLE on main, +75/-5 across 5 files, two-way door).
  • CI at review time: 20 checks QUEUED, 0 failures.

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Nov 28, 2026
@github-actions

Copy link
Copy Markdown

Merge readiness at 307675b6: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 307675b6
Conflicts ok none
PR text ok Risk: two-way · Macs on the v147 and v266 DCP clients (T6030/T6031, J613/J615, externals)

Areas: area:display

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

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 28, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at 307675b6. App approved; rows: hardware rows at 47cf16e + clean main merge + KUnit-only commit. Merges 1 h from now under the 6-point rule once hosted CI is green, unless you object.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merging under the 6-point rule (Ryan 09:29, permanent), at 307675b6. (1) The review App approved at this head. (2) Full CI is green. (3/4) Rows: hardware-rows-at-47cf16ef-+-clean-main-merge-+-KUnit-only-commit. (5) There's no blocking review. (6) Dj was pinged here 440 min ago with no objection. Revert: git revert -m 1 <merge>.

@RyanTheTide
RyanTheTide merged commit ef0bd8e into main Nov 29, 2026
21 of 25 checks passed
@RyanTheTide
RyanTheTide deleted the hack/round3-c branch November 29, 2026 02:31
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:m3 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (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.

1 participant