[PATCH] clk: add new Kconfig to control default behavior of disabling unused clocks

Brian Masney
2026-03-16T22:34:12Z

At the 2023 Linux Plumbers Conference in Richmond VA, there was a
discussion about how large number of systems need to boot with
clk_ignore_unused. Per the discussions at the conference, the existing
behavior in the clk core is broken, and there is a desire to completely
remove this functionality.

This series introduces a new Kconfig called
CONFIG_COMMON_CLK_DISABLE_UNUSED that when set has the existing
behavior as clk_ignore_unused so that people no longer have to specify
this parameter on the kernel command line. This Kconfig is disabled by
default to keep compatibility with existing systems. A kernel that was
compiled with this Kconfig enabled can have the clk subsystem disable
the unused clocks by passing clk_ignore_unused=0 on the kernel command
line.

Note: The existing clk code calls __setup("clk_ignore_unused", ...)
without the equals in the name. So someone can actually pass a kernel
parameter today clk_ignore_unused_foo that'll also match the existing
parameter. We can't change the existing behavior, so we need to look
for the equals sign in the value.

Link: https://lpc.events/event/17/contributions/1432/
Link: https://www.youtube.com/watch?v=tXYzM8yLIQA
Signed-off-by: Brian Masney <bmasney@redhat.com>
---
I searched the mailinglist archive, and couldn't find where anyone
submitted something like this after LPC 2023. This was the last
suggestion discussed on the LPC talk, and it sounds like around 14:40
that this is an acceptable change.

I looked at adding some Kunit tests for this to clk_test.c. I planned to
export clk_ignore_unused_setup() for Kunit testing, however that will
require putting "=0" instead of just "0" in the tests. This won't match
the behavior on the kernel command line. See comment in the code about
the equals.
---
Documentation/admin-guide/kernel-parameters.txt | 9 +++++++++
Documentation/driver-api/clk.rst | 7 +++++++
drivers/clk/Kconfig | 16 ++++++++++++++++
drivers/clk/clk.c | 17 ++++++++++++++---
4 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index fa6171b5fdd5ff55b3203272568509bb45c69856..d559c387ca32425c0a3776bec899f48a21ed3026 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -830,6 +830,15 @@ Kernel parameters
platform with proper driver support. For more
information, see Documentation/driver-api/clk.rst.

+ clk_ignore_unused=0
+ [CLK]
+ Force the clock framework to automatically gate unused
+ clocks at late init, even if CONFIG_COMMON_CLK_DISABLE_UNUSED
+ is enabled. This overrides the compile-time configuration
+ to re-enable power saving by disabling unused clocks.
+
+ For more information, see Documentation/driver-api/clk.rst.
+
clock= [BUGS=X86-32, HW] gettimeofday clocksource override.
[Deprecated]
Forces specified clocksource (if available) to be used
diff --git a/Documentation/driver-api/clk.rst b/Documentation/driver-api/clk.rst
index 93bab5336dfda06069eea700d2830089bf3bce03..31ce4e3889f09a4f9c3b63cad7ded214125702f7 100644
--- a/Documentation/driver-api/clk.rst
+++ b/Documentation/driver-api/clk.rst
@@ -266,6 +266,13 @@ parameters::
To bypass this disabling, include "clk_ignore_unused" in the bootargs to the
kernel.

+Alternatively, you can enable CONFIG_COMMON_CLK_DISABLE_UNUSED at compile time
+to prevent the automatic disabling of unused clocks by default. When this
+option is enabled, unused clocks will remain enabled unless you explicitly
+force their disabling by passing "clk_ignore_unused=0" on the kernel command
+line. This can be useful for platforms that require certain clocks to remain
+enabled for proper operation, or for debugging purposes.
+
Locking
=======

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 8cc300b90b5fd9fb38ce94fcb1098810c3f52c36..d7503517f6ec1ed773b2dcb9e3a7a0b5bcdea353 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -33,6 +33,22 @@ menuconfig COMMON_CLK

if COMMON_CLK

+config COMMON_CLK_DISABLE_UNUSED
+ bool "Do not automatically disable unused clocks"
+ help
+ Say Y here if you want to prevent the clock framework from
+ automatically disabling unused clocks at late initialization time.
+ This keeps clocks running even if no driver is using them, which
+ may be necessary for certain hardware configurations or debugging.
+
+ By default (N), the kernel will automatically disable unused clocks
+ to save power.
+
+ This behavior can be overridden at boot time on the kernel command
+ line with the parameter clk_ignore_unused.
+
+ If unsure, say N.
+
config COMMON_CLK_WM831X
tristate "Clock driver for WM831x/2x PMICs"
depends on MFD_WM831X
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 47093cda9df32223c1120c3710261296027c4cd3..4afbf011de6f1727a2bf330465c95407e51d04ad 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1508,10 +1508,21 @@ static void __init clk_disable_unused_subtree(struct clk_core *core)
clk_core_disable_unprepare(core->parent);
}

-static bool clk_ignore_unused __initdata;
-static int __init clk_ignore_unused_setup(char *__unused)
+static bool clk_ignore_unused __initdata = IS_ENABLED(CONFIG_COMMON_CLK_DISABLE_UNUSED);
+static int __init clk_ignore_unused_setup(char *str)
{
- clk_ignore_unused = true;
+ if (!str) {
+ clk_ignore_unused = true;
+ } else {
+ /*
+ * Typically the equals is added to the __setup below, however we
+ * need to be able to support clk_ignore_unused without an equals
+ * since tons of systems just pass clk_ignore_unused. So look for
+ * the equals here.
+ */
+ clk_ignore_unused = strcmp(str, "=0") != 0;
+ }
+
return 1;
}
__setup("clk_ignore_unused", clk_ignore_unused_setup);

---
base-commit: 95c541ddfb0815a0ea8477af778bb13bb075079a
change-id: 20260316-clk-ignore-unused-kconfig-7e77eb5b8306

Best regards,
--
Brian Masney <bmasney@redhat.com>