From: Takashi Iwai <tiwai@suse.de>
To: "Cássio Gabriel" <cassiogabrielcontato@gmail.com>
Cc: Takashi Iwai <tiwai@suse.com>, Jaroslav Kysela <perex@perex.cz>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ALSA: als4000: Fix capture trigger chip->mode race
Date: Mon, 20 Apr 2026 09:08:40 +0200 [thread overview]
Message-ID: <87se8qaz2f.wl-tiwai@suse.de> (raw)
In-Reply-To: <20260417-als4000-capture-trigger-race-v1-1-daeffc2feb67@gmail.com>
On Fri, 17 Apr 2026 22:30:18 +0200,
Cássio Gabriel wrote:
>
> snd_als4000_capture_trigger() updates chip->mode under mixer_lock,
> while snd_als4000_set_rate() and snd_als4000_playback_trigger()
> serialize the same rate-lock state with reg_lock.
>
> The PCM core serializes callbacks only per acted-on substream, or for an
> explicitly linked group, so unlinked playback and capture streams can
> run concurrently.
>
> That leaves two races on ALS4000 rate-lock state:
> - playback and capture trigger callbacks can concurrently update
> chip->mode and lose one of the SB_RATE_LOCK bits
> - snd_als4000_set_rate() can observe chip->mode without the capture
> lock bit set and reprogram the shared sample rate while capture is
> being started
>
> Fix this by taking reg_lock as the outer lock in
> snd_als4000_capture_trigger() and nesting mixer_lock only for the CR1E
> write. This keeps chip->mode serialized with the rest of the ALS4000
> rate-lock users while preserving the existing CR1E programming
> sequence.
>
> Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
Applied now. Thanks.
Takashi
prev parent reply other threads:[~2026-04-20 7:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-17 20:30 [PATCH] ALSA: als4000: Fix capture trigger chip->mode race Cássio Gabriel
2026-04-20 7:08 ` Takashi Iwai [this message]
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=87se8qaz2f.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=cassiogabrielcontato@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/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