linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "<Vishal Badole>" <badolevishal1116@gmail.com>
To: Stephen Boyd <sboyd@kernel.org>,
	mturquette@baylibre.com, linux-clk@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: chinmoyghosh2001@gmail.com, mintupatel89@gmail.com
Subject: Re: [PATCH] Common clock: ​​To list active consumers of clocks
Date: Wed, 22 Jun 2022 22:32:20 +0530	[thread overview]
Message-ID: <20220622170219.GA6978@Mahakal> (raw)
In-Reply-To: <20220610194013.DD39DC34114@smtp.kernel.org>


From f2e9d78bd0f135206fbfbf2e0178a5782b972939 Mon Sep 17 00:00:00 2001
From: Vishal Badole <badolevishal1116@gmail.com>
Date: Tue, 21 Jun 2022 09:55:51 +0530
Subject: [PATCH] Common clock: To list active consumers of clocks

This feature lists the name of clocks and their consumer devices.
Using this feature user can easily check which device is using a
perticular clock. Consumers without dev_id are listed as no_dev_id.

Co-developed-by: Chinmoy Ghosh <chinmoyghosh2001@gmail.com>
Signed-off-by: Chinmoy Ghosh <chinmoyghosh2001@gmail.com>
Co-developed-by: Mintu Patel <mintupatel89@gmail.com>
Signed-off-by: Mintu Patel <mintupatel89@gmail.com>
Acked-by: Vimal Kumar <vimal.kumar32@gmail.com>
Signed-off-by: Vishal Badole <badolevishal1116@gmail.com>
---
 drivers/clk/clk.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index ed11918..b191009 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3018,6 +3018,63 @@ static int clk_summary_show(struct seq_file *s, void *data)
 }
 DEFINE_SHOW_ATTRIBUTE(clk_summary);
 
+static void clk_consumer_show_one(struct seq_file *s, struct clk_core *core, int level)
+{
+	struct clk *clk_user;
+	const char *consumer;
+
+	hlist_for_each_entry(clk_user, &core->clks, clks_node) {
+		if (!clk_user->dev_id)
+			consumer = "no_dev_id";
+		else
+			consumer = clk_user->dev_id;
+
+		seq_printf(s, "%*s%-*s %30s %5d %7d ",
+			   level * 3 + 1, "",
+			   30 - level * 3, clk_user->core->name, consumer,
+			   clk_user->core->enable_count, clk_user->core->prepare_count);
+
+		if (clk_user->core->ops->is_enabled)
+			seq_printf(s, " %8c\n", clk_core_is_enabled(clk_user->core) ? 'Y' : 'N');
+		else if (!clk_user->core->ops->enable)
+			seq_printf(s, " %8c\n", 'Y');
+		else
+			seq_printf(s, " %8c\n", '?');
+	}
+}
+
+static void clk_consumer_show_subtree(struct seq_file *s, struct clk_core *c, int level)
+{
+	struct clk_core *child;
+
+	clk_consumer_show_one(s, c, level);
+
+	hlist_for_each_entry(child, &c->children, child_node)
+		clk_consumer_show_subtree(s, child, level + 1);
+}
+
+static int clk_consumer_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   hardware\n");
+	seq_puts(s, "   clock                                       consumer        count     count     enable\n");
+	seq_puts(s, "-----------------------------------------------------------------------------------------\n");
+	clk_prepare_lock();
+
+	/*Traversing Linked List to print clock consumer*/
+
+	for (; *lists; lists++)
+		hlist_for_each_entry(c, *lists, child_node)
+			clk_consumer_show_subtree(s, c, 0);
+
+	clk_prepare_unlock();
+
+	return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(clk_consumer);
+
 static void clk_dump_one(struct seq_file *s, struct clk_core *c, int level)
 {
 	int phase;
@@ -3437,6 +3494,8 @@ static int __init clk_debug_init(void)
 			    &clk_summary_fops);
 	debugfs_create_file("clk_orphan_dump", 0444, rootdir, &orphan_list,
 			    &clk_dump_fops);
+	debugfs_create_file("clk_consumer", 0444, rootdir, &all_lists,
+			    &clk_consumer_fops);
 
 	mutex_lock(&clk_debug_lock);
 	hlist_for_each_entry(core, &clk_debug_list, debug_node)
-- 
2.7.4


  parent reply	other threads:[~2022-06-22 17:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAEXpiVQihEadxsNodarz2-wxSAipfpzEaA8zKpnozszC+weYTQ@mail.gmail.com>
2022-06-10 19:40 ` [PATCH 5.4] Common clock: ​​To list active consumers of clocks Stephen Boyd
     [not found]   ` <CAOUcgRfB-r3aERYeLumExgpTVzsDsBuyOWT+nCJ_OfOv1g0L9g@mail.gmail.com>
2022-06-15 19:23     ` <Vishal Badole>
2022-06-22 16:32   ` [PATCH] " <Vishal Badole>
2022-06-22 19:37     ` Randy Dunlap
2022-06-22 17:02   ` <Vishal Badole> [this message]
     [not found]     ` <20220624010550.582BBC341C7@smtp.kernel.org>
2022-06-26 18:25       ` <Vishal Badole>
2022-08-02 22:49         ` Elliott, Robert (Servers)
2022-08-08 17:00           ` <Vishal Badole>
2022-08-21  5:07             ` Elliott, Robert (Servers)
2022-08-21 17:59               ` <Vishal Badole>
2022-06-28  5:08       ` [PATCH v3] Common clock: To " Vishal Badole
2022-08-02 18:09       ` Vishal Badole
2022-08-08 16:46         ` <Vishal Badole>
2022-08-21 18:06         ` <Vishal Badole>
2022-08-22 23:50         ` Stephen Boyd
2022-08-26 17:34           ` <Vishal Badole>
2022-11-27 18:00           ` <Vishal Badole>

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220622170219.GA6978@Mahakal \
    --to=badolevishal1116@gmail.com \
    --cc=chinmoyghosh2001@gmail.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mintupatel89@gmail.com \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).