linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] clk: expand clk_ignore_unused mechanism to keep only a few clks on
@ 2021-08-19 12:14 Uwe Kleine-König
  2021-09-22  8:15 ` Uwe Kleine-König
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2021-08-19 12:14 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: Jonathan Corbet, linux-doc, linux-kernel, linux-clk, kernel

Allow to pass an integer n that results in only keeping n unused clocks
enabled.

This helps to debug the problem if you only know that clk_ignore_unused
helps but you have no clue yet which clock is the culprit.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Hello,

Interdiff against (implicit) v1:

  diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
  index 7189a56bb29f..afa9f9397ddb 100644
  --- a/drivers/clk/clk.c
  +++ b/drivers/clk/clk.c
  @@ -1312,8 +1312,8 @@ static int __init clk_disable_unused(void)
   	if (clk_ignore_unused) {
   		pr_warn("clk: Not disabling unused clocks\n");
   		return 0;
  -	} else if (clk_ignore_unused) {
  -		pr_warn("clk: Not disabling %u unused clocks\n", clk_ignore_unused);
  +	} else if (clk_unused_keep_on) {
  +		pr_warn("clk: Not disabling %u unused clocks\n", clk_unused_keep_on);
   	}
   
   	clk_prepare_lock();

which fixes the debug output. Found by the kernel test robot; Thanks!

Best regards
Uwe

 Documentation/driver-api/clk.rst |  4 +++-
 drivers/clk/clk.c                | 33 ++++++++++++++++++++++++--------
 2 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/Documentation/driver-api/clk.rst b/Documentation/driver-api/clk.rst
index 3cad45d14187..65ae7c3e2b33 100644
--- a/Documentation/driver-api/clk.rst
+++ b/Documentation/driver-api/clk.rst
@@ -259,7 +259,9 @@ the disabling means that the driver will remain functional while the issues
 are sorted out.
 
 To bypass this disabling, include "clk_ignore_unused" in the bootargs to the
-kernel.
+kernel. If you pass "clk_ignore_unused=n" (where n is an integer) the first n
+found clocks are not disabled which can be useful for bisecting over the unused
+clks if you don't know yet which of them is reponsible for your problem.
 
 Locking
 =======
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 65508eb89ec9..afa9f9397ddb 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1236,6 +1236,8 @@ static void __init clk_unprepare_unused_subtree(struct clk_core *core)
 	clk_pm_runtime_put(core);
 }
 
+static unsigned clk_unused_keep_on __initdata;
+
 static void __init clk_disable_unused_subtree(struct clk_core *core)
 {
 	struct clk_core *child;
@@ -1266,12 +1268,17 @@ static void __init clk_disable_unused_subtree(struct clk_core *core)
 	 * back to .disable
 	 */
 	if (clk_core_is_enabled(core)) {
-		trace_clk_disable(core);
-		if (core->ops->disable_unused)
-			core->ops->disable_unused(core->hw);
-		else if (core->ops->disable)
-			core->ops->disable(core->hw);
-		trace_clk_disable_complete(core);
+		if (clk_unused_keep_on) {
+			pr_warn("Keep unused clk \"%s\" on\n", core->name);
+			clk_unused_keep_on -= 1;
+		} else {
+			trace_clk_disable(core);
+			if (core->ops->disable_unused)
+				core->ops->disable_unused(core->hw);
+			else if (core->ops->disable)
+				core->ops->disable(core->hw);
+			trace_clk_disable_complete(core);
+		}
 	}
 
 unlock_out:
@@ -1283,9 +1290,17 @@ static void __init clk_disable_unused_subtree(struct clk_core *core)
 }
 
 static bool clk_ignore_unused __initdata;
-static int __init clk_ignore_unused_setup(char *__unused)
+static int __init clk_ignore_unused_setup(char *keep)
 {
-	clk_ignore_unused = true;
+	if (*keep == '=') {
+		int ret;
+
+		ret = kstrtouint(keep + 1, 0, &clk_unused_keep_on);
+		if (ret < 0)
+			pr_err("Warning: failed to parse clk_ignore_unused parameter, ignoring");
+	} else {
+		clk_ignore_unused = true;
+	}
 	return 1;
 }
 __setup("clk_ignore_unused", clk_ignore_unused_setup);
@@ -1297,6 +1312,8 @@ static int __init clk_disable_unused(void)
 	if (clk_ignore_unused) {
 		pr_warn("clk: Not disabling unused clocks\n");
 		return 0;
+	} else if (clk_unused_keep_on) {
+		pr_warn("clk: Not disabling %u unused clocks\n", clk_unused_keep_on);
 	}
 
 	clk_prepare_lock();
-- 
2.30.2


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

* Re: [PATCH v2] clk: expand clk_ignore_unused mechanism to keep only a few clks on
  2021-08-19 12:14 [PATCH v2] clk: expand clk_ignore_unused mechanism to keep only a few clks on Uwe Kleine-König
@ 2021-09-22  8:15 ` Uwe Kleine-König
  2021-10-14 15:43   ` Uwe Kleine-König
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2021-09-22  8:15 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: linux-doc, linux-clk, linux-kernel, kernel, Jonathan Corbet

[-- Attachment #1: Type: text/plain, Size: 895 bytes --]

Hello,

On Thu, Aug 19, 2021 at 02:14:03PM +0200, Uwe Kleine-König wrote:
> Allow to pass an integer n that results in only keeping n unused clocks
> enabled.
> 
> This helps to debug the problem if you only know that clk_ignore_unused
> helps but you have no clue yet which clock is the culprit.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

I consider this patch really helpful, it helped me to debug a clk issue
without having to recompile the kernel for each bisection step.

On #kernelnewbies I got some positive feedback for it (1629304050 < j_ey>
ukleinek: nice clk_ignore_unused patch, I added a pr_err there recently
to print the clocks that were being disabled).

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH v2] clk: expand clk_ignore_unused mechanism to keep only a few clks on
  2021-09-22  8:15 ` Uwe Kleine-König
