From: Sam Protsenko <semen.protsenko@linaro.org>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Wim Van Sebroeck <wim@linux-watchdog.org>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>,
linux-watchdog@vger.kernel.org,
devicetree <devicetree@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-arm Mailing List <linux-arm-kernel@lists.infradead.org>,
Linux Samsung SOC <linux-samsung-soc@vger.kernel.org>
Subject: Re: [PATCH 7/7] watchdog: s3c2410: Let kernel kick watchdog
Date: Sat, 30 Oct 2021 19:59:42 +0300 [thread overview]
Message-ID: <CAPLW+4kTANfSaw5g=rnJUJTMcT_J1Z8ju09kzmAPE70U_8KWDQ@mail.gmail.com> (raw)
In-Reply-To: <7c9a8dd4-7607-55a2-3d65-a445fa246667@roeck-us.net>
On Sat, 30 Oct 2021 at 18:14, Guenter Roeck <linux@roeck-us.net> wrote:
>
> On 10/30/21 7:29 AM, Sam Protsenko wrote:
> > On Fri, 29 Oct 2021 at 03:30, Guenter Roeck <linux@roeck-us.net> wrote:
> >>
> >> On 10/28/21 11:35 AM, Sam Protsenko wrote:
> >>> When "tmr_atboot" module param is set, the watchdog is started in
> >>> driver's probe. In that case, also set WDOG_HW_RUNNING bit to let
> >>> watchdog core driver know it's running. This way wathcdog core can kick
> >>> the watchdog for us (if CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED option is
> >>> enabled), until user space takes control.
> >>>
> >>> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> >>> ---
> >>> drivers/watchdog/s3c2410_wdt.c | 26 +++++++++++++++-----------
> >>> 1 file changed, 15 insertions(+), 11 deletions(-)
> >>>
> >>> diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
> >>> index ca082b1226e3..9af014ff1468 100644
> >>> --- a/drivers/watchdog/s3c2410_wdt.c
> >>> +++ b/drivers/watchdog/s3c2410_wdt.c
> >>> @@ -732,6 +732,21 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
> >>> wdt->wdt_device.bootstatus = s3c2410wdt_get_bootstatus(wdt);
> >>> wdt->wdt_device.parent = dev;
> >>>
> >>> + /*
> >>> + * If "tmr_atboot" param is non-zero, start the watchdog right now. Also
> >>> + * set WDOG_HW_RUNNING bit, so that watchdog core can kick the watchdog.
> >>> + *
> >>> + * If we're not enabling the watchdog, then ensure it is disabled if it
> >>> + * has been left running from the bootloader or other source.
> >>> + */
> >>> + if (tmr_atboot && started == 0) {
> >>> + dev_info(dev, "starting watchdog timer\n");
> >>> + s3c2410wdt_start(&wdt->wdt_device);
> >>> + set_bit(WDOG_HW_RUNNING, &wdt->wdt_device.status);
> >>> + } else if (!tmr_atboot) {
> >>> + s3c2410wdt_stop(&wdt->wdt_device);
> >>> + }
> >>> +
> >>
> >> This doesn't cover the case where the watchdog is already enabled by the BIOS.
> >> In that case, WDOG_HW_RUNNING won't be set, and the watchdog will time out
> >> if the userspace handler is not loaded fast enough. The code should consistently
> >> set WDOG_HW_RUNNING if the watchdog is running.
> >>
> >
> > As I understand, in the case when bootloader started the watchdog, the
> > driver just stops it. You can see it in the code you replied to.
> >
> > } else if (!tmr_atboot) {
> > s3c2410wdt_stop(&wdt->wdt_device);
> >
> > In other words, having "tmr_atboot" module param makes it irrelevant
> > whether bootloader enabled WDT or no.
> >
>
> Sure, but I am concerned about "if (tmr_atboot && started)", which doesn't
> set WDOG_HW_RUNNING with your current code, and I was looking for something
> like
>
> if (tmr_atboot) {
> if (!started) {
> dev_info(dev, "starting watchdog timer\n");
> s3c2410wdt_start(&wdt->wdt_device);
> }
> set_bit(WDOG_HW_RUNNING, &wdt->wdt_device.status);
> } else {
> s3c2410wdt_stop(&wdt->wdt_device);
> }
>
Wow, I really overlooked that case. Nice catch! Not having '} else {'
section is vicious...
Though if started != 0, it means s3c2410wdt_set_heartbeat() failed to
set wdd->timeout, and without that the watchdog core won't be able to
calculate correctly ping interval in watchdog_next_keepalive(), and
WDOG_HW_RUNNING bit won't do much good, right? So I'll probably just
call s3c2410wdt_stop() in that case, to be on the safe side.
Also this 'started' variable name is misleading, I'll convert it to
"bool timeout_ok" while at it.
> Guenter
next prev parent reply other threads:[~2021-10-30 17:00 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-28 18:35 [PATCH 0/7] watchdog: s3c2410: Add Exynos850 support Sam Protsenko
2021-10-28 18:35 ` [PATCH 1/7] dt-bindings: watchdog: Require samsung,syscon-phandle for Exynos7 Sam Protsenko
2021-10-29 7:55 ` Krzysztof Kozlowski
2021-10-28 18:35 ` [PATCH 2/7] dt-bindings: watchdog: Document Exynos850 watchdog bindings Sam Protsenko
2021-10-29 8:02 ` Krzysztof Kozlowski
2021-10-29 17:48 ` Sam Protsenko
2021-10-28 18:35 ` [PATCH 3/7] watchdog: s3c2410: Make reset disable optional Sam Protsenko
2021-10-29 0:16 ` Guenter Roeck
2021-10-29 8:04 ` Krzysztof Kozlowski
2021-10-29 19:25 ` Sam Protsenko
2021-10-29 19:23 ` Sam Protsenko
2021-10-28 18:35 ` [PATCH 4/7] watchdog: s3c2410: Add support for WDT counter enable Sam Protsenko
2021-10-29 0:16 ` Guenter Roeck
2021-10-29 20:44 ` Sam Protsenko
2021-10-28 18:35 ` [PATCH 5/7] watchdog: s3c2410: Introduce separate source clock Sam Protsenko
2021-10-29 0:21 ` Guenter Roeck
2021-10-30 12:39 ` Sam Protsenko
2021-10-29 8:18 ` Krzysztof Kozlowski
2021-10-30 14:12 ` Sam Protsenko
2021-10-28 18:35 ` [PATCH 6/7] watchdog: s3c2410: Add Exynos850 support Sam Protsenko
2021-10-28 18:35 ` [PATCH 7/7] watchdog: s3c2410: Let kernel kick watchdog Sam Protsenko
2021-10-29 0:30 ` Guenter Roeck
2021-10-30 14:29 ` Sam Protsenko
2021-10-30 15:14 ` Guenter Roeck
2021-10-30 16:59 ` Sam Protsenko [this message]
2021-10-30 17:47 ` Guenter Roeck
2021-10-30 19:25 ` Sam Protsenko
2021-10-29 8:20 ` Krzysztof Kozlowski
2021-10-30 14:59 ` Sam Protsenko
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='CAPLW+4kTANfSaw5g=rnJUJTMcT_J1Z8ju09kzmAPE70U_8KWDQ@mail.gmail.com' \
--to=semen.protsenko@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski@canonical.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).