mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: robby.cai@oss.nxp.com
To: lgirdwood@gmail.com, broonie@kernel.org, andreas@kemnade.info
Cc: linux-kernel@vger.kernel.org, imx@lists.linux.dev
Subject: [PATCH v2 2/2] regulator: fp9931: Fix Runtime PM usage count underflow in v3p3 ops
Date: Fri, 24 Jul 2026 18:34:41 +0800	[thread overview]
Message-ID: <20260724103441.800522-3-robby.cai@oss.nxp.com> (raw)
In-Reply-To: <20260724103441.800522-1-robby.cai@oss.nxp.com>

From: Robby Cai <robby.cai@nxp.com>

The fp9931_v3p3_enable() callback acquires a Runtime PM reference which
remains held until fp9931_v3p3_disable() releases it.

Device-level Runtime PM lifetime is also managed through the shared
VCOM enable path: fp9931_set_enable() acquires a reference and
fp9931_clear_enable() releases it.

As a result, the Runtime PM usage count may already have reached 0
before fp9931_v3p3_disable() is invoked. In that case,
fp9931_v3p3_disable() calls pm_runtime_put_autosuspend() on an
already-zero count, triggering:

  fp9931 1-0018: Runtime PM usage count underflow!

Holding a Runtime PM reference across the V3P3 regulator lifetime is
unnecessary. V3P3 only needs the device to be runtime-active for the
duration of the register access.

Fix this by scoping the Runtime PM reference lifetime to the register
access itself, pairing pm_runtime_resume_and_get() and
pm_runtime_put_autosuspend() within each callback.

Fixes: 12d821bd13d4 ("regulator: Add FP9931/JD9930 driver")
Signed-off-by: Robby Cai <robby.cai@nxp.com>
---
 drivers/regulator/fp9931.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/fp9931.c b/drivers/regulator/fp9931.c
index ff743a8b0dfe..0d926546221a 100644
--- a/drivers/regulator/fp9931.c
+++ b/drivers/regulator/fp9931.c
@@ -214,8 +214,7 @@ static int fp9931_v3p3_enable(struct regulator_dev *rdev)
 		return ret;
 
 	ret = regulator_enable_regmap(rdev);
-	if (ret < 0)
-		pm_runtime_put_autosuspend(data->dev);
+	pm_runtime_put_autosuspend(data->dev);
 
 	return ret;
 }
@@ -225,6 +224,10 @@ static int fp9931_v3p3_disable(struct regulator_dev *rdev)
 	struct fp9931_data *data = rdev_get_drvdata(rdev);
 	int ret;
 
+	ret = pm_runtime_resume_and_get(data->dev);
+	if (ret < 0)
+		return ret;
+
 	ret = regulator_disable_regmap(rdev);
 	pm_runtime_put_autosuspend(data->dev);
 
-- 
2.50.1


  parent reply	other threads:[~2026-07-24 10:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24 10:34 [PATCH v2 0/2] regulator: fp9931: fix voltage mapping and runtime PM issues robby.cai
2026-07-24 10:34 ` [PATCH v2 1/2] regulator: fp9931: Fix VPOS/VNEG voltage selector table robby.cai
2026-08-04 22:36   ` Andreas Kemnade
2026-07-24 10:34 ` robby.cai [this message]
2026-07-25 19:50   ` [PATCH v2 2/2] regulator: fp9931: Fix Runtime PM usage count underflow in v3p3 ops Andreas Kemnade
2026-07-31  8:35     ` Robby Cai (OSS)

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=20260724103441.800522-3-robby.cai@oss.nxp.com \
    --to=robby.cai@oss.nxp.com \
    --cc=andreas@kemnade.info \
    --cc=broonie@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®