linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sylwester Nawrocki <s.nawrocki@samsung.com>
To: broonie@kernel.org
Cc: lgirdwood@gmail.com, krzk@kernel.org, sbkim73@samsung.com,
	m.szyprowski@samsung.com, b.zolnierkie@samsung.com,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	linux-samsung-soc@vger.kernel.org,
	Sylwester Nawrocki <s.nawrocki@samsung.com>
Subject: [PATCH v3 05/13] ASoC: samsung: i2s: Get rid of a static spinlock
Date: Wed, 13 Feb 2019 19:42:04 +0100	[thread overview]
Message-ID: <20190213184212.5473-6-s.nawrocki@samsung.com> (raw)
In-Reply-To: <20190213184212.5473-1-s.nawrocki@samsung.com>

This patch makes the spinlock serializing access to the primary/secondary
PCM a per I2S controller lock, rather than a global one. There is no need
to have a global lock across multiple I2S controllers in the SoC.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 sound/soc/samsung/i2s.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c
index 8f0af4b0f25a..692a752b194c 100644
--- a/sound/soc/samsung/i2s.c
+++ b/sound/soc/samsung/i2s.c
@@ -88,9 +88,6 @@ struct i2s_dai {
 	struct samsung_i2s_priv *priv;
 };
 
-/* Lock for cross i/f checks */
-static DEFINE_SPINLOCK(lock);
-
 struct samsung_i2s_priv {
 	struct platform_device *pdev;
 	struct platform_device *pdev_sec;
@@ -101,6 +98,9 @@ struct samsung_i2s_priv {
 	/* Spinlock protecting access to the device's registers */
 	spinlock_t lock;
 
+	/* Lock for cross i/f checks */
+	spinlock_t pcm_lock;
+
 	/* CPU DAIs and their corresponding drivers */
 	struct i2s_dai *dai;
 	struct snd_soc_dai_driver *dai_drv;
@@ -832,7 +832,7 @@ static int i2s_startup(struct snd_pcm_substream *substream,
 
 	pm_runtime_get_sync(dai->dev);
 
-	spin_lock_irqsave(&lock, flags);
+	spin_lock_irqsave(&priv->pcm_lock, flags);
 
 	i2s->mode |= DAI_OPENED;
 
@@ -844,7 +844,7 @@ static int i2s_startup(struct snd_pcm_substream *substream,
 	if (!any_active(i2s) && (priv->quirks & QUIRK_NEED_RSTCLR))
 		writel(CON_RSTCLR, i2s->priv->addr + I2SCON);
 
-	spin_unlock_irqrestore(&lock, flags);
+	spin_unlock_irqrestore(&priv->pcm_lock, flags);
 
 	return 0;
 }
@@ -852,11 +852,12 @@ static int i2s_startup(struct snd_pcm_substream *substream,
 static void i2s_shutdown(struct snd_pcm_substream *substream,
 	struct snd_soc_dai *dai)
 {
+	struct samsung_i2s_priv *priv = snd_soc_dai_get_drvdata(dai);
 	struct i2s_dai *i2s = to_info(dai);
 	struct i2s_dai *other = get_other_dai(i2s);
 	unsigned long flags;
 
-	spin_lock_irqsave(&lock, flags);
+	spin_lock_irqsave(&priv->pcm_lock, flags);
 
 	i2s->mode &= ~DAI_OPENED;
 	i2s->mode &= ~DAI_MANAGER;
@@ -868,7 +869,7 @@ static void i2s_shutdown(struct snd_pcm_substream *substream,
 	i2s->rfs = 0;
 	i2s->bfs = 0;
 
-	spin_unlock_irqrestore(&lock, flags);
+	spin_unlock_irqrestore(&priv->pcm_lock, flags);
 
 	pm_runtime_put(dai->dev);
 }
@@ -1406,6 +1407,7 @@ static int samsung_i2s_probe(struct platform_device *pdev)
 	pri_dai = &priv->dai[SAMSUNG_I2S_ID_PRIMARY - 1];
 
 	spin_lock_init(&priv->lock);
+	spin_lock_init(&priv->pcm_lock);
 
 	if (!np) {
 		if (i2s_pdata == NULL) {
-- 
2.17.1


  parent reply	other threads:[~2019-02-13 18:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20190213184252epcas1p131e1023b7f6ec280e880b160a4a96345@epcas1p1.samsung.com>
2019-02-13 18:41 ` [PATCH v3 00/13] ASoC: dmaengine updates, secondary CPU DAI for Odroid boards Sylwester Nawrocki
     [not found]   ` <CGME20190213184256epcas2p34078238855e1f9c1730f42e70094b114@epcas2p3.samsung.com>
2019-02-13 18:42     ` [PATCH v3 01/13] ASoC: samsung: i2s: Move SFR pointer to common driver data structure Sylwester Nawrocki
     [not found]   ` <CGME20190213184259epcas1p16fa2f1a7f049d88ad627c823a117fc36@epcas1p1.samsung.com>
2019-02-13 18:42     ` [PATCH v3 02/13] ASoC: samsung: i2s: Drop spinlock pointer from i2s_dai " Sylwester Nawrocki
     [not found]   ` <CGME20190213184303epcas2p2d72076c025cac4b25bd7b4e77a71595c@epcas2p2.samsung.com>
2019-02-13 18:42     ` [PATCH v3 03/13] ASoC: samsung: i2s: Move IP variant data to common driver " Sylwester Nawrocki
     [not found]   ` <CGME20190213184306epcas1p4ff854f370c8ea8371430e26c3bfeac19@epcas1p4.samsung.com>
2019-02-13 18:42     ` [PATCH v3 04/13] ASoC: samsung: i2s: Move quirks " Sylwester Nawrocki
     [not found]   ` <CGME20190213184310epcas2p239500afce801a9828da360fef41bb886@epcas2p2.samsung.com>
2019-02-13 18:42     ` Sylwester Nawrocki [this message]
     [not found]   ` <CGME20190213184313epcas1p4d40c267289cd3ff64879a224b91da6d0@epcas1p4.samsung.com>
2019-02-13 18:42     ` [PATCH v3 06/13] ASoC: samsung: odroid: Add support for secondary CPU DAI Sylwester Nawrocki
     [not found]   ` <CGME20190213184317epcas2p17fc18ee2ac4b92a7d1690c56e36739d6@epcas2p1.samsung.com>
2019-02-13 18:42     ` [PATCH v3 07/13] ASoC: samsung: Specify DMA channel names through custom DMA config Sylwester Nawrocki
     [not found]   ` <CGME20190213184320epcas2p2d54cbd017c6c666239a4d6f8d78cf620@epcas2p2.samsung.com>
2019-02-13 18:42     ` [PATCH v3 08/13] ASoC: samsung: Drop DAI DMA data chan_name assignments Sylwester Nawrocki
     [not found]   ` <CGME20190213184324epcas1p4d5d9d8896938f7a5230372381627340e@epcas1p4.samsung.com>
2019-02-13 18:42     ` [PATCH v3 09/13] ASoC: dmaengine: Remove unused SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME flag Sylwester Nawrocki
     [not found]   ` <CGME20190213184328epcas2p3c89ed5fa3e58baf4b5af9b56418fb0d9@epcas2p3.samsung.com>
2019-02-13 18:42     ` [PATCH v3 10/13] ASoC: samsung: i2s: Simplify pri_dai, sec_dai pointers usage Sylwester Nawrocki
     [not found]   ` <CGME20190213184331epcas1p1651b43c8fe68d537a4f39ddfa91a38b1@epcas1p1.samsung.com>
2019-02-13 18:42     ` [PATCH v3 11/13] ASoC: samsung: i2s: Change indentation in SAMSUNG_I2S_FMTS definition Sylwester Nawrocki
     [not found]   ` <CGME20190213184335epcas1p4e8d7ef4cfb788dc882fa3678ad66bec4@epcas1p4.samsung.com>
2019-02-13 18:42     ` [PATCH v3 12/13] ASoC: samsung: i2s: Comments clean up Sylwester Nawrocki
     [not found]   ` <CGME20190213184338epcas2p4a0384a9160084df777c92dd5bf55f04a@epcas2p4.samsung.com>
2019-02-13 18:42     ` [PATCH v3 13/13] ASoC: samsung: i2s: Convert to SPDX License Indentifier Sylwester Nawrocki
2019-02-14  9:34   ` [PATCH v3 00/13] ASoC: dmaengine updates, secondary CPU DAI for Odroid boards Sylwester Nawrocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190213184212.5473-6-s.nawrocki@samsung.com \
    --to=s.nawrocki@samsung.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=b.zolnierkie@samsung.com \
    --cc=broonie@kernel.org \
    --cc=krzk@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=sbkim73@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).