[PATCH RFC 08/10] clk: Move runtime PM calls out of the prepare_lock in clk_unregister()
From: Miquel Raynal
Date: Wed Mar 26 2025 - 14:28:27 EST
In order to fix the ABBA locking situation between clock and power
domains, let's disimburse these two locks by preventing any runtime PM
call to happen with the clk prepare_lock mutex acquired.
The clk_unregister() routine calls clk_core_set_parent_nolock() which
can runtime resume basically any clock randomly in the system after
having acquired the main clk lock. In this case the easier approach to
avoid failures is to make sure we wake up all runtime PM enabled clocks
in the system before acquiring the lock. We are not in a hot path
anyway.
Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>
---
drivers/clk/clk.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 4c2f2d2b7735dfbe323fec4e0d331302534bc849..339ebfa8cca729ffb84127e01a21f741bc270cb3 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -4574,6 +4574,9 @@ void clk_unregister(struct clk *clk)
clk_debug_unregister(clk->core);
+ if (clk_pm_runtime_get_all())
+ return;
+
clk_prepare_lock();
ops = clk->core->ops;
@@ -4617,6 +4620,8 @@ void clk_unregister(struct clk *clk)
__func__, clk->core->name);
clk_prepare_unlock();
+ clk_pm_runtime_put_all();
+
kref_put(&clk->core->ref, __clk_release);
free_clk(clk);
}
--
2.48.1