Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp472606ybx; Wed, 6 Nov 2019 03:38:26 -0800 (PST) X-Google-Smtp-Source: APXvYqzMF0IG1fZRspI3wNsdObQNDyT/fGbFhb76/PBvx1GfHxm+kxjNPmkpVQaYt0TtevGgZneM X-Received: by 2002:a05:6402:2042:: with SMTP id bc2mr2055913edb.167.1573040305957; Wed, 06 Nov 2019 03:38:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573040305; cv=none; d=google.com; s=arc-20160816; b=FDJEIBS0pqklccZQUUaViqblDbdXl/zCFu7XB6wMDKd3urnbPM1CUFjBtFf4FEclth 6CH35uZO1R1v2I3I1DwcuCRLbxcPZMmWFm6+53ezR9QsQX6kCDRMBE3bbfphyRWDXH3A A0fmAgYFrc3++dTw/Aom9/zV+XaV6xtasgTEOxNw90pegCv8/Wqa1itnCRBDDfDwZ+Fb ipKusrGKQi/1CQsRDAV/R620XzQmbZi8kd5lGYP1wORYeNJ/+KeryRn9jWxJDcQFeE9v yk2G3b3TZhWlX2+HDnqls9QyDmnuhrRFpPYlYaDb/Ib2tVtrNyQ42l1DJRzzN6Sx73XF K/3g== 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=OCw5fZ9l2RrOi3SE8aqoJuN0UEZysLXdrRoRB/SxvBQ=; b=Wzoin+v+H3gLJFz+0uAr0LlDuAs58KmvqsvE5KiEiNatCXN6sNcPSgym+Qr0cBEdli SeD9iG1pJAKwEh+YyK08KmpIVBa5HyQXaZHX5da1bFoUmoE5/XjnNVQNQP4xKQcwnhZr 5HrVZvAKx1BhvHHkN+gcP/k/XEx4KTksLl/XONxiRzcDze3gqAMoBfL16mYD2jwzcEb6 7DUpnT12ovjcdVCdvb4g5uqon8fYl6KDsMnqxYTbiDbwKDv+KEPGs10N35n4NlRY86yy dKGRjR+TVyRWwodU3WRW+dV+tFTYvXF/lmmBqT1b0z+uzX0la2SuVO8mRc3hJnt8I02M qi2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cp3zwyxx; 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 c11si13547206edb.425.2019.11.06.03.38.02; Wed, 06 Nov 2019 03:38:25 -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=cp3zwyxx; 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 S1730091AbfKFLgl (ORCPT + 99 others); Wed, 6 Nov 2019 06:36:41 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35083 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725856AbfKFLgk (ORCPT ); Wed, 6 Nov 2019 06:36:40 -0500 Received: by mail-wr1-f66.google.com with SMTP id p2so112363wro.2 for ; Wed, 06 Nov 2019 03:36:39 -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=OCw5fZ9l2RrOi3SE8aqoJuN0UEZysLXdrRoRB/SxvBQ=; b=cp3zwyxxGArn6yB7UddfdzaHFMsp10QWEUHJUO0vPDt8WXjEKvzzCwG8xusRCA+PJS XkIAfXXJcOPnfFo39YKbHA1s4qQcxejVHSqrhFIfmpSZQqvkLx90rBW+OCy0c68xJGWI 4+FUYZgWb15MxOtMawwLF7fnoW69g0OtktE26iIljd7V9AeTipZcWWcswuWycY31CsOh 8/bnNr7wHEcZwGZbIYr5rL8GBPBBn9QeI2eEy76QjH6XzZzcMHLM52q6j/VD7asOqnXJ G12h0bezxKBl2VGTO95uzQyU2QcDUxxe2YtPboFfK9DItm5As9C6GaTRrSJHC87Eilqs KdxQ== 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=OCw5fZ9l2RrOi3SE8aqoJuN0UEZysLXdrRoRB/SxvBQ=; b=dxFTa+aYj7dnK5fCvAh71KbdZPOyJZDDqKF9XBjAx4vWNGff0ta6wcEMuX5zca6hIF Nx5ZLB/eXoyoZrEcURjjS0nfJeXpMjXdtBhT8bVzZyEOA4MQe3dEfXGhU7dynL+Eurmt GdrDGKaNuOXi6lnsIuCwqP/3aqdktuCIq4VsiZCbW6LdXb+uW1RRlPQmkghdsZN/UA1j eybwkZMg4+BKtOmFLWHtQ/XHHpK/0p32W7rIiml5Q5nrMLZ0Blad47Fc71/eiIvO2hkm mpMz+oKCJj+XuLXgAxn8NA/zE8/6HbOmRZH9VdBwHvQTFXM9u0p/bH/bcyTjTjiU/bzw tN+A== X-Gm-Message-State: APjAAAXiS290tDBAv0hEnfhsqLNrtR/VbQsV1MVyIRwMz4JUID4THxZg NcOJUp7s/VDZl4t3Uku0b8NOlT+dioGIYzDNXut3FxM2 X-Received: by 2002:a5d:5306:: with SMTP id e6mr2160142wrv.187.1573040198673; Wed, 06 Nov 2019 03:36:38 -0800 (PST) MIME-Version: 1.0 References: <1573025265-31852-1-git-send-email-shengjiu.wang@nxp.com> In-Reply-To: <1573025265-31852-1-git-send-email-shengjiu.wang@nxp.com> From: Daniel Baluta Date: Wed, 6 Nov 2019 13:36:26 +0200 Message-ID: Subject: Re: [alsa-devel] [PATCH] ASoC: fsl_audmix: Add spin lock to protect tdms To: Shengjiu Wang Cc: Timur Tabi , Nicolin Chen , Xiubo Li , Fabio Estevam , 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 Hi Shengjiu, Comments inline. On Wed, Nov 6, 2019 at 9:30 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. > > Signed-off-by: Shengjiu Wang > --- > 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); Why do we need to disable interrupts here? I assume that lock is only used in process context. thanks, Daniel.