Re: [PATCH v2] watchdog: npcm: fix sleeping clock call in restart handler
From: Guenter Roeck
Date: Sat Nov 14 2026 - 12:15:06 EST
On Wed, Nov 11, 2026 at 04:32:36PM +0800, zhaofeng2@xxxxxxxxxxxxxxxxxxxx wrote:
> From: Zhao Feng <zhaofeng2@xxxxxxxxxxxxxxxxxxxx>
>
> The watchdog .restart callback runs in atomic context: it is invoked
> from the restart handler chain via atomic_notifier_call_chain(), under
> an RCU read-side critical section, on every reboot or restart. Since
> commit af084fdccfaf ("watchdog: npcm: Enable clock if provided"),
> npcm_wdt_restart() calls clk_prepare_enable(), and clk_prepare()
> takes a mutex unconditionally, so kernels built with
> CONFIG_DEBUG_ATOMIC_SLEEP=y report
>
> BUG: sleeping function called from invalid context
>
> on every reboot. Worse, a panic-time restart can block on
> prepare_lock and never issue the reset at all.
>
> Get the clock with devm_clk_get_optional_prepared() at probe time and
> keep it prepared for the lifetime of the driver, so the restart
> handler only needs clk_enable(), which is safe in atomic context.
> With the clock permanently prepared, npcm_wdt_start() and
> npcm_wdt_stop() are simplified to clk_enable()/clk_disable() as well.
>
> Fixes: af084fdccfaf ("watchdog: npcm: Enable clock if provided")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Zhao Feng <zhaofeng2@xxxxxxxxxxxxxxxxxxxx>
Applied.
Thanks,
Guenter