Skip to content

drm/apple: stop the DCPLink when a notification fails - #2458

Closed
RyanTheTide wants to merge 2 commits into
integration/aurorafrom
hack/round3-b
Closed

RyanTheTide wants to merge 2 commits into
integration/aurorafrom
hack/round3-b

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #2386 (hack/drm-misc-retry-a), whose link_fail() in iomfb_v26_6_link.c frees the queued events; review only the top commit. Merge #2386 first.

Problem

dcp_v14_idle() (drivers/gpu/drm/apple/iomfb_v14_7.c:1447) and dcp_v26_idle() (iomfb_v26_6.c:774) handle firmware callbacks that arrive while no call is in progress. If one fails (a callback handler error, a malformed callback, an unsolicited reply, or a failed reply), they mark the session failed ("recovery requires a reboot") and return with the DCPLink still running.

After that, nothing pumps the link again, because the loop stops on failed. dcp_vNN_link_receive() keeps accepting every firmware callback, queues a kmalloc'd copy of each (up to 32), and queues the idle work again for each, which then does nothing. The copies stay until reboot unless a 33rd event arrives: the link state outlives the device, and nothing else frees the list.

This is the leak that Chris Kearney's d203ba4 fixed for abandoned calls in the 14.7 client, and #2386 fixed in the 26.6 copy. Neither fix covered the notification path.

Change

On that failure path, both idle functions call dcp_vNN_link_fail(), the same mechanism the call paths use. It frees the queued events under the link lock, wakes any waiter, and makes the receive path drop whatever arrives next. The two functions stay identical. link_fail() is idempotent, so the case where the pump failed because the link had already failed (-EIO) is unaffected.

Nothing that worked before stops working. Every later call already returns -EIO on a failed session (dcp_v14_call_guarded(), dcp_v26_call()). The firmware buffers and RPC memory are still kept until reboot.

Which SoCs reach this code:

  • iomfb_v14_7.c (DCP_FIRMWARE_V_14_7): T6030 J514s/J516s (internal panel and the native apple,t6030-dcpext session), T6031 J514c/J516c, and T8122 J613/J615 internal panels with the 14.7 DCP image.
  • iomfb_v26_6.c (DCP_FIRMWARE_V_26_6): J613/J615 with the 25G83 image only.

Testing

  • Built for arm64 (LLVM, W=1, release config): iomfb_v14_7.o and iomfb_v26_6.o, 0 warnings.
  • checkpatch --strict: clean, apart from the unknown-commit-id warnings that --no-tree always gives.
  • Host tests (tools/asahi/run-host-tests.py --only ...): display26, dcp14-panel, dcp14-backlight and backlight-coldboot (with negative controls): all passed. The apple-dcp selftest suite hit the 30-minute cap on the loaded box after 53 cases, all ok and none failed.
  • KUnit: no suite covers the idle work. The change only calls the existing dcp_vNN_link_fail() from one more place, so no new suite was written.

Still to run

  • The complete tools/asahi/run-host-tests.py --only apple-dcp run (capped here after 53/53 ok).

None of the lab Macs (Neo T8140, J616s T6040, M1 Pro T6000, M2 T8112) runs either file, so the lab has no row for this change. Owner rows:

  • J514s/J516s (T6030), J514c/J516c (T6031), J613 with 14.7 firmware: boot. The panel shows, and an external display on J514s/J516s comes up. dmesg | grep -E 'DCP notification failed|DCP link stopped' is empty, as on the base kernel.
  • J613 with 25G83 firmware: the same rows.
  • If a notification failure happens: DCP link stopped; firmware buffers are kept until reboot now follows DCP notification failed immediately, and no further callback ... failed lines or idle-work activity follow. With kmemleak, there are no new unreferenced objects from link_event.

Port of Chris Kearney's DCPLink stop-on-failure fixes to the notification path.

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.

Assisted-by: LLM (Claude:Opus 5.5)

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]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

No blockers.

I checked the top commit 36c07e5 against both link layers at the head. dcp_v14_link_fail() and dcp_v26_link_fail() take only the link lock, and the idle work already holds the session lock (iomfb_v14_7.c:1452, iomfb_v26_6.c:779). That is the same order as the call paths, and nothing takes the link lock and then the session lock. link_fail() frees only events still on the list, and the pump dequeues under the link lock (iomfb_v14_7_link.c:35-48), so the event in hand when the pump failed was already freed by the pump. Once failed is set, link_receive() drops new messages (iomfb_v14_7_link.c:164) and link_submit()/link_reply() return -EIO, so a late dcp_v14_external_stopped() cannot reach a stopped link. The extra complete(&link->ready) cannot wake anyone at that point, because link_start() returned long before.

This depends on #2386, which is still a draft, for the v26 link_fail() that frees the queue. Without it, the v26 hunk only sets failed and the events still leak. Merge #2386 first. Then this can leave draft as is.

HW row (owner Mac, not in the lab): J514s/J516s (T6030) on 14.7 and J613 on 25G83 with this head. Panel up, an external display on the J514s, and dmesg | grep -E 'DCP notification failed|DCP link stopped' empty. 0 AVC, 0 failed units, no new kernel errors. The lab boot-clean rows already cover the Macs that don't run these files.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Folded into #2460, which carries this commit together with #2386 and the start/swap paths.

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