linux/include/sound
Takashi Iwai 05619290c1 ASoC: dpcm: Fix race between FE/BE updates and trigger
commit ea9d0d771f upstream.

DPCM can update the FE/BE connection states totally asynchronously
from the FE's PCM state.  Most of FE/BE state changes are protected by
mutex, so that they won't race, but there are still some actions that
are uncovered.  For example, suppose to switch a BE while a FE's
stream is running.  This would call soc_dpcm_runtime_update(), which
sets FE's runtime_update flag, then sets up and starts BEs, and clears
FE's runtime_update flag again.

When a device emits XRUN during this operation, the PCM core triggers
snd_pcm_stop(XRUN).  Since the trigger action is an atomic ops, this
isn't blocked by the mutex, thus it kicks off DPCM's trigger action.
It eventually updates and clears FE's runtime_update flag while
soc_dpcm_runtime_update() is running concurrently, and it results in
confusion.

Usually, for avoiding such a race, we take a lock.  There is a PCM
stream lock for that purpose.  However, as already mentioned, the
trigger action is atomic, and we can't take the lock for the whole
soc_dpcm_runtime_update() or other operations that include the lengthy
jobs like hw_params or prepare.

This patch provides an alternative solution.  This adds a way to defer
the conflicting trigger callback to be executed at the end of FE/BE
state changes.  For doing it, two things are introduced:

- Each runtime_update state change of FEs is protected via PCM stream
  lock.
- The FE's trigger callback checks the runtime_update flag.  If it's
  not set, the trigger action is executed there.  If set, mark the
  pending trigger action and returns immediately.
- At the exit of runtime_update state change, it checks whether the
  pending trigger is present.  If yes, it executes the trigger action
  at this point.

