Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Christian Zigotzky <chzigotzky@xenosoft.de>
Cc: Vincent Cloutier <vincent.cloutier@icloud.com>,
	Takashi Iwai <tiwai@suse.de>,
	Vincent Cloutier <vincent@cloutier.co>,
	Cen Zhang <zzzccc427@gmail.com>, Jaroslav Kysela <perex@perex.cz>,
	linux-sound@vger.kernel.org, "R.T.Dickinson" <rtd2@xtra.co.nz>,
	mad skateman <madskateman@gmail.com>,
	Damien Stewart <hypexed@yahoo.com.au>,
	Christian Zigotzky <info@xenosoft.de>
Subject: Re: [PATCH] ALSA: pcm: Allow HW_REFINE queries with mapped buffers
Date: Wed, 04 Nov 2026 08:30:03 +0100	[thread overview]
Message-ID: <87jymtuk90.wl-tiwai@suse.de> (raw)
In-Reply-To: <18b03c3e-a6d7-f500-50ce-3097d01ab042@xenosoft.de>

On Wed, 04 Nov 2026 06:27:00 +0100,
Christian Zigotzky wrote:
> 
> On 11/04/2026 01:40 AM, Vincent Cloutier wrote:
> > From: Vincent Cloutier <vincent@cloutier.co>
> > 
> > PulseAudio 16.1 queries supported formats after configuring and mapping
> > a PCM buffer. Sharing HW_PARAMS' state checker with HW_REFINE causes
> > these queries to fail with -EBADFD because a non-OSS stream has active
> > buffer mappings. PulseAudio then fails to create its sinks and sources.
> > 
> > Make the mmap restriction optional in the shared state checker. Keep it
> > for HW_PARAMS, which can reconfigure the mapped buffer, but skip it for
> > HW_REFINE, which only refines the caller's constraint structure. Keep
> > the stream-state checks and buffer access locking for native, compat
> > and legacy refinement ioctls rather than bypassing their wrapper.
> > Leave the accepted stream states unchanged.
> > 
> > On Librem 5, both L5 and Modem cards reproduce the failure for playback
> > and capture: refinement succeeds before setup and after RW setup, but
> > fails after MMAP setup in PREPARED state. With this change, all eight
> > cases pass, PulseAudio starts normally and audible playback works.
> > The reproducer does not start streams or transfer audio data.
> > 
> > Fixes: ad28d2f607d1 ("ALSA: pcm: Serialize and check HW_REFINE ioctls")
> > Link: https://lore.kernel.org/linux-sound/41a2e39a-5637-8afa-f84f-f79e63b3b56e@xenosoft.de/
> > Link: https://lore.kernel.org/linux-sound/874idyx9n6.wl-tiwai@suse.de/
> > Assisted-by: OpenCode:GPT-6.1 Sol
> > Signed-off-by: Vincent Cloutier <vincent@cloutier.co>
> > ---
> >   sound/core/pcm_native.c | 10 ++++++----
> >   1 file changed, 6 insertions(+), 4 deletions(-)
> > 
> > diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
> > index 5cbf88da7626..01d9f5ad4ea9 100644
> > --- a/sound/core/pcm_native.c
> > +++ b/sound/core/pcm_native.c
> > @@ -776,14 +776,15 @@ static void pcm_qos_req_update(struct snd_pcm_substream *substream, int usecs)
> >   					    usecs);
> >   }
> >   -static int hw_params_state_check(struct snd_pcm_substream
> > *substream)
> > +static int hw_params_state_check(struct snd_pcm_substream *substream,
> > +				 bool check_mmap)
> >   {
> >   	guard(pcm_stream_lock_irq)(substream);
> >   	switch (substream->runtime->state) {
> >   	case SNDRV_PCM_STATE_OPEN:
> >   	case SNDRV_PCM_STATE_SETUP:
> >   	case SNDRV_PCM_STATE_PREPARED:
> > -		if (!is_oss_stream(substream) &&
> > +		if (check_mmap && !is_oss_stream(substream) &&
> >   		    atomic_read(&substream->mmap_count))
> >   			return -EBADFD;
> >   		return 0;
> > @@ -806,7 +807,7 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
> >   	err = snd_pcm_buffer_access_lock(runtime);
> >   	if (err < 0)
> >   		return err;
> > -	err = hw_params_state_check(substream);
> > +	err = hw_params_state_check(substream, true);
> >   	if (err)
> >   		goto unlock;
> >   @@ -944,7 +945,8 @@ static int snd_pcm_hw_refine_with_lock(struct
> > snd_pcm_substream *substream,
> >   	err = snd_pcm_buffer_access_lock(runtime);
> >   	if (err < 0)
> >   		return err;
> > -	err = hw_params_state_check(substream);
> > +	/* Refinement queries constraints without changing the mapped buffer. */
> > +	err = hw_params_state_check(substream, false);
> >   	if (err)
> >   		goto unlock;
> >   
> > base-commit: 05441d697f7f9a927264f4058cbbc6a03dfcac9d
> @Takashi
> 
> Should I still try to find out which replacement of
> snd_pcm_hw_refine_with_lock() actually matters or has the issue been
> sorted out with Vincent's patch?

Try Vincent's patch at first.  If it doesn't help, go for further
investigations.


thanks,

Takashi

  reply	other threads:[~2026-11-04  7:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-01  9:15 Void PPC: PulseAudio issue with sound updates 7.4-rc1 Christian Zigotzky
2026-11-01 14:53 ` Christian Zigotzky
2026-11-01 15:26   ` Takashi Iwai
2026-11-03  7:34     ` Christian Zigotzky
2026-11-03  7:44       ` Takashi Iwai
2026-11-03 12:00         ` Christian Zigotzky
2026-11-03 14:38           ` Takashi Iwai
2026-11-04  0:40             ` [PATCH] ALSA: pcm: Allow HW_REFINE queries with mapped buffers Vincent Cloutier
2026-11-04  5:27               ` Christian Zigotzky
2026-11-04  7:30                 ` Takashi Iwai [this message]
2026-11-04  7:28               ` Takashi Iwai
2026-11-04 11:38               ` Christian Zigotzky

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=87jymtuk90.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=chzigotzky@xenosoft.de \
    --cc=hypexed@yahoo.com.au \
    --cc=info@xenosoft.de \
    --cc=linux-sound@vger.kernel.org \
    --cc=madskateman@gmail.com \
    --cc=perex@perex.cz \
    --cc=rtd2@xtra.co.nz \
    --cc=vincent.cloutier@icloud.com \
    --cc=vincent@cloutier.co \
    --cc=zzzccc427@gmail.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