public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] Fix a deadlock with clk_pm_runtime_get()
@ 2024-03-25 18:41 Stephen Boyd
  2024-03-25 18:41 ` [PATCH v2 1/5] clk: Remove prepare_lock hold assertion in __clk_release() Stephen Boyd
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Stephen Boyd @ 2024-03-25 18:41 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: linux-kernel, linux-clk, patches, linux-arm-msm, Douglas Anderson,
	Krzysztof Kozlowski, Marek Szyprowski, Taniya Das, Ulf Hansson

This patch series fixes a deadlock reported[1] on ChromeOS devices
(Qualcomm sc7180 Trogdor). To get there, we allow __clk_release() to run
without the prepare_lock held. Then we add runtime PM enabled clk_core
structs to a list that we iterate and enable runtime PM for each entry
before grabbing the prepare_lock to walk the clk tree. The details are
in patch #4.

The patch after that is based on the analysis in the disable unused
patch. We similarly resume devices from runtime suspend when walking the
clk tree for the debugfs clk_summary.

Unfortunately this doesn't fix all problems with the usage of runtime PM
in the clk framework. We still have a problem if preparing a clk happens
in parallel to the device providing that clk runtime resuming or
suspending. In that case, the task will go to sleep waiting for the
runtime PM state to change, and we'll deadlock. This is primarily a
problem with the global prepare_lock. I suspect we'll be able to fix
this by implementing per-clk locking, because then we will be able to
split up the big prepare_lock into smaller locks that don't deadlock on
some device runtime PM transitions.

I'll start working on that problem in earnest now because I'm worried
we're going to run into that problem very soon.

Changes from v1 (https://lore.kernel.org/r/):
 * Check return value of clk_pm_runtime_get_all() in last patch
 * Fix order of args for error print in clk_pm_runtime_get_all()
 * Pick up review tags
 * Move clk_pm_runtime_{get,put}_all() to the pm runtime section
 * Use kernel-doc for function comments
 * Drop clk_pm_runtime_{get,put}() calls when they're not doing anything

Stephen Boyd (5):
  clk: Remove prepare_lock hold assertion in __clk_release()
  clk: Don't hold prepare_lock when calling kref_put()
  clk: Initialize struct clk_core kref earlier
  clk: Get runtime PM before walking tree during disable_unused
  clk: Get runtime PM before walking tree for clk_summary

 drivers/clk/clk.c | 173 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 135 insertions(+), 38 deletions(-)

Cc: Douglas Anderson <dianders@chromium.org>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Taniya Das <quic_tdas@quicinc.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>

[1] https://lore.kernel.org/all/20220922084322.RFC.2.I375b6b9e0a0a5348962f004beb3dafee6a12dfbb@changeid/

base-commit: e8f897f4afef0031fe618a8e94127a0934896aba
-- 
https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/
https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-04-09 11:55 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-25 18:41 [PATCH v2 0/5] Fix a deadlock with clk_pm_runtime_get() Stephen Boyd
2024-03-25 18:41 ` [PATCH v2 1/5] clk: Remove prepare_lock hold assertion in __clk_release() Stephen Boyd
2024-04-08  2:35   ` Stephen Boyd
2024-03-25 18:41 ` [PATCH v2 2/5] clk: Don't hold prepare_lock when calling kref_put() Stephen Boyd
2024-04-08  2:35   ` Stephen Boyd
2024-03-25 18:41 ` [PATCH v2 3/5] clk: Initialize struct clk_core kref earlier Stephen Boyd
2024-04-08  2:36   ` Stephen Boyd
2024-03-25 18:41 ` [PATCH v2 4/5] clk: Get runtime PM before walking tree during disable_unused Stephen Boyd
2024-03-25 19:39   ` Doug Anderson
2024-04-08  2:36   ` Stephen Boyd
2024-04-09 10:32     ` Ulf Hansson
2024-04-09 11:55       ` Stephen Boyd
2024-03-25 18:41 ` [PATCH v2 5/5] clk: Get runtime PM before walking tree for clk_summary Stephen Boyd
2024-03-25 19:39   ` Doug Anderson
2024-04-08  2:37   ` Stephen Boyd
2024-03-25 18:44 ` [PATCH v2 0/5] Fix a deadlock with clk_pm_runtime_get() Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox