Skip to contentSkip to conversation

add clock debug information for imx51 babbage

PATCH New Yong Shen 3 participants 6 messages Dec 1, 2010 – Dec 2, 2010

lore
Share & tools
lore

Yong Shen

author
#0 lore raw

PATCH 1/1 add clock debug information for imx51 babbage

Hi there,

This patch makes BSP development easier, since it displays the whole clock information in tree-like manner. The final goal is to make it a part of common clock framework, but so far this goal depends on other unfinished work.

PS: Due to the firewall problem, I send out patch this way. Please give comments inline and use attached patch for testing.

#1 lore raw

PATCH 1/1 add clock debug information for imx51 babbage

Quoted 7 lines · Yong Shen

Hi there,

This patch makes BSP development easier, since it displays the whole clock information in tree-like manner. The final goal is to make it a part of common clock framework, but so far this goal depends on other unfinished work.

Quoted 7 lines

PS: Due to the firewall problem, I send out patch this way. Please give comments inline and use attached patch for testing.

Quoted 1 line

From a856d68c53cf91b3fa30a7742057f7afdaf77482 Mon Sep 17 00:00:00 2001

From: Yong Shen <[email protected]>
Date: Wed, 1 Dec 2010 19:18:34 +0800
Subject: [PATCH] add clock debug information for imx51 babbage

why "imx51 babbage" ? I guess it should be working for all imx51/53 boards

Quoted 4 lines

Add code to expose a tree-like clock debug information in sysfs.

[...]

