Linux Watchdog driver development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Henry Qin" <henry.qin@starfivetech.com>
Cc: linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 3/3] watchdog: starfive: Add jhb100 support
Date: Fri, 04 Dec 2026 14:35:51 +0000	[thread overview]
Message-ID: <sashiko-outbox-249987@kernel.org> (raw)
In-Reply-To: <20261204135336.632-4-henry.qin@starfivetech.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] watchdog: starfive: starfive_wdt_start() discards wdt->reload
  on JHB100 resume
- [Low] watchdog: starfive: starfive_wdt_int_clr() writes RESTART before
  LOAD
--

commit ee0848390c3f02cfdb4636176c3d8234c91dfb17
Author: Henry Qin <henry.qin@starfivetech.com>

watchdog: starfive: Add jhb100 support

This commit adds watchdog support for the StarFive JHB100 SoC, introducing
its register layout, unlock and restart keys, and first-timeout reset mode.

> diff --git a/drivers/watchdog/starfive-wdt.c b/drivers/watchdog/starfive-wdt.c
> index 24909afacd4ee..045b922c76ab8 100644
> --- a/drivers/watchdog/starfive-wdt.c
> +++ b/drivers/watchdog/starfive-wdt.c

[ ... ]

> @@ -144,6 +170,23 @@ static const struct starfive_wdt_variant starfive_wdt_jh7110_variant = {
>  	.double_timeout = true,
>  };
>  
> +/* Register layout and configuration for the JHB100 */
> +static const struct starfive_wdt_variant starfive_wdt_jhb100_variant = {
> +	.control = STARFIVE_WDT_JHB100_CONTROL,
> +	.load = STARFIVE_WDT_JHB100_LOAD,
> +	.enable = STARFIVE_WDT_JHB100_CONTROL,
> +	.value = STARFIVE_WDT_JHB100_VALUE,
> +	.unlock = STARFIVE_WDT_JHB100_LOCK,
> +	.unlock_key = STARFIVE_WDT_JHB100_UNLOCK_KEY,
> +	.restart = STARFIVE_WDT_JHB100_RESTART,
> +	.restart_key = STARFIVE_WDT_JHB100_RESTART_KEY,
> +	.rst_mode = STARFIVE_WDT_JHB100_RST_MODE,
> +	.enrst_shift = STARFIVE_WDT_JHB100_RST_EN_SHIFT,
> +	.en_shift = STARFIVE_WDT_EN_SHIFT,
> +	.intclr_check = false,
> +	.double_timeout = false,
> +};

[Severity: Medium]
Does leaving .reload unset here discard wdt->reload on JHB100 system resume?

On resume, starfive_wdt_resume() calls starfive_wdt_start(wdt, wdt->reload):

drivers/watchdog/starfive-wdt.c:starfive_wdt_start() {
    ...
	starfive_wdt_set_reload_count(wdt, count);
	if (count != wdt->count)
		starfive_wdt_set_count(wdt, wdt->count);
	starfive_wdt_enable(wdt);
    ...
}

With variant->reload unset, starfive_wdt_set_reload_count() only writes
wdt->reload to LOAD without latching the counter.  The next call then
overwrites LOAD with wdt->count before starfive_wdt_enable() reloads the
counter from LOAD, resetting the watchdog to the full timeout.

[ ... ]

> @@ -255,7 +299,12 @@ static int starfive_wdt_int_clr(struct starfive_wdt *wdt)
>  			return dev_err_probe(wdt->wdd.parent, ret,
>  					     "watchdog is not ready to clear interrupt.\n");
>  	}
> -	writel(STARFIVE_WDT_INTCLR, wdt->base + wdt->variant->int_clr);
> +
> +	/* JHB100 restarts the counter by writing the restart key */
> +	if (wdt->variant->restart)
> +		writel(wdt->variant->restart_key, wdt->base + wdt->variant->restart);
> +	else
> +		writel(STARFIVE_WDT_INTCLR, wdt->base + wdt->variant->int_clr);
>  
>  	return 0;
>  }

[Severity: Low]
Should writing the JHB100 RESTART key happen in
starfive_wdt_set_reload_count() instead of starfive_wdt_int_clr()?

In starfive_wdt_keepalive(), starfive_wdt_int_clr() runs before
starfive_wdt_set_reload_count(), so RESTART is written before LOAD and the
LOAD update does not take effect for that ping.  In starfive_wdt_start(),
it also writes RESTART while disabled and before LOAD is programmed.

Skipping the interrupt-clear write when variant->int_clr is unset and
extending variant->reload in starfive_wdt_set_reload_count() with a reload
key would keep LOAD written before RESTART and avoid duplicating the reload
mechanism.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204135336.632-1-henry.qin@starfivetech.com?part=3

  reply	other threads:[~2026-12-04 14:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 13:53 [PATCH 0/3] watchdog: starfive: Add jhb100 support Henry Qin
2026-12-04 13:53 ` [PATCH 1/3] dt-bindings: watchdog: starfive,jh7100-wdt: Remove jh8100 Henry Qin
2026-12-04 13:53 ` [PATCH 2/3] dt-bindings: watchdog: starfive,jh7100-wdt: Add jhb100 support Henry Qin
2026-12-04 13:53 ` [PATCH 3/3] watchdog: starfive: " Henry Qin
2026-12-04 14:35   ` sashiko-bot [this message]
2026-12-04 18:55 ` [PATCH 0/3] " Guenter Roeck

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=sashiko-outbox-249987@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=henry.qin@starfivetech.com \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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