From patchwork Mon Dec 16 17:49:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 181783 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp4669234ile; Mon, 16 Dec 2019 10:19:46 -0800 (PST) X-Google-Smtp-Source: APXvYqwACa7S0lj7IOUcPyOlu24fO2g1WgO6J7uyfIjqzoplUz9hETESBewOowedD9YQF+WPYAA0 X-Received: by 2002:a9d:6e12:: with SMTP id e18mr31351410otr.47.1576520386203; Mon, 16 Dec 2019 10:19:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576520386; cv=none; d=google.com; s=arc-20160816; b=f4T8gl5SHLKKbIXKW0yOlriIbyEeOAIs0NnutmErhDwGCsOCuaFTma6RChVp0I0L4w iFooo2daDM+h6CRMDFfmMX+5utyiGgd1EkPPZd7nRAiQeAEJCbf4d5AghzsL71eM/pxw 4vBiIhU0cl09BU1cm2Mb7w5cncDyFqjwAFVrXUO+dNFMTg8bDIOUiOCWKQYO4pV9UW1o TtsK0xYRWeInlhYGWzPBseeV+/GYhGvnqRAEGHi5Je3E030RbdD9Cz/TWiXLMANeOv4d AclM2VBuKzc3m971BVVoT059+lN744KGcuJqZp+W0pryUOs5VGXe9ZcaCI27pX5dz+Gl psNw== 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=lJluwGm3tA+cF4KJsGnFV0z8itdNWl1ACtASmGzKe/E=; b=txWBpNzDER7XglDonF3apU92N5Uf9hbp7dx9lKESQ8eh20ehtV1J8ngopcx8fQQN/K ezJfhCzrrIWUauzeZblNvURt59bzfnTpnTbf0qaLvKCJfO/mAFCGS39XQx2IVkDXd5PG LuQNpnDtwzyXbVdR7buoXgHATBnYQGTe4ped0boKOtcO3HaDac0g0E3M0cjIGai7+Hbs ptR91zsFN5NPmk8XWHuACixIi/+yfoG6zzr4Jrwxy0JKA19oNWcj/JYgT2shpG1w9Ehs dKD5z52YOtPuAn4dS+vpmXXlHoV6JjLsQFa2pBeuQZwv+jQVNs3Mj/u0G+V2FV+z9V+L 11uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UZOr5Lk4; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 u12si10931474otq.51.2019.12.16.10.19.46; Mon, 16 Dec 2019 10:19:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=UZOr5Lk4; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731837AbfLPSTo (ORCPT + 14 others); Mon, 16 Dec 2019 13:19:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:48356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731968AbfLPSTl (ORCPT ); Mon, 16 Dec 2019 13:19:41 -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 A6B00207FF; Mon, 16 Dec 2019 18:19:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576520381; bh=ykyXuBjdrvDsfkhIUrb1x8jlBJIu+YyjtsYEWvJ6v0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UZOr5Lk4qOIc2nvxIJxRYk2dD2L96sYASTtCda+BPDF/UihAxGcHQ2DTTBLDwOOg7 n58gBQbX1xbnULzGCTF33qPLv9du8VDQ9zOZ1Cg0xZqaSUjyyQ85OSm0S+Z3rVTlsi QWoNQDgHZYbn0ih98BIV1oiE19r6ACKXTKiICyAU= 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.4 090/177] ASoC: fsl_audmix: Add spin lock to protect tdms Date: Mon, 16 Dec 2019 18:49:06 +0100 Message-Id: <20191216174839.092227511@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191216174811.158424118@linuxfoundation.org> References: <20191216174811.158424118@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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; @@ -491,6 +496,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; };