Skip to content

drm/apple: audio: make the legacy test's DMA channel private - #4036

Merged
DjDeveloperr merged 1 commit into
mainfrom
fix/dcpaud-legacy-test-private-dma
Dec 3, 2026
Merged

DjDeveloperr merged 1 commit into
mainfrom
fix/dcpaud-legacy-test-private-dma

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

What: main's kernel-release smoke fails in the KUnit suite apple-dcpaud-legacy, so nothing is published. The test's fake DMA device is public, so a loaded async_tx takes its only channel before the test can. Make it private, like apple-sio, the DMA controller the driver really uses. Two lines, test only.

Tested: no runtime change (KUnit only). At 0078f0d25287, apple-dcpaud-legacy on UML with async_tx present: main fails 20 of 20 boots, this passes 20 of 20 (11/11 cases each). Without async_tx: 10 of 10 pass on both. arm64 W=1 of audio.o with the test built in: 0 warnings. checkpatch --strict: 0/0/0.

Risk: two-way door · none. Test-only: audio.c and everything a Mac runs are the same.

Not yet: the kernel-release smoke, which runs on main after the merge. No hardware row is needed.

Details
  • The failing line is the setup's dma_request_channel(), before any plug or unplug in the case. The driver has not touched dcpaud->chan yet, so it is not a teardown that clears the channel.
  • dma_async_device_register() takes a reference on every channel of a device without DMA_PRIVATE when a dmaengine_get() user exists. async_tx is the only one in the tree (crypto/async_tx/async_tx.c, CONFIG_ASYNC_TX_DMA=y in aurora_defconfig). dma_request_channel() then skips the busy channel and returns NULL. The cleanup WARN, "1 clients hold a reference", is that same reference.
  • The smoke deals modules to guests in a fixed order, so it fails on every run, not now and then.
  • The driver is not affected: drivers/dma/apple-sio.c sets DMA_PRIVATE, so async_tx never gets its channels.
  • Hosted KUnit dcp-display does not have async_tx, so it passes with and without this.
  • drm/apple: audio: no reports to a card that is gone #3265 touches the same driver but not this test.
Evidence

UML (x86_64, clang 23.1.3, uniprocessor), source main 1ab453e8b404, ASYNC_TX_DMA=y, async_tx built in. audio.c and its tests are compiled from the tree; the rest of appledrm is stubbed and audio-no-sio-test.c is left out, because DRM_APPLE needs arm64. async_tx off = initcall_blacklist=async_tx_init. The two kernels differ only in audio-legacy-test.c.

boots suite case 8 unregister WARN
main, async_tx on 20 20 failed 20 failed, all at line 698 20
this PR, async_tx on 20 20 passed 20 passed 0
main, async_tx off 10 10 passed 10 passed 0
this PR, async_tx off 10 10 passed 10 passed 0

Smoke runs on main:

Boot times in seconds of async_tx: api initialized and of the suite, from the smoke-edge-* artifacts. Three guests run the suite in each run.

run commit guest 4 guest 9 guest 11
46995296707 37a6306 suite 54, async 133: ok async 18, suite 91: FAIL no async_tx: ok
46998849058 0fefa44 suite 53, async 131: ok async 16, suite 87: FAIL no async_tx: ok
47002186070 2b26819 suite 55, async 138: ok async 17, suite 87: FAIL no async_tx: ok
47005434962 622a059 suite 51, async 127: ok async 16, suite 86: FAIL no async_tx: ok
47007932165 d1ae4f2 suite 53, async 135: ok async 19, suite 91: FAIL no async_tx: ok
47010696533 5d50604 suite 51, async 127: ok async 17, suite 88: FAIL no async_tx: ok

The kernel-release smoke on main fails in apple-dcpaud-legacy:

  dcpaud_legacy_plugged_close_unplug_reopen_vmalloc: ASSERTION FAILED at
  drivers/gpu/drm/apple/audio-legacy-test.c:698
    Expected dcpaud->chan == &t->channel, but dcpaud->chan == NULL
  __dma_async_device_channel_unregister called while 1 clients hold a
  reference

The case registers a fake DMA device without DMA_PRIVATE. The dmaengine
core hands the channels of such a device to dmaengine_get() users: if
there is one, dma_async_device_register() takes a reference on every
channel for it. async_tx is such a user, so once async_tx.ko is loaded
the channel is busy before the case can request it, and the reference
is still there when the device is unregistered.

apple-sio, the DMA controller the driver really uses, sets DMA_PRIVATE,
so the DP audio driver never sees this. Set it in the test as well.

This is the order the modules are loaded in, not a race: in each of the
six main runs checked, the case fails in the smoke guest that loads
async_tx before appledrm, and passes in the one that loads it later and
in the one that does not load it.

Fixes: 9f33c3f ("drm/apple: select DP audio buffer ownership per PCM open")
Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr
DjDeveloperr marked this pull request as ready for review December 3, 2026 02:27
@DjDeveloperr
DjDeveloperr requested review from a team as code owners December 3, 2026 02:27
@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) blast:none 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) labels Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Merge readiness at 0078f0d2: not ready yet

Check Detail
CI at head running running: apple-build, host-tests, KUnit plan
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok not needed: no runtime change
Conflicts ok none
PR text ok Risk: two-way · none. Test-only: audio.c and everything a Mac runs are the same.

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 ci-failing A check failed at the PR head (bot) label Dec 3, 2026
@DjDeveloperr
DjDeveloperr merged commit 5f32aa7 into main Dec 3, 2026
9 of 13 checks passed
@DjDeveloperr
DjDeveloperr deleted the fix/dcpaud-legacy-test-private-dma branch December 3, 2026 02:29

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

Reviewed 0078f0d. The fake channel now uses the private capability of the actual SIO controller, so async_tx cannot reserve it before the test. The reported 20/20 UML pass with async_tx and unchanged clean control without it isolate the fix. Runtime code is untouched.

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:none Macs affected, from Merge risk (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.

2 participants