Skip to content

drm/apple: stop the J613 DCPLink when a call is abandoned - #2386

Closed
RyanTheTide wants to merge 1 commit into
mainfrom
hack/drm-misc-retry-a
Closed

RyanTheTide wants to merge 1 commit into
mainfrom
hack/drm-misc-retry-a

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

drivers/gpu/drm/apple/iomfb_v26_6_link.c (the J613 / apple,t8122-dcp 25G83 DCPLink client, added in aa504d6) is a copy of the T6030 14.7 client iomfb_v14_7_link.c. Two fixes landed in the 14.7 copy and never reached the 26.6 one: d203ba4 ("drm/apple: stop the T6030 DCPLink when a call is abandoned") and 90139dc ("drm/apple: stop the T6030 DCPLink when a call fails before submit"), both by Chris Kearney.

In the 26.6 copy, dcp_v26_link_call() still returns with the link running and calls[nested].active set when a call times out, fails its reply check or has a callback handler fail. It does the same when a queued notification fails while draining before an outer call, and when a nested call finds no callback to answer. dcp_v26_call() then latches the session as failed and nothing pumps the link again, but dcp_v26_link_receive() keeps accepting the late reply and later callbacks and queues a kmalloc'd copy of each until the 32-event limit. link_fail() then wakes the waiters and leaves those copies on a list nothing dequeues.

Change

Port the two 14.7 fixes. Every return that gives up on a call now stops the link and clears the abandoned call's active flag, so the receive path drops anything that arrives for it. link_fail() frees the queued events under the lock. The -EBUSY retry before submit stays as it is. It handles a callback that arrives between the drain and the submit: it drains that callback and resubmits, bounded by the call deadline. That is the protocol's own ordering, not a retry that hides a failure.

Safe for every SoC it reaches: the file is built for the J613 backend only (iomfb_v26_6.o), and the only caller already treats any failed call as the end of the session (dcp_v26_call() sets v26->failed, "recovery requires a reboot"). Only the queueing of messages nobody will read changes.

Testing

  • make W=1 of drivers/gpu/drm/apple/iomfb_v26_6_link.o and a full build of drivers/gpu/drm/apple/ (arm64, LLVM, release config, all three hack/drm-misc-retry branches applied): no warnings.
  • No KUnit suite covers the 26.6 link client.
  • checkpatch.pl --strict: clean apart from commit-id lookups that need a tree.

Still to run

None of the four test Macs (J700, J616s, J316s, J413) uses this file, so there is no hardware row there. On a J613, if one is available: boot, then check that dmesg | grep -c "DCP link stopped" is 0 and the panel comes up as before. Then force a call timeout (for example by crashing the DCP with its debugfs crash trigger) and check that the message appears once and kmemleak shows no dcp_v26_event allocations.

Remaining difference between the two link clients

After this change the 14.7 and 26.6 clients still differ on purpose: 14.7 answers callbacks in the order they were handled (41e7226, needed for external processors whose callbacks come from separate firmware threads) and has an admission veto. 26.6 serves a panel with strictly nested callbacks and keeps arrival timestamps for page-flip events. Merging both into one shared core is possible but is a bigger refactor than this fix. Both idle workers (dcp_v14_idle(), dcp_v26_idle()) also set the session failed on a notification error without stopping the link. That is the same kind of bounded leak and is left for a follow-up because it touches iomfb_v14_7.c.

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 iomfb_v26_6 (J613/J615 only); 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]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

No blockers.

Checked the port against the 14.7 client on integration/aurora: every exit of dcp_v26_link_call() after a submit (timeout, -EIO from link_next_event(), bad reply, failed callback, wrong completion id) now goes through abandon at drivers/gpu/drm/apple/iomfb_v26_6_link.c:518, which clears calls[nested].active and stops the link. link_fail() frees the queued events under the lock, and an event a caller has already taken is off the list, so there is no double free. A failed nested call stops the link before its handler returns, and the outer call then exits through abandon as well. dcp_v26_call() already treats any error as the end of the session, so nothing that worked before stops working. host-tests pass.

  1. Nit, drivers/gpu/drm/apple/iomfb_v26_6_link.c:478-482: a link_submit() failure before anything is sent (-EBUSY once the deadline has passed, -EMSGSIZE, -EOPNOTSUPP) still returns without link_fail(). dcp_v26_call() then marks the session failed, and later callbacks are queued until the 32-event limit. With this change link_fail() frees them at that point, so the queue is bounded and freed. The commit message says every return that gives up on a call stops the link; either stop the link there too or narrow that sentence. The 14.7 client has the same gap.

HW row: J613 (or J615) on the 25G83 firmware: boot with 0 "DCP link stopped" lines and the panel up. Then force one call timeout (DCP crash trigger): exactly one "DCP link stopped" line, and kmemleak shows no dcp_v26_event allocations. Plus 0 AVC, 0 failed units and 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Folded into #2460, which carries this PR's commits unchanged; review continues there.

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.

1 participant