* [RFC PATCH 2/4] clk: Add consumers count to core
2022-07-07 10:03 [RFC PATCH 1/4] clk: Use clk_core_unlink_consumer on __clk_put Abel Vesa
@ 2022-07-07 10:03 ` Abel Vesa
2022-07-07 10:03 ` [RFC PATCH 3/4] clk: Add consumers count information to debugfs Abel Vesa
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Abel Vesa @ 2022-07-07 10:03 UTC (permalink / raw)
To: Mike Turquette, Stephen Boyd
Cc: linux-clk, Linux Kernel Mailing List, linux-arm-msm, Abel Vesa
Keep a count of all consumers per clock. One usage of could be to make
core decisions (like disabling unused clocks) based on the number of
consumers a clock has.
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
---
drivers/clk/clk.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index e1d8245866b1..9b54afd2fee8 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -72,6 +72,7 @@ struct clk_core {
unsigned long flags;
bool orphan;
bool rpm_enabled;
+ unsigned int consumers_count;
unsigned int enable_count;
unsigned int prepare_count;
unsigned int protect_count;
@@ -3682,6 +3683,9 @@ static int __clk_core_init(struct clk_core *core)
core->hw->core = NULL;
}
+ if (!ret)
+ core->consumers_count = 0;
+
clk_prepare_unlock();
if (!ret)
@@ -3699,6 +3703,7 @@ static void clk_core_link_consumer(struct clk_core *core, struct clk *clk)
{
clk_prepare_lock();
hlist_add_head(&clk->clks_node, &core->clks);
+ clk->core->consumers_count++;
clk_prepare_unlock();
}
@@ -3710,6 +3715,7 @@ static void clk_core_unlink_consumer(struct clk *clk)
{
lockdep_assert_held(&prepare_lock);
hlist_del(&clk->clks_node);
+ clk->core->consumers_count--;
}
/**
--
2.34.3
^ permalink raw reply related [flat|nested] 5+ messages in thread* [RFC PATCH 3/4] clk: Add consumers count information to debugfs
2022-07-07 10:03 [RFC PATCH 1/4] clk: Use clk_core_unlink_consumer on __clk_put Abel Vesa
2022-07-07 10:03 ` [RFC PATCH 2/4] clk: Add consumers count to core Abel Vesa
@ 2022-07-07 10:03 ` Abel Vesa
2022-07-07 10:03 ` [RFC PATCH 4/4] clk: Skip disabling clocks if they have consumers Abel Vesa
2022-07-21 8:17 ` [RFC PATCH 1/4] clk: Use clk_core_unlink_consumer on __clk_put Abel Vesa
3 siblings, 0 replies; 5+ messages in thread
From: Abel Vesa @ 2022-07-07 10:03 UTC (permalink / raw)
To: Mike Turquette, Stephen Boyd
Cc: linux-clk, Linux Kernel Mailing List, linux-arm-msm, Abel Vesa
Lets add consumers count information to debugfs. It could be useful for
identifying which clocks do not have a consumer but are enabled at boot
and should be disabled since they are unused. Also you could tell which
clocks are marked as critical since they do not have consumers, but
their enable_count is non-zero.
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
---
drivers/clk/clk.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 9b54afd2fee8..e412e83a6e28 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2955,9 +2955,9 @@ static void clk_summary_show_one(struct seq_file *s, struct clk_core *c,
{
int phase;
- seq_printf(s, "%*s%-*s %7d %8d %8d %11lu %10lu ",
+ seq_printf(s, "%*s%-*s %7d %7d %8d %8d %11lu %10lu ",
level * 3 + 1, "",
- 30 - level * 3, c->name,
+ 30 - level * 3, c->name, c->consumers_count,
c->enable_count, c->prepare_count, c->protect_count,
clk_core_get_rate_recalc(c),
clk_core_get_accuracy_recalc(c));
@@ -2996,9 +2996,9 @@ static int clk_summary_show(struct seq_file *s, void *data)
struct clk_core *c;
struct hlist_head **lists = (struct hlist_head **)s->private;
- seq_puts(s, " enable prepare protect duty hardware\n");
- seq_puts(s, " clock count count count rate accuracy phase cycle enable\n");
- seq_puts(s, "-------------------------------------------------------------------------------------------------------\n");
+ seq_puts(s, " counsumers enable prepare protect duty hardware\n");
+ seq_puts(s, " clock count count count count rate accuracy phase cycle enable\n");
+ seq_puts(s, "-------------------------------------------------------------------------------------------------------------------\n");
clk_prepare_lock();
@@ -3021,6 +3021,7 @@ static void clk_dump_one(struct seq_file *s, struct clk_core *c, int level)
/* This should be JSON format, i.e. elements separated with a comma */
seq_printf(s, "\"%s\": { ", c->name);
+ seq_printf(s, "\"consumers_count\": %d,", c->consumers_count);
seq_printf(s, "\"enable_count\": %d,", c->enable_count);
seq_printf(s, "\"prepare_count\": %d,", c->prepare_count);
seq_printf(s, "\"protect_count\": %d,", c->protect_count);
@@ -3330,6 +3331,7 @@ static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
debugfs_create_u32("clk_phase", 0444, root, &core->phase);
debugfs_create_file("clk_flags", 0444, root, core, &clk_flags_fops);
debugfs_create_u32("clk_prepare_count", 0444, root, &core->prepare_count);
+ debugfs_create_u32("clk_consumers_count", 0444, root, &core->consumers_count);
debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count);
debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count);
debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count);
--
2.34.3
^ permalink raw reply related [flat|nested] 5+ messages in thread