Skip to content

Commit dcce5cc

Browse files
VishalBadolebebarino
authored andcommitted
clk: Show active consumers of clocks in debugfs
This feature lists the clock consumer's name and respective connection id. Using this feature user can easily check that which user has acquired and enabled a particular clock. Usage: >> cat /sys/kernel/debug/clk/clk_summary enable prepare protect duty hardware Connection clock count count count rate accuracy phase cycle enable consumer Id ------------------------------------------------------------------------------------------------------------------------------ clk_mcasp0_fixed 0 0 0 24576000 0 0 50000 Y deviceless of_clk_get_from_provider deviceless no_connection_id clk_mcasp0 0 0 0 24576000 0 0 50000 N simple-audio-card,cpu no_connection_id deviceless no_connection_id Co-developed-by: Chinmoy Ghosh <[email protected]> Signed-off-by: Chinmoy Ghosh <[email protected]> Co-developed-by: Mintu Patel <[email protected]> Signed-off-by: Mintu Patel <[email protected]> Co-developed-by: Vimal Kumar <[email protected]> Signed-off-by: Vimal Kumar <[email protected]> Signed-off-by: Vishal Badole <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 0bb80ec commit dcce5cc

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

drivers/clk/clk.c

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3188,28 +3188,41 @@ static void clk_summary_show_one(struct seq_file *s, struct clk_core *c,
31883188
int level)
31893189
{
31903190
int phase;
3191+
struct clk *clk_user;
3192+
int multi_node = 0;
31913193

3192-
seq_printf(s, "%*s%-*s %7d %8d %8d %11lu %10lu ",
3194+
seq_printf(s, "%*s%-*s %-7d %-8d %-8d %-11lu %-10lu ",
31933195
level * 3 + 1, "",
3194-
30 - level * 3, c->name,
3196+
35 - level * 3, c->name,
31953197
c->enable_count, c->prepare_count, c->protect_count,
31963198
clk_core_get_rate_recalc(c),
31973199
clk_core_get_accuracy_recalc(c));
31983200

31993201
phase = clk_core_get_phase(c);
32003202
if (phase >= 0)
3201-
seq_printf(s, "%5d", phase);
3203+
seq_printf(s, "%-5d", phase);
32023204
else
32033205
seq_puts(s, "-----");
32043206

3205-
seq_printf(s, " %6d", clk_core_get_scaled_duty_cycle(c, 100000));
3207+
seq_printf(s, " %-6d", clk_core_get_scaled_duty_cycle(c, 100000));
32063208

32073209
if (c->ops->is_enabled)
3208-
seq_printf(s, " %9c\n", clk_core_is_enabled(c) ? 'Y' : 'N');
3210+
seq_printf(s, " %5c ", clk_core_is_enabled(c) ? 'Y' : 'N');
32093211
else if (!c->ops->enable)
3210-
seq_printf(s, " %9c\n", 'Y');
3212+
seq_printf(s, " %5c ", 'Y');
32113213
else
3212-
seq_printf(s, " %9c\n", '?');
3214+
seq_printf(s, " %5c ", '?');
3215+
3216+
hlist_for_each_entry(clk_user, &c->clks, clks_node) {
3217+
seq_printf(s, "%*s%-*s %-25s\n",
3218+
level * 3 + 2 + 105 * multi_node, "",
3219+
30,
3220+
clk_user->dev_id ? clk_user->dev_id : "deviceless",
3221+
clk_user->con_id ? clk_user->con_id : "no_connection_id");
3222+
3223+
multi_node = 1;
3224+
}
3225+
32133226
}
32143227

32153228
static void clk_summary_show_subtree(struct seq_file *s, struct clk_core *c,
@@ -3230,9 +3243,10 @@ static int clk_summary_show(struct seq_file *s, void *data)
32303243
struct clk_core *c;
32313244
struct hlist_head **lists = s->private;
32323245

3233-
seq_puts(s, " enable prepare protect duty hardware\n");
3234-
seq_puts(s, " clock count count count rate accuracy phase cycle enable\n");
3235-
seq_puts(s, "-------------------------------------------------------------------------------------------------------\n");
3246+
seq_puts(s, " enable prepare protect duty hardware connection\n");
3247+
seq_puts(s, " clock count count count rate accuracy phase cycle enable consumer id\n");
3248+
seq_puts(s, "---------------------------------------------------------------------------------------------------------------------------------------------\n");
3249+
32363250

32373251
clk_prepare_lock();
32383252

0 commit comments

Comments
 (0)