Skip to content

drm/apple: av: recycle AV endpoint service slots - #322

Closed
sithglan wants to merge 1 commit into
aurora-silicon:aurora-wipfrom
sithglan:dcp-av-slot-reuse
Closed

sithglan wants to merge 1 commit into
aurora-silicon:aurora-wipfrom
sithglan:dcp-av-slot-reuse

Conversation

@sithglan

Copy link
Copy Markdown

The AV endpoint (0x29) announces a fresh DCPAVSimpleVideoInterface and DCPAVAudioInterface on new channels for every DPTX connection. A display replug uses two more slots, and so does a DPMS wake on a monitor that drops HPD (both EIZO EV2780 and Fujitsu E24T-7 Pro do). Since 5837706 ("drm/apple: pin DP service owners before recycling retired AFK slots") a torn-down slot is only reclaimed if its ops set .reusable, which the AV services never did. After eight connections the 16-slot table is full:

apple-dcp 271c00000.dcp: AFK[ep:29]: no reusable service slots
apple-dcp 271c00000.dcp: AFK[ep:29]: expected announce but got 0xc0 on channel 151

From then on the audio service of that port is not registered again until reboot, so DP audio on it stays silent. The display itself keeps working.

5837706 left these services out on purpose because their owners did not pin them. This PR converts them and opts in:

  • DCPAVSimpleVideoInterface keeps no pointer to its service.
  • asrv->srv holds an owner pin from init until teardown. Teardown of an older generation no longer clears the pointer or unplugs the jack of its successor.
  • av_service_connect() and av_service_disconnect() call into the service after dropping srv_rwsem, so they pin it for the call. The new afk_service_pin() does that; unlike afk_service_get() it also succeeds after teardown, so the close is still sent.
  • KUnit case afk_service_close_pin_test: a close pinned across teardown keeps the slot until it is put.

Testing

Mac mini (j274), EIZO EV2780 on USB-C (dcp@271c00000) and on HDMI, aurora-wip 27da3a5 with #275, #276, #277, #281 and this PR:

before after
connections on 271c until slots ran out 8 (last new service on channel 31) none in 18 (swaymsg output DP-1 power off/on; channels up to 71, 36 services on 16 slots)
no reusable service slots / expected announce 64 / 196 in a 17 min hotplug run 0 / 0
DP audio on USB-C after the slots cycled not registered plays (SIO mailbox ~757 IRQs per 4 s, same as before cycling)
DPMS off/on during playback service stopped and restarted cleanly, new playback works afterwards
kernel warnings 0 0

The KUnit case was not run (no CONFIG_KUNIT in the test config). The DCP host selftests pass 45/52; the same 7 fail on 27da3a5 alone, because the harnesses lack stubs for dev_dbg() and cd321x_display_taken().

The AV endpoint (0x29) announces a fresh DCPAVSimpleVideoInterface and
DCPAVAudioInterface on new channels for every DPTX connection, so every
display replug or DPMS wake that drops HPD uses two more slots. Since
"drm/apple: pin DP service owners before recycling retired AFK slots" a
torn-down slot is only reclaimed if its ops opt in with .reusable, which
the AV services never did. After eight connections the 16-slot table is
full, every later announcement fails with

  AFK[ep:29]: no reusable service slots

and the audio service of that port is not re-registered until reboot.

Convert the AV owners and opt in to reuse:

 - DCPAVSimpleVideoInterface keeps no pointer to its service.
 - asrv->srv now holds an owner pin taken in init and dropped in
   teardown. A teardown of an older generation no longer clears the
   pointer or unplugs the jack of its successor.
 - av_service_connect() and av_service_disconnect() call into the
   service after dropping srv_rwsem, so they pin it for the duration.
   Add afk_service_pin() for this; unlike afk_service_get() it also
   succeeds after teardown, so the close is still sent.

Add a KUnit case for a close pinned across teardown.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Closing as superseded: this work was ported by #328 (merged 2026-10-16) and carried into the maintained 7.3 integration/aurora line. Thanks for the original change; nothing here is lost.

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.

2 participants