From patchwork Thu Dec 11 17:45:47 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: 5477011 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 603DEBEEA8 for ; Thu, 11 Dec 2014 17:52:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7F3B6201BB for ; Thu, 11 Dec 2014 17:52:58 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 4598420160 for ; Thu, 11 Dec 2014 17:52:57 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 6847F265840; Thu, 11 Dec 2014 18:52:56 +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 30F412656EE; Thu, 11 Dec 2014 18:48:52 +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 E43272656EE; Thu, 11 Dec 2014 18:48:50 +0100 (CET) Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by alsa0.perex.cz (Postfix) with ESMTP id 4B89E26530B for ; Thu, 11 Dec 2014 18:46:51 +0100 (CET) Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NGF00K6QIQ2WC50@mailout3.samsung.com> for alsa-devel@alsa-project.org; Fri, 12 Dec 2014 02:46:50 +0900 (KST) X-AuditID: cbfee61b-f79d76d0000024d6-0e-5489d88a70ab Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id EA.4C.09430.A88D9845; Fri, 12 Dec 2014 02:46:50 +0900 (KST) Received: from amdc1344.digital.local ([106.116.147.32]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NGF00MHSIP1T280@mmp1.samsung.com>; Fri, 12 Dec 2014 02:46:50 +0900 (KST) From: Sylwester Nawrocki To: alsa-devel@alsa-project.org, linux-samsung-soc@vger.kernel.org Date: Thu, 11 Dec 2014 18:45:47 +0100 Message-id: <1418319952-10163-10-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1418319952-10163-1-git-send-email-s.nawrocki@samsung.com> References: <1418319952-10163-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMLMWRmVeSWpSXmKPExsVy+t9jAd2uG50hBrtPcltcuXiIyWLqwyds Fo/mP2a2mHF+H5PF75vf2SwOv2lntbi44guTA7vHhs9NbB6Lvmd5bFrVyebRt2UVo8fnTXIB rFFcNimpOZllqUX6dglcGdve7mUv2CVSMW/efZYGxocCXYycHBICJhJvr85jh7DFJC7cW8/W xcjFISSwiFFiyoe7LBBOB5PEpVcXwarYBAwleo/2MYLYIgJOEjPnvAfrYBZoZpQ4/+sGE0hC WCBa4vWCzWwgNouAqsSf281gzbwC7hLnFi0BauYAWqcgMWeSDUiYEyi8/tc5FhBbSMBN4tHG BtYJjLwLGBlWMYqmFiQXFCel5xrpFSfmFpfmpesl5+duYgQH1TPpHYyrGiwOMQpwMCrx8GbE d4YIsSaWFVfmHmKU4GBWEuHdcxkoxJuSWFmVWpQfX1Sak1p8iFGag0VJnFfJvi1ESCA9sSQ1 OzW1ILUIJsvEwSnVwFiraiLp+jv65O70FrUrVtphjh766f2Pa2erx05r4DpyqoGnxUw0Qv3c 8WnT5qw54p37+Vig89dfpw5vSYptl8vv03pwheM78+kUs/Qff60fsQnYPWd6r/tGaRdftUGG n3D+x9tTC/muyRx22XbhlsaL67LPt/2byVQ4fWd8/D7B0gV3M9/c91RiKc5INNRiLipOBADH J+PZJgIAAA== Cc: sbkim73@samsung.com, broonie@kernel.org, drake@endlessm.com, Sylwester Nawrocki , padma.v@samsung.com Subject: [alsa-devel] [PATCH/RFC 09/14] 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 doesn'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 some of the 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 a131621..e8e0107 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";