avr32: fix deadlock when reading clock list in debugfs
When writing out /sys/kernel/debug/at32ap_clk, clock list lock is being held while clk_get() is called. clk_get() attempts to take the same lock, which results in deadlock. Introduce and call lock free version, __clk_get(), instead. Signed-off-by: Ole Henrik Jahren <olehenja@alumni.ntnu.no> Cc: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com> Signed-off-by: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
This commit is contained in:
parent
51ef85d8f9
commit
6e2ad51190
1 changed files with 20 additions and 12 deletions
|
@ -35,22 +35,30 @@ void at32_clk_register(struct clk *clk)
|
||||||
spin_unlock(&clk_list_lock);
|
spin_unlock(&clk_list_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct clk *__clk_get(struct device *dev, const char *id)
|
||||||
|
{
|
||||||
|
struct clk *clk;
|
||||||
|
|
||||||
|
list_for_each_entry(clk, &at32_clock_list, list) {
|
||||||
|
if (clk->dev == dev && strcmp(id, clk->name) == 0) {
|
||||||
|
return clk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ERR_PTR(-ENOENT);
|
||||||
|
}
|
||||||
|
|
||||||
struct clk *clk_get(struct device *dev, const char *id)
|
struct clk *clk_get(struct device *dev, const char *id)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
|
|
||||||
spin_lock(&clk_list_lock);
|
spin_lock(&clk_list_lock);
|
||||||
|
clk = __clk_get(dev, id);
|
||||||
list_for_each_entry(clk, &at32_clock_list, list) {
|
|
||||||
if (clk->dev == dev && strcmp(id, clk->name) == 0) {
|
|
||||||
spin_unlock(&clk_list_lock);
|
spin_unlock(&clk_list_lock);
|
||||||
|
|
||||||
return clk;
|
return clk;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
spin_unlock(&clk_list_lock);
|
|
||||||
return ERR_PTR(-ENOENT);
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL(clk_get);
|
EXPORT_SYMBOL(clk_get);
|
||||||
|
|
||||||
void clk_put(struct clk *clk)
|
void clk_put(struct clk *clk)
|
||||||
|
@ -257,15 +265,15 @@ static int clk_show(struct seq_file *s, void *unused)
|
||||||
spin_lock(&clk_list_lock);
|
spin_lock(&clk_list_lock);
|
||||||
|
|
||||||
/* show clock tree as derived from the three oscillators */
|
/* show clock tree as derived from the three oscillators */
|
||||||
clk = clk_get(NULL, "osc32k");
|
clk = __clk_get(NULL, "osc32k");
|
||||||
dump_clock(clk, &r);
|
dump_clock(clk, &r);
|
||||||
clk_put(clk);
|
clk_put(clk);
|
||||||
|
|
||||||
clk = clk_get(NULL, "osc0");
|
clk = __clk_get(NULL, "osc0");
|
||||||
dump_clock(clk, &r);
|
dump_clock(clk, &r);
|
||||||
clk_put(clk);
|
clk_put(clk);
|
||||||
|
|
||||||
clk = clk_get(NULL, "osc1");
|
clk = __clk_get(NULL, "osc1");
|
||||||
dump_clock(clk, &r);
|
dump_clock(clk, &r);
|
||||||
clk_put(clk);
|
clk_put(clk);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue