From patchwork Fri Dec 19 13:55:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 5519851 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F21FB9F30B for ; Fri, 19 Dec 2014 14:04:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0F1612014A for ; Fri, 19 Dec 2014 14:04:50 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id C6CD420145 for ; Fri, 19 Dec 2014 14:04:48 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8C528265051; Fri, 19 Dec 2014 15:04:47 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 6F2A5265171; Fri, 19 Dec 2014 15:01:16 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 84E31265176; Fri, 19 Dec 2014 15:01:14 +0100 (CET) Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by alsa0.perex.cz (Postfix) with ESMTP id C5B49264F23 for ; Fri, 19 Dec 2014 14:58:46 +0100 (CET) Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NGU00A8Z1HXMC80@mailout1.samsung.com> for alsa-devel@alsa-project.org; Fri, 19 Dec 2014 22:58:45 +0900 (KST) X-AuditID: cbfee61b-f79d76d0000024d6-12-54942f150f0b Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 52.D6.09430.51F24945; Fri, 19 Dec 2014 22:58:45 +0900 (KST) Received: from amdc1344.digital.local ([106.116.147.32]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NGU00HVQ1CREV30@mmp2.samsung.com>; Fri, 19 Dec 2014 22:58:45 +0900 (KST) From: Sylwester Nawrocki To: broonie@kernel.org, kgene@kernel.org, alsa-devel@alsa-project.org Date: Fri, 19 Dec 2014 14:55:29 +0100 Message-id: <1418997336-17777-10-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1418997336-17777-1-git-send-email-s.nawrocki@samsung.com> References: <1418997336-17777-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKLMWRmVeSWpSXmKPExsVy+t9jQV1R/SkhBqsPqFpcuXiIyWLqwyds FvOPnGO1eDT/MbNF/+PXzBabHl9jtZhxfh+Txe+b39ksDr9pZ7W4uOILkwOXx4bPTWwei75n eWxa1cnmsXlJvUffllWMHp83yQWwRXHZpKTmZJalFunbJXBl/Fg6h6Vgj0jF5VnHWRsYHwt0 MXJySAiYSHyZ0MMOYYtJXLi3nq2LkYtDSGA6o8S5lXuhnA4miYOP77OAVLEJGEr0Hu1jBLFF BFwlHv+/yQJSxCxwjVHixacpYKOEBaIkHs9tBbNZBFQl1m15yQRi8wq4Szx5tApoKgfQOgWJ OZNsQExOoPCypR4gFUICbhLbT2xnm8DIu4CRYRWjaGpBckFxUnqukV5xYm5xaV66XnJ+7iZG cOA9k97BuKrB4hCjAAejEg9vR+HkECHWxLLiytxDjBIczEoivB+Fp4QI8aYkVlalFuXHF5Xm pBYfYpTmYFES51WybwsREkhPLEnNTk0tSC2CyTJxcEo1MPLkFvycX5Kz0ENstu22dxK2t2Ue 7L4U3JMfvOWaWbBtruHh/ID463ve89642hQylfnmLoXU5Vw5veeeih8/ZBYfNPE0d1GeFdNs HxaZxTM/RYZpV7zbmFEY/vGLj1ptn4GYjYczI+/dw8ISpzs35Mv+Xeyl8SdE8Lvu8bz2fylC UZ0MW+L+K7EUZyQaajEXFScCAGwJE/U4AgAA Cc: devicetree@vger.kernel.org, linux-samsung-soc@vger.kernel.org, padma.v@samsung.com, sbkim73@samsung.com, drake@endlessm.com, Sylwester Nawrocki , linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [PATCH v2 09/16] ASoC: samsung: i2s: Add spinlock in place of local_irq_* calls X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP It seems this driver hasn't been updated for SMP, as local_irq_save/ local_irq_restore don't provide proper protection of read/modify/write of the device's registers on such systems. Introduce a spinlock serializing access to the register region, it will be helpful later when I2SMOD, I2SPSR registers are made also accessible through the clk API. Signed-off-by: Sylwester Nawrocki --- sound/soc/samsung/i2s.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index cd66e58..b5b6b1e 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -94,6 +94,10 @@ struct i2s_dai { u32 suspend_i2scon; u32 suspend_i2spsr; const struct samsung_i2s_variant_regs *variant_regs; + + /* Spinlock protecting access to the device's registers */ + spinlock_t spinlock; + spinlock_t *lock; }; /* Lock for cross i/f checks */ @@ -867,10 +871,10 @@ static int i2s_trigger(struct snd_pcm_substream *substream, case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - local_irq_save(flags); + spin_lock_irqsave(i2s->lock, flags); if (config_setup(i2s)) { - local_irq_restore(flags); + spin_unlock_irqrestore(i2s->lock, flags); return -EINVAL; } @@ -879,12 +883,12 @@ static int i2s_trigger(struct snd_pcm_substream *substream, else i2s_txctrl(i2s, 1); - local_irq_restore(flags); + spin_unlock_irqrestore(i2s->lock, flags); break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - local_irq_save(flags); + spin_lock_irqsave(i2s->lock, flags); if (capture) { i2s_rxctrl(i2s, 0); @@ -894,7 +898,7 @@ static int i2s_trigger(struct snd_pcm_substream *substream, i2s_fifo(i2s, FIC_TXFLUSH); } - local_irq_restore(flags); + spin_unlock_irqrestore(i2s->lock, flags); break; } @@ -1157,6 +1161,9 @@ static int samsung_i2s_probe(struct platform_device *pdev) return -ENOMEM; } + spin_lock_init(&pri_dai->spinlock); + pri_dai->lock = &pri_dai->spinlock; + if (!np) { res = platform_get_resource(pdev, IORESOURCE_DMA, 0); if (!res) { @@ -1234,6 +1241,7 @@ static int samsung_i2s_probe(struct platform_device *pdev) return -ENOMEM; } + sec_dai->lock = &pri_dai->spinlock; sec_dai->variant_regs = pri_dai->variant_regs; sec_dai->dma_playback.dma_addr = regs_base + I2STXDS; sec_dai->dma_playback.ch_name = "tx-sec";