All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] ALSA: hda: Wait for PCM files on codec teardown
@ 2026-10-30  8:03 Cen Zhang
  2026-10-30  8:03 ` [PATCH v3 1/5] ALSA: hda: Serialize codec probe and remove on the same bus Cen Zhang
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Cen Zhang @ 2026-10-30  8:03 UTC (permalink / raw)
  To: perex, tiwai
  Cc: linux-sound, linux-kernel, tiwai, baijiaju1990, jjzuming,
	zzzccc427

When an HD-audio codec is unbound while the card stays registered, the
codec remove frees its PCMs while files can still use them, and the
probe and remove of codecs on one bus can run at the same time.

Following Takashi's suggestion on v2, this version fixes both in the
HD-audio layer: patch 1 serializes the codec probe and remove on a bus,
and patch 5 makes the codec teardown wait until the files opened on its
PCMs are closed.

Patches 2 and 3 add the file to the card while the PCM minor is looked
up, so that the wait does not miss an open between the lookup and
snd_card_file_add(), and record the device a file was opened for. The
teardown waits only for the files of its own PCMs, because the card
files also include the control device, which a sound server keeps open
for as long as it runs. Patch 4 makes an open fail once its PCM is
disconnected, so that a late open does not get a working stream and
hold off the teardown.

---
Cen Zhang (5):
  ALSA: hda: Serialize codec probe and remove on the same bus
  ALSA: core: Add the card file while looking up a minor
  ALSA: pcm: Add the file to the card while looking up the minor
  ALSA: pcm: Refuse to open a disconnected PCM
  ALSA: hda: Wait for the files of the codec PCMs before freeing them

 include/sound/core.h     |  7 +++++
 include/sound/hdaudio.h  |  1 +
 include/sound/pcm.h      |  1 +
 sound/core/init.c        | 61 ++++++++++++++++++++++++++++++++++++----
 sound/core/oss/pcm_oss.c | 19 ++++---------
 sound/core/pcm.c         |  3 ++
 sound/core/pcm_native.c  | 37 ++++++++++--------------
 sound/core/sound.c       | 34 ++++++++++++++++++++++
 sound/core/sound_oss.c   | 21 ++++++++++++++
 sound/hda/common/bind.c  | 24 ++++++++++++++++
 sound/hda/core/bus.c     |  1 +
 11 files changed, 168 insertions(+), 41 deletions(-)


base-commit: a4311e9447bbb219044db38897f95be112f46a8a
-- 
2.43.0

Changes in v3:
- Fix the codec teardown in the HD-audio layer as suggested by Takashi,
  instead of retaining the PCM in the PCM core: serialize the codec probe
  and remove on a bus, and wait for the files opened on the codec PCMs
  before freeing them.
- Add the card file while looking up the PCM minor, so that the wait cannot
  miss an open, and wait only for the files of the codec PCMs instead of all
  files of the card.
- Refuse to open a disconnected PCM.
- Drop the Assisted-by tag, which has been removed from the documentation
  and checkpatch.

Link to v1: https://lore.kernel.org/r/pm-pmb-a4703edca61d34aa679b-v6-680f350d78e44f9de7a7@gmail.com
Link to v2: https://lore.kernel.org/r/pm-pmb-a4703edca61d34aa679b-v9-c4f3df026f28aea10fd1-0@gmail.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-30  8:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30  8:03 [PATCH v3 0/5] ALSA: hda: Wait for PCM files on codec teardown Cen Zhang
2026-10-30  8:03 ` [PATCH v3 1/5] ALSA: hda: Serialize codec probe and remove on the same bus Cen Zhang
2026-10-30  8:29   ` sashiko-bot
2026-10-30  8:03 ` [PATCH v3 2/5] ALSA: core: Add the card file while looking up a minor Cen Zhang
2026-10-30  8:03 ` [PATCH v3 3/5] ALSA: pcm: Add the file to the card while looking up the minor Cen Zhang
2026-10-30  8:03 ` [PATCH v3 4/5] ALSA: pcm: Refuse to open a disconnected PCM Cen Zhang
2026-10-30  8:03 ` [PATCH v3 5/5] ALSA: hda: Wait for the files of the codec PCMs before freeing them Cen Zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.