Repository navigation
drm/apple: audio: free the test PCM preallocation with an exported call - #4001
Merged
Merged
Conversation
The apple-dcpaud-legacy KUnit cases release the substream's preallocated buffer with snd_pcm_lib_preallocate_free(), which ALSA does not export. aurora_defconfig builds DRM_APPLE, SND and KUNIT as modules with KUNIT_ALL_TESTS, so DRM_APPLE_DISPLAY_KUNIT_TEST is on, audio.c includes the test into appledrm.ko, and modpost rejects the module with snd_pcm_lib_preallocate_free undefined. The exported snd_pcm_lib_preallocate_free_for_all() is no stand-in: it walks pcm->streams[], and the tests' PCM is a zeroed struct with no substream on that list, so it would free nothing and leak the 1 MiB buffer. Free the substream's dma_buffer with snd_dma_free_pages() instead. It is the exported call snd_pcm_lib_preallocate_free() ends in, and the one audio.c already uses for its void buffer. The steps left out are the card's total_pcm_alloc_bytes decrement and clearing dma_buffer.area, on a test card and substream that KUnit frees right after. Fixes: f39fdee ("drm/apple: defer unplugged DP audio DMA and pin idle-off external DCP") Reported-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Closes: #3410 (comment) Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
Contributor
Author
|
Local checks at
Independent review of this diff: no code findings. Its note on the commit message (name both skipped steps) is in this head. There is no GitHub approval; merging with the maintainer bypass because this fixes the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What:
aurora_defconfigbuilds ofmainfail at modpost since #3410: theapple-dcpaud-legacyKUnit test callssnd_pcm_lib_preallocate_free(), which ALSA does not export. Free the test substream's preallocated buffer with the exportedsnd_dma_free_pages()instead. Thanks to Joshua Warren for the report.Tested: no runtime change (one KUnit test file). At
917359aa6398(onmain2a6502ffdfd5):aurora_defconfig,make Image modules:mainf4b229b300bbfails, this head passes modpost over every module.W=1onaudio.o: 0 warnings.checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks.kunit.py build(display.kunitconfigplus sound): builds and links all threedcpaudsuites. Built, not run.Risk: two-way door · none. Test code only; it is compiled into
appledrm.koonly withDRM_APPLE_DISPLAY_KUNIT_TEST.Not yet: the
apple-dcpaud-legacycases were not executed at this head. Hosted KUnit does not cover them either:display.kunitconfighas noCONFIG_SND, soaudio.cis not built there. No hardware row is needed.Details
aurora_defconfighasDRM_APPLE=m,SND=m,KUNIT=mandKUNIT_ALL_TESTS=m, so the boolDRM_APPLE_DISPLAY_KUNIT_TESTisyandaudio.cincludesaudio-legacy-test.cintoappledrm.ko. Configs withSND=yandDRM_APPLE=ylink the symbol directly, which is why earlier KUnit runs passed.snd_pcm_lib_preallocate_free_for_all(sub->pcm)is exported and fixes the link, but it frees nothing here: it walkspcm->streams[], and the tests' PCM is a zeroed struct with no substream on that list. The 1 MiB buffer would leak on each run of two of the three cases.snd_dma_free_pages(&sub->dma_buffer)is the callsnd_pcm_lib_preallocate_free()ends in, andaudio.calready uses it for the void buffer. Theareacheck matchesdo_free_pages(), so the case that preallocates nothing (unplugged_hotplug_managed_buffer) is skipped. The steps left out are the card'stotal_pcm_alloc_bytesdecrement and clearingdma_buffer.area, on a test card and substream that KUnit frees right after.f39fdeec3e43;9f33c3f95939added a third user of the cleanup action.Evidence
Incremental builds in a warm
O=directory, clang 23.1.3,ARCH=arm64 LLVM=1;.configbyte-identical to a freshaurora_defconfigfor both builds.mainf4b229b300bbmake aurora_defconfig olddefconfig; make -j20 Image modulesERROR: modpost: drivers/gpu/drm/apple/appledrm.ko: symbol 'snd_pcm_lib_preallocate_free' undefined!(the only modpost error)917359aa6398missing MODULE_DESCRIPTION()warnings in other modules, same as onmain917359aa6398make W=1 drivers/gpu/drm/apple/audio.oaudio.cincludes the test;DRM_WERROR=y)917359aa6398scripts/checkpatch.pl --strict -g HEAD917359aa6398kunit.py build --arch=arm64 --make_options LLVM=1 --kunitconfig=drivers/gpu/drm/apple/tests/display.kunitconfig --kconfig_add CONFIG_{SOUND,SND,DRM_APPLE_AUDIO,DMADEVICES,DRM_APPLE_DCP_T6030_AUDIO}=y --kconfig_add CONFIG_WERROR=ndcpaud_legacy_suite,dcpaud_link_suite,dcpaud_no_sio_suiteinvmlinuxllvm-nm -u appledrm.koat this head listssnd_dma_free_pagesand nopreallocatesymbol.Module.symvershassnd_dma_free_pagesfromsound/core/snd-pcm.