Linux RTC
 help / color / mirror / Atom feed
From: Jiawen Liu <liu1298662399@gmail.com>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-rtc@vger.kernel.org
Subject: [PATCH] rtc: omap: abort probe if runtime resume fails
Date: Sun, 29 Nov 2026 19:25:33 +0000	[thread overview]
Message-ID: <179598033474.2.16434657830284928463.pattern-ext-052.2@gmail.com> (raw)

On AM335x, the ti-sysc parent can runtime suspend before a later RTC
probe. If its functional clock fails to become ready during resume,
the RTC's synchronous runtime PM acquisition can fail. Probe ignores
that result and immediately writes the KICK and interrupt registers
while the parent remains suspended.

Use pm_runtime_resume_and_get() and return its error before accessing
any RTC registers. The helper balances the usage count on failure,
so disable runtime PM and release the optional oscillator clock in
the early error path. Check clk_prepare_enable() so that this path
only releases a clock that was successfully enabled. A successful
probe retains its runtime PM reference for the existing cleanup.

Source review traced probe and
removal. The rtc-omap object built for ARM OMAP2+ with AM33xx and
CONFIG_PM=y and for x86_64 COMPILE_TEST with CONFIG_PM=n. Both
git diff --check and checkpatch.pl passed. Runtime and hardware
reproduction were not performed.

Fixes: fc9bd9022e8d ("rtc: omap: add runtime pm support")
Signed-off-by: Jiawen Liu <liu1298662399@gmail.com>
---
 drivers/rtc/rtc-omap.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 3c978edd6c2cb..acc9bb787b150 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -757,8 +757,11 @@ static int omap_rtc_probe(struct platform_device *pdev)
 	else
 		rtc->clk = devm_clk_get(&pdev->dev, "int-clk");
 
-	if (!IS_ERR(rtc->clk))
-		clk_prepare_enable(rtc->clk);
+	if (!IS_ERR(rtc->clk)) {
+		ret = clk_prepare_enable(rtc->clk);
+		if (ret)
+			return ret;
+	}
 
 	rtc->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(rtc->base)) {
@@ -770,7 +773,13 @@ static int omap_rtc_probe(struct platform_device *pdev)
 
 	/* Enable the clock/module so that we can access the registers */
 	pm_runtime_enable(&pdev->dev);
-	pm_runtime_get_sync(&pdev->dev);
+	ret = pm_runtime_resume_and_get(&pdev->dev);
+	if (ret < 0) {
+		pm_runtime_disable(&pdev->dev);
+		if (!IS_ERR(rtc->clk))
+			clk_disable_unprepare(rtc->clk);
+		return ret;
+	}
 
 	rtc->type->unlock(rtc);
 
-- 
2.34.1

             reply	other threads:[~2026-11-29 19:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 19:25 Jiawen Liu [this message]
2026-11-29 19:31 ` [PATCH] rtc: omap: abort probe if runtime resume fails 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=179598033474.2.16434657830284928463.pattern-ext-052.2@gmail.com \
    --to=liu1298662399@gmail.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-rtc@vger.kernel.org \
    /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