lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250326-cross-lock-dep-v1-8-3199e49e8652@bootlin.com>
Date: Wed, 26 Mar 2025 19:26:23 +0100
From: Miquel Raynal <miquel.raynal@...tlin.com>
To: "Rafael J. Wysocki" <rafael@...nel.org>, Pavel Machek <pavel@....cz>, 
 Len Brown <len.brown@...el.com>, 
 Greg Kroah-Hartman <gregkh@...uxfoundation.org>, 
 Danilo Krummrich <dakr@...nel.org>, 
 Michael Turquette <mturquette@...libre.com>, 
 Stephen Boyd <sboyd@...nel.org>
Cc: Thomas Petazzoni <thomas.petazzoni@...tlin.com>, 
 linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org, 
 linux-clk@...r.kernel.org, Chen-Yu Tsai <wenst@...omium.org>, 
 Lucas Stach <l.stach@...gutronix.de>, 
 Laurent Pinchart <laurent.pinchart@...asonboard.com>, 
 Marek Vasut <marex@...x.de>, Ulf Hansson <ulf.hansson@...aro.org>, 
 Kevin Hilman <khilman@...nel.org>, Fabio Estevam <festevam@...x.de>, 
 Jacky Bai <ping.bai@....com>, Peng Fan <peng.fan@....com>, 
 Shawn Guo <shawnguo@...nel.org>, Shengjiu Wang <shengjiu.wang@....com>, 
 linux-imx@....com, Ian Ray <ian.ray@...ealthcare.com>, 
 Hervé Codina <herve.codina@...tlin.com>, 
 Luca Ceresoli <luca.ceresoli@...tlin.com>, 
 Saravana Kannan <saravanak@...gle.com>, 
 Miquel Raynal <miquel.raynal@...tlin.com>
Subject: [PATCH RFC 08/10] clk: Move runtime PM calls out of the
 prepare_lock in clk_unregister()

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@...tlin.com>
---
 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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