From: Guenter Roeck <linux@roeck-us.net>
To: Ben Wolsieffer <ben.wolsieffer@hefring.com>,
linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org
Cc: Wim Van Sebroeck <wim@linux-watchdog.org>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Christophe Roullier <christophe.roullier@st.com>
Subject: Re: [PATCH] watchdog: stm32_iwdg: initialize default timeout
Date: Wed, 28 Feb 2024 10:36:31 -0800 [thread overview]
Message-ID: <f147ed12-8b7f-43c8-9b55-3000b6e4fd27@roeck-us.net> (raw)
In-Reply-To: <20240228182723.12855-1-ben.wolsieffer@hefring.com>
On 2/28/24 10:27, Ben Wolsieffer wrote:
> The driver never sets a default timeout value, therefore it is
> initialized to zero. When CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED is
> enabled, the watchdog is started during probe. The kernel is supposed to
> automatically ping the watchdog from this point until userspace takes
> over, but this does not happen if the configured timeout is zero. A zero
> timeout causes watchdog_need_worker() to return false, so the heartbeat
> worker does not run and the system therefore resets soon after the
> driver is probed.
>
> This patch fixes this by setting an arbitrary non-zero default timeout.
> The default could be read from the hardware instead, but I didn't see
> any reason to add this complexity.
>
> This has been tested on an STM32F746.
>
> Fixes: 85fdc63fe256 ("drivers: watchdog: stm32_iwdg: set WDOG_HW_RUNNING at probe")
> Signed-off-by: Ben Wolsieffer <ben.wolsieffer@hefring.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> drivers/watchdog/stm32_iwdg.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/watchdog/stm32_iwdg.c b/drivers/watchdog/stm32_iwdg.c
> index d9fd50df9802..5404e0387620 100644
> --- a/drivers/watchdog/stm32_iwdg.c
> +++ b/drivers/watchdog/stm32_iwdg.c
> @@ -20,6 +20,8 @@
> #include <linux/platform_device.h>
> #include <linux/watchdog.h>
>
> +#define DEFAULT_TIMEOUT 10
> +
> /* IWDG registers */
> #define IWDG_KR 0x00 /* Key register */
> #define IWDG_PR 0x04 /* Prescaler Register */
> @@ -248,6 +250,7 @@ static int stm32_iwdg_probe(struct platform_device *pdev)
> wdd->parent = dev;
> wdd->info = &stm32_iwdg_info;
> wdd->ops = &stm32_iwdg_ops;
> + wdd->timeout = DEFAULT_TIMEOUT;
> wdd->min_timeout = DIV_ROUND_UP((RLR_MIN + 1) * PR_MIN, wdt->rate);
> wdd->max_hw_heartbeat_ms = ((RLR_MAX + 1) * wdt->data->max_prescaler *
> 1000) / wdt->rate;
prev parent reply other threads:[~2024-02-28 18:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-28 18:27 [PATCH] watchdog: stm32_iwdg: initialize default timeout Ben Wolsieffer
2024-02-28 18:36 ` 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=f147ed12-8b7f-43c8-9b55-3000b6e4fd27@roeck-us.net \
--to=linux@roeck-us.net \
--cc=alexandre.torgue@foss.st.com \
--cc=ben.wolsieffer@hefring.com \
--cc=christophe.roullier@st.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux-watchdog@vger.kernel.org \
--cc=mcoquelin.stm32@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).