Skip to content

Commit

Permalink
clk: Get runtime PM before walking tree for clk_summary
Browse files Browse the repository at this point in the history
[ Upstream commit 9d1e795 ]

Similar to the previous commit, we should make sure that all devices are
runtime resumed before printing the clk_summary through debugfs. Failure
to do so would result in a deadlock if the thread is resuming a device
to print clk state and that device is also runtime resuming in another
thread, e.g the screen is turning on and the display driver is starting
up. We remove the calls to clk_pm_runtime_{get,put}() in this path
because they're superfluous now that we know the devices are runtime
resumed. This also squashes a bug where the return value of
clk_pm_runtime_get() wasn't checked, leading to an RPM count underflow
on error paths.

Fixes: 1bb294a ("clk: Enable/Disable runtime PM for clk_summary")
Cc: Taniya Das <quic_tdas@quicinc.com>
Cc: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20240325184204.745706-6-sboyd@kernel.org
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
bebarino authored and gregkh committed Apr 27, 2024
1 parent 888a44f commit 2c077fd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions drivers/clk/clk.c
Expand Up @@ -3321,9 +3321,7 @@ static void clk_summary_show_subtree(struct seq_file *s, struct clk_core *c,
{
struct clk_core *child;

clk_pm_runtime_get(c);
clk_summary_show_one(s, c, level);
clk_pm_runtime_put(c);

hlist_for_each_entry(child, &c->children, child_node)
clk_summary_show_subtree(s, child, level + 1);
Expand All @@ -3333,11 +3331,15 @@ static int clk_summary_show(struct seq_file *s, void *data)
{
struct clk_core *c;
struct hlist_head **lists = s->private;
int ret;

seq_puts(s, " enable prepare protect duty hardware connection\n");
seq_puts(s, " clock count count count rate accuracy phase cycle enable consumer id\n");
seq_puts(s, "---------------------------------------------------------------------------------------------------------------------------------------------\n");

ret = clk_pm_runtime_get_all();
if (ret)
return ret;

clk_prepare_lock();

Expand All @@ -3346,6 +3348,7 @@ static int clk_summary_show(struct seq_file *s, void *data)
clk_summary_show_subtree(s, c, 0);

clk_prepare_unlock();
clk_pm_runtime_put_all();

return 0;
}
Expand Down Expand Up @@ -3393,8 +3396,14 @@ static int clk_dump_show(struct seq_file *s, void *data)
struct clk_core *c;
bool first_node = true;
struct hlist_head **lists = s->private;
int ret;

ret = clk_pm_runtime_get_all();
if (ret)
return ret;

seq_putc(s, '{');

clk_prepare_lock();

for (; *lists; lists++) {
Expand All @@ -3407,6 +3416,7 @@ static int clk_dump_show(struct seq_file *s, void *data)
}

clk_prepare_unlock();
clk_pm_runtime_put_all();

seq_puts(s, "}\n");
return 0;
Expand Down

0 comments on commit 2c077fd

Please sign in to comment.