Re: [PATCH v2 0/3] ALSA: pcm: Retain components across codec teardown

From: Takashi Iwai

Date: Mon Oct 26 2026 - 04:39:41 EST


On Sat, 24 Oct 2026 13:41:13 +0200,
Cen Zhang wrote:
>
> A pending PCM opener can retain the card without retaining a PCM removed
> by codec-only unbind. A late codec probe can also publish PCM devices
> before a subsequent registration failure starts cleanup.
>
> Retain native and OSS PCM lookups through file release, close admission
> at component disconnect, and drain codec users before probe-error cleanup.
> Keep the existing proc rundown outside open_mutex at disconnect, and wait
> for PCM references in final cleanup after the lookup gate is closed.
>
> ---
> Cen Zhang (3):
> ALSA: pcm: Retain components across native minor lookups
> ALSA: pcm: oss: Retain the PCM from minor lookup through release
> ALSA: hda: Drain PCM users before cleaning up a failed codec probe

I guess fixing in lower layer would become a whack-a-mole game.

My current thought is to rather plug on the upper layer, that is:

- Serialize concurrent probe and remove calls for the same HD-audio
bus

- At remove, synchronize the all opened fds on the card; you can check
list_empty(&card->files_list) and notify from snd_card_file_remove()
call.

The proc files are removed and synced at disconnection, so the above
should cover most of corner cases, I suppose.


thanks,

Takashi