Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: Prabhakar <prabhakar.csengg@gmail.com>
Cc: linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org,
	conor+dt@kernel.org, wsa+renesas@sang-engineering.com,
	robh@kernel.org
Subject: Re: [PATCH v6 6/8] watchdog: rzv2h: Add syscon support for WDTDCR
Date: Wed, 23 Sep 2026 10:52:37 +0000	[thread overview]
Message-ID: <20260923105237.7B87D1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260923104054.3324830-7-prabhakar.mahadev-lad.rj@bp.renesas.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] watchdog: rzv2h: Deadlock in restart handler via syscon regmap locking
--

commit 1e1b26069f70735a537750b22a51257bb422c2e4
Author: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

watchdog: rzv2h: Add syscon support for WDTDCR

The commit adds support for accessing the WDTDCR register via a syscon
regmap interface for RZ/T2H and RZ/N2H SoCs. It looks up the SYSC regmap
using the "renesas,sysc" property or falls back to MMIO access if absent.

> diff --git a/drivers/watchdog/rzv2h_wdt.c b/drivers/watchdog/rzv2h_wdt.c
> index 76c1d315b0e77..30b0b70fecaa9 100644
> --- a/drivers/watchdog/rzv2h_wdt.c
> +++ b/drivers/watchdog/rzv2h_wdt.c

[ ... ]

> @@ -93,18 +104,22 @@ static int rzv2h_wdt_ping(struct watchdog_device *wdev)
>  
>  static int rzt2h_wdt_wdtdcr_count_stop(struct rzv2h_wdt_priv *priv)
>  {
> -	guard(spinlock_irqsave)(&priv->regmap_lock);
> -	return regmap_set_bits(priv->wdtdcr_regmap, WDTDCR, WDTDCR_WDTSTOPCTRL);
> +	struct rzv2h_sysc_wdtdcr *sysc = &priv->sysc;
> +
> +	guard(spinlock_irqsave)(&sysc->regmap_lock);
> +	return regmap_set_bits(sysc->regmap, sysc->offset, WDTDCR_WDTSTOPCTRL);
>  }

[Severity: High]
Is the external sysc->regmap_lock still necessary here?

When using the syscon regmap returned by syscon_regmap_lookup_by_phandle_args(),
the regmap has internal locking enabled by default. Since regmap_set_bits()
already performs an atomic read-modify-write using the syscon's internal lock,
this external wrapper lock appears redundant for the syscon path.

>  
>  static inline int rzt2h_wdt_wdtdcr_count_start_nolock(struct rzv2h_wdt_priv *priv)
>  {
> -	return regmap_clear_bits(priv->wdtdcr_regmap, WDTDCR, WDTDCR_WDTSTOPCTRL);
> +	struct rzv2h_sysc_wdtdcr *sysc = &priv->sysc;
> +
> +	return regmap_clear_bits(sysc->regmap, sysc->offset, WDTDCR_WDTSTOPCTRL);
>  }

[Severity: High]
Could this lead to a deadlock during a system panic or restart?

This function is called by the rzv2h_wdt_restart() handler, which executes in
atomic or panic context and must remain strictly lockless to prevent deadlocks.

While bypassing the driver's local sysc->regmap_lock was safe in the legacy
MMIO fallback case (where rzv2h_wdtdcr_regmap_config disables locking), the
syscon regmap has internal locking enabled.

Calling regmap_clear_bits() unconditionally attempts to acquire the syscon
regmap's internal spinlock. If the system panics while another CPU is accessing
the shared syscon block, the restart handler could hang trying to acquire this
lock, defeating the purpose of the watchdog restart recovery.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260923104054.3324830-1-prabhakar.mahadev-lad.rj@bp.renesas.com?part=6

  reply	other threads:[~2026-09-23 10:52 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23 10:40 [PATCH v6 0/8] Add syscon support for Renesas WDT driver Prabhakar
2026-09-23 10:40 ` [PATCH v6 1/8] watchdog: rzv2h: Use pm_runtime_put_sync() Prabhakar
2026-09-23 10:40 ` [PATCH v6 2/8] watchdog: rzv2h: Drop enabling clocks in the restart handler Prabhakar
2026-09-23 10:40 ` [PATCH v6 3/8] watchdog: rzv2h: Drop WDTRCR_RSTIRQS define Prabhakar
2026-09-23 10:40 ` [PATCH v6 4/8] watchdog: rzv2h: Propagate WDTDCR access errors Prabhakar
2026-09-23 10:48   ` sashiko-bot
2026-09-23 21:17   ` Guenter Roeck
2026-09-24 12:59     ` Lad, Prabhakar
2026-09-23 21:19   ` Guenter Roeck
2026-09-23 10:40 ` [PATCH v6 5/8] watchdog: rzv2h: Convert WDTDCR handling to regmap Prabhakar
2026-09-23 10:40 ` [PATCH v6 6/8] watchdog: rzv2h: Add syscon support for WDTDCR Prabhakar
2026-09-23 10:52   ` sashiko-bot [this message]
2026-09-24 13:44     ` Lad, Prabhakar
2026-09-24 21:48       ` Guenter Roeck
2026-09-25  4:13         ` Biju Das
2026-09-25  4:50           ` Guenter Roeck
2026-09-25  5:11             ` Biju Das
2026-09-25  9:06               ` Lad, Prabhakar
2026-09-25  9:09                 ` Geert Uytterhoeven
2026-09-25  9:20                   ` Lad, Prabhakar
2026-09-25 12:24                     ` Lad, Prabhakar
2026-09-25 13:41                       ` Guenter Roeck
2026-09-23 10:40 ` [PATCH v6 7/8] arm64: dts: renesas: r9a09g077: Use CPG/MSSR syscon for WDTDCR access Prabhakar
2026-09-23 11:05   ` sashiko-bot
2026-09-23 10:40 ` [PATCH v6 8/8] arm64: dts: renesas: r9a09g087: " Prabhakar
2026-09-23 10:53   ` sashiko-bot

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=20260923105237.7B87D1F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=prabhakar.csengg@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wsa+renesas@sang-engineering.com \
    /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