Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3512406ybg; Mon, 28 Oct 2019 14:07:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwczcZQKCctVcB9xnbtA6GsMS7gR+hxMkhXRG/JbOyoqBDUKDsBOOvCdToMUy1kTidC4iiN X-Received: by 2002:a17:906:e57:: with SMTP id q23mr18664685eji.303.1572296879496; Mon, 28 Oct 2019 14:07:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572296879; cv=none; d=google.com; s=arc-20160816; b=W+OkkXCah6ZJSbPdcWtUSN3tUiW9gc28so9IMdNBm9HdAK0IjaF7y2nflwucVr7uQF 6PpkwZ7Rfd0ynMM2pY7fify9NrxChN8r6JgOxN1v2SX/cepuFif2C4topdMW/p8ROtjb 73Yr+1JlLciqpFN9vMccE+s9oIMe7lTNp8+kL7g4IdK1w2scVyYyWgxzx7PiXi6QhtzJ v1YrB3HTSZEPGLjU+LFIoZYK+Xlt7pMJOWAEKpN/1FpUlSP0QrG4Hed9YmS4SyY8Fd2m Y4RpXkHJJjvP1Y9QJ+Dnyg0r/ka5nY6L802gHW1BGFQrhTg+Vdtt5nZQOijh7Y3sUSsL /CcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:in-reply-to:subject:cc:to :from:dkim-signature; bh=lLXTCpICWi659xs2yPkSm7HYK750Tj1NUn0NyJCUbx4=; b=hmPgeIwvaGgVxjLBDJbN2G+61a7jHBNHAunC4hsfHz33bmeKm6G5PJ5gAuaZLBVFfd y/A3FuUN/AdwkzIFVMZqKRokBqKUGcO/YhPqDkfW4r2qToH/alm1dRPNKIGgHXc8qFbB PU8FIjGcgSQ4tvPpVpZRyX1MrtW+TVauCdKTadKxjgEoRiQS7Gi6OcnSxbo/uuuefBIF QQ27Ffi4d7Pl1OdSGnKc0XN9RLMu9MOblG+On4KjR8rrKiNpfJmgNuJCTA3FX5xGxPbD Wqu9cfSDIn9XYwKo/wnooakWt43KItCZJ6z6x/5/h4I4GD408QCE9OJI71WKMSYzlNDz hOaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=tUqOqnfn; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dx21si7211987ejb.101.2019.10.28.14.07.35; Mon, 28 Oct 2019 14:07:59 -0700 (PDT) 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=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=tUqOqnfn; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390534AbfJ1O5R (ORCPT + 99 others); Mon, 28 Oct 2019 10:57:17 -0400 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:39876 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390427AbfJ1O4t (ORCPT ); Mon, 28 Oct 2019 10:56:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=lLXTCpICWi659xs2yPkSm7HYK750Tj1NUn0NyJCUbx4=; b=tUqOqnfn92Yu E2xQO9YXBZx1AKlOdAdfx9pMdxD0yByLumn5KM9rhoRntlwnPOv/ay8ZmPSf/TyEG72Kf5cAdb5V1 vU7EW+oNTsO+Nw2Axk2g60e8JzenuLIn6YzGYqrkvgyE8OkeReRxYhSFM3XKYgXne8EPun3A1+aur zod0c=; Received: from cpc102320-sgyl38-2-0-cust46.18-2.cable.virginm.net ([82.37.168.47] helo=ypsilon.sirena.org.uk) by heliosphere.sirena.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iP6Ri-0008RZ-BZ; Mon, 28 Oct 2019 14:56:38 +0000 Received: by ypsilon.sirena.org.uk (Postfix, from userid 1000) id 9EEAF27403F6; Mon, 28 Oct 2019 14:56:36 +0000 (GMT) From: Mark Brown To: Shengjiu Wang Cc: alsa-devel@alsa-project.org, broonie@kernel.org, festevam@gmail.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Mark Brown , nicoleotsuka@gmail.com, Nicolin Chen , perex@perex.cz, timur@kernel.org, tiwai@suse.com, Xiubo.Lee@gmail.com Subject: Applied "ASoC: fsl_esai: Add spin lock to protect reset, stop and start" to the asoc tree In-Reply-To: <52e92c4221a83e39a84a6cd92fc3d5479b44894c.1572252321.git.shengjiu.wang@nxp.com> X-Patchwork-Hint: ignore Message-Id: <20191028145636.9EEAF27403F6@ypsilon.sirena.org.uk> Date: Mon, 28 Oct 2019 14:56:36 +0000 (GMT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch ASoC: fsl_esai: Add spin lock to protect reset, stop and start has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5 All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From 35dac627471938eda89fa39ee4ead1f7667e0f57 Mon Sep 17 00:00:00 2001 From: Shengjiu Wang Date: Mon, 28 Oct 2019 17:11:05 +0800 Subject: [PATCH] ASoC: fsl_esai: Add spin lock to protect reset, stop and start xrun may happen at the end of stream, the trigger->fsl_esai_trigger_stop maybe called in the middle of fsl_esai_hw_reset, this may cause esai in wrong state after stop, and there may be endless xrun interrupt. This issue may also happen with trigger->fsl_esai_trigger_start. So Add spin lock to lock those functions. Fixes: 7ccafa2b3879 ("ASoC: fsl_esai: recover the channel swap after xrun") Signed-off-by: Shengjiu Wang Acked-by: Nicolin Chen Link: https://lore.kernel.org/r/52e92c4221a83e39a84a6cd92fc3d5479b44894c.1572252321.git.shengjiu.wang@nxp.com Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_esai.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index a78e4ab478df..c7a49d03463a 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c @@ -33,6 +33,7 @@ * @fsysclk: system clock source to derive HCK, SCK and FS * @spbaclk: SPBA clock (optional, depending on SoC design) * @task: tasklet to handle the reset operation + * @lock: spin lock between hw_reset() and trigger() * @fifo_depth: depth of tx/rx FIFO * @slot_width: width of each DAI slot * @slots: number of slots @@ -56,6 +57,7 @@ struct fsl_esai { struct clk *fsysclk; struct clk *spbaclk; struct tasklet_struct task; + spinlock_t lock; /* Protect hw_reset and trigger */ u32 fifo_depth; u32 slot_width; u32 slots; @@ -676,8 +678,10 @@ static void fsl_esai_hw_reset(unsigned long arg) { struct fsl_esai *esai_priv = (struct fsl_esai *)arg; bool tx = true, rx = false, enabled[2]; + unsigned long lock_flags; u32 tfcr, rfcr; + spin_lock_irqsave(&esai_priv->lock, lock_flags); /* Save the registers */ regmap_read(esai_priv->regmap, REG_ESAI_TFCR, &tfcr); regmap_read(esai_priv->regmap, REG_ESAI_RFCR, &rfcr); @@ -715,6 +719,8 @@ static void fsl_esai_hw_reset(unsigned long arg) fsl_esai_trigger_start(esai_priv, tx); if (enabled[rx]) fsl_esai_trigger_start(esai_priv, rx); + + spin_unlock_irqrestore(&esai_priv->lock, lock_flags); } static int fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd, @@ -722,6 +728,7 @@ static int fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd, { struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai); bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; + unsigned long lock_flags; esai_priv->channels[tx] = substream->runtime->channels; @@ -729,12 +736,16 @@ static int fsl_esai_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(&esai_priv->lock, lock_flags); fsl_esai_trigger_start(esai_priv, tx); + spin_unlock_irqrestore(&esai_priv->lock, lock_flags); break; case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + spin_lock_irqsave(&esai_priv->lock, lock_flags); fsl_esai_trigger_stop(esai_priv, tx); + spin_unlock_irqrestore(&esai_priv->lock, lock_flags); break; default: return -EINVAL; @@ -1002,6 +1013,7 @@ static int fsl_esai_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, esai_priv); + spin_lock_init(&esai_priv->lock); ret = fsl_esai_hw_init(esai_priv); if (ret) return ret; -- 2.20.1