Re: [PATCH v4 2/2] watchdog: dw_wdt: manage reset line during system suspend/resume
From: Artem Shimko
Date: Sun Oct 25 2026 - 14:33:31 EST
Hi Igor,
On Sat, Oct 24, 2026 at 9:46 PM Igor Velkov <iav@xxxxxx> wrote:
>
> On Sat, Oct 24, 2026 at 05:08:51PM +0300, Artem Shimko wrote:
> > err = clk_prepare_enable(dw_wdt->pclk);
> > - if (err) {
> > - clk_disable_unprepare(dw_wdt->clk);
> > - return err;
> > - }
> > + if (err)
> > + goto unprepare_clk;
> > +
> > + err = reset_control_deassert(dw_wdt->rst);
> > + if (err)
> > + goto unprepare_pclk;
>
> If clk_prepare_enable() fails in dw_wdt_resume(), we return with the reset
> still asserted. The _deasserted devres then asserts it once more at unbind,
> and on a shared control with deassert_count already at 0 that is a WARN_ON
> and -EINVAL; the next suspend hits the same. Deasserting before the clocks
> are enabled (or on the error paths) keeps every exit balanced.
> Not tested on hardware: I can't make the clock enable fail.
The official datasheet DW_apb_wdt_databook says:
The reset must be de-asserted synchronously after the rising edge of tclk.
That means we can't switch the sequence of clk and reset in suspend/resume.
At the same time, we can't do a deassert reset in the error paths by this
reason as well (when we have errors in clocks).
Given this, i think the WARN_ON on a clock failure is a minor concern
comparing to violating the hardware synchronization requirement. I'd
prefer to keep v4 as it is and not to send v5.
Best regards,
Artem