Skip to content

RFC clk: Avoid potential deadlock when disabling unused clocks

Douglas Anderson linux-clk linux-pm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2PM: runtime: Add pm_runtime_try_put_sync() and pm_runtime_try_get_sync()drivers/base/power/runtime.c include/linux/pm_runtime.h+33 -22 replies
2/2clk: core: Avoid potential deadlock when disabling unused clocksdrivers/clk/clk.c+110 -270 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/2] clk: Avoid potential deadlock when disabling unused clocks

These two patches together fix a deadlock that I seem to be hitting every time with my particular setup (a sc7280-herobrine board running the downstream chromeos-5.15 kernel).

FWIW:
* Others tried with the very a similar setup to me and they didn't reproduce the hang, which makes sense after the analysis in the commit message of the clock patch. To hit this you just need to be lucky.
* I bisected this in our tree and landed on a cherry-pick of commit 1b771839de05 ("clk: qcom: gdsc: enable optional power domain support") as the first one where I saw the hang (and the "fix" of that commit upstream didn't change things). Nothing about that patch was directly touching the code paths that my analysis showed so I can only assume it changed the timing in a way to make this happen reliably for me.

While the solution proposed in this patch series doesn't seem too terrible to me, it's still not exactly elegant. This is why I'm marking it as an RFC. If someone wants to send out patches that solve this in a better way then I'd be more than happy.

NOTE also that at the same time I started getting the deadlock I also started getting a lockdep warning talking about similar locks. Unfortunately, the lockdep warning seems to be unrelated. This fix handles the deadlock but the lockdep still shows up. I can also fix the lockdep without fixing the deadlock. I'll send a separate patch about the lockdep.

Douglas Anderson (2):
PM: runtime: Add pm_runtime_try_put_sync() and
pm_runtime_try_get_sync()
clk: core: Avoid potential deadlock when disabling unused clocks

 drivers/base/power/runtime.c |   7 +-
 drivers/clk/clk.c            | 137 ++++++++++++++++++++++++++++-------
 include/linux/pm_runtime.h   |  28 +++++++
 3 files changed, 143 insertions(+), 29 deletions(-)
Signature · 1 line
2.37.3.968.ga6b4b080e4-goog