Skip to contentSkip to conversation

MSM: clock debugfs and cleanups

PATCH Superseded Stephen Boyd 4 participants 14 messages Jan 25, 2011 – Jan 26, 2011

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover MSM: clock debugfs and cleanups

These patches were previously posted as part of a larger series. I've refreshed these against the latest msm for-next branch.

They cleanup debugfs and the clock code and add support for some proc_comm clocks.

Matt Wagantall (1):
msm: clock: Move debugfs code from clock.c to clock-debug.c

Stephen Boyd (3):
msm: clock: Remove unused code and definitions
msm: clock: Invert debugfs directory layout
msm: clock: Add support for more proc_comm clocks

 arch/arm/mach-msm/Makefile          |    3 +
 arch/arm/mach-msm/board-msm8x60.c   |    5 +-
 arch/arm/mach-msm/clock-debug.c     |  131 +++++++++++++++++++++++++++++++
 arch/arm/mach-msm/clock-pcom.c      |    1 +
 arch/arm/mach-msm/clock-pcom.h      |    4 +-
 arch/arm/mach-msm/clock.c           |  148 ++---------------------------------
 arch/arm/mach-msm/clock.h           |   52 ++----------
 arch/arm/mach-msm/devices-msm7x30.c |    3 +
 arch/arm/mach-msm/devices-qsd8x50.c |    7 ++
 9 files changed, 165 insertions(+), 189 deletions(-)
 create mode 100644 arch/arm/mach-msm/clock-debug.c
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#1 lore raw

PATCH 1/4 msm: clock: Remove unused code and definitions

Remove dead code and push out clock-7x30.h and clock-pcom.h to where they are actually used.

---
 arch/arm/mach-msm/board-msm8x60.c   |    5 +---
 arch/arm/mach-msm/clock-pcom.c      |    1 +
 arch/arm/mach-msm/clock.c           |   21 ++--------------
 arch/arm/mach-msm/clock.h           |   45 -----------------------------------
 arch/arm/mach-msm/devices-msm7x30.c |    1 +
 arch/arm/mach-msm/devices-qsd8x50.c |    1 +
 6 files changed, 7 insertions(+), 67 deletions(-)
arch/arm/mach-msm/board-msm8x60.c +1 -4
index 9b5eb2b..e09c174 100644
@@ -28,10 +28,7 @@
 #include <mach/board.h>
 #include <mach/msm_iomap.h>
 
-unsigned long clk_get_max_axi_khz(void)
-{
-	return 0;
-}
+#include "devices.h"
 
 static void __init msm8x60_map_io(void)
 {
arch/arm/mach-msm/clock-pcom.c +1 -0
index a3b4562..8c4e867 100644
@@ -20,6 +20,7 @@
 
 #include "proc_comm.h"
 #include "clock.h"
+#include "clock-pcom.h"
 
 /*
  * glue for the proc_comm interface
arch/arm/mach-msm/clock.c +3 -18
index 2069bfa..8f71f8d 100644
@@ -29,6 +29,7 @@
 #include "clock.h"
 #include "proc_comm.h"
 #include "clock-7x30.h"
+#include "clock-pcom.h"
 
 static DEFINE_MUTEX(clocks_mutex);
 static DEFINE_SPINLOCK(clocks_lock);
@@ -37,13 +38,6 @@ struct clk *msm_clocks;
 unsigned msm_num_clocks;
 
 /*
- * Bitmap of enabled clocks, excluding ACPU which is always
- * enabled
- */
-static DECLARE_BITMAP(clock_map_enabled, NR_CLKS);
-static DEFINE_SPINLOCK(clock_map_lock);
-
-/*
  * Standard clock functions defined in include/linux/clk.h
  */
 struct clk *clk_get(struct device *dev, const char *id)
@@ -77,12 +71,8 @@ int clk_enable(struct clk *clk)
 	unsigned long flags;
 	spin_lock_irqsave(&clocks_lock, flags);
 	clk->count++;
-	if (clk->count == 1) {
+	if (clk->count == 1)
 		clk->ops->enable(clk->id);
-		spin_lock(&clock_map_lock);
-		clock_map_enabled[BIT_WORD(clk->id)] |= BIT_MASK(clk->id);
-		spin_unlock(&clock_map_lock);
-	}
 	spin_unlock_irqrestore(&clocks_lock, flags);
 	return 0;
 }
