From patchwork Mon Dec 16 17:48:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 181774 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp4659392ile; Mon, 16 Dec 2019 10:11:52 -0800 (PST) X-Google-Smtp-Source: APXvYqwNAuFAlMP6b79F/PVLp5fIIt/sO2+pC75kYVEUVfZmJBDcbsoASWSYX1iw2Osa0kDTHeKw X-Received: by 2002:a9d:7c8f:: with SMTP id q15mr34513369otn.341.1576519912497; Mon, 16 Dec 2019 10:11:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576519912; cv=none; d=google.com; s=arc-20160816; b=DP9eK7KZShLaO3sqBDKjxaAEutui+QCvl+E1bVU4jVDNDk7eEAJZYjUw71qtLJTpjW pz5/52bWNxm4aJvXOp6HY+MQdDbZsnkkjd+tCes3JRzaayw1X9ALSNH9ABee5/EeJECp Q7prd6WuBs33jURU0mZgu6/qUacuCJD2CROcFXbtOWjTeCv/9ADP+K/hnLpi5eduOlid FsLORO5XsFnDWUvsKkOKq7uGX0PAfa7wLXduIvYwLNzA64eOmbqHrr0h8nXbMTQZgYic r2g5nWe31KKV0zWuKmO9qlaoMBEC8wipC7Y7kq+apbOaSFWSYN3OR9qgVKG1dH+VrAE6 QSwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hhx10U1ifVP//yvTNZCN8MOhSwqAbAN9NV/PRc9xVPE=; b=ENOsleqPin+8oaG0g1wL9KDB+IKaLImzKjsoI7+3Aaea+C5A0Z1n7Ma2xICwFdS1cK rjCeNNuHI3SLKr7mPmJe/Wv+fg3/m88jlj1C5k/a+obhNYVGOwULcy7u1fVUnZ/KkqTe eRVle+uPnUN105g1m7yHi+hVnq/eCaLsQj31c3rzcvLvxQF3pE4/cUcll/K4gyf8nlpX 6tB554qrrZsTqRbAEmSpJRiZtSklNgDn5QUGHR5gVv4God3DqWSEBb/efzkjSrhH2CWy eJHtO9K91EtORtX5/tKzsnmLOrKJTnhlf3oREkeCDFWUFwpC6BHso1yLfaMXZ2MpnWMP 8Cfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qGIFrQao; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 11si15312212otz.101.2019.12.16.10.11.52; Mon, 16 Dec 2019 10:11:52 -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=@kernel.org header.s=default header.b=qGIFrQao; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730849AbfLPSLv (ORCPT + 27 others); Mon, 16 Dec 2019 13:11:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:56176 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730832AbfLPSLs (ORCPT ); Mon, 16 Dec 2019 13:11:48 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DD9352072D; Mon, 16 Dec 2019 18:11:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576519908; bh=00g5RKiIENXMC3oLyUK6qvQXapP1X6bpjKBjMZkmUmE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qGIFrQaobMNG/LsTmsqCpIuCF47JVbxBxTt8vdWD+/lrpzWx8NmT+OHYOd8delBqY Z+CIwFn7FYDwtpX2a65M258xAH4691aNuKe9hJtzDRj+clrM5MKbGGQRYhIYqTz+Z4 NC2teG/eE+XygGsQ0ngiKrN60Sd1fU9Q+elI0UvM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shengjiu Wang , Nicolin Chen , Daniel Baluta , Mark Brown Subject: [PATCH 5.3 078/180] ASoC: fsl_audmix: Add spin lock to protect tdms Date: Mon, 16 Dec 2019 18:48:38 +0100 Message-Id: <20191216174830.960022512@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191216174806.018988360@linuxfoundation.org> References: <20191216174806.018988360@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shengjiu Wang commit fe965096c9495ddcf78ec163348105e2baf8d185 upstream. 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") Signed-off-by: Shengjiu Wang Acked-by: Nicolin Chen Reviewed-by: Daniel Baluta Link: https://lore.kernel.org/r/1e706afe53fdd1fbbbc79277c48a98f8416ba873.1573458378.git.shengjiu.wang@nxp.com Signed-off-by: Mark Brown Cc: Signed-off-by: Greg Kroah-Hartman --- sound/soc/fsl/fsl_audmix.c | 6 ++++++ sound/soc/fsl/fsl_audmix.h | 1 + 2 files changed, 7 insertions(+) --- 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 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 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; @@ -493,6 +498,7 @@ static int fsl_audmix_probe(struct platf return PTR_ERR(priv->ipg_clk); } + spin_lock_init(&priv->lock); platform_set_drvdata(pdev, priv); pm_runtime_enable(dev); --- 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; };