All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: Prabhakar <prabhakar.csengg@gmail.com>
Cc: devicetree@vger.kernel.org, wsa+renesas@sang-engineering.com,
	conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH 12/12] rtc: rzn1: Add support for Renesas RZ/T2H and RZ/N2H SoCs
Date: Mon, 15 Jun 2026 15:58:46 +0000	[thread overview]
Message-ID: <20260615155847.177301F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260615154805.1619693-13-prabhakar.mahadev-lad.rj@bp.renesas.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [High] Missing validation allows RZ/T2H variants to fall back to SUBU mode, which accesses physically non-existent registers, potentially causing an SError or Data Abort.

Pre-existing issues:
- [High] If the optional `xtal` clock is omitted in the device tree, `rtc->sync_time` remains 0, leading to infinite tight-polling in `readl_poll_timeout`.
--

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

rtc: rzn1: Add support for Renesas RZ/T2H and RZ/N2H SoCs

Add a new compatible string "renesas,r9a09g077-rtc" to the OF match table
to support the RTC IP variant found on the RZ/T2H and RZ/N2H SoCs. These
newer SoCs integrate a closely related variant of the RZ/N1 RTC IP but lack
the RTCA0SUBU and RTCA0TCR registers.

> diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
> index 9f9cf9882fc49..dfff8dc8c3212 100644
> --- a/drivers/rtc/rtc-rzn1.c
> +++ b/drivers/rtc/rtc-rzn1.c
> @@ -597,6 +597,7 @@ static int rzn1_rtc_resume(struct device *dev)
>  static DEFINE_SIMPLE_DEV_PM_OPS(rzn1_rtc_pm_ops, rzn1_rtc_suspend, rzn1_rtc_resume);
>  
>  static const struct of_device_id rzn1_rtc_of_match[] = {
> +	{ .compatible	= "renesas,r9a09g077-rtc" },

[Severity: High]
The commit message notes that the new RZ/T2H variants lack the RTCA0SUBU
register and rely on rzn1_rtc_ops_scmp configurations. However, is it safe to
rely on the clock configuration to select between SCMP and SUBU operations?

In rzn1_rtc_probe(), the fallback to SUBU mode is based solely on the xtal
clock:

drivers/rtc/rtc-rzn1.c:rzn1_rtc_probe() {
	if (xtal) {
		rate = clk_get_rate(xtal);
		...
		if (rate != 32768)
			scmp_val = RZN1_RTC_CTL0_SLSB_SCMP;
		...
	}

	if (scmp_val) {
		writel(rate - 1, rtc->base + RZN1_RTC_SCMP);
		rtc->rtcdev->ops = &rzn1_rtc_ops_scmp;
	} else {
		rtc->rtcdev->ops = &rzn1_rtc_ops_subu;
	}
}

If the device tree misconfigures the clock (e.g., rate is exactly 32768) or
omits the optional xtal clock entirely, scmp_val will be 0. The driver will
dynamically assign rzn1_rtc_ops_subu as the ops.

Subsequent operations like rzn1_rtc_read_offset() will directly access the
missing register:

drivers/rtc/rtc-rzn1.c:rzn1_rtc_read_offset() {
	val = readl(rtc->base + RZN1_RTC_SUBU);
}

Could this cause an unhandled SError or Data Abort when accessing the
physically non-existent SUBU register on RZ/T2H? Should the driver explicitly
enforce the use of SCMP operations for this compatible string regardless of the
clock configuration?


[Severity: High]
This is a pre-existing issue, but if the optional xtal clock is omitted in the
device tree, rtc->sync_time remains 0 since it is initialized by devm_kzalloc()
and the calculation block is skipped.

Later in rzn1_rtc_probe():

	/* Wait 2-4 RTC_PCLK clock cycles for the disabled controller to stop */
	ret = readl_poll_timeout(rtc->base + RZN1_RTC_CTL0, val,
				 !(val & RZN1_RTC_CTL0_CEST), rtc->sync_time,
				 rtc->sync_time * 2);

Passing a timeout of 0 to readl_poll_timeout() instructs it to never time out.
Combined with a sleep_us of 0, could this result in an infinite tight loop
if the hardware condition !(val & RZN1_RTC_CTL0_CEST) is never met during
probe?

>  	{ .compatible	= "renesas,rzn1-rtc" },
>  	{},
>  };

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

  reply	other threads:[~2026-06-15 15:58 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-15 15:47 [PATCH 00/12] Add RTC support for Renesas RZ/T2H and RZ/N2H SoCs Prabhakar
2026-06-15 15:47 ` [PATCH 01/12] dt-bindings: rtc: renesas,rzn1-rtc: Add RZ/T2H and RZ/N2H support Prabhakar
2026-06-15 15:56   ` sashiko-bot
2026-06-15 16:22   ` Conor Dooley
2026-06-17  9:38   ` Wolfram Sang
2026-06-15 15:47 ` [PATCH 02/12] rtc: rzn1: Handle EPROBE_DEFER for optional pps interrupt Prabhakar
2026-06-15 15:58   ` sashiko-bot
2026-06-17  9:55   ` Wolfram Sang
2026-06-15 15:47 ` [PATCH 03/12] rtc: rzn1: Fix malformed MODULE_AUTHOR string Prabhakar
2026-06-17  7:19   ` Geert Uytterhoeven
2026-06-17  9:55   ` Wolfram Sang
2026-06-15 15:47 ` [PATCH 04/12] rtc: Kconfig: Broaden RTC_DRV_RZN1 dependency to ARCH_RENESAS Prabhakar
2026-06-17  9:57   ` Wolfram Sang
2026-06-15 15:47 ` [PATCH 05/12] rtc: rzn1: Add system suspend/resume support and wakeup capability Prabhakar
2026-06-15 15:59   ` sashiko-bot
2026-06-17 10:02   ` Wolfram Sang
2026-06-15 15:47 ` [PATCH 06/12] rtc: rzn1: Sort headers alphabetically Prabhakar
2026-06-17  7:22   ` Geert Uytterhoeven
2026-06-17 10:04     ` Wolfram Sang
2026-06-15 15:48 ` [PATCH 07/12] rtc: rzn1: fix alarm range check truncation on 32-bit systems Prabhakar
2026-06-15 16:00   ` sashiko-bot
2026-06-17  7:29   ` Geert Uytterhoeven
2026-06-17 10:49   ` Wolfram Sang
2026-06-17 10:57   ` Wolfram Sang
2026-06-15 15:48 ` [PATCH 08/12] rtc: rzn1: Dynamically calculate synchronization delay based on clock rate Prabhakar
2026-06-15 15:57   ` sashiko-bot
2026-06-17 10:58   ` Wolfram Sang
2026-06-15 15:48 ` [PATCH 09/12] rtc: rzn1: Use temporary variable for struct device Prabhakar
2026-06-15 17:56   ` sashiko-bot
2026-06-17 11:00   ` Wolfram Sang
2026-06-17 11:08   ` Wolfram Sang
2026-06-15 15:48 ` [PATCH 10/12] rtc: rzn1: Consistently use dev_err_probe() Prabhakar
2026-06-17  7:24   ` Geert Uytterhoeven
2026-06-17 11:01   ` Wolfram Sang
2026-06-15 15:48 ` [PATCH 11/12] rtc: rzn1: use FIELD_PREP/FIELD_GET and GENMASK for register access Prabhakar
2026-06-15 15:57   ` sashiko-bot
2026-06-17 11:06   ` Wolfram Sang
2026-06-15 15:48 ` [PATCH 12/12] rtc: rzn1: Add support for Renesas RZ/T2H and RZ/N2H SoCs Prabhakar
2026-06-15 15:58   ` sashiko-bot [this message]
2026-06-17 11:10   ` Wolfram Sang
2026-06-17  9:18 ` [PATCH 00/12] Add RTC " Wolfram Sang
2026-06-17 11:12   ` Wolfram Sang

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=20260615155847.177301F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.