Review static struct clk emi_slow_clk = { · line 877

Quoted 8 lines
(quoted diff) +2 -0
@@ -842,8 +871,10 @@ static struct clk emi_slow_clk = {
 	.get_rate = clk_emi_slow_get_rate,
 };
 
+
 #define DEFINE_CLOCK_CCGR(name, i, er, es, pfx, p, s)	\
 	static struct clk name = {			\
+		__INIT_CLK_DEBUG(name)			\

why not ".name = name," no matter of CONFIG_CLK_DEBUG value ?

Quoted 12 lines
(quoted diff) +1 -0
 		.id		= i,			\
 		.enable_reg	= er,			\
 		.enable_shift	= es,			\
@@ -859,6 +890,7 @@ static struct clk emi_slow_clk = {
 
 #define DEFINE_CLOCK_MAX(name, i, er, es, pfx, p, s)	\
 	static struct clk name = {			\
+		__INIT_CLK_DEBUG(name)			\
 		.id		= i,			\
 		.enable_reg	= er,			\
 		.enable_shift	= es,			\
@@ -937,6 +969,7 @@ CLK_GET_RATE(uart, 1, UART)

[...]

Quoted 4 lines
(quoted diff) +4 -0
+struct preinit_clk {
+	struct list_head list;
+	struct clk *clk;
+};

Review

Quoted 10 lines
(quoted diff) +10 -0
+static LIST_HEAD(preinit_clks);
+static DEFINE_MUTEX(preinit_lock);
+static int init_done;
+
+void clk_debug_register(struct clk *clk)
+{
+	int err;
+	struct clk *pa;
+
+	if (init_done) {

is there a reason for not using debugfs_initialized() directly ?

Quoted 50 lines
(quoted diff) +43 -0
+		pa = clk_get_parent(clk);
+
+		if (pa && !IS_ERR(pa) && !pa->dentry)
+			clk_debug_register(pa);
+
+		if (!clk->dentry) {
+			err = clk_debug_register_one(clk);
+			if (err)
+				return;
+		}
+	} else {
+		struct preinit_clk *p;
+		mutex_lock(&preinit_lock);
+		p = kmalloc(sizeof(*p), GFP_KERNEL);
+		if (!p)
+			goto unlock;
+		p->clk = clk;
+		list_add(&p->list, &preinit_clks);
+unlock:
+		mutex_unlock(&preinit_lock);
+	}
+}
+EXPORT_SYMBOL_GPL(clk_debug_register);
+
+static int __init clk_debugfs_init(void)
+{
+	struct preinit_clk *pclk, *tmp;
+
+	if (debugfs_initialized())
+		init_done = 1;
+
+	list_for_each_entry(pclk, &preinit_clks, list) {
+		clk_debug_register(pclk->clk);
+	}
+
+	list_for_each_entry_safe(pclk, tmp, &preinit_clks, list) {
+		list_del(&pclk->list);
+		kfree(pclk);
+	}
+	return 0;
+}
+late_initcall(clk_debugfs_init);
+#endif
arch/arm/plat-mxc/include/mach/clock.h +0 -0
index 753a598..fb0e0bd 100644
@@ -23,9 +23,14 @@
 #ifndef __ASSEMBLY__

arch/arm/plat-mxc/include/mach/clock.h line 33

Quoted 10 lines
arch/arm/plat-mxc/include/mach/clock.h +5 -0
 #include <linux/list.h>
 
+#define CLK_NAME_LEN 32
 struct module;
 
 struct clk {
+#ifdef CONFIG_CLK_DEBUG
+	char name[CLK_NAME_LEN];
+	struct dentry           *dentry;
+#endif

Do we really need the #ifdef here ?

Arnaud

author
#2 lore raw

PATCH 1/1 add clock debug information for imx51 babbage

Hi,

Quoted 12 lines · Arnaud Patard
Quoted 10 lines · Yong Shen

Hi there,

This patch makes BSP development easier, since it displays the whole clock information in tree-like manner. The final goal is to make it a part of common clock framework, but so far this goal depends on other unfinished work.

PS: Due to the firewall problem, I send out patch this way. Please give comments inline and use attached patch for testing.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

From a856d68c53cf91b3fa30a7742057f7afdaf77482 Mon Sep 17 00:00:00 2001

From: Yong Shen <[email protected]>
Date: Wed, 1 Dec 2010 19:18:34 +0800
Subject: [PATCH] add clock debug information for imx51 babbage

why "imx51 babbage" ? I guess it should be working for all imx51/53 boards

I meant to enable it for babbage (since my task is mainly on it), and I only have babbage for test. If someone wants to enable it for other boards, they need to add few lines of code themselves.

Quoted 12 lines
Quoted 4 lines

Add code to expose a tree-like clock debug information in sysfs.

[...]

Quoted 4 lines
(quoted diff) +0 -0
@@ -842,8 +871,10 @@ static struct clk emi_slow_clk = {
 ? ? ? .get_rate = clk_emi_slow_get_rate,
 ?};
 
Quoted 6 lines

Review static struct clk emi_slow_clk = { · line 877

Quoted 4 lines
(quoted diff) +2 -0
+
 ?#define DEFINE_CLOCK_CCGR(name, i, er, es, pfx, p, s) ? ? ? ?\
 ? ? ? static struct clk name = { ? ? ? ? ? ? ? ? ? ? ?\
+ ? ? ? ? ? ? __INIT_CLK_DEBUG(name) ? ? ? ? ? ? ? ? ?\

why not ".name = name," no matter of CONFIG_CLK_DEBUG value ?

it is all about that 'shall we include name as a common field in the clk struct'? I will explain later.

Quoted 16 lines
Quoted 13 lines
(quoted diff) +1 -0
 ? ? ? ? ? ? ? .id ? ? ? ? ? ? = i, ? ? ? ? ? ? ? ? ? ?\
 ? ? ? ? ? ? ? .enable_reg ? ? = er, ? ? ? ? ? ? ? ? ? \
 ? ? ? ? ? ? ? .enable_shift ? = es, ? ? ? ? ? ? ? ? ? \
@@ -859,6 +890,7 @@ static struct clk emi_slow_clk = {
 
 ?#define DEFINE_CLOCK_MAX(name, i, er, es, pfx, p, s) \
 ? ? ? static struct clk name = { ? ? ? ? ? ? ? ? ? ? ?\
+ ? ? ? ? ? ? __INIT_CLK_DEBUG(name) ? ? ? ? ? ? ? ? ?\
 ? ? ? ? ? ? ? .id ? ? ? ? ? ? = i, ? ? ? ? ? ? ? ? ? ?\
 ? ? ? ? ? ? ? .enable_reg ? ? = er, ? ? ? ? ? ? ? ? ? \
 ? ? ? ? ? ? ? .enable_shift ? = es, ? ? ? ? ? ? ? ? ? \
@@ -937,6 +969,7 @@ CLK_GET_RATE(uart, 1, UART)

[...]

Quoted 16 lines
Quoted 4 lines
(quoted diff) +4 -0
+struct preinit_clk {
+ ? ? struct list_head list;
+ ? ? struct clk *clk;
+};

Review

Quoted 10 lines
(quoted diff) +10 -0
+static LIST_HEAD(preinit_clks);
+static DEFINE_MUTEX(preinit_lock);
+static int init_done;
+
+void clk_debug_register(struct clk *clk)
+{
+ ? ? int err;
+ ? ? struct clk *pa;
+
+ ? ? if (init_done) {

is there a reason for not using debugfs_initialized() directly ?

clk_debug_register will be called many times, so the cost of a variable could be less than a function call.

Quoted 56 lines
Quoted 56 lines

+ ? ? ? ? ? ? pa = clk_get_parent(clk);

(quoted diff) +42 -0
+
+ ? ? ? ? ? ? if (pa && !IS_ERR(pa) && !pa->dentry)
+ ? ? ? ? ? ? ? ? ? ? clk_debug_register(pa);
+
+ ? ? ? ? ? ? if (!clk->dentry) {
+ ? ? ? ? ? ? ? ? ? ? err = clk_debug_register_one(clk);
+ ? ? ? ? ? ? ? ? ? ? if (err)
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? return;
+ ? ? ? ? ? ? }
+ ? ? } else {
+ ? ? ? ? ? ? struct preinit_clk *p;
+ ? ? ? ? ? ? mutex_lock(&preinit_lock);
+ ? ? ? ? ? ? p = kmalloc(sizeof(*p), GFP_KERNEL);
+ ? ? ? ? ? ? if (!p)
+ ? ? ? ? ? ? ? ? ? ? goto unlock;
+ ? ? ? ? ? ? p->clk = clk;
+ ? ? ? ? ? ? list_add(&p->list, &preinit_clks);
+unlock:
+ ? ? ? ? ? ? mutex_unlock(&preinit_lock);
+ ? ? }
+}
+EXPORT_SYMBOL_GPL(clk_debug_register);
+
+static int __init clk_debugfs_init(void)
+{
+ ? ? struct preinit_clk *pclk, *tmp;
+
+ ? ? if (debugfs_initialized())
+ ? ? ? ? ? ? init_done = 1;
+
+ ? ? list_for_each_entry(pclk, &preinit_clks, list) {
+ ? ? ? ? ? ? clk_debug_register(pclk->clk);
+ ? ? }
+
+ ? ? list_for_each_entry_safe(pclk, tmp, &preinit_clks, list) {
+ ? ? ? ? ? ? list_del(&pclk->list);
+ ? ? ? ? ? ? kfree(pclk);
+ ? ? }
+ ? ? return 0;
+}
+late_initcall(clk_debugfs_init);
+#endif
arch/arm/plat-mxc/include/mach/clock.h +0 -0
index 753a598..fb0e0bd 100644
@@ -23,9 +23,14 @@

?#ifndef __ASSEMBLY__
?#include <linux/list.h>

+#define CLK_NAME_LEN 32
?struct module;

Quoted 7 lines

arch/arm/plat-mxc/include/mach/clock.h

Quoted 5 lines

?struct clk {

arch/arm/plat-mxc/include/mach/clock.h +4 -0
+#ifdef CONFIG_CLK_DEBUG
+ ? ? char name[CLK_NAME_LEN];
+ ? ? struct dentry ? ? ? ? ? *dentry;
+#endif

Do we really need the #ifdef here ?

In the formal release, these debug informations are not needed. It doesn't make sense to keep them in the clk struct which will consume some memery, like 32+4 bytes more (depends on the compiler).

Quoted 3 lines

Arnaud

#3 lore raw

PATCH 1/1 add clock debug information for imx51 babbage

In reply to Yong Shen

Hello,

Review

Quoted 5 lines
(quoted diff) +5 -0
+
+config CLK_DEBUG
+	bool "clock debug information export to user space"
+	depends on PM_DEBUG && DEBUG_FS
+	default n

You can skip that "default n" as it's the default.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
author
#4 lore raw

PATCH 1/1 add clock debug information for imx51 babbage

Hi,

2010/12/1 Uwe Kleine-K?nig <[email protected]>:

Quoted 8 lines

Hello,

Review

Quoted 5 lines
(quoted diff) +5 -0
+
+config CLK_DEBUG
+ ? ? bool "clock debug information export to user space"
+ ? ? depends on PM_DEBUG && DEBUG_FS
+ ? ? default n

You can skip that "default n" as it's the default.

Acked.

Quoted 8 lines

Best regards
Uwe

--

Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? | Uwe Kleine-K?nig ? ? ? ? ? ?|
Industrial Linux Solutions ? ? ? ? ? ? ? ? | http://www.pengutronix.de/ ?|
#5 lore raw

PATCH 1/1 add clock debug information for imx51 babbage

In reply to Yong Shen

Hello,

Quoted 6 lines · Yong Shen

Hi there,

This patch makes BSP development easier, since it displays the whole clock information in tree-like manner. The final goal is to make it a part of common clock framework, but so far this goal depends on other unfinished work.

BTW, I would prefer to have this on top of the generic clkdev patches (see http://thread.gmane.org/gmane.linux.ports.arm.kernel/90225)

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |