Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6165410ybx; Mon, 11 Nov 2019 05:00:58 -0800 (PST) X-Google-Smtp-Source: APXvYqw6F65L58bT5fi7bx0PXPiFcOHoJJxUb+yoRxXgr29IGhVqz2+R4DSjznXmsgpSzi2CipqU X-Received: by 2002:a50:958d:: with SMTP id w13mr26595334eda.243.1573477257713; Mon, 11 Nov 2019 05:00:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573477257; cv=none; d=google.com; s=arc-20160816; b=yxBNVWll88NCfpwm7hSJmHE/MomkphIqL33/ibVa5SzMQpCBjl5dfDLE7Uo566WKrL 9+SNfWYHCoQaAkeAcqyyC6nTsIPCGtDW7l6JAEW9kEi+lVIUzFKu6ym8PwaQ5tsXJr+1 w2aYDJ2KlH9FdJVtJnjGDu0zxrxWdt27ulL9j0TxNhki66sVKW7EHhrMbXHFCYYa7tKG DSjh88mAqrVEJfpJBtzwi6K3n9L65oIoAyW6N71Cc/0sJOovp6AFcZi4eCz5Ukv7Pklz dL97FCfEjFaLnaz7Blqy3UUFF5npMs7NFmGlEvFuSZ7niaL4WoKDmLrsaEnwwUz4u/ej 69yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=h4ubUXtKB+J2uUhFjOOYE/2DGaUw76V9ImU/UoPSd30=; b=fsBXjccNJt4k+7VsxrwKlEVZOSEXTNvAb8X8QVS0cybn5q8/7bMtOaNKLe6QwC5fkI N3ch3mwTqMkCeaPsZby6jkjG8pgnWAB72apLd0+aTGtB4F02bCg28fOOzyFiMnx4ly0n zqRtqhR6/BSdg953yWOVxtNih3twY7sQoiUpCrIdJTW5e/lnWQ09h8ywdJnbCs/on98Z 5BsefPKeMdiqbA71pcrtuCGFjyiCCYhK+/r9ejF/gW1rzqK7Kj7jALRf1fWbISAQUqBA sY3ca+7mfFPC4YeU7oP61g5KNlsuKfbv7DuE9MIIAhsMjq5XxftoDQv9r25+vTXlUVab mbxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=O8TpWEM1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c12si9229782ejz.290.2019.11.11.05.00.33; Mon, 11 Nov 2019 05:00:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=O8TpWEM1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726915AbfKKM7W (ORCPT + 99 others); Mon, 11 Nov 2019 07:59:22 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:40886 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726811AbfKKM7V (ORCPT ); Mon, 11 Nov 2019 07:59:21 -0500 Received: by mail-wr1-f65.google.com with SMTP id i10so14527025wrs.7 for ; Mon, 11 Nov 2019 04:59:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=h4ubUXtKB+J2uUhFjOOYE/2DGaUw76V9ImU/UoPSd30=; b=O8TpWEM1zGN5JwYiXACyejO7elmVd/iwBpF91Bd2ZnSE+j/HHDU/insUNU7DnLKpdZ oUkOs5qn4NpTMYIuMsOcYJ2GmJak18C1L7ZRfiVxRNZFaGRLqvEzSbz+xd1ObzBHdvDn WBrjSXpX8bXvWgL+wKqCudksk8dnwZqRqvpj0HnFJUI4NLTQl2HO46mfISiZ5Db4oEwt 2IL+Z51y6+8Yy56FzJWIBynCj0zC7+4Wtpb4fp6FBsCWWcg3MuaDARwwVxLtuoNtIaVB rdT0kH7QgZpbZCQ+6lqlWmPGpVtdpdBn+Le1aorzrinqEiVlCGM6SBAnBQdKRJxjB9/d k2Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=h4ubUXtKB+J2uUhFjOOYE/2DGaUw76V9ImU/UoPSd30=; b=rd1OhY8xYPTtm+oYUSKA6cE64QM9q2wJNI6SbjGQ5QK6MrWMG6AE6jnxvpc6srPxwS xn8Dqh7350tMqoAm5aaNZRzejttEnLvTVuvQ1w7zIWt5fX0m5SVkMxMsva/qoyTROwLh 2NYHU4NEheChKuIn9YO9/B4tB4TiEsfSRd2yzMYDSNAsXKWmbKLDMaCYNyyntGkq0b6G kfBPedLFvp57GCCD1SpRrvu+1P9fk6zWuxAVHSuHsd5pC/ktjc5ozHgFy/cGL1fOhuUu CFFcAOgFlB20YeujsH9LZJfmnOTuAH4QAzBKmOGlHdgwPvwC5+jm6iSMsqeXujZT2iK1 mjkQ== X-Gm-Message-State: APjAAAVssUnDafBj11sv4WuwARVHHOXm4aoEbBomc65tklTRTxILvUj8 ejsp3UJSTLoLtrKM+MsbUON8Pc3Cmcx/KyDFccqOlNKk X-Received: by 2002:a05:6000:1181:: with SMTP id g1mr21673345wrx.131.1573477158306; Mon, 11 Nov 2019 04:59:18 -0800 (PST) MIME-Version: 1.0 References: <1e706afe53fdd1fbbbc79277c48a98f8416ba873.1573458378.git.shengjiu.wang@nxp.com> In-Reply-To: <1e706afe53fdd1fbbbc79277c48a98f8416ba873.1573458378.git.shengjiu.wang@nxp.com> From: Daniel Baluta Date: Mon, 11 Nov 2019 14:59:07 +0200 Message-ID: Subject: Re: [alsa-devel] [PATCH V2] ASoC: fsl_audmix: Add spin lock to protect tdms To: Shengjiu Wang Cc: Timur Tabi , Nicolin Chen , Xiubo Li , Fabio Estevam , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Linux-ALSA , linuxppc-dev@lists.ozlabs.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 11, 2019 at 9:53 AM Shengjiu Wang 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: > Signed-off-by: Shengjiu Wang > Acked-by: Nicolin Chen Reviewed-by: Daniel Baluta > --- > 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