diff options
author | Viorel Suman <viorel.suman@nxp.com> | 2019-12-09 17:29:20 +0200 |
---|---|---|
committer | Viorel Suman <viorel.suman@nxp.com> | 2019-12-09 17:31:04 +0200 |
commit | f789e4d7ab53580f49da3fb5a4d67f5077d3f25b (patch) | |
tree | 9c30f7280015ff11118684cb9eb89bfb835dbce1 /sound | |
parent | 5b07f684deb1b5519ac641baf7df953e80113e93 (diff) |
ASoC: fsl_audmix: Add spin lock to protect tdms
When two stream start to run, the trigger function
may be called by two substream in same time, that
the priv->tdms may be updated wrongly.
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/fsl/fsl_amix.c | 6 | ||||
-rw-r--r-- | sound/soc/fsl/fsl_amix.h | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/sound/soc/fsl/fsl_amix.c b/sound/soc/fsl/fsl_amix.c index 934bc55f8b63..33a075713c18 100644 --- a/sound/soc/fsl/fsl_amix.c +++ b/sound/soc/fsl/fsl_amix.c @@ -423,6 +423,7 @@ static int fsl_amix_dai_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { struct fsl_amix *priv = snd_soc_dai_get_drvdata(dai); + unsigned long lock_flags; /* Capture stream shall not be handled */ if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) @@ -432,12 +433,16 @@ static int fsl_amix_dai_trigger(struct snd_pcm_substream *substream, int cmd, case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + spin_lock_irqsave(&priv->lock, lock_flags); priv->tdms |= BIT(dai->driver->id); + spin_unlock_irqrestore(&priv->lock, lock_flags); break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + spin_lock_irqsave(&priv->lock, lock_flags); priv->tdms &= ~BIT(dai->driver->id); + spin_unlock_irqrestore(&priv->lock, lock_flags); break; default: return -EINVAL; @@ -614,6 +619,7 @@ static int fsl_amix_probe(struct platform_device *pdev) return PTR_ERR(priv->ipg_clk); } + spin_lock_init(&priv->lock); platform_set_drvdata(pdev, priv); pm_runtime_enable(&pdev->dev); diff --git a/sound/soc/fsl/fsl_amix.h b/sound/soc/fsl/fsl_amix.h index 582fb981849d..5ae6cae6609e 100644 --- a/sound/soc/fsl/fsl_amix.h +++ b/sound/soc/fsl/fsl_amix.h @@ -96,6 +96,7 @@ struct fsl_amix { struct platform_device *pdev; struct regmap *regmap; struct clk *ipg_clk; + spinlock_t lock; /* Protect tdms */ u8 tdms; }; |