android_kernel_oneplus_msm8998/sound
Takashi Iwai 49ad739854 ALSA: pcm: Don't suspend stream in unrecoverable PCM state
commit 113ce08109f8e3b091399e7cc32486df1cff48e7 upstream.

Currently PCM core sets each opened stream forcibly to SUSPENDED state
via snd_pcm_suspend_all() call, and the user-space is responsible for
re-triggering the resume manually either via snd_pcm_resume() or
prepare call.  The scheme works fine usually, but there are corner
cases where the stream can't be resumed by that call: the streams
still in OPEN state before finishing hw_params.  When they are
suspended, user-space cannot perform resume or prepare because they
haven't been set up yet.  The only possible recovery is to re-open the
device, which isn't nice at all.  Similarly, when a stream is in
DISCONNECTED state, it makes no sense to change it to SUSPENDED
state.  Ditto for in SETUP state; which you can re-prepare directly.

So, this patch addresses these issues by filtering the PCM streams to
be suspended by checking the PCM state.  When a stream is in either
OPEN, SETUP or DISCONNECTED as well as already SUSPENDED, the suspend
action is skipped.

To be noted, this problem was originally reported for the PCM runtime
PM on HD-audio.  And, the runtime PM problem itself was already
addressed (although not intended) by the code refactoring commits
3d21ef0b49f8 ("ALSA: pcm: Suspend streams globally via device type PM
ops") and 17bc4815de58 ("ALSA: pci: Remove superfluous
snd_pcm_suspend*() calls").  These commits eliminated the
snd_pcm_suspend*() calls from the runtime PM suspend callback code
path, hence the racy OPEN state won't appear while runtime PM.
(FWIW, the race window is between snd_pcm_open_substream() and the
first power up in azx_pcm_open().)

Although the runtime PM issue was already "fixed", the same problem is
still present for the system PM, hence this patch is still needed.
And for stable trees, this patch alone should suffice for fixing the
runtime PM problem, too.

Reported-and-tested-by: Jon Hunter <jonathanh@nvidia.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-04-03 06:23:26 +02:00
..
aoa ALSA: snd-aoa: add of_node_put() in error path 2018-10-10 08:52:05 +02:00
arm
atmel
core ALSA: pcm: Don't suspend stream in unrecoverable PCM state 2019-04-03 06:23:26 +02:00
drivers ALSA: aloop: Add missing cable lock to ctl API callbacks 2018-05-16 10:06:47 +02:00
firewire ALSA: bebob: use more identical mod_alias for Saffire Pro 10 I/O against Liquid Saffire 56 2019-03-23 08:44:31 +01:00
hda sound: enable interrupt after dma buffer initialization 2018-10-20 09:52:33 +02:00
i2c
isa ALSA: isa/wavefront: prevent some out of bound writes 2018-12-21 14:09:54 +01:00
mips
oss
parisc
pci ALSA: hda - Enforces runtime_resume after S3 and S4 for each codec 2019-04-03 06:23:17 +02:00
pcmcia ALSA: vxpocket: Fix invalid endian conversions 2018-08-22 07:48:36 +02:00
ppc
sh
soc ASoC: topology: free created components in tplg load error 2019-03-23 08:44:33 +01:00
sparc ALSA: sparc: Fix invalid snd_free_pages() at error path 2018-12-13 09:21:27 +01:00
spi
synth ALSA: emux: Fix potential Spectre v1 vulnerabilities 2019-01-13 10:05:29 +01:00
usb ALSA: usb-audio: Fix implicit fb endpoint setup by quirk 2019-02-20 10:13:22 +01:00
ac97_bus.c
Kconfig
last.c
Makefile
sound_core.c
sound_firmware.c