Linux RTC
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: Prabhakar <prabhakar.csengg@gmail.com>
Cc: devicetree@vger.kernel.org, linux-rtc@vger.kernel.org,
	robh@kernel.org,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	wsa+renesas@sang-engineering.com, conor+dt@kernel.org
Subject: Re: [PATCH v3 09/12] rtc: rzn1: Use temporary variable for struct device
Date: Mon, 06 Jul 2026 17:56:54 +0000	[thread overview]
Message-ID: <20260706175655.6A31D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260706175138.12587-10-prabhakar.mahadev-lad.rj@bp.renesas.com>

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

Pre-existing issues:
- [High] Asynchronous pm_runtime_put() is used immediately before pm_runtime_disable() during devres cleanup, creating a race condition that leaves the device active.
--

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

rtc: rzn1: Use temporary variable for struct device

This commit introduces a temporary variable to store the device pointer in
the probe function. This replaces multiple occurrences to avoid repeated
dereferencing.

> diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
> index 12bbbc18f7eab..4917bd223efd7 100644
> --- a/drivers/rtc/rtc-rzn1.c
> +++ b/drivers/rtc/rtc-rzn1.c

[ ... ]

> @@ -421,19 +422,19 @@ static int rzn1_rtc_probe(struct platform_device *pdev)
>  	rtc->rtcdev->range_max = RTC_TIMESTAMP_END_2099;
>  	rtc->rtcdev->alarm_offset_max = 7 * 86400;
>  
> -	ret = devm_pm_runtime_enable(&pdev->dev);
> +	ret = devm_pm_runtime_enable(dev);
>  	if (ret < 0)
>  		return ret;
> -	ret = pm_runtime_resume_and_get(&pdev->dev);
> +	ret = pm_runtime_resume_and_get(dev);
>  	if (ret < 0)
>  		return ret;
>  
> -	ret = devm_add_action_or_reset(&pdev->dev, rzn1_rtc_disable_hardware, &pdev->dev);
> +	ret = devm_add_action_or_reset(dev, rzn1_rtc_disable_hardware, dev);

[Severity: High]
This is a pre-existing issue, but does the async suspend queued by
rzn1_rtc_disable_hardware() race with the subsequent runtime PM disable?

During devres cleanup (such as probe failure or driver removal), the cleanup
actions execute in reverse order (LIFO). First, the custom hardware disable
action runs:

static void rzn1_rtc_disable_hardware(void *data)
{
        ...
        pm_runtime_put(dev);
}

Because this is an asynchronous put, the suspend work is only queued.

Immediately after, devres unwinds devm_pm_runtime_enable() which calls
pm_runtime_disable(). This cleanup triggers __pm_runtime_barrier(), canceling
any pending async idle or suspend work and leaving the hardware powered on.

Should rzn1_rtc_disable_hardware() use pm_runtime_put_sync() instead to
ensure the suspend completes before runtime PM is disabled?

>  	if (ret)
>  		return ret;
>

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

  reply	other threads:[~2026-07-06 17:56 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06 17:51 [PATCH v3 00/12] Add RTC support for Renesas RZ/T2H and RZ/N2H SoCs Prabhakar
2026-07-06 17:51 ` [PATCH v3 01/12] dt-bindings: rtc: renesas,rzn1-rtc: Add RZ/T2H and RZ/N2H support Prabhakar
2026-07-06 17:58   ` sashiko-bot
2026-07-06 17:51 ` [PATCH v3 02/12] rtc: rzn1: Handle EPROBE_DEFER for optional pps interrupt Prabhakar
2026-07-06 17:56   ` sashiko-bot
2026-07-06 17:51 ` [PATCH v3 03/12] rtc: rzn1: fix weekday underflow when alarm crosses month boundary Prabhakar
2026-07-06 18:00   ` sashiko-bot
2026-07-06 17:51 ` [PATCH v3 04/12] rtc: rzn1: Fix malformed MODULE_AUTHOR string Prabhakar
2026-07-06 17:53   ` sashiko-bot
2026-07-06 17:51 ` [PATCH v3 05/12] rtc: Kconfig: Broaden RTC_DRV_RZN1 dependency to ARCH_RENESAS Prabhakar
2026-07-06 17:54   ` sashiko-bot
2026-07-06 17:51 ` [PATCH v3 06/12] rtc: rzn1: Fix alarm range check truncation on 32-bit systems Prabhakar
2026-07-06 18:04   ` sashiko-bot
2026-07-06 17:51 ` [PATCH v3 07/12] rtc: rzn1: Replace remove callback with devm_add_action_or_reset() Prabhakar
2026-07-06 17:58   ` sashiko-bot
2026-07-06 17:51 ` [PATCH v3 08/12] rtc: rzn1: Dynamically calculate synchronization delay based on clock rate Prabhakar
2026-07-06 17:58   ` sashiko-bot
2026-07-06 17:51 ` [PATCH v3 09/12] rtc: rzn1: Use temporary variable for struct device Prabhakar
2026-07-06 17:56   ` sashiko-bot [this message]
2026-07-06 17:51 ` [PATCH v3 10/12] rtc: rzn1: Consistently use dev_err_probe() Prabhakar
2026-07-06 17:55   ` sashiko-bot
2026-07-06 17:51 ` [PATCH v3 11/12] rtc: rzn1: use FIELD_PREP/FIELD_GET and GENMASK for register access Prabhakar
2026-07-06 17:57   ` sashiko-bot
2026-07-06 17:51 ` [PATCH v3 12/12] rtc: rzn1: Add support for Renesas RZ/T2H and RZ/N2H SoCs Prabhakar
2026-07-06 18:03   ` 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=20260706175655.6A31D1F000E9@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