Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ed69e69b authored by Vikram Mulukutla's avatar Vikram Mulukutla
Browse files

msm: clock-debug: Modify measure logic to account for multiple CCs



In the near future, multiple clock controllers will be
registered, each with their own lookup tables. Modify
the debugfs measure node creation logic to account for
this. The assumption is that there will be one measure
clock that will apply to all clock controllers.

Change-Id: I8d2d7a6df2a7a0228bdc7fbc743d5207f2a1bab0
Signed-off-by: default avatarVikram Mulukutla <markivx@codeaurora.org>
parent e344168f
Loading
Loading
Loading
Loading
+40 −23
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@
#include "clock.h"

static LIST_HEAD(clk_list);
static DEFINE_SPINLOCK(clk_list_lock);
static DEFINE_MUTEX(clk_list_lock);

static struct dentry *debugfs_base;
static u32 debug_suspend;
@@ -275,16 +275,18 @@ static int clock_debug_print_clock(struct clk *c, struct seq_file *m)
static void clock_debug_print_enabled_clocks(struct seq_file *m)
{
	struct clk_table *table;
	unsigned long flags;
	int i, cnt = 0;

	if (!mutex_trylock(&clk_list_lock)) {
		pr_err("clock-debug: Clocks are being registered. Cannot print clock state now.\n");
		return;
	}
	clock_debug_output(m, 0, "Enabled clocks:\n");
	spin_lock_irqsave(&clk_list_lock, flags);
	list_for_each_entry(table, &clk_list, node) {
		for (i = 0; i < table->num_clocks; i++)
			cnt += clock_debug_print_clock(table->clocks[i].clk, m);
	}
	spin_unlock_irqrestore(&clk_list_lock, flags);
	mutex_unlock(&clk_list_lock);

	if (cnt)
		clock_debug_output(m, 0, "Enabled clock count: %d\n", cnt);
@@ -368,7 +370,6 @@ static ssize_t clock_parent_write(struct file *filp,
	struct clk *clock = filp->private_data;
	char buf[256];
	char *cmp;
	unsigned long flags;
	struct clk_table *table;
	int i, ret;
	struct clk *parent = NULL;
@@ -379,7 +380,7 @@ static ssize_t clock_parent_write(struct file *filp,
	buf[cnt] = '\0';
	cmp = strstrip(buf);

	spin_lock_irqsave(&clk_list_lock, flags);
	mutex_lock(&clk_list_lock);
	list_for_each_entry(table, &clk_list, node) {
		for (i = 0; i < table->num_clocks; i++)
			if (!strcmp(cmp, table->clocks[i].clk->dbg_name)) {
@@ -395,14 +396,14 @@ static ssize_t clock_parent_write(struct file *filp,
		goto err;
	}

	spin_unlock_irqrestore(&clk_list_lock, flags);
	mutex_unlock(&clk_list_lock);
	ret = clk_set_parent(clock, table->clocks[i].clk);
	if (ret)
		return ret;

	return cnt;
err:
	spin_unlock_irqrestore(&clk_list_lock, flags);
	mutex_unlock(&clk_list_lock);
	return ret;
}

@@ -463,6 +464,18 @@ static const struct file_operations clock_print_hw_fops = {
};


static void clock_measure_add(struct clk *clock)
{
	if (IS_ERR_OR_NULL(measure))
		return;

	if (clk_set_parent(measure, clock))
		return;

	debugfs_create_file("measure", S_IRUGO, clock->clk_dir, clock,
				&clock_measure_fops);
}

static int clock_debug_add(struct clk *clock)
{
	char temp[50], *ptr;
@@ -479,6 +492,8 @@ static int clock_debug_add(struct clk *clock)
	if (!clk_dir)
		return -ENOMEM;

	clock->clk_dir = clk_dir;

	if (!debugfs_create_file("rate", S_IRUGO | S_IWUSR, clk_dir,
				clock, &clock_rate_fops))
		goto error;
@@ -495,12 +510,6 @@ static int clock_debug_add(struct clk *clock)
				&clock_hwcg_fops))
		goto error;

	if (measure &&
	    !clk_set_parent(measure, clock) &&
	    !debugfs_create_file("measure", S_IRUGO, clk_dir, clock,
				&clock_measure_fops))
		goto error;

	if (clock->ops->list_rate)
		if (!debugfs_create_file("list_rates",
				S_IRUGO, clk_dir, clock, &list_rates_fops))
@@ -518,6 +527,8 @@ static int clock_debug_add(struct clk *clock)
				&clock_print_hw_fops))
			goto error;

	clock_measure_add(clock);

	return 0;
error:
	debugfs_remove_recursive(clk_dir);
@@ -551,10 +562,6 @@ static int clock_debug_init(void)
				&enabled_clocks_fops))
		return -ENOMEM;

	measure = clk_get_sys("debug", "measure");
	if (IS_ERR(measure))
		measure = NULL;

	return 0;
}

@@ -566,8 +573,7 @@ static int clock_debug_init(void)
 */
int clock_debug_register(struct clk_lookup *table, size_t size)
{
	struct clk_table *clk_table;
	unsigned long flags;
	struct clk_table *clk_table, *clk_table_tmp;
	int i, ret;

	mutex_lock(&clk_debug_lock);
@@ -585,13 +591,24 @@ int clock_debug_register(struct clk_lookup *table, size_t size)
	clk_table->clocks = table;
	clk_table->num_clocks = size;

	spin_lock_irqsave(&clk_list_lock, flags);
	if (IS_ERR_OR_NULL(measure)) {
		measure = clk_get_sys("debug", "measure");
		if (!IS_ERR(measure)) {
			mutex_lock(&clk_list_lock);
			list_for_each_entry(clk_table_tmp, &clk_list, node) {
			for (i = 0; i < clk_table_tmp->num_clocks; i++)
				clock_measure_add(clk_table_tmp->clocks[i].clk);
			}
			mutex_unlock(&clk_list_lock);
		}
	}

	mutex_lock(&clk_list_lock);
	list_add_tail(&clk_table->node, &clk_list);
	spin_unlock_irqrestore(&clk_list_lock, flags);
	mutex_unlock(&clk_list_lock);

	for (i = 0; i < size; i++)
		clock_debug_add(table[i].clk);

out:
	mutex_unlock(&clk_debug_lock);
	return ret;
+2 −0
Original line number Diff line number Diff line
@@ -178,6 +178,8 @@ struct clk {
	spinlock_t lock;
	unsigned prepare_count;
	struct mutex prepare_lock;

	struct dentry *clk_dir;
};

#define CLK_INIT(name) \