Reported-and-tested-by: Qiao Zhou <zhouqiao@marvell.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-12-06 15:55:35 -08:00
..
ac97_codec.h Sound updates for 3.7-rc1 2012-10-09 07:07:14 +09:00
aci.h
ad1816a.h Sound updates for 3.7-rc1 2012-10-09 07:07:14 +09:00
ad1843.h
adau1373.h
aess.h ASoC: TI AESS: add autogating-enable function, callable from architecture code 2013-02-10 11:22:23 -07:00
ak4xxx-adda.h
ak4113.h
ak4114.h ALSA: ak4114: Fix wrong register array size 2013-10-29 16:42:36 +01:00
ak4117.h
ak4531_codec.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
ak4641.h
alc5623.h
asequencer.h UAPI: (Scripted) Disintegrate include/sound 2012-10-09 09:49:13 +01:00
asound.h UAPI: (Scripted) Disintegrate include/sound 2012-10-09 09:49:13 +01:00
asoundef.h ALSA: Add definitions for CEA-861 Audio InfoFrames 2012-04-18 08:00:36 +02:00
atmel-abdac.h
atmel-ac97c.h
compress_driver.h ALSA: compress: fix drain calls blocking other compress functions (v6) 2013-11-07 10:12:27 +01:00
control.h ALSA: vmaster: Add snd_ctl_sync_vmaster() helper function 2013-06-24 15:51:54 +02:00
core.h ALSA: control: Protect user controls against concurrent access 2014-06-26 15:15:43 -04:00
cs42l52.h ASoC: cs42l52: Make MICA/B mixer dependent on mic config 2013-11-28 10:20:51 +00:00
cs42l73.h ASoC: cs42l73: Add platform data support for cs42l73 codec 2013-10-18 00:37:29 +01:00
cs4231-regs.h
cs4271.h ALSA: ASoC: cs4271: add optional soft reset workaround 2012-12-24 15:53:28 +00:00
cs8403.h
cs8427.h
da7213.h ASoC: codecs: Add da7213 codec 2013-02-14 17:27:17 +00:00
da9055.h ASoC: codecs: Add DA9055 codec driver 2012-09-28 14:21:54 +01:00
designware_i2s.h ASoC: Add support for synopsys i2s controller as per ASoC framework. 2012-06-22 10:25:45 +01:00
dmaengine_pcm.h ASoC: dmaengine: add custom DMA config to snd_dmaengine_pcm_config 2013-12-09 18:45:01 +00:00
emu10k1.h ALSA: emu10k1: Fix dock firmware loading 2013-04-24 08:11:49 +02:00
emu10k1_synth.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
emu8000.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
emu8000_reg.h
emux_legacy.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
emux_synth.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
es1688.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
gus.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
hda_hwdep.h
hda_verbs.h ALSA: hda - Split verb definitions into sound/hda_verbs.h 2013-12-09 17:31:40 +01:00
hwdep.h
i2c.h
info.h switch procfs to umode_t use 2012-01-03 22:54:56 -05:00
initval.h ALSA: isa: Move snd_legacy_find_free_ioport to initval.h 2012-08-03 12:57:44 +02:00
jack.h ALSA: Use a define for the number of jack switch types 2012-02-27 17:34:44 +01:00
l3.h
max9768.h ASoC: max9768: add driver for max9768 amplifier 2012-01-30 21:50:55 +00:00
max98088.h
max98090.h ASoC:: max98090: Remove executable bit 2013-03-20 10:54:12 +01:00
max98095.h ASoC: max98095: Single bit bitfields should be unsigned 2012-05-13 23:33:53 +01:00
memalloc.h ALSA: Remove memory reservation code from memalloc helper 2014-01-09 07:32:10 +01:00
minors.h ALSA: core: add support for compressed devices 2011-12-23 10:07:46 +01:00
mixer_oss.h
mpu401.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
opl3.h
opl4.h
pcm-indirect.h
pcm.h Merge remote-tracking branch 'asoc/topic/pcm' into for-tiwai 2014-01-16 12:42:57 +00:00
pcm_oss.h
pcm_params.h ALSA: Add params_width() helpers 2013-12-30 12:19:26 +00:00
pt2258.h
pxa2xx-lib.h ASoC: pxa: use snd_dmaengine_dai_dma_data 2013-08-15 11:29:07 +01:00
rawmidi.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
rcar_snd.h ARM: SoC board updates for 3.14 2014-01-23 18:48:28 -08:00
rt5640.h ASoC: add RT5640 CODEC driver 2013-06-12 17:46:54 +01:00
s3c24xx_uda134x.h
sb.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
sb16_csp.h UAPI: (Scripted) Disintegrate include/sound 2012-10-09 09:49:13 +01:00
seq_device.h
seq_kernel.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
seq_midi_emul.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
seq_midi_event.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
seq_oss.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
seq_oss_legacy.h
seq_virmidi.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
sh_dac_audio.h
sh_fsi.h ASoC: fsi: cleanup sh_fsi.h 2012-12-24 15:57:20 +00:00
simple_card.h ASoC: simple-card: add asoc_simple_dai for initializing 2013-01-14 06:55:43 +09:00
snd_wavefront.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
soc-dai.h Merge remote-tracking branch 'asoc/topic/dapm' into for-tiwai 2014-01-16 12:42:53 +00:00
soc-dapm.h ASoC: dapm: Add locking to snd_soc_dapm_xxxx_pin functions 2014-02-20 18:40:07 +09:00
soc-dpcm.h ASoC: dpcm: Fix race between FE/BE updates and trigger 2014-12-06 15:55:35 -08:00
soc.h Merge remote-tracking branch 'asoc/topic/compress' into asoc-next 2014-01-20 11:50:41 +00:00
soundfont.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
spear_dma.h ASoC: SPEAr: remove custom DMA alloc compat function 2013-12-18 18:55:06 +00:00
spear_spdif.h ASoC: SPEAr spdif_in: Add spdif IN support 2012-06-23 11:58:10 +01:00
sta32x.h
tas5086.h ALSA: ASoC: add codec driver for TI TAS5086 2013-03-08 21:06:09 +08:00
tea6330t.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
timer.h
tlv.h ALSA: Add comment for control TLV API 2013-05-08 15:43:56 +02:00
tlv320aic3x.h ASoC: tlv320aic3x: Convert mic bias to a supply widget 2013-02-04 18:35:19 +00:00
tlv320aic32x4.h ASoC: tlv320aic32x4: Add rstn gpio to platform data. 2012-11-01 14:35:56 +00:00
tlv320dac33-plat.h
tpa6130a2-plat.h
uda134x.h
uda1380.h
util_mem.h
vx_core.h ALSA: vx: hard dependency on the standard fw loader 2012-11-22 17:48:01 +01:00
wavefront.h
wm0010.h ASoC: wm0010: Add initial wm0010 DSP driver 2012-08-23 16:12:12 +01:00
wm1250-ev1.h
wm2000.h ASoC: wm2000: Use clock API integration to configure MCLK divisor 2012-12-24 15:42:35 +00:00
wm2200.h ASoC: wm2200: Provide platform data for MICBIAS configuration 2013-02-05 15:53:07 +00:00
wm5100.h
wm8903.h ASoC: WM8903: Fix platform data gpio_cfg confusion 2011-12-06 10:29:22 +00:00
wm8904.h
wm8955.h
wm8960.h ASoC: wm8960: remove 'dres' field from platform data structure 2012-09-21 08:35:06 -04:00
wm8962.h ASoC: wm8962: Optimise power consumption for IN4 DC measurement usage 2012-01-24 21:19:45 +00:00
wm8993.h ASoC: wm_hubs: Allow configuration of MICBIAS power up delay via pdata 2012-08-22 19:00:37 +01:00
wm8996.h
wm9081.h
wm9090.h
wss.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00