android_kernel_oneplus_msm8998/sound/core
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
..
oss ALSA: pcm: Fix possible OOB access in PCM oss plugins 2019-04-03 06:23:26 +02:00
seq ALSA: seq: oss: Fix Spectre v1 vulnerability 2019-04-03 06:23:26 +02:00
compress_offload.c ALSA: compress: add support for 32bit calls in a 64bit kernel 2019-04-03 06:23:26 +02:00
control.c ALSA: control: Fix race between adding and removing a user element 2018-12-13 09:21:27 +01:00
control_compat.c ALSA: control: fix a redundant-copy issue 2018-05-26 08:48:52 +02:00
ctljack.c ALSA: jack: Fix endless loop at unique index detection 2015-06-26 06:59:57 +02:00
device.c
hrtimer.c ALSA: hrtimer: Fix stall by hrtimer_cancel() 2016-01-31 11:28:57 -08:00
hwdep.c ALSA: replace CONFIG_PROC_FS with CONFIG_SND_PROC_FS 2015-05-27 21:25:19 +02:00
hwdep_compat.c
info.c ALSA: info: Limit the proc text input size 2016-11-18 10:48:33 +01:00
info_oss.c ALSA: core: Clean up OSS proc file management 2015-04-24 17:31:08 +02:00
init.c ALSA: Fix uninintialized error return 2015-06-29 19:08:31 +02:00
isadma.c
jack.c ALSA: jack: Remove MODULE_*() macros 2015-05-21 11:32:51 +02:00
Kconfig ALSA: timer: add config item to export PCM timer disabling for expert 2015-10-16 14:31:38 +02:00
Makefile ALSA: timer: add config item to export PCM timer disabling for expert 2015-10-16 14:31:38 +02:00
memalloc.c ALSA: memalloc: Don't exceed over the requested size 2018-08-22 07:48:36 +02:00
memory.c
misc.c
pcm.c ALSA: pcm: Fix potential Spectre v1 vulnerability 2019-01-13 10:05:29 +01:00
pcm_compat.c ALSA: pcm: Check PCM state at xfern compat ioctl 2018-05-16 10:06:47 +02:00
pcm_dmaengine.c
pcm_drm_eld.c ALSA: pcm: add DRM ELD helper 2015-05-22 16:01:44 +02:00
pcm_iec958.c ALSA: pcm: add IEC958 channel status helper 2015-05-22 16:01:47 +02:00
pcm_lib.c ALSA: pcm: remove SNDRV_PCM_IOCTL1_INFO internal command 2018-12-17 21:55:12 +01:00
pcm_memory.c
pcm_misc.c
pcm_native.c ALSA: pcm: Don't suspend stream in unrecoverable PCM state 2019-04-03 06:23:26 +02:00
pcm_timer.c
pcm_trace.h
rawmidi.c ALSA: rawmidi: Fix potential Spectre v1 vulnerability 2019-04-03 06:23:26 +02:00
rawmidi_compat.c ALSA: rawmidi: Fix missing input substream checks in compat ioctls 2018-04-24 09:32:10 +02:00
rtctimer.c
sgbuf.c
sound.c ALSA: replace CONFIG_PROC_FS with CONFIG_SND_PROC_FS 2015-05-27 21:25:19 +02:00
sound_oss.c ALSA: replace CONFIG_PROC_FS with CONFIG_SND_PROC_FS 2015-05-27 21:25:19 +02:00
timer.c ALSA: timer: Fix zero-division by continue of uninitialized instance 2018-11-10 07:41:38 -08:00
timer_compat.c ALSA: timer: Remove kernel warning at compat ioctl error paths 2017-11-30 08:37:22 +00:00
vmaster.c ALSA: vmaster: Propagate slave error 2018-05-30 07:49:13 +02:00