* [PATCH 1/2] clk: Add debug clk summary
@ 2012-12-26 13:46 Prashant Gaikwad
2012-12-26 13:46 ` [PATCH 2/2] clk: Add debug entry to dump clock information Prashant Gaikwad
2013-01-12 3:54 ` [PATCH 1/2] clk: Add debug clk summary Mike Turquette
0 siblings, 2 replies; 3+ messages in thread
From: Prashant Gaikwad @ 2012-12-26 13:46 UTC (permalink / raw)
To: mturquette, swarren; +Cc: linux-kernel, linux-arm-kernel, Prashant Gaikwad
Adds debug file "clk_summary" in /sys/kernel/debug/clk dir.
It helps to view all the clock registered in human-readable format.
For example:
clock enable_cnt prepare_cnt rate
---------------------------------------------------------------------
i2s0_sync 0 0 24000000
spdif_in_sync 0 0 24000000
spdif_mux 0 0 24000000
spdif 0 0 24000000
spdif_doubler 0 0 48000000
spdif_div 0 0 48000000
spdif_2x 0 0 48000000
clk_32k 2 2 32768
blink_override 1 1 32768
blink 1 1 32768
clk_m 2 2 12000000
clk_out_3_mux 0 0 12000000
clk_out_3 0 0 12000000
pll_ref 3 3 12000000
pll_e_mux 0 0 12000000
pll_e 0 0 100000000
cml0 0 0 100000000
cml1 0 0 100000000
pciex 0 0 100000000
pll_d2 0 0 1000000
pll_d2_out0 0 0 500000
pll_d 0 0 1000000
pll_d_out0 0 0 500000
dsib_mux 0 0 500000
dsib 0 0 500000
dsia 0 0 500000
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
---
drivers/clk/clk.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 67 insertions(+), 0 deletions(-)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 56e4495e..d79c088 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -34,6 +34,67 @@ static struct dentry *rootdir;
static struct dentry *orphandir;
static int inited = 0;
+static void clk_summary_show_one(struct seq_file *s, struct clk *c, int level)
+{
+ if (!c)
+ return;
+
+ seq_printf(s, "%*s%-*s %-11d %-12d %-10lu",
+ level * 3 + 1, "",
+ 30 - level * 3, c->name,
+ c->enable_count, c->prepare_count, c->rate);
+ seq_printf(s, "\n");
+}
+
+static void clk_summary_show_subtree(struct seq_file *s, struct clk *c,
+ int level)
+{
+ struct clk *child;
+ struct hlist_node *tmp;
+
+ if (!c)
+ return;
+
+ clk_summary_show_one(s, c, level);
+
+ hlist_for_each_entry(child, tmp, &c->children, child_node)
+ clk_summary_show_subtree(s, child, level + 1);
+}
+
+static int clk_summary_show(struct seq_file *s, void *data)
+{
+ struct clk *c;
+ struct hlist_node *tmp;
+
+ seq_printf(s, " clock enable_cnt prepare_cnt rate\n");
+ seq_printf(s, "---------------------------------------------------------------------\n");
+
+ mutex_lock(&prepare_lock);
+
+ hlist_for_each_entry(c, tmp, &clk_root_list, child_node)
+ clk_summary_show_subtree(s, c, 0);
+
+ hlist_for_each_entry(c, tmp, &clk_orphan_list, child_node)
+ clk_summary_show_subtree(s, c, 0);
+
+ mutex_unlock(&prepare_lock);
+
+ return 0;
+}
+
+
+static int clk_summary_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, clk_summary_show, inode->i_private);
+}
+
+static const struct file_operations clk_summary_fops = {
+ .open = clk_summary_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
/* caller must hold prepare_lock */
static int clk_debug_create_one(struct clk *clk, struct dentry *pdentry)
{
@@ -167,12 +228,18 @@ static int __init clk_debug_init(void)
{
struct clk *clk;
struct hlist_node *tmp;
+ struct dentry *d;
rootdir = debugfs_create_dir("clk", NULL);
if (!rootdir)
return -ENOMEM;
+ d = debugfs_create_file("clk_summary", S_IRUGO, rootdir, NULL,
+ &clk_summary_fops);
+ if (!d)
+ return -ENOMEM;
+
orphandir = debugfs_create_dir("orphans", rootdir);
if (!orphandir)
--
1.7.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] clk: Add debug entry to dump clock information
2012-12-26 13:46 [PATCH 1/2] clk: Add debug clk summary Prashant Gaikwad
@ 2012-12-26 13:46 ` Prashant Gaikwad
2013-01-12 3:54 ` [PATCH 1/2] clk: Add debug clk summary Mike Turquette
1 sibling, 0 replies; 3+ messages in thread
From: Prashant Gaikwad @ 2012-12-26 13:46 UTC (permalink / raw)
To: mturquette, swarren; +Cc: linux-kernel, linux-arm-kernel, Prashant Gaikwad
Clock information is dumped in JSON format which is easy
for machines to parse.
Each clock is represented as an object which has same name as
clock and following properties
- enable_count
- prepare_count
- rate
Output is verified using online JSON editor.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
---
drivers/clk/clk.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 75 insertions(+), 0 deletions(-)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index d79c088..1cd70ec 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -95,6 +95,76 @@ static const struct file_operations clk_summary_fops = {
.release = single_release,
};
+static void clk_dump_one(struct seq_file *s, struct clk *c, int level)
+{
+ if (!c)
+ return;
+
+ seq_printf(s, "\"%s\": { ", c->name);
+ seq_printf(s, "\"enable_count\": %d,", c->enable_count);
+ seq_printf(s, "\"prepare_count\": %d,", c->prepare_count);
+ seq_printf(s, "\"rate\": %lu", c->rate);
+}
+
+static void clk_dump_subtree(struct seq_file *s, struct clk *c, int level)
+{
+ struct clk *child;
+ struct hlist_node *tmp;
+
+ if (!c)
+ return;
+
+ clk_dump_one(s, c, level);
+
+ hlist_for_each_entry(child, tmp, &c->children, child_node) {
+ seq_printf(s, ",");
+ clk_dump_subtree(s, child, level + 1);
+ }
+
+ seq_printf(s, "}");
+}
+
+static int clk_dump(struct seq_file *s, void *data)
+{
+ struct clk *c;
+ struct hlist_node *tmp;
+ bool first_node = true;
+
+ seq_printf(s, "{");
+
+ mutex_lock(&prepare_lock);
+
+ hlist_for_each_entry(c, tmp, &clk_root_list, child_node) {
+ if (!first_node)
+ seq_printf(s, ",");
+ first_node = false;
+ clk_dump_subtree(s, c, 0);
+ }
+
+ hlist_for_each_entry(c, tmp, &clk_orphan_list, child_node) {
+ seq_printf(s, ",");
+ clk_dump_subtree(s, c, 0);
+ }
+
+ mutex_unlock(&prepare_lock);
+
+ seq_printf(s, "}");
+ return 0;
+}
+
+
+static int clk_dump_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, clk_dump, inode->i_private);
+}
+
+static const struct file_operations clk_dump_fops = {
+ .open = clk_dump_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
/* caller must hold prepare_lock */
static int clk_debug_create_one(struct clk *clk, struct dentry *pdentry)
{
@@ -240,6 +310,11 @@ static int __init clk_debug_init(void)
if (!d)
return -ENOMEM;
+ d = debugfs_create_file("clk_dump", S_IRUGO, rootdir, NULL,
+ &clk_dump_fops);
+ if (!d)
+ return -ENOMEM;
+
orphandir = debugfs_create_dir("orphans", rootdir);
if (!orphandir)
--
1.7.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] clk: Add debug clk summary
2012-12-26 13:46 [PATCH 1/2] clk: Add debug clk summary Prashant Gaikwad
2012-12-26 13:46 ` [PATCH 2/2] clk: Add debug entry to dump clock information Prashant Gaikwad
@ 2013-01-12 3:54 ` Mike Turquette
1 sibling, 0 replies; 3+ messages in thread
From: Mike Turquette @ 2013-01-12 3:54 UTC (permalink / raw)
To: Prashant Gaikwad, swarren
Cc: linux-kernel, linux-arm-kernel, Prashant Gaikwad
Quoting Prashant Gaikwad (2012-12-26 05:46:22)
> Adds debug file "clk_summary" in /sys/kernel/debug/clk dir.
> It helps to view all the clock registered in human-readable format.
>
> For example:
> clock enable_cnt prepare_cnt rate
> ---------------------------------------------------------------------
> i2s0_sync 0 0 24000000
> spdif_in_sync 0 0 24000000
> spdif_mux 0 0 24000000
> spdif 0 0 24000000
> spdif_doubler 0 0 48000000
> spdif_div 0 0 48000000
> spdif_2x 0 0 48000000
> clk_32k 2 2 32768
> blink_override 1 1 32768
> blink 1 1 32768
> clk_m 2 2 12000000
> clk_out_3_mux 0 0 12000000
> clk_out_3 0 0 12000000
> pll_ref 3 3 12000000
> pll_e_mux 0 0 12000000
> pll_e 0 0 100000000
> cml0 0 0 100000000
> cml1 0 0 100000000
> pciex 0 0 100000000
> pll_d2 0 0 1000000
> pll_d2_out0 0 0 500000
> pll_d 0 0 1000000
> pll_d_out0 0 0 500000
> dsib_mux 0 0 500000
> dsib 0 0 500000
> dsia 0 0 500000
>
> Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
Thanks for the respin of patch #1 and for generating the JSON output
format in patch #2. I've taken both of these into clk-next.
Regards,
Mike
> ---
> drivers/clk/clk.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 67 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index 56e4495e..d79c088 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -34,6 +34,67 @@ static struct dentry *rootdir;
> static struct dentry *orphandir;
> static int inited = 0;
>
> +static void clk_summary_show_one(struct seq_file *s, struct clk *c, int level)
> +{
> + if (!c)
> + return;
> +
> + seq_printf(s, "%*s%-*s %-11d %-12d %-10lu",
> + level * 3 + 1, "",
> + 30 - level * 3, c->name,
> + c->enable_count, c->prepare_count, c->rate);
> + seq_printf(s, "\n");
> +}
> +
> +static void clk_summary_show_subtree(struct seq_file *s, struct clk *c,
> + int level)
> +{
> + struct clk *child;
> + struct hlist_node *tmp;
> +
> + if (!c)
> + return;
> +
> + clk_summary_show_one(s, c, level);
> +
> + hlist_for_each_entry(child, tmp, &c->children, child_node)
> + clk_summary_show_subtree(s, child, level + 1);
> +}
> +
> +static int clk_summary_show(struct seq_file *s, void *data)
> +{
> + struct clk *c;
> + struct hlist_node *tmp;
> +
> + seq_printf(s, " clock enable_cnt prepare_cnt rate\n");
> + seq_printf(s, "---------------------------------------------------------------------\n");
> +
> + mutex_lock(&prepare_lock);
> +
> + hlist_for_each_entry(c, tmp, &clk_root_list, child_node)
> + clk_summary_show_subtree(s, c, 0);
> +
> + hlist_for_each_entry(c, tmp, &clk_orphan_list, child_node)
> + clk_summary_show_subtree(s, c, 0);
> +
> + mutex_unlock(&prepare_lock);
> +
> + return 0;
> +}
> +
> +
> +static int clk_summary_open(struct inode *inode, struct file *file)
> +{
> + return single_open(file, clk_summary_show, inode->i_private);
> +}
> +
> +static const struct file_operations clk_summary_fops = {
> + .open = clk_summary_open,
> + .read = seq_read,
> + .llseek = seq_lseek,
> + .release = single_release,
> +};
> +
> /* caller must hold prepare_lock */
> static int clk_debug_create_one(struct clk *clk, struct dentry *pdentry)
> {
> @@ -167,12 +228,18 @@ static int __init clk_debug_init(void)
> {
> struct clk *clk;
> struct hlist_node *tmp;
> + struct dentry *d;
>
> rootdir = debugfs_create_dir("clk", NULL);
>
> if (!rootdir)
> return -ENOMEM;
>
> + d = debugfs_create_file("clk_summary", S_IRUGO, rootdir, NULL,
> + &clk_summary_fops);
> + if (!d)
> + return -ENOMEM;
> +
> orphandir = debugfs_create_dir("orphans", rootdir);
>
> if (!orphandir)
> --
> 1.7.4.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-01-12 3:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-26 13:46 [PATCH 1/2] clk: Add debug clk summary Prashant Gaikwad
2012-12-26 13:46 ` [PATCH 2/2] clk: Add debug entry to dump clock information Prashant Gaikwad
2013-01-12 3:54 ` [PATCH 1/2] clk: Add debug clk summary Mike Turquette
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).