All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: rsnd: don't call clk_disable_unprepare() if can't use
@ 2020-12-17  2:28 Kuninori Morimoto
  2020-12-17  8:04 ` Geert Uytterhoeven
  2020-12-18 12:16 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Kuninori Morimoto @ 2020-12-17  2:28 UTC (permalink / raw)
  To: Mark Brown, Geert Uytterhoeven; +Cc: Linux-ALSA

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

We need to care clock accessibility,
because we might can't use clock for some reasons.

It sets clk_rate for each clocks when enabled.
This means it doesn't have clk_rate if we can't use.
We can avoid to call clk_disable_unprepare() in such case.

Link: https://lore.kernel.org/r/CAMuHMdWvB+p=2JqTsO7bR8uJqKqO5A2XgXFXsVAjHk3hcxgcTw@mail.gmail.com
Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v1 -> v2

	- reset adg->clk_rate[i] = 0

 sound/soc/sh/rcar/adg.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c
index b9aacf3d3b29..abdfd9cf91e2 100644
--- a/sound/soc/sh/rcar/adg.c
+++ b/sound/soc/sh/rcar/adg.c
@@ -366,25 +366,27 @@ void rsnd_adg_clk_control(struct rsnd_priv *priv, int enable)
 	struct rsnd_adg *adg = rsnd_priv_to_adg(priv);
 	struct device *dev = rsnd_priv_to_dev(priv);
 	struct clk *clk;
-	int i, ret;
+	int i;
 
 	for_each_rsnd_clk(clk, adg, i) {
-		ret = 0;
 		if (enable) {
-			ret = clk_prepare_enable(clk);
+			int ret = clk_prepare_enable(clk);
 
 			/*
 			 * We shouldn't use clk_get_rate() under
 			 * atomic context. Let's keep it when
 			 * rsnd_adg_clk_enable() was called
 			 */
-			adg->clk_rate[i] = clk_get_rate(adg->clk[i]);
+			adg->clk_rate[i] = 0;
+			if (ret < 0)
+				dev_warn(dev, "can't use clk %d\n", i);
+			else
+				adg->clk_rate[i] = clk_get_rate(clk);
 		} else {
-			clk_disable_unprepare(clk);
+			if (adg->clk_rate[i])
+				clk_disable_unprepare(clk);
+			adg->clk_rate[i] = 0;
 		}
-
-		if (ret < 0)
-			dev_warn(dev, "can't use clk %d\n", i);
 	}
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] ASoC: rsnd: don't call clk_disable_unprepare() if can't use
  2020-12-17  2:28 [PATCH v2] ASoC: rsnd: don't call clk_disable_unprepare() if can't use Kuninori Morimoto
@ 2020-12-17  8:04 ` Geert Uytterhoeven
  2020-12-18 12:16 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2020-12-17  8:04 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Mark Brown

On Thu, Dec 17, 2020 at 3:28 AM Kuninori Morimoto
<kuninori.morimoto.gx@renesas.com> wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>
> We need to care clock accessibility,
> because we might can't use clock for some reasons.
>
> It sets clk_rate for each clocks when enabled.
> This means it doesn't have clk_rate if we can't use.
> We can avoid to call clk_disable_unprepare() in such case.
>
> Link: https://lore.kernel.org/r/CAMuHMdWvB+p=2JqTsO7bR8uJqKqO5A2XgXFXsVAjHk3hcxgcTw@mail.gmail.com
> Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] ASoC: rsnd: don't call clk_disable_unprepare() if can't use
  2020-12-17  2:28 [PATCH v2] ASoC: rsnd: don't call clk_disable_unprepare() if can't use Kuninori Morimoto
  2020-12-17  8:04 ` Geert Uytterhoeven
@ 2020-12-18 12:16 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2020-12-18 12:16 UTC (permalink / raw)
  To: Geert Uytterhoeven, Kuninori Morimoto; +Cc: Linux-ALSA

On 17 Dec 2020 11:28:49 +0900, Kuninori Morimoto wrote:
> We need to care clock accessibility,
> because we might can't use clock for some reasons.
> 
> It sets clk_rate for each clocks when enabled.
> This means it doesn't have clk_rate if we can't use.
> We can avoid to call clk_disable_unprepare() in such case.

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: rsnd: don't call clk_disable_unprepare() if can't use
      commit: 61c7dbec33777ade95d3db58beec8d7f177868c8

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-18 12:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-17  2:28 [PATCH v2] ASoC: rsnd: don't call clk_disable_unprepare() if can't use Kuninori Morimoto
2020-12-17  8:04 ` Geert Uytterhoeven
2020-12-18 12:16 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.