@@ -94,12 +84,8 @@ void clk_disable(struct clk *clk)
 	spin_lock_irqsave(&clocks_lock, flags);
 	BUG_ON(clk->count == 0);
 	clk->count--;
-	if (clk->count == 0) {
+	if (clk->count == 0)
 		clk->ops->disable(clk->id);
-		spin_lock(&clock_map_lock);
-		clock_map_enabled[BIT_WORD(clk->id)] &= ~BIT_MASK(clk->id);
-		spin_unlock(&clock_map_lock);
-	}
 	spin_unlock_irqrestore(&clocks_lock, flags);
 }
 EXPORT_SYMBOL(clk_disable);
@@ -196,7 +182,6 @@ void __init msm_clock_init(struct clk *clock_tbl, unsigned num_clocks)
 {
 	unsigned n;
 
-	spin_lock_init(&clocks_lock);
 	mutex_lock(&clocks_mutex);
 	msm_clocks = clock_tbl;
 	msm_num_clocks = num_clocks;
arch/arm/mach-msm/clock.h +0 -45

60 lines not on this page · raw message

arch/arm/mach-msm/devices-msm7x30.c +1 -0
index d4c7afc..e430fdd 100644
@@ -28,6 +28,7 @@
 #include <asm/mach/flash.h>
 
 #include "clock-pcom.h"
+#include "clock-7x30.h"
 
 #include <mach/mmc.h>
 
arch/arm/mach-msm/devices-qsd8x50.c +1 -0
index c9fa655..c5dad8f 100644
@@ -27,6 +27,7 @@
 #include <asm/mach/flash.h>
 
 #include <mach/mmc.h>
+#include "clock-pcom.h"
 
 static struct resource resources_uart3[] = {
 	{
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#8 lore raw

PATCH 2/4 msm: clock: Move debugfs code from clock.c to clock-debug.c

In reply to Stephen Boyd

From: Matt Wagantall <[email protected]>

The clock debugfs code is large enough, and easy enough to separate, that it deserves its own file which is compiled only when CONFIG_DEBUG_FS is enabled.

Also, cleanup header file #includes that are no longer required.

---
 arch/arm/mach-msm/Makefile      |    3 +
 arch/arm/mach-msm/clock-debug.c |  133 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-msm/clock.c       |  127 ++-----------------------------------
 arch/arm/mach-msm/clock.h       |    9 +++
 4 files changed, 150 insertions(+), 122 deletions(-)
 create mode 100644 arch/arm/mach-msm/clock-debug.c
arch/arm/mach-msm/Makefile +3 -0
index 0e5c9dc..c796441 100644
@@ -1,4 +1,7 @@
 obj-y += io.o idle.o timer.o
+ifdef CONFIG_MSM_PROC_COMM
+obj-$(CONFIG_DEBUG_FS) += clock-debug.o
+endif
 
 obj-$(CONFIG_MSM_VIC) += irq-vic.o
 
arch/arm/mach-msm/clock-debug.c new file +133 -0

133 lines not on this page · raw message

arch/arm/mach-msm/clock.c +5 -122

163 lines not on this page · raw message

arch/arm/mach-msm/clock.h +9 -0
index 6a0cade..70216b0 100644
@@ -17,6 +17,7 @@
 #ifndef __ARCH_ARM_MACH_MSM_CLOCK_H
 #define __ARCH_ARM_MACH_MSM_CLOCK_H
 
+#include <linux/init.h>
 #include <linux/list.h>
 #include <mach/clk.h>
 
@@ -61,4 +62,12 @@ struct clk {
 #define CLK_MAX CLKFLAG_MAX
 #define CLK_MINMAX (CLK_MIN | CLK_MAX)
 
+#ifdef CONFIG_DEBUG_FS
+int __init clock_debug_init(void);
+int __init clock_debug_add(struct clk *clock);
+#else
+static inline int __init clock_debug_init(void) { return 0; }
+static inline int __init clock_debug_add(struct clk *clock) { return 0; }
+#endif
+
 #endif
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#9 lore raw

PATCH 3/4 msm: clock: Invert debugfs directory layout

In reply to Stephen Boyd

There are currently 3 separate directories for clock debugging in
debugfs: clk_enable, clk_rate, and clk_local. Each of these directories contains a list of clocks. This is rather annoying when you are focusing on one clock and want to enable/disable it and then check its rate. You either have to cd to the other directory or cat ../clk_rate/<clk>.

Invert the layout so that there is one clock directory containing a directory for each clock. Inside each respective clock directory place an enable, rate, and is_local file relating to the clk_enable, clk_disable, and clk_local directories that exist today.

---
 arch/arm/mach-msm/clock-debug.c |   48 ++++++++++++++++++--------------------
 1 files changed, 23 insertions(+), 25 deletions(-)
arch/arm/mach-msm/clock-debug.c +23 -25
index 6f603ed..b67b9e82 100644
@@ -87,47 +87,45 @@ static int clock_debug_local_get(void *data, u64 *val)
 DEFINE_SIMPLE_ATTRIBUTE(clock_local_fops, clock_debug_local_get,
 			NULL, "%llu\n");
 
-static struct dentry *dent_rate, *dent_enable, *dent_local;
+static struct dentry *debugfs_base;
 
 int __init clock_debug_init(void)
 {
-	dent_rate = debugfs_create_dir("clk_rate", 0);
-	if (!dent_rate)
-		goto err;
-
-	dent_enable = debugfs_create_dir("clk_enable", 0);
-	if (!dent_enable)
-		goto err;
-
-	dent_local = debugfs_create_dir("clk_local", NULL);
-	if (!dent_local)
-		goto err;
-
+	debugfs_base = debugfs_create_dir("clk", NULL);
+	if (!debugfs_base)
+		return -ENOMEM;
 	return 0;
-err:
-	debugfs_remove(dent_local);
-	debugfs_remove(dent_enable);
-	debugfs_remove(dent_rate);
-	return -ENOMEM;
 }
 
 int __init clock_debug_add(struct clk *clock)
 {
 	char temp[50], *ptr;
+	struct dentry *clk_dir;
 
-	if (!dent_rate || !dent_enable || !dent_local)
+	if (!debugfs_base)
 		return -ENOMEM;
 
 	strncpy(temp, clock->dbg_name, ARRAY_SIZE(temp)-1);
 	for (ptr = temp; *ptr; ptr++)
 		*ptr = tolower(*ptr);
 
-	debugfs_create_file(temp, S_IRUGO | S_IWUSR, dent_rate,
-			    clock, &clock_rate_fops);
-	debugfs_create_file(temp, S_IRUGO | S_IWUSR, dent_enable,
-			    clock, &clock_enable_fops);
-	debugfs_create_file(temp, S_IRUGO, dent_local,
-			    clock, &clock_local_fops);
+	clk_dir = debugfs_create_dir(temp, debugfs_base);
+	if (!clk_dir)
+		return -ENOMEM;
+
+	if (!debugfs_create_file("rate", S_IRUGO | S_IWUSR, clk_dir,
+				clock, &clock_rate_fops))
+		goto error;
 
+	if (!debugfs_create_file("enable", S_IRUGO | S_IWUSR, clk_dir,
+				clock, &clock_enable_fops))
+		goto error;
+
+	if (!debugfs_create_file("is_local", S_IRUGO, clk_dir, clock,
+				&clock_local_fops))
+		goto error;
 	return 0;
+error:
+	debugfs_remove_recursive(clk_dir);
+	return -ENOMEM;
 }
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#10 lore raw

PATCH 4/4 msm: clock: Add support for more proc_comm clocks

In reply to Stephen Boyd

Support the CE_CLK and CODEC_SSBI_CLK. Also add support for uart, and i2c clocks on targets which support proc_comm clocks.

---
 arch/arm/mach-msm/clock-pcom.h      |    4 +++-
 arch/arm/mach-msm/devices-msm7x30.c |    2 ++
 arch/arm/mach-msm/devices-qsd8x50.c |    6 ++++++
 3 files changed, 11 insertions(+), 1 deletions(-)
arch/arm/mach-msm/clock-pcom.h +3 -1
index 17d027b..2c813f1 100644
@@ -132,8 +132,10 @@
 #define P_CSI1_P_CLK		97
 #define P_GSBI_CLK		98
 #define P_GSBI_P_CLK		99
+#define P_CE_CLK		100 /* Crypto engine */
+#define P_CODEC_SSBI_CLK	101
 
-#define P_NR_CLKS		100
+#define P_NR_CLKS		102
 
 struct clk_ops;
 extern struct clk_ops clk_ops_pcom;
arch/arm/mach-msm/devices-msm7x30.c +2 -0
index e430fdd..cd4343b 100644
@@ -134,6 +134,8 @@ struct clk msm_clocks_7x30[] = {
 	CLK_PCOM("adsp_clk",	ADSP_CLK,	NULL, 0),
 	CLK_PCOM("cam_m_clk",	CAM_M_CLK,	NULL, 0),
 	CLK_PCOM("camif_pad_pclk",	CAMIF_PAD_P_CLK,	NULL, OFF),
+	CLK_PCOM("ce_clk",	CE_CLK,	NULL, 0),
+	CLK_PCOM("codec_ssbi_clk",	CODEC_SSBI_CLK,	NULL, 0),
 	CLK_PCOM("ebi1_clk",	EBI1_CLK,	NULL, CLK_MIN),
 	CLK_PCOM("ecodec_clk",	ECODEC_CLK,	NULL, 0),
 	CLK_PCOM("emdh_clk",	EMDH_CLK,	NULL, OFF | CLK_MINMAX),
arch/arm/mach-msm/devices-qsd8x50.c +6 -0
index c5dad8f..bd545f9 100644
@@ -316,12 +316,14 @@ int __init msm_add_sdcc(unsigned int controller,
 
 struct clk msm_clocks_8x50[] = {
 	CLK_PCOM("adm_clk",	ADM_CLK,	NULL, 0),
+	CLK_PCOM("ce_clk",	CE_CLK,		NULL, 0),
 	CLK_PCOM("ebi1_clk",	EBI1_CLK,	NULL, CLK_MIN),
 	CLK_PCOM("ebi2_clk",	EBI2_CLK,	NULL, 0),
 	CLK_PCOM("ecodec_clk",	ECODEC_CLK,	NULL, 0),
 	CLK_PCOM("emdh_clk",	EMDH_CLK,	NULL, OFF | CLK_MINMAX),
 	CLK_PCOM("gp_clk",	GP_CLK,		NULL, 0),
 	CLK_PCOM("grp_clk",	GRP_3D_CLK,	NULL, 0),
+	CLK_PCOM("i2c_clk",	I2C_CLK,	NULL, 0),
 	CLK_PCOM("icodec_rx_clk",	ICODEC_RX_CLK,	NULL, 0),
 	CLK_PCOM("icodec_tx_clk",	ICODEC_TX_CLK,	NULL, 0),
 	CLK_PCOM("imem_clk",	IMEM_CLK,	NULL, OFF),
@@ -347,7 +349,11 @@ struct clk msm_clocks_8x50[] = {
 	CLK_PCOM("tsif_ref_clk",	TSIF_REF_CLK,	NULL, 0),
 	CLK_PCOM("tv_dac_clk",	TV_DAC_CLK,	NULL, 0),
 	CLK_PCOM("tv_enc_clk",	TV_ENC_CLK,	NULL, 0),
+	CLK_PCOM("uart_clk",	UART1_CLK,	NULL, OFF),
+	CLK_PCOM("uart_clk",	UART2_CLK,	NULL, 0),
 	CLK_PCOM("uart_clk",	UART3_CLK,	&msm_device_uart3.dev, OFF),
+	CLK_PCOM("uartdm_clk",	UART1DM_CLK,	NULL, OFF),
+	CLK_PCOM("uartdm_clk",	UART2DM_CLK,	NULL, 0),
 	CLK_PCOM("usb_hs_clk",	USB_HS_CLK,	NULL, OFF),
 	CLK_PCOM("usb_hs_pclk",	USB_HS_P_CLK,	NULL, OFF),
 	CLK_PCOM("usb_otg_clk",	USB_OTG_CLK,	NULL, 0),
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#2 lore raw

Re: [PATCH 1/4] msm: clock: Remove unused code and definitions

In reply to Stephen Boyd
Quoted 3 lines · Stephen Boyd

Remove dead code and push out clock-7x30.h and clock-pcom.h to where they are actually used.

I'd do two patches for this. The stuff your doing is too disconnected.

Daniel

Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#3 lore raw

Re: [PATCH 1/4] msm: clock: Remove unused code and definitions

Quoted 9 lines · Daniel Walker
Quoted 3 lines · Stephen Boyd

Remove dead code and push out clock-7x30.h and clock-pcom.h to where they are actually used.

I'd do two patches for this. The stuff your doing is too disconnected.

Daniel

There is a whole bunch of unused code in the clock files and it's being deleted. I don't see a point of splitting it up per file.

-Saravana

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#11 lore raw

Re: [PATCH 4/4] msm: clock: Add support for more proc_comm clocks

In reply to Stephen Boyd
Quoted 2 lines · Stephen Boyd

Support the CE_CLK and CODEC_SSBI_CLK. Also add support for uart, and i2c clocks on targets which support proc_comm clocks.

Basically when you catch yourself writing "also" in the commit text you need to re-evaluate making two patches.. In this case it looks appropriate..

I'd do CE_CLK and CODEC_SSBI_CLK in one, with the increment for the number of clocks, and adding those two clocks.

Then the rest of it I'm not sure. If it was me I'd break out uart and i2c in different patches but that might be overkill.

Daniel

Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#4 lore raw

Re: [PATCH 1/4] msm: clock: Remove unused code and definitions

In reply to Saravana Kannan
Quoted 6 lines · Saravana Kannan
Quoted 5 lines · Daniel Walker
Quoted 3 lines · Stephen Boyd

Remove dead code and push out clock-7x30.h and clock-pcom.h to where they are actually used.

Quoted 6 lines
Quoted 4 lines

I'd do two patches for this. The stuff your doing is too disconnected.

Daniel

There is a whole bunch of unused code in the clock files and it's being deleted. I don't see a point of splitting it up per file.

It's easier to review when changes aren't merged that don't related to each other.

Daniel

Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#5 lore raw

Re: [PATCH 1/4] msm: clock: Remove unused code and definitions

Quoted 9 lines · Daniel Walker
Quoted 8 lines · Saravana Kannan
Quoted 7 lines · Daniel Walker
Quoted 3 lines · Stephen Boyd

Remove dead code and push out clock-7x30.h and clock-pcom.h to where they are actually used.

I'd do two patches for this. The stuff your doing is too disconnected.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Daniel

There is a whole bunch of unused code in the clock files and it's being deleted. I don't see a point of splitting it up per file.

It's easier to review when changes aren't merged that don't related to each other.

In this particular case, the patch is a bunch of removal of dead code, and kind of makes sense to keep it together. I'm fine with it as is.

David Brown

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#6 lore raw

Re: [PATCH 1/4] msm: clock: Remove unused code and definitions

Quoted 13 lines · David Brown
Quoted 11 lines · Daniel Walker
Quoted 10 lines · Saravana Kannan
Quoted 9 lines · Daniel Walker
Quoted 3 lines · Stephen Boyd

Remove dead code and push out clock-7x30.h and clock-pcom.h to where they are actually used.

I'd do two patches for this. The stuff your doing is too disconnected.

Daniel

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

There is a whole bunch of unused code in the clock files and it's being deleted. I don't see a point of splitting it up per file.

It's easier to review when changes aren't merged that don't related to each other.

In this particular case, the patch is a bunch of removal of dead code, and kind of makes sense to keep it together. I'm fine with it as is.

He's adding stuff too .. So it's not _just_ removal which is what I was getting at.

Daniel

Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#12 lore raw

Re: [PATCH 4/4] msm: clock: Add support for more proc_comm clocks

In reply to Daniel Walker
Quoted 7 lines · Daniel Walker
Quoted 2 lines · Stephen Boyd

Support the CE_CLK and CODEC_SSBI_CLK. Also add support for uart, and i2c clocks on targets which support proc_comm clocks.

Basically when you catch yourself writing "also" in the commit text you need to re-evaluate making two patches.. In this case it looks appropriate..

Or it is just an argument to not use the word also in the commit text. I don't think it's really necessary to split up a patch that adds a few clocks to the clock table.

David

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#13 lore raw

Re: [PATCH 4/4] msm: clock: Add support for more proc_comm clocks

Quoted 6 lines · David Brown
Quoted 4 lines · Daniel Walker
Quoted 2 lines · Stephen Boyd

Support the CE_CLK and CODEC_SSBI_CLK. Also add support for uart, and i2c clocks on targets which support proc_comm clocks.

Quoted 7 lines
Quoted 3 lines

Basically when you catch yourself writing "also" in the commit text you need to re-evaluate making two patches.. In this case it looks appropriate..

Or it is just an argument to not use the word also in the commit text. I don't think it's really necessary to split up a patch that adds a few clocks to the clock table.

This one it actually makes a lot of sense to break it up. He's doing some very different things here all in the same patch ..

Daniel

Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#7 lore raw

Re: [PATCH 1/4] msm: clock: Remove unused code and definitions

In reply to Daniel Walker
Quoted 3 lines · Daniel Walker

He's adding stuff too .. So it's not _just_ removal which is what I was getting at.

I'll split this, no worries.

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.