From: Cen Zhang <zzzccc427@gmail.com>
To: perex@perex.cz, tiwai@suse.com, thierry.reding@kernel.org,
jonathanh@nvidia.com
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-tegra@vger.kernel.org, tiwai@suse.de,
baijiaju1990@gmail.com, jjzuming@gmail.com, zzzccc427@gmail.com
Subject: [PATCH v4 0/5] ALSA: hda: Wait for PCM files on codec teardown
Date: Sat, 31 Oct 2026 13:14:25 +0800 [thread overview]
Message-ID: <pm-pmb-a4703edca61d34aa679b-v12-b75145090f6bcd7cf145-0@gmail.com> (raw)
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 and the
card registration 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/hda_codec.h | 1 +
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 | 43 +++++++++++++++++++++
sound/hda/common/sysfs.c | 2 +-
sound/hda/controllers/acpi.c | 2 +-
sound/hda/controllers/cix-ipbloq.c | 2 +-
sound/hda/controllers/intel.c | 2 +-
sound/hda/controllers/tegra.c | 2 +-
sound/hda/core/bus.c | 1 +
17 files changed, 193 insertions(+), 46 deletions(-)
base-commit: a4311e9447bbb219044db38897f95be112f46a8a
---
Changes in v4:
- Address the unlocked snd_card_register() callers raised by Sashiko:
https://sashiko.dev/#/patchset/98644
- Patch 1: add snd_hda_card_register() and use it in the controller probes
and in the reconfig sysfs knob, so that the card registration is
serialized with codec probe and remove as well.
- Patch 1: use mutex_lock() and mutex_unlock() in hda_codec_driver_probe()
instead of mixing guard() with goto.
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
Link to v3: https://lore.kernel.org/r/pm-pmb-a4703edca61d34aa679b-v11-d9186d19e8afb48972af-0@gmail.com
next reply other threads:[~2026-10-31 5:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-31 5:14 Cen Zhang [this message]
2026-10-31 5:14 ` [PATCH v4 1/5] ALSA: hda: Serialize codec probe and remove on the same bus Cen Zhang
2026-10-31 5:14 ` [PATCH v4 2/5] ALSA: core: Add the card file while looking up a minor Cen Zhang
2026-10-31 5:14 ` [PATCH v4 3/5] ALSA: pcm: Add the file to the card while looking up the minor Cen Zhang
2026-10-31 5:14 ` [PATCH v4 4/5] ALSA: pcm: Refuse to open a disconnected PCM Cen Zhang
2026-10-31 5:14 ` [PATCH v4 5/5] ALSA: hda: Wait for the files of the codec PCMs before freeing them Cen Zhang
2026-11-06 14:18 ` [PATCH v4 0/5] ALSA: hda: Wait for PCM files on codec teardown Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pm-pmb-a4703edca61d34aa679b-v12-b75145090f6bcd7cf145-0@gmail.com \
--to=zzzccc427@gmail.com \
--cc=baijiaju1990@gmail.com \
--cc=jjzuming@gmail.com \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=perex@perex.cz \
--cc=thierry.reding@kernel.org \
--cc=tiwai@suse.com \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®