mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Alexey Charkov <alchark@gmail.com>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Daniel Lezcano <daniel.lezcano@kernel.org>,
	Thomas Gleixner <tglx@kernel.org>,
	Wim Van Sebroeck <wim@linux-watchdog.org>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org
Subject: Re: [PATCH v6 4/4] watchdog: vt8500: Add a restart handler
Date: Thu, 12 Nov 2026 16:42:41 -0800	[thread overview]
Message-ID: <468e51cb-5852-4c8a-938d-bda2aca8c83e@roeck-us.net> (raw)
In-Reply-To: <20261112-vt8500-timer-updates-v6-4-fd1cea645d1f@gmail.com>

On 11/12/26 10:55, Alexey Charkov wrote:
> Reset the SoC through the watchdog when the machine's own restart hook
> leaves it running: the PMSR write in vt8500_restart() has no effect on
> WM8950, so a reboot there ends in "Reboot failed -- System halted"
> unless a watchdog armed from userspace happens to fire.
> 
> Arm the match a millisecond ahead of the current count, which leaves
> ample margin for the register writes to land.
> 
> Register at priority 128, the default for restart handlers and also the
> priority of the ARM machine restart hook. That hook is registered first,
> from setup_arch(), and handlers of equal priority run in registration
> order, so this one runs right after it and only matters where the hook
> fails to reset the SoC.

This isn't really the idea of restart handlers. The sequence should be well
defined. That is what the priorities are for. Why not give it a slightly
lower priority ?

> 
> Signed-off-by: Alexey Charkov <alchark@gmail.com>
> ---
>   drivers/watchdog/vt8500-wdt.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/watchdog/vt8500-wdt.c b/drivers/watchdog/vt8500-wdt.c
> index e0f838fd1d50..0ce1e2b06410 100644
> --- a/drivers/watchdog/vt8500-wdt.c
> +++ b/drivers/watchdog/vt8500-wdt.c
> @@ -25,6 +25,9 @@
>   
>   #define VT8500_WDT_DEFAULT_TIMEOUT	30	/* seconds */
>   
> +/* How far ahead of the current count to arm the match for a restart */
> +#define VT8500_WDT_RESTART_TICKS	(VT8500_TIMER_HZ / 1000)	/* 1 ms */
> +
>   static bool nowayout = WATCHDOG_NOWAYOUT;
>   module_param(nowayout, bool, 0);
>   MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
> @@ -75,9 +78,18 @@ static int vt8500_watchdog_stop(struct watchdog_device *wdd)
>   	return 0;
>   }
>   
> +static int vt8500_watchdog_restart(struct watchdog_device *wdd,
> +				   unsigned long action, void *data)
> +{
> +	struct vt8500_wdt_info *info = watchdog_get_drvdata(wdd);
> +
> +	return vt8500_watchdog_arm(info, VT8500_WDT_RESTART_TICKS);

This sets a 1-ms timer and doesn't wait for it to fire, so the next
restart handler (if it exists) will be called. That seems odd,
and may introduce unexpected behavior. Is this intentional ? If so,
it should be explained.

Thanks,
Guenter

> +}
> +
>   static const struct watchdog_ops vt8500_watchdog_ops = {
>   	.start			= vt8500_watchdog_start,
>   	.stop			= vt8500_watchdog_stop,
> +	.restart		= vt8500_watchdog_restart,
>   };
>   
>   static const struct watchdog_info vt8500_watchdog_info = {
> @@ -107,6 +119,7 @@ static int vt8500_wdt_probe(struct auxiliary_device *auxdev,
>   	info = container_of(auxdev, struct vt8500_wdt_info, auxdev);
>   	watchdog_set_drvdata(wdd, info);
>   	watchdog_set_nowayout(wdd, nowayout);
> +	watchdog_set_restart_priority(wdd, 128);
>   
>   	/* Let the core feed a watchdog left running, e.g. across kexec */
>   	if (readl(info->regbase + VT8500_WDT_EN_REG) & VT8500_WDT_EN)
> 


      reply	other threads:[~2026-11-13  0:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 18:55 [PATCH v6 0/4] clocksource/drivers/timer-vt8500: clean up and add watchdog function Alexey Charkov
2026-11-12 18:55 ` [PATCH v6 1/4] clocksource/drivers/timer-vt8500: Add defines for magic constants Alexey Charkov
2026-11-12 18:55 ` [PATCH v6 2/4] clocksource/drivers/timer-vt8500: Prepare for watchdog functionality Alexey Charkov
2026-11-12 18:55 ` [PATCH v6 3/4] watchdog: Add support for VIA/WonderMedia SoC " Alexey Charkov
2026-11-12 18:55 ` [PATCH v6 4/4] watchdog: vt8500: Add a restart handler Alexey Charkov
2026-11-13  0:42   ` Guenter Roeck [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=468e51cb-5852-4c8a-938d-bda2aca8c83e@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=alchark@gmail.com \
    --cc=daniel.lezcano@kernel.org \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=tglx@kernel.org \
    --cc=wim@linux-watchdog.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®