lkml.org 
[lkml]   [2019]   [Nov]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [alsa-devel] [PATCH V2] ASoC: fsl_audmix: Add spin lock to protect tdms
On Mon, Nov 11, 2019 at 9:53 AM Shengjiu Wang <shengjiu.wang@nxp.com> wrote:
>
> Audmix support two substream, When two substream start
> to run, the trigger function may be called by two substream
> in same time, that the priv->tdms may be updated wrongly.
>
> The expected priv->tdms is 0x3, but sometimes the
> result is 0x2, or 0x1.
>
> Fixes: be1df61cf06e ("ASoC: fsl: Add Audio Mixer CPU DAI driver")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>

Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>

> ---
> Change in v2
> -add Fixes, Cc stable, and Acked-by.
>
> sound/soc/fsl/fsl_audmix.c | 6 ++++++
> sound/soc/fsl/fsl_audmix.h | 1 +
> 2 files changed, 7 insertions(+)
>
> diff --git a/sound/soc/fsl/fsl_audmix.c b/sound/soc/fsl/fsl_audmix.c
> index c7e4e9757dce..a1db1bce330f 100644
> --- a/sound/soc/fsl/fsl_audmix.c
> +++ b/sound/soc/fsl/fsl_audmix.c
> @@ -286,6 +286,7 @@ static int fsl_audmix_dai_trigger(struct snd_pcm_substream *substream, int cmd,
> struct snd_soc_dai *dai)
> {
> struct fsl_audmix *priv = snd_soc_dai_get_drvdata(dai);
> + unsigned long lock_flags;
>
> /* Capture stream shall not be handled */
> if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
> @@ -295,12 +296,16 @@ static int fsl_audmix_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;
> @@ -491,6 +496,7 @@ static int fsl_audmix_probe(struct platform_device *pdev)
> return PTR_ERR(priv->ipg_clk);
> }
>
> + spin_lock_init(&priv->lock);
> platform_set_drvdata(pdev, priv);
> pm_runtime_enable(dev);
>
> diff --git a/sound/soc/fsl/fsl_audmix.h b/sound/soc/fsl/fsl_audmix.h
> index 7812ffec45c5..479f05695d53 100644
> --- a/sound/soc/fsl/fsl_audmix.h
> +++ b/sound/soc/fsl/fsl_audmix.h
> @@ -96,6 +96,7 @@ struct fsl_audmix {
> struct platform_device *pdev;
> struct regmap *regmap;
> struct clk *ipg_clk;
> + spinlock_t lock; /* Protect tdms */
> u8 tdms;
> };
>
> --
> 2.21.0
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

\
 
 \ /
  Last update: 2019-11-11 13:59    [W:0.145 / U:0.620 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site