From: Guenter Roeck <linux@roeck-us.net>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Hari Nagalla <hnagalla@ti.com>, Nishanth Menon <nm@ti.com>,
Wim Van Sebroeck <wim@linux-watchdog.org>,
linux-watchdog@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] watchdog: rti_wdt: Fix calculation and evaluation of preset heartbeat
Date: Sat, 14 May 2022 07:00:46 -0700 [thread overview]
Message-ID: <20220514140046.GA1244552@roeck-us.net> (raw)
In-Reply-To: <6a4b54ac-9588-e172-c4c7-b91d524a851e@siemens.com>
On Mon, Feb 21, 2022 at 05:22:38PM +0100, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> This ensures that the same value is read back as was eventually
> programmed when using seconds as accuracy. Even then, comparing the more
> precise heartbeat_ms against heartbeat in seconds will almost never
> provide a match and will needlessly raise a warning. Fix by comparing
> apples to apples.
>
> Tested in combination with U-Boot as watchdog starter.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
>
> To fully work, it also needs a U-Boot patch to add the same 10% margin
> to the clock frequency:
>
> https://patchwork.ozlabs.org/project/uboot/patch/9b3603a3-1bf4-eb57-c378-20d5c2accc34@siemens.com/
>
> drivers/watchdog/rti_wdt.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c
> index 117bc2a8eb0a..3ecd14e180fb 100644
> --- a/drivers/watchdog/rti_wdt.c
> +++ b/drivers/watchdog/rti_wdt.c
> @@ -252,6 +252,7 @@ static int rti_wdt_probe(struct platform_device *pdev)
> }
>
> if (readl(wdt->base + RTIDWDCTRL) == WDENABLE_KEY) {
> + int preset_heartbeat;
> u32 time_left_ms;
> u64 heartbeat_ms;
> u32 wsize;
> @@ -262,11 +263,12 @@ static int rti_wdt_probe(struct platform_device *pdev)
> heartbeat_ms <<= WDT_PRELOAD_SHIFT;
> heartbeat_ms *= 1000;
> do_div(heartbeat_ms, wdt->freq);
> - if (heartbeat_ms != heartbeat * 1000)
> + preset_heartbeat = heartbeat_ms + 500;
> + preset_heartbeat /= 1000;
> + if (preset_heartbeat != heartbeat)
> dev_warn(dev, "watchdog already running, ignoring heartbeat config!\n");
>
> - heartbeat = heartbeat_ms;
> - heartbeat /= 1000;
> + heartbeat = preset_heartbeat;
>
> wsize = readl(wdt->base + RTIWWDSIZECTRL);
> ret = rti_wdt_setup_hw_hb(wdd, wsize);
prev parent reply other threads:[~2022-05-14 14:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-21 16:22 [PATCH] watchdog: rti_wdt: Fix calculation and evaluation of preset heartbeat Jan Kiszka
2022-05-14 14:00 ` 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=20220514140046.GA1244552@roeck-us.net \
--to=linux@roeck-us.net \
--cc=hnagalla@ti.com \
--cc=jan.kiszka@siemens.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=nm@ti.com \
--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