From: Tero Kristo <t-kristo@ti.com>
To: Guenter Roeck <linux@roeck-us.net>,
Jan Kiszka <jan.kiszka@siemens.com>, <wim@linux-watchdog.org>,
<linux-watchdog@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] watchdog: rti: tweak min_hw_heartbeat_ms to match initial allowed window
Date: Thu, 25 Jun 2020 20:04:50 +0300 [thread overview]
Message-ID: <1d84e633-b808-d6ac-a34c-9cc4709e43f6@ti.com> (raw)
In-Reply-To: <25bf3ed1-5434-9b45-20ae-e1b2cfc5e5c0@roeck-us.net>
On 25/06/2020 16:35, Guenter Roeck wrote:
> On 6/25/20 1:32 AM, Tero Kristo wrote:
>> On 24/06/2020 18:24, Jan Kiszka wrote:
>>> On 24.06.20 13:45, Tero Kristo wrote:
>>>> If the RTI watchdog has been started by someone (like bootloader) when
>>>> the driver probes, we must adjust the initial ping timeout to match the
>>>> currently running watchdog window to avoid generating watchdog reset.
>>>>
>>>> Signed-off-by: Tero Kristo <t-kristo@ti.com>
>>>> ---
>>>> drivers/watchdog/rti_wdt.c | 25 +++++++++++++++++++++++++
>>>> 1 file changed, 25 insertions(+)
>>>>
>>>> diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c
>>>> index d456dd72d99a..02ea2b2435f5 100644
>>>> --- a/drivers/watchdog/rti_wdt.c
>>>> +++ b/drivers/watchdog/rti_wdt.c
>>>> @@ -55,11 +55,13 @@ static int heartbeat;
>>>> * @base - base io address of WD device
>>>> * @freq - source clock frequency of WDT
>>>> * @wdd - hold watchdog device as is in WDT core
>>>> + * @min_hw_heartbeat_save - save of the min hw heartbeat value
>>>> */
>>>> struct rti_wdt_device {
>>>> void __iomem *base;
>>>> unsigned long freq;
>>>> struct watchdog_device wdd;
>>>> + unsigned int min_hw_heartbeat_save;
>>>> };
>>>> static int rti_wdt_start(struct watchdog_device *wdd)
>>>> @@ -107,6 +109,11 @@ static int rti_wdt_ping(struct watchdog_device *wdd)
>>>> /* put watchdog in active state */
>>>> writel_relaxed(WDKEY_SEQ1, wdt->base + RTIWDKEY);
>>>> + if (wdt->min_hw_heartbeat_save) {
>>>> + wdd->min_hw_heartbeat_ms = wdt->min_hw_heartbeat_save;
>>>> + wdt->min_hw_heartbeat_save = 0;
>>>> + }
>>>> +
>>>> return 0;
>>>> }
>>>> @@ -201,6 +208,24 @@ static int rti_wdt_probe(struct platform_device *pdev)
>>>> goto err_iomap;
>>>> }
>>>> + if (readl(wdt->base + RTIDWDCTRL) == WDENABLE_KEY) {
>>>> + u32 time_left;
>>>> + u32 heartbeat;
>>>> +
>>>> + set_bit(WDOG_HW_RUNNING, &wdd->status);
>>>> + time_left = rti_wdt_get_timeleft(wdd);
>>>> + heartbeat = readl(wdt->base + RTIDWDPRLD);
>>>> + heartbeat <<= WDT_PRELOAD_SHIFT;
>>>> + heartbeat /= wdt->freq;
>>>> + if (time_left < heartbeat / 2)
>>>> + wdd->min_hw_heartbeat_ms = 0;
>>>> + else
>>>> + wdd->min_hw_heartbeat_ms =
>>>> + (time_left - heartbeat / 2 + 1) * 1000;
>>>> +
>>>> + wdt->min_hw_heartbeat_save = 11 * heartbeat * 1000 / 20;
>>>> + }
>>>> +
>>>> ret = watchdog_register_device(wdd);
>>>> if (ret) {
>>>> dev_err(dev, "cannot register watchdog device\n");
>>>>
>>>
>>> This assumes that the bootloader also programmed a 50% window, right? The pending U-Boot patch will do that, but what if that may chance or someone uses a different setup?
>>
>> Yes, we assume 50%. I think based on the hw design, 50% is the only sane value to be used, otherwise you just shrink the open window too much and for no apparent reason.
>>
>
> Not sure if that is a valid assumption. Someone who designs a watchdog
> with such a narrow ping window might as well also use it. The question
> is if you want to rely on that assumption, or check and change it if needed.
Right, if that is a blocker, I can modify the code. Should be maybe
couple of lines addition.
> Also, I wonder if we should add an API function such as
> "set_last_hw_keepalive()" to avoid all that complexity.
I can try adding that also if it is desirable.
-Tero
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
next prev parent reply other threads:[~2020-06-25 17:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-24 11:45 [PATCH 0/2] watchdog: rti: adjust initial ping for attach Tero Kristo
2020-06-24 11:45 ` [PATCH 1/2] watchdog: use __watchdog_ping in startup Tero Kristo
2020-06-30 20:36 ` Guenter Roeck
2020-06-24 11:45 ` [PATCH 2/2] watchdog: rti: tweak min_hw_heartbeat_ms to match initial allowed window Tero Kristo
2020-06-24 15:24 ` Jan Kiszka
2020-06-25 8:32 ` Tero Kristo
2020-06-25 10:00 ` Jan Kiszka
2020-06-25 13:35 ` Guenter Roeck
2020-06-25 17:04 ` Tero Kristo [this message]
2020-06-30 20:23 ` Guenter Roeck
2020-07-01 5:50 ` Tero Kristo
2020-07-01 13:34 ` Guenter Roeck
2020-07-01 14:36 ` Tero Kristo
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=1d84e633-b808-d6ac-a34c-9cc4709e43f6@ti.com \
--to=t-kristo@ti.com \
--cc=jan.kiszka@siemens.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--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).