kernel_optimize_test/include/sound
Takashi Iwai ea9d0d771f ASoC: dpcm: Fix race between FE/BE updates and trigger
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>
Cc: stable@vger.kernel.org
2014-11-04 17:18:32 +00:00
..
ac97_codec.h
aci.h
ad1816a.h
ad1843.h
adau1373.h
aess.h
ak4xxx-adda.h
ak4113.h
ak4114.h
ak4117.h
ak4531_codec.h
ak4641.h
alc5623.h
asequencer.h
asound.h
asoundef.h
atmel-abdac.h dmaengine: dw: move dw_dmac.h to where it belongs to 2014-09-11 11:48:12 +05:30
atmel-ac97c.h dmaengine: dw: move dw_dmac.h to where it belongs to 2014-09-11 11:48:12 +05:30
compress_driver.h
control.h ALSA: control: Define SNDRV_CTL_TLV_OP_* constants 2014-07-15 16:31:01 +02:00
core.h ALSA: control: Protect user controls against concurrent access 2014-06-18 15:12:33 +02:00
cs42l52.h
cs42l56.h
cs42l73.h
cs4231-regs.h
cs4271.h
cs8403.h
cs8427.h
da7213.h
da9055.h
designware_i2s.h
dmaengine_pcm.h
emu10k1_synth.h
emu10k1.h
emu8000_reg.h
emu8000.h
emux_legacy.h
emux_synth.h
es1688.h
gus.h
hda_hwdep.h
hda_verbs.h
hwdep.h
i2c.h
info.h
initval.h
jack.h
l3.h
max9768.h
max98088.h
max98090.h
max98095.h
memalloc.h
minors.h
mixer_oss.h
mpu401.h
omap-pcm.h
opl3.h
opl4.h
pcm_oss.h
pcm_params.h
pcm-indirect.h
pcm.h ALSA: pcm: add new DSD sampleformat for native DSD playback on XMOS based devices 2014-09-08 17:11:00 +02:00
pt2258.h
pxa2xx-lib.h
rawmidi.h
rcar_snd.h ASoC: rsnd: SSI + DMA can select BUSIF 2014-06-28 14:41:19 +01:00
rt286.h ASoC: add RT286 CODEC driver 2014-07-04 18:50:51 +01:00
rt5640.h
rt5645.h ASoC: rt5645: Add headset detect function 2014-10-01 19:28:44 +01:00
rt5651.h
rt5670.h ASoC: add RT5670 CODEC driver 2014-07-02 20:49:25 +01:00
rt5677.h ASoC: rt5677: Add dts properties for input/output differential configuration 2014-09-29 19:46:20 +01:00
s3c24xx_uda134x.h
sb16_csp.h
sb.h
seq_device.h
seq_kernel.h
seq_midi_emul.h
seq_midi_event.h
seq_oss_legacy.h
seq_oss.h
seq_virmidi.h
sh_dac_audio.h
sh_fsi.h
simple_card.h
snd_wavefront.h
soc-dai.h ASoC: core: Add initial support for DAI multicodec 2014-07-16 22:58:49 +01:00
soc-dapm.h Merge remote-tracking branches 'asoc/topic/davinci', 'asoc/topic/dmic', 'asoc/topic/drivers', 'asoc/topic/es8328' and 'asoc/topic/fsl' into asoc-next 2014-10-06 12:48:57 +01:00
soc-dpcm.h ASoC: dpcm: Fix race between FE/BE updates and trigger 2014-11-04 17:18:32 +00:00
soc.h Merge remote-tracking branches 'asoc/topic/davinci', 'asoc/topic/dmic', 'asoc/topic/drivers', 'asoc/topic/es8328' and 'asoc/topic/fsl' into asoc-next 2014-10-06 12:48:57 +01:00
soundfont.h
spear_dma.h
spear_spdif.h
sta32x.h
sta350.h
tas2552-plat.h ASoC: tas2552: Support TI TAS2552 Amplifier 2014-07-17 17:57:05 +01:00
tas5086.h
tea6330t.h
timer.h
tlv320aic3x.h
tlv320aic32x4.h
tlv320dac33-plat.h
tlv.h
tpa6130a2-plat.h
uda134x.h
uda1380.h
util_mem.h
vx_core.h ALSA: vx: Use nonatomic PCM ops 2014-09-15 15:52:03 +02:00
wavefront.h
wm0010.h
wm1250-ev1.h
wm2000.h
wm2200.h
wm5100.h
wm8903.h
wm8904.h
wm8955.h
wm8960.h
wm8962.h ASoC: wm8962: Let CODEC driver enable and disable its own MCLK 2014-07-31 20:51:26 +01:00
wm8993.h
wm8996.h
wm9081.h
wm9090.h
wss.h