Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: Prabhakar <prabhakar.csengg@gmail.com>
Cc: robh@kernel.org, wsa+renesas@sang-engineering.com,
	linux-rtc@vger.kernel.org, conor+dt@kernel.org,
	devicetree@vger.kernel.org,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH v2 10/10] rtc: rzn1: Add support for Renesas RZ/T2H and RZ/N2H SoCs
Date: Wed, 01 Jul 2026 14:54:54 +0000	[thread overview]
Message-ID: <20260701145455.02B451F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260701142953.2014895-11-prabhakar.mahadev-lad.rj@bp.renesas.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The driver does not enforce SCMP mode for the new RZ/T2H compatible, allowing an unsafe fallback to SUBU mode that accesses the unimplemented RTCA0SUBU register.
- [Medium] The driver clears the entire `RZN1_RTC_CTL1` register to disable interrupts, which inadvertently destroys the state of the RZ/T2H-specific 1 Hz output control bit.
--

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

rtc: rzn1: Add support for Renesas RZ/T2H and RZ/N2H SoCs
    
Add support for the RTC block found on the Renesas RZ/T2H (R9A09G077)
and RZ/N2H (R9A09G087) SoCs by matching the new
renesas,r9a09g077-rtc compatible string.

>     These SoCs integrate a closely related variant of the RZ/N1 RTC IP.
>     Unlike the RZ/N1 implementation, the RZ/T2H and RZ/N2H variants lack
>     the RTCA0SUBU register. However, this register is not accessed when
>     operating in SCMP mode using the existing rzn1_rtc_ops_scmp
>     configuration, allowing the current driver infrastructure to be reused
>     without modification.

[Severity: High]
Does the current driver infrastructure guarantee SCMP mode is always used?

If the xtal clock is missing (since devm_clk_get_optional() is used) or
if its rate is exactly 32768 Hz, scmp_val remains 0:

drivers/rtc/rtc-rzn1.c:rzn1_rtc_probe() {
	...
	xtal = devm_clk_get_optional(dev, "xtal");
	if (IS_ERR(xtal)) {
		...
	} else if (xtal) {
		rate = clk_get_rate(xtal);
		...
		if (rate != 32768)
			scmp_val = RZN1_RTC_CTL0_SLSB_SCMP;
	}
	...

This causes the driver to fall back to the SUBU ops:

	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 this happens, the SUBU ops will access the missing RTCA0SUBU register,
which can trigger a synchronous external abort. Should the driver use OF match
data to identify variants lacking the SUBU register and explicitly prevent
assigning rzn1_rtc_ops_subu?

>     The RZ/T2H RTC variant also supports a 1 Hz output signal on the
>     RTCAT1HZ pin, controlled by the RTCA0CTL1[RTCA01HZE] bit. This bit is
>     marked as reserved in the RZ/N1 hardware manual, making RZ/T2H a
>     distinct RTC variant despite its overall compatibility with the RZ/N1
>     implementation.

[Severity: Medium]
Will this 1 Hz output signal be inadvertently disabled during probe and removal?

During probe and removal, the driver unconditionally clears the entire
RZN1_RTC_CTL1 register to disable interrupts:

drivers/rtc/rtc-rzn1.c:rzn1_rtc_probe() {
	...
	/* Disable all interrupts */
	writel(0, rtc->base + RZN1_RTC_CTL1);
	...

If the bootloader or firmware previously configured the 1 Hz output signal,
won't this unconditional write to 0 destroy that state? Could the driver
perform a read-modify-write operation to clear only the interrupt enable bits
instead?

> diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
> index e77b7e7bcd5bd..26a5cde41c6b2 100644
> --- a/drivers/rtc/rtc-rzn1.c
> +++ b/drivers/rtc/rtc-rzn1.c
> @@ -518,6 +518,7 @@ static void rzn1_rtc_remove(struct platform_device *pdev)
>  }
>  
>  static const struct of_device_id rzn1_rtc_of_match[] = {
> +	{ .compatible	= "renesas,r9a09g077-rtc" },
>  	{ .compatible	= "renesas,rzn1-rtc" },
>  	{},
>  };

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

      reply	other threads:[~2026-07-01 14:54 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01 14:29 [PATCH v2 00/10] Add RTC support for Renesas RZ/T2H and RZ/N2H SoCs Prabhakar
2026-07-01 14:29 ` [PATCH v2 01/10] dt-bindings: rtc: renesas,rzn1-rtc: Add RZ/T2H and RZ/N2H support Prabhakar
2026-07-01 14:35   ` sashiko-bot
2026-07-01 14:29 ` [PATCH v2 02/10] rtc: rzn1: Handle EPROBE_DEFER for optional pps interrupt Prabhakar
2026-07-01 14:39   ` sashiko-bot
2026-07-01 14:29 ` [PATCH v2 03/10] rtc: rzn1: Fix malformed MODULE_AUTHOR string Prabhakar
2026-07-01 14:32   ` sashiko-bot
2026-07-01 14:29 ` [PATCH v2 04/10] rtc: Kconfig: Broaden RTC_DRV_RZN1 dependency to ARCH_RENESAS Prabhakar
2026-07-01 14:39   ` sashiko-bot
2026-07-01 14:29 ` [PATCH v2 05/10] rtc: rzn1: Fix alarm range check truncation on 32-bit systems Prabhakar
2026-07-01 14:45   ` sashiko-bot
2026-07-01 14:29 ` [PATCH v2 06/10] rtc: rzn1: Dynamically calculate synchronization delay based on clock rate Prabhakar
2026-07-01 14:49   ` sashiko-bot
2026-07-01 14:29 ` [PATCH v2 07/10] rtc: rzn1: Use temporary variable for struct device Prabhakar
2026-07-01 14:43   ` sashiko-bot
2026-07-01 14:29 ` [PATCH v2 08/10] rtc: rzn1: Consistently use dev_err_probe() Prabhakar
2026-07-01 14:50   ` sashiko-bot
2026-07-01 14:29 ` [PATCH v2 09/10] rtc: rzn1: use FIELD_PREP/FIELD_GET and GENMASK for register access Prabhakar
2026-07-01 14:48   ` sashiko-bot
2026-07-01 14:29 ` [PATCH v2 10/10] rtc: rzn1: Add support for Renesas RZ/T2H and RZ/N2H SoCs Prabhakar
2026-07-01 14:54   ` sashiko-bot [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=20260701145455.02B451F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-rtc@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