mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Antonio Borneo <antonio.borneo@foss.st.com>,
	Julius Werner <jwerner@chromium.org>,
	Evan Benn <evanbenn@chromium.org>,
	Wim Van Sebroeck <wim@linux-watchdog.org>,
	linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH v2] watchdog: arm_smc_wdt: get wdt status through SMCWD_GET_TIMELEFT
Date: Tue, 20 May 2025 11:48:11 -0700	[thread overview]
Message-ID: <c45c7b81-9952-43e2-91a8-e92d0860fa5e@roeck-us.net> (raw)
In-Reply-To: <20250520085952.210723-1-antonio.borneo@foss.st.com>

On 5/20/25 01:59, Antonio Borneo wrote:
> The optional SMCWD_GET_TIMELEFT command can be used to detect if
> the watchdog has already been started.
> See the implementation in OP-TEE secure OS [1].
> 
> At probe time, check if the watchdog is already started and then
> set WDOG_HW_RUNNING in the watchdog status. This will cause the
> watchdog framework to ping the watchdog until a userspace watchdog
> daemon takes over the control.
> 
> Link: https://github.com/OP-TEE/optee_os/commit/a7f2d4bd8632 [1]
> 
> Signed-off-by: Antonio Borneo <antonio.borneo@foss.st.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/watchdog/arm_smc_wdt.c | 17 ++++++++++++++---
>   1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/watchdog/arm_smc_wdt.c b/drivers/watchdog/arm_smc_wdt.c
> index 8f3d0c3a005fb..bbba23ace7b85 100644
> --- a/drivers/watchdog/arm_smc_wdt.c
> +++ b/drivers/watchdog/arm_smc_wdt.c
> @@ -46,6 +46,8 @@ static int smcwd_call(struct watchdog_device *wdd, enum smcwd_call call,
>   		return -ENODEV;
>   	if (res->a0 == PSCI_RET_INVALID_PARAMS)
>   		return -EINVAL;
> +	if (res->a0 == PSCI_RET_DISABLED)
> +		return -ENODATA;
>   	if (res->a0 != PSCI_RET_SUCCESS)
>   		return -EIO;
>   	return 0;
> @@ -131,10 +133,19 @@ static int smcwd_probe(struct platform_device *pdev)
>   
>   	wdd->info = &smcwd_info;
>   	/* get_timeleft is optional */
> -	if (smcwd_call(wdd, SMCWD_GET_TIMELEFT, 0, NULL))
> -		wdd->ops = &smcwd_ops;
> -	else
> +	err = smcwd_call(wdd, SMCWD_GET_TIMELEFT, 0, NULL);
> +	switch (err) {
> +	case 0:
> +		set_bit(WDOG_HW_RUNNING, &wdd->status);
> +		fallthrough;
> +	case -ENODATA:
>   		wdd->ops = &smcwd_timeleft_ops;
> +		break;
> +	default:
> +		wdd->ops = &smcwd_ops;
> +		break;
> +	}
> +
>   	wdd->timeout = res.a2;
>   	wdd->max_timeout = res.a2;
>   	wdd->min_timeout = res.a1;
> 
> base-commit: a5806cd506af5a7c19bcd596e4708b5c464bfd21


      reply	other threads:[~2025-05-20 18:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-19 17:00 [PATCH] " Antonio Borneo
2025-05-19 17:58 ` Guenter Roeck
2025-05-20  0:12   ` Julius Werner
2025-05-20  1:13     ` Guenter Roeck
2025-05-20  8:49       ` Antonio Borneo
2025-05-20  8:59 ` [PATCH v2] " Antonio Borneo
2025-05-20 18:48   ` 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=c45c7b81-9952-43e2-91a8-e92d0860fa5e@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=antonio.borneo@foss.st.com \
    --cc=evanbenn@chromium.org \
    --cc=jwerner@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-watchdog@vger.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®