@ 2021-10-14 15:43   ` Uwe Kleine-König
  2022-05-25  8:17     ` Uwe Kleine-König
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2021-10-14 15:43 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: linux-kernel, Jonathan Corbet, linux-clk, kernel, linux-doc

[-- Attachment #1: Type: text/plain, Size: 1093 bytes --]

Hello,

On Wed, Sep 22, 2021 at 10:15:49AM +0200, Uwe Kleine-König wrote:
> On Thu, Aug 19, 2021 at 02:14:03PM +0200, Uwe Kleine-König wrote:
> > Allow to pass an integer n that results in only keeping n unused clocks
> > enabled.
> > 
> > This helps to debug the problem if you only know that clk_ignore_unused
> > helps but you have no clue yet which clock is the culprit.
> > 
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> 
> I consider this patch really helpful, it helped me to debug a clk issue
> without having to recompile the kernel for each bisection step.
> 
> On #kernelnewbies I got some positive feedback for it (1629304050 < j_ey>
> ukleinek: nice clk_ignore_unused patch, I added a pr_err there recently
> to print the clocks that were being disabled).

Any thoughts on this patch? Would be great if it makes it into the next
merge window.

Thanks for considering,
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH v2] clk: expand clk_ignore_unused mechanism to keep only a few clks on
  2021-10-14 15:43   ` Uwe Kleine-König
@ 2022-05-25  8:17     ` Uwe Kleine-König
  0 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2022-05-25  8:17 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: linux-doc, linux-clk, linux-kernel, kernel, Jonathan Corbet

[-- Attachment #1: Type: text/plain, Size: 1320 bytes --]

On Thu, Oct 14, 2021 at 05:43:07PM +0200, Uwe Kleine-König wrote:
> Hello,
> 
> On Wed, Sep 22, 2021 at 10:15:49AM +0200, Uwe Kleine-König wrote:
> > On Thu, Aug 19, 2021 at 02:14:03PM +0200, Uwe Kleine-König wrote:
> > > Allow to pass an integer n that results in only keeping n unused clocks
> > > enabled.
> > > 
> > > This helps to debug the problem if you only know that clk_ignore_unused
> > > helps but you have no clue yet which clock is the culprit.
> > > 
> > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > 
> > I consider this patch really helpful, it helped me to debug a clk issue
> > without having to recompile the kernel for each bisection step.
> > 
> > On #kernelnewbies I got some positive feedback for it (1629304050 < j_ey>
> > ukleinek: nice clk_ignore_unused patch, I added a pr_err there recently
> > to print the clocks that were being disabled).
> 
> Any thoughts on this patch? Would be great if it makes it into the next
> merge window.

Back then I thought this patch could make it into 5.16, now 5.18 is
released and i didn't get any feedback on this patch :-\

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2022-05-25  8:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-19 12:14 [PATCH v2] clk: expand clk_ignore_unused mechanism to keep only a few clks on Uwe Kleine-König
2021-09-22  8:15 ` Uwe Kleine-König
2021-10-14 15:43   ` Uwe Kleine-König
2022-05-25  8:17     ` Uwe Kleine-König

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).