* [RFC/PATCH] clk: add lockdep_ignore_clk_prepare_lock cmdline option [not found] <CGME20260828131428eucas1p2cc2d9767d5ed62b8297c2cff0295226d@eucas1p2.samsung.com> @ 2026-08-28 13:14 ` Marek Szyprowski 2026-08-28 13:38 ` Peter Zijlstra 0 siblings, 1 reply; 2+ messages in thread From: Marek Szyprowski @ 2026-08-28 13:14 UTC (permalink / raw) To: linux-clk, linux-kernel, linux-pwm Cc: Marek Szyprowski, Stephen Boyd, Brian Masney, Jerome Brunet, Peter Zijlstra, Ingo Molnar, Will Deacon, Waiman Long, we Kleine-König The clock framework uses a single global re-entrant mutex, prepare_lock, to serialize all operations on the whole clock tree. It is taken by nearly every clk API call and it is held while calling into the clock providers, which in turn often take their own locks or trigger runtime PM. As a result prepare_lock sits in the middle of a large number of lock chains and lockdep frequently reports possible circular locking dependencies involving it. Such reports are often not real deadlocks, but once the first one is hit lockdep turns itself off and all subsequent locking problems - including the ones actually being investigated - are no longer reported. Add a "lockdep_ignore_clk_prepare_lock" kernel command line parameter, which marks the prepare_lock class as novalidate, so lockdep skips the dependency tracking for it and keeps validating the rest of the system. The option is only available when CONFIG_LOCKDEP is enabled and is meant purely as a debugging aid. Assisted-by: Claude:claude-opus-5 Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> --- The problems with clock framework's prepare_lock are well known and there are machines that always report lockdep issues related to it. A good example are Khadas VIM3/VIM3l boards, on which prepare_lock interferes with locks used in PWM subsytem: https://lore.kernel.org/all/adqtn6iljcguv3m3ovhltusbbf4mljzlwg73yklaudvjjtazxv@vyf5fvuzic6x/ This new cmdline option allows to hide prepare_lock related issues on the test machines possibly enabling lockdep to catch other issues. Best regards, Marek Szyprowski --- drivers/clk/clk.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index fef87167a60b..a5c8c4256102 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -168,6 +168,17 @@ struct clk { struct hlist_node clks_node; }; +#ifdef CONFIG_LOCKDEP +static int __init lockdep_ignore_clk_prepare_lock_setup(char *__unused) +{ + lockdep_set_novalidate_class(&prepare_lock); + pr_warn("lockdep: ignoring prepare_lock class in clock subsystem\n"); + return 1; +} +__setup("lockdep_ignore_clk_prepare_lock", + lockdep_ignore_clk_prepare_lock_setup); +#endif + /*** runtime pm ***/ static int clk_pm_runtime_get(struct clk_core *core) { -- 2.43.0 ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFC/PATCH] clk: add lockdep_ignore_clk_prepare_lock cmdline option 2026-08-28 13:14 ` [RFC/PATCH] clk: add lockdep_ignore_clk_prepare_lock cmdline option Marek Szyprowski @ 2026-08-28 13:38 ` Peter Zijlstra 0 siblings, 0 replies; 2+ messages in thread From: Peter Zijlstra @ 2026-08-28 13:38 UTC (permalink / raw) To: Marek Szyprowski Cc: linux-clk, linux-kernel, linux-pwm, Stephen Boyd, Brian Masney, Jerome Brunet, Ingo Molnar, Will Deacon, Waiman Long, we Kleine-König On Fri, Aug 28, 2026 at 03:14:07PM +0200, Marek Szyprowski wrote: > The clock framework uses a single global re-entrant mutex, prepare_lock, There is no such primitive in the kernel -- this means the clock people rolled their own. Why ?! > to serialize all operations on the whole clock tree. It is taken by > nearly every clk API call and it is held while calling into the clock > providers, which in turn often take their own locks or trigger runtime > PM. As a result prepare_lock sits in the middle of a large number of > lock chains and lockdep frequently reports possible circular locking > dependencies involving it. > > Such reports are often not real deadlocks, but once the first one is hit > lockdep turns itself off and all subsequent locking problems - including > the ones actually being investigated - are no longer reported. > > Add a "lockdep_ignore_clk_prepare_lock" kernel command line parameter, > which marks the prepare_lock class as novalidate, so lockdep skips the > dependency tracking for it and keeps validating the rest of the system. > > The option is only available when CONFIG_LOCKDEP is enabled and is meant > purely as a debugging aid. > > Assisted-by: Claude:claude-opus-5 > Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> > --- > The problems with clock framework's prepare_lock are well known and > there are machines that always report lockdep issues related to it. A > good example are Khadas VIM3/VIM3l boards, on which prepare_lock > interferes with locks used in PWM subsytem: > > https://lore.kernel.org/all/adqtn6iljcguv3m3ovhltusbbf4mljzlwg73yklaudvjjtazxv@vyf5fvuzic6x/ > > This new cmdline option allows to hide prepare_lock related issues on > the test machines possibly enabling lockdep to catch other issues. This is horrible. Why not fix the clock framework? ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-28 13:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20260828131428eucas1p2cc2d9767d5ed62b8297c2cff0295226d@eucas1p2.samsung.com>
2026-08-28 13:14 ` [RFC/PATCH] clk: add lockdep_ignore_clk_prepare_lock cmdline option Marek Szyprowski
2026-08-28 13:38 ` Peter Zijlstra
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®