* [PATCH] ALSA: pcm: Apply sync-stop at SNDRV_PCM_IOCTL_DROP ioctl @ 2026-10-14 14:24 ` Takashi Iwai 2026-10-15 18:30 ` Marek Szyprowski 0 siblings, 1 reply; 3+ messages in thread From: Takashi Iwai @ 2026-10-14 14:24 UTC (permalink / raw) To: linux-sound; +Cc: linux-kernel When a PCM stream is stopped via SNDRV_PCM_IOCTL_DROP ioctl, it calls snd_pcm_stop() but sync-stop operation is missing. Although this is usually no big issue, let's add snd_pcm_sync_stop() call, just to be sure. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/core/pcm_native.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 6c379068b54c..7ffbf2c0ea92 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -2332,6 +2332,8 @@ static int snd_pcm_drop(struct snd_pcm_substream *substream) result = snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); /* runtime->control->appl_ptr = runtime->status->hw_ptr; */ + snd_pcm_sync_stop(substream, true); + return result; } -- 2.55.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ALSA: pcm: Apply sync-stop at SNDRV_PCM_IOCTL_DROP ioctl 2026-10-14 14:24 ` [PATCH] ALSA: pcm: Apply sync-stop at SNDRV_PCM_IOCTL_DROP ioctl Takashi Iwai @ 2026-10-15 18:30 ` Marek Szyprowski 2026-10-15 18:56 ` Takashi Iwai 0 siblings, 1 reply; 3+ messages in thread From: Marek Szyprowski @ 2026-10-15 18:30 UTC (permalink / raw) To: Takashi Iwai, linux-sound; +Cc: linux-kernel On 14.10.2026 16:24, Takashi Iwai wrote: > When a PCM stream is stopped via SNDRV_PCM_IOCTL_DROP ioctl, it calls > snd_pcm_stop() but sync-stop operation is missing. Although this is > usually no big issue, let's add snd_pcm_sync_stop() call, just to be > sure. > > Signed-off-by: Takashi Iwai <tiwai@suse.de> > --- > sound/core/pcm_native.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c > index 6c379068b54c..7ffbf2c0ea92 100644 > --- a/sound/core/pcm_native.c > +++ b/sound/core/pcm_native.c > @@ -2332,6 +2332,8 @@ static int snd_pcm_drop(struct snd_pcm_substream *substream) > result = snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); > /* runtime->control->appl_ptr = runtime->status->hw_ptr; */ > > + snd_pcm_sync_stop(substream, true); > + > return result; > } This patch landed in today's linux-next as commit fdf9a21cda78 ("ALSA: pcm: Apply sync-stop at SNDRV_PCM_IOCTL_DROP ioctl"). In my tests I found that it triggers the kernel bug about invalid context for sleeping. It looks that thissnd_pcm_sync_stop() should be called outside the scope of the guard(pcm_stream_lock_irq)(substream). Here is log from one of my test boards: --->8---- root@target:~# speaker-test -l1 speaker-test 1.1.3 Playback device is default Stream parameters are 48000Hz, S16_LE, 1 channels Using 16 octaves of pink noise Rate set to 48000Hz (requested 48000Hz) Buffer size range from 128 to 131072 Period size range from 64 to 65536 Using max buffer size 131072 Periods = 4 was set period_size = 32768 was set buffer_size = 131072 0 - Front Left Time per period = 0.030588 BUG: sleeping function called from invalid context at ./include/linux/dmaengine.h:1326 in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 1691, name: speaker-test preempt_count: 1, expected: 0 RCU nest depth: 0, expected: 0 locks held by speaker-test/1691: 1, last CPU#3: #0: c22ad2a4 (&group->lock#2){..-.}-{3:3}, at: snd_pcm_drop+0x30/0xd0 irq event stamp: 10920 hardirqs last enabled at (10919): [<c0dcda30>] _raw_spin_unlock_irqrestore+0x5c/0x60 hardirqs last disabled at (10920): [<c0dcd5e0>] _raw_spin_lock_irq+0x60/0x64 softirqs last enabled at (10832): [<c0113ab4>] vfp_support_entry+0x98/0x400 softirqs last disabled at (10830): [<c0113a44>] vfp_support_entry+0x28/0x400 CPU: 3 UID: 0 PID: 1691 Comm: speaker-test Not tainted 7.3.0-rc6-00238-gfdf9a21cda78 #13903 PREEMPT Hardware name: Samsung Exynos (Flattened Device Tree) Call trace: unwind_backtrace from show_stack+0x10/0x14 show_stack from dump_stack_lvl+0x6c/0x8c dump_stack_lvl from __might_resched+0x198/0x264 __might_resched from snd_dmaengine_pcm_sync_stop+0x8c/0xac snd_dmaengine_pcm_sync_stop from snd_soc_pcm_component_sync_stop+0x3c/0x98 snd_soc_pcm_component_sync_stop from snd_pcm_drop+0x68/0xd0 snd_pcm_drop from sys_ioctl+0x508/0xc2c sys_ioctl from ret_fast_syscall+0x0/0x1c Exception stack(0xf1da1fa8 to 0xf1da1ff0) ... root@target:~# --->8---- Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ALSA: pcm: Apply sync-stop at SNDRV_PCM_IOCTL_DROP ioctl 2026-10-15 18:30 ` Marek Szyprowski @ 2026-10-15 18:56 ` Takashi Iwai 0 siblings, 0 replies; 3+ messages in thread From: Takashi Iwai @ 2026-10-15 18:56 UTC (permalink / raw) To: Marek Szyprowski; +Cc: Takashi Iwai, linux-sound, linux-kernel On Thu, 15 Oct 2026 20:30:21 +0200, Marek Szyprowski wrote: > > On 14.10.2026 16:24, Takashi Iwai wrote: > > When a PCM stream is stopped via SNDRV_PCM_IOCTL_DROP ioctl, it calls > > snd_pcm_stop() but sync-stop operation is missing. Although this is > > usually no big issue, let's add snd_pcm_sync_stop() call, just to be > > sure. > > > > Signed-off-by: Takashi Iwai <tiwai@suse.de> > > --- > > sound/core/pcm_native.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c > > index 6c379068b54c..7ffbf2c0ea92 100644 > > --- a/sound/core/pcm_native.c > > +++ b/sound/core/pcm_native.c > > @@ -2332,6 +2332,8 @@ static int snd_pcm_drop(struct snd_pcm_substream *substream) > > result = snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); > > /* runtime->control->appl_ptr = runtime->status->hw_ptr; */ > > > > + snd_pcm_sync_stop(substream, true); > > + > > return result; > > } > > This patch landed in today's linux-next as commit fdf9a21cda78 ("ALSA: pcm: Apply > sync-stop at SNDRV_PCM_IOCTL_DROP ioctl"). In my tests I found that it triggers > the kernel bug about invalid context for sleeping. > > It looks that thissnd_pcm_sync_stop() should be called outside the scope of > the guard(pcm_stream_lock_irq)(substream). Gah, obviously it's calling in a wrong context, and I overlooked guard() line. I'm going to submit the trivial fix. thanks, Takashi ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-15 18:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20261015183022eucas1p10d5777e112c34458f4b360407d2228c4@eucas1p1.samsung.com>
2026-10-14 14:24 ` [PATCH] ALSA: pcm: Apply sync-stop at SNDRV_PCM_IOCTL_DROP ioctl Takashi Iwai
2026-10-15 18:30 ` Marek Szyprowski
2026-10-15 18:56 ` Takashi Iwai
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.