From: sashiko-bot@kernel.org
To: Prabhakar <prabhakar.csengg@gmail.com>
Cc: linux-rtc@vger.kernel.org, conor+dt@kernel.org,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
robh@kernel.org, devicetree@vger.kernel.org,
wsa+renesas@sang-engineering.com
Subject: Re: [PATCH v2 06/10] rtc: rzn1: Dynamically calculate synchronization delay based on clock rate
Date: Wed, 01 Jul 2026 14:49:39 +0000 [thread overview]
Message-ID: <20260701144940.69FD71F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260701142953.2014895-7-prabhakar.mahadev-lad.rj@bp.renesas.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Low] Incorrect time conversion macro NSEC_PER_MSEC used instead of USEC_PER_SEC for microsecond calculation.
Pre-existing issues:
- [High] Race condition between PM runtime teardown and devres device unregistration can lead to accessing powered-down hardware.
--
commit f3a6e4b28e451318639b10e7927bf136a7d225d3
Author: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
rtc: rzn1: Dynamically calculate synchronization delay based on clock rate
This patch replaces hardcoded hardware synchronization delays with a
calculated time window derived from the runtime clock rate. It stores this
synchronization time in the driver private structure to dynamically adjust
wait boundaries.
> diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
> index 9969bcefede72..583d174954043 100644
> --- a/drivers/rtc/rtc-rzn1.c
> +++ b/drivers/rtc/rtc-rzn1.c
[ ... ]
> @@ -432,12 +433,20 @@ static int rzn1_rtc_probe(struct platform_device *pdev)
> scmp_val = RZN1_RTC_CTL0_SLSB_SCMP;
> }
>
> + /*
> + * The internal clock counter operates in synchronization with the
> + * RTC_PCLK clock. Calculate the duration of two RTC_PCLK clock
> + * cycles in microseconds required for operations to complete.
> + */
> + rtc->sync_time = DIV_ROUND_UP(2 * NSEC_PER_MSEC, rate);
[Severity: Low]
This isn't a bug, but should this macro be USEC_PER_SEC instead?
The comment mentions calculating the duration in microseconds. While
NSEC_PER_MSEC evaluates to 1,000,000 which produces the correct runtime
result for converting cycles per second into microseconds, using
USEC_PER_SEC would more accurately reflect the intended units and improve
readability.
[Severity: High]
This is a pre-existing issue, but is there a race condition between the
PM runtime teardown and devres cleanup?
In drivers/rtc/rtc-rzn1.c, the RTC device is registered via devres
during rzn1_rtc_probe():
ret = devm_rtc_register_device(rtc->rtcdev);
Devres runs its cleanup (which calls rtc_unregister_device()) strictly
after the driver's remove callback returns. However, in rzn1_rtc_remove(),
the driver manually drops the PM runtime reference:
pm_runtime_put(&pdev->dev);
This powers down the hardware while the RTC character device is still
registered and exposed to userspace. If a userspace process calls an ioctl,
such as RTC_RD_TIME, during this window, the driver's rzn1_rtc_read_time()
callback executes and attempts to access unclocked registers, which could
lead to a synchronous external abort or bus fault.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260701142953.2014895-1-prabhakar.mahadev-lad.rj@bp.renesas.com?part=6
next prev parent reply other threads:[~2026-07-01 14:49 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 [this message]
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
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=20260701144940.69FD71F000E9@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