From: Takashi Iwai <tiwai@suse.de>
To: Chancel Liu <chancel.liu@nxp.com>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
Jaroslav Kysela <perex@perex.cz>,
"S.J. Wang" <shengjiu.wang@nxp.com>
Subject: Re: Suspend/resume Issue on pcm_dmix.c in alsa-lib
Date: Tue, 27 Aug 2024 11:54:29 +0200 [thread overview]
Message-ID: <87r0aa1eay.wl-tiwai@suse.de> (raw)
In-Reply-To: <DB9PR04MB94988752ED7C43B399E0BC00E3942@DB9PR04MB9498.eurprd04.prod.outlook.com>
On Tue, 27 Aug 2024 09:06:39 +0200,
Chancel Liu wrote:
>
>
> Hi Takashi Iwai, Jaroslav Kysela
>
> We found an issue on dmix in alsa-lib when do suspend and resume. It can be
> easily reproduced by following steps:
>
> 1. Run two dmix clients in parallel. (Only one client doesn’t has such issue)
>
> ~# aplay xxx1.wav &
>
> ~# aplay xxx2.wav &
>
> Here I attach the asound.conf we're using.
>
> ~# cat /etc/asound.conf
>
> defaults.pcm.rate_converter "linear"
>
> pcm.dmix_44100{
>
> type dmix
>
> ipc_key 5678293
>
> ipc_key_add_uid yes
>
> slave{
>
> pcm "hw:0,0"
>
> period_time 40000
>
> format S16_LE
>
> rate 44100
>
> }
>
> }
>
> pcm.asymed{
>
> type asym
>
> playback.pcm "dmix_44100"
>
> capture.pcm "dsnoop_44100"
>
> }
>
> pcm.!default{
>
> type plug
>
> route_policy "average"
>
> slave.pcm "asymed"
>
> }
>
> 2. Let linux enter into suspend and then resume(Repeat this step if not
> reproduced)
>
> 3. After resume, aplay will get stuck in snd_pcm_wait(). The GDB shows:
>
> (gdb) bt
>
> #0 0x0000fffff7da9264 in __GI___poll (fds=fds@entry=0xfffffffff480, nfds=
> nfds@entry=1, timeout=timeout@entry=240)
>
> at /usr/src/debug/glibc/2.39+git/sysdeps/unix/sysv/linux/poll.c:41
>
> #1 0x0000fffff7edf468 in poll (__timeout=240, __nfds=1, __fds=0xfffffffff480)
>
> #2 snd1_pcm_wait_nocheck (pcm=pcm@entry=0xaaaaaaad2cb0, timeout=240,
> timeout@entry=-10001) at pcm.c:2993
>
> #3 0x0000fffff7ee54a0 in snd1_pcm_write_areas (pcm=pcm@entry=0xaaaaaaad2cb0,
> areas=areas@entry=0xfffffffff560, offset=<optimized out>, offset@entry=0, size
> =<optimized out>,
>
> size@entry=1768, func=func@entry=0xfffff7ef5190
> <snd_pcm_plugin_write_areas>) at pcm.c:7699
>
> #4 0x0000fffff7ef5020 in snd_pcm_plugin_writei (pcm=0xaaaaaaad2cb0, buffer=
> <optimized out>, size=1768) at pcm_plugin.c:354
>
> It seems that sometimes after suspend and resume there's no available space
> for data written into buffer. Then aplay keeps stuck in snd_pcm_wait(). I
> checked the hw_ptr of dmix and found that hw_ptr is always 0 after resume.
>
> I don't have a solution now so I turn to you for help. The version of alsa-lib
> is v1.2.11. Could you please help check it?
I tried your setup but I couldn't reproduce the issue locally with my
laptop and HD-audio device. Possibly depending on the kernel driver?
In the case of dmix, it's a poll() against the PCM slave timer. So
it doesn't take care of suspend/resume state unlike the real PCM
device. OTOH, the timer device should send notification events at
suspend/resume, and it should trigger the poll wakeup, too.
Does poll() return after the suspend/resume once but falls into a loop
due to revents being unset? Or it's stuck and never returns at
suspend/resume?
thanks,
Takashi
next prev parent reply other threads:[~2024-08-27 11:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-27 7:06 Suspend/resume Issue on pcm_dmix.c in alsa-lib Chancel Liu
2024-08-27 9:54 ` Takashi Iwai [this message]
2024-08-27 10:49 ` Takashi Iwai
2024-09-04 9:07 ` Chancel Liu
2024-09-04 9:29 ` Jaroslav Kysela
2024-09-04 10:04 ` Takashi Iwai
2024-09-04 9:57 ` Takashi Iwai
2024-09-05 7:44 ` Chancel Liu
2024-09-05 8:10 ` Takashi Iwai
2024-09-05 11:01 ` [EXT] " Chancel Liu
2024-09-05 13:36 ` Takashi Iwai
2024-09-06 6:22 ` Chancel Liu
2024-09-06 6:31 ` 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=87r0aa1eay.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=chancel.liu@nxp.com \
--cc=perex@perex.cz \
--cc=shengjiu.wang@nxp.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