The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: phucduc.bui@gmail.com
To: Mark Brown <broonie@kernel.org>,
	Florian Fainelli <florian.fainelli@broadcom.com>,
	bcm-kernel-feedback-list@broadcom.com
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	Ray Jui <rjui@broadcom.com>,
	Scott Branden <sbranden@broadcom.com>,
	linux-sound@vger.kernel.org, Kees Cook <kees+treewide@kernel.org>,
	linux-rpi-kernel@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
	bui duc phuc <phucduc.bui@gmail.com>
Subject: [PATCH 1/2] ASoC: bcm2835-i2s: Remove redundant clock start/stop in trigger path
Date: Thu,  3 Dec 2026 13:34:33 +0700	[thread overview]
Message-ID: <20261203063435.13517-2-phucduc.bui@gmail.com> (raw)
In-Reply-To: <20261203063435.13517-1-phucduc.bui@gmail.com>

From: bui duc phuc <phucduc.bui@gmail.com>

bcm2835_i2s_stop() is called from .trigger and .shutdown, and stops
the clock when the DAI is no longer active and SND_SOC_DAIFMT_CONT is
not set. In .trigger the DAI is always active, so the clock is never
stopped there. In .shutdown, bcm2835_i2s_shutdown() stops the clock
itself right after calling bcm2835_i2s_stop() once no stream is left.
The check in bcm2835_i2s_stop() is therefore not needed and can be
removed.

Likewise, the bcm2835_i2s_start_clock() call in .trigger has no
effect, as the clock has already been started in .hw_params and is
not stopped before the stream is started.

Remove both, which also keeps clk_prepare_enable() and
clk_disable_unprepare(), which may sleep, out of the atomic .trigger
callback. Drop the now unused dai argument of bcm2835_i2s_stop() and
the outdated comment in bcm2835_i2s_shutdown().

No functional change intended.

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
 sound/soc/bcm/bcm2835-i2s.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/sound/soc/bcm/bcm2835-i2s.c b/sound/soc/bcm/bcm2835-i2s.c
index 8702f1d062df..68be1ded6f93 100644
--- a/sound/soc/bcm/bcm2835-i2s.c
+++ b/sound/soc/bcm/bcm2835-i2s.c
@@ -639,8 +639,7 @@ static int bcm2835_i2s_prepare(struct snd_pcm_substream *substream,
 }
 
 static void bcm2835_i2s_stop(struct bcm2835_i2s_dev *dev,
-		struct snd_pcm_substream *substream,
-		struct snd_soc_dai *dai)
+			     struct snd_pcm_substream *substream)
 {
 	uint32_t mask;
 
@@ -651,10 +650,6 @@ static void bcm2835_i2s_stop(struct bcm2835_i2s_dev *dev,
 
 	regmap_update_bits(dev->i2s_regmap,
 			BCM2835_I2S_CS_A_REG, mask, 0);
-
-	/* Stop also the clock when not SND_SOC_DAIFMT_CONT */
-	if (!snd_soc_dai_active(dai) && !(dev->fmt & SND_SOC_DAIFMT_CONT))
-		bcm2835_i2s_stop_clock(dev);
 }
 
 static int bcm2835_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
@@ -667,7 +662,6 @@ static int bcm2835_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
 	case SNDRV_PCM_TRIGGER_START:
 	case SNDRV_PCM_TRIGGER_RESUME:
 	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-		bcm2835_i2s_start_clock(dev);
 
 		if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
 			mask = BCM2835_I2S_RXON;
@@ -681,7 +675,7 @@ static int bcm2835_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
 	case SNDRV_PCM_TRIGGER_STOP:
 	case SNDRV_PCM_TRIGGER_SUSPEND:
 	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-		bcm2835_i2s_stop(dev, substream, dai);
+		bcm2835_i2s_stop(dev, substream);
 		break;
 	default:
 		return -EINVAL;
@@ -720,7 +714,7 @@ static void bcm2835_i2s_shutdown(struct snd_pcm_substream *substream,
 {
 	struct bcm2835_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
 
-	bcm2835_i2s_stop(dev, substream, dai);
+	bcm2835_i2s_stop(dev, substream);
 
 	/* If both streams are stopped, disable module and clock */
 	if (snd_soc_dai_active(dai))
@@ -730,10 +724,6 @@ static void bcm2835_i2s_shutdown(struct snd_pcm_substream *substream,
 	regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_CS_A_REG,
 			BCM2835_I2S_EN, 0);
 
-	/*
-	 * Stopping clock is necessary, because stop does
-	 * not stop the clock when SND_SOC_DAIFMT_CONT
-	 */
 	bcm2835_i2s_stop_clock(dev);
 }
 
-- 
2.43.0


  reply	other threads:[~2026-12-03  6:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  6:34 [PATCH 0/2] ASoC: bcm2835-i2s: Fix clock handling phucduc.bui
2026-12-03  6:34 ` phucduc.bui [this message]
2026-12-03  6:34 ` [PATCH 2/2] ASoC: bcm2835-i2s: Check clock enable return value phucduc.bui

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=20261203063435.13517-2-phucduc.bui@gmail.com \
    --to=phucduc.bui@gmail.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=broonie@kernel.org \
    --cc=florian.fainelli@broadcom.com \
    --cc=kees+treewide@kernel.org \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=rjui@broadcom.com \
    --cc=sbranden@broadcom.com \
    --cc=tiwai@suse.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