* [PATCH v2 0/2] regulator: fp9931: fix voltage mapping and runtime PM issues
@ 2026-07-24 10:34 robby.cai
2026-07-24 10:34 ` [PATCH v2 1/2] regulator: fp9931: Fix VPOS/VNEG voltage selector table robby.cai
2026-07-24 10:34 ` [PATCH v2 2/2] regulator: fp9931: Fix Runtime PM usage count underflow in v3p3 ops robby.cai
0 siblings, 2 replies; 6+ messages in thread
From: robby.cai @ 2026-07-24 10:34 UTC (permalink / raw)
To: lgirdwood, broonie, andreas; +Cc: linux-kernel, imx
From: Robby Cai <robby.cai@nxp.com>
This series fixes two issues in the FP9931/JD9930 regulator driver.
Patch 1 fixes errors in the VPOS/VNEG voltage selector table, correcting
an off-by-one entry and extending the table to cover the full selector
range defined by the datasheet [1].
Patch 2 fixes a Runtime PM reference counting bug in the V3P3 regulator
callbacks that can lead to "Runtime PM usage count underflow!" warnings.
[1] https://www.fitipower.com/dl/file/flXa6hIchVeu0W3K (Datasheet, p.13)
Thanks,
Robby
---
Changes in v2:
- [1/2] Extend VPOSNEG_table[] to cover selectors 0x29-0x3f as defined by the datasheet and reformat the table for readability.
- [2/2] Refine commit message; no code change.
Link to v1: https://lore.kernel.org/imx/20260721095959.1855436-1-robby.cai@oss.nxp.com/
---
Robby Cai (2):
regulator: fp9931: Fix VPOS/VNEG voltage selector table
regulator: fp9931: Fix Runtime PM usage count underflow in v3p3 ops
drivers/regulator/fp9931.c | 61 +++++++++++---------------------------
1 file changed, 17 insertions(+), 44 deletions(-)
--
2.50.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] regulator: fp9931: Fix VPOS/VNEG voltage selector table
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 ` robby.cai
2026-08-04 22:36 ` Andreas Kemnade
2026-07-24 10:34 ` [PATCH v2 2/2] regulator: fp9931: Fix Runtime PM usage count underflow in v3p3 ops robby.cai
1 sibling, 1 reply; 6+ messages in thread
From: robby.cai @ 2026-07-24 10:34 UTC (permalink / raw)
To: lgirdwood, broonie, andreas; +Cc: linux-kernel, imx
From: Robby Cai <robby.cai@nxp.com>
The VPOSNEG_table[] mapping does not match the FP9931 datasheet.
The datasheet defines the VPOS/VNEG voltage mapping as:
00h-04h -> 7.04V (-7.04V)
05h -> 7.26V (-7.26V)
06h -> 7.49V (-7.49V)
...
28h-3Fh -> 15.06V (-15.06V)
However, VPOSNEG_table[] has two issues:
1. Selector 0x00~0x04 should all map to 7.04V (5 entries), but the
table has 6 entries of 7.04V, causing all subsequent entries to be
shifted by one position.
2. Selectors 0x29~0x3F should all clamp to 15.06V (23 entries), but
the table has only 41 entries. Any selector value above 0x28
would result in an out-of-bounds table access.
Fix both issues by removing the duplicate 7.04V entry and appending
the missing 23 clamped 15.06V entries, bringing the table to the
correct size of 64 entries (0x00~0x3F).
Fixes: 12d821bd13d4 ("regulator: Add FP9931/JD9930 driver")
Signed-off-by: Robby Cai <robby.cai@nxp.com>
---
drivers/regulator/fp9931.c | 54 +++++++++-----------------------------
1 file changed, 12 insertions(+), 42 deletions(-)
diff --git a/drivers/regulator/fp9931.c b/drivers/regulator/fp9931.c
index 002b41f53eff..ff743a8b0dfe 100644
--- a/drivers/regulator/fp9931.c
+++ b/drivers/regulator/fp9931.c
@@ -37,48 +37,18 @@ struct fp9931_data {
};
static const unsigned int VPOSNEG_table[] = {
- 7040000,
- 7040000,
- 7040000,
- 7040000,
- 7040000,
- 7040000,
- 7260000,
- 7490000,
- 7710000,
- 7930000,
- 8150000,
- 8380000,
- 8600000,
- 8820000,
- 9040000,
- 9270000,
- 9490000,
- 9710000,
- 9940000,
- 10160000,
- 10380000,
- 10600000,
- 10830000,
- 11050000,
- 11270000,
- 11490000,
- 11720000,
- 11940000,
- 12160000,
- 12380000,
- 12610000,
- 12830000,
- 13050000,
- 13280000,
- 13500000,
- 13720000,
- 13940000,
- 14170000,
- 14390000,
- 14610000,
- 14830000,
- 15060000,
+ 7040000, 7040000, 7040000, 7040000, 7040000, /* 00h-04h */
+ 7260000, 7490000, 7710000, 7930000, 8150000, 8380000, /* 05h-0Ah */
+ 8600000, 8820000, 9040000, 9270000, 9490000, 9710000, /* 0Bh-10h */
+ 9940000, 10160000, 10380000, 10600000, 10830000, 11050000, /* 11h-16h */
+ 11270000, 11490000, 11720000, 11940000, 12160000, 12380000, /* 17h-1Ch */
+ 12610000, 12830000, 13050000, 13280000, 13500000, 13720000, /* 1Dh-22h */
+ 13940000, 14170000, 14390000, 14610000, 14830000, 15060000, /* 23h-28h */
+ /* 29h-3Fh: clamped to 15.06V per datasheet */
+ 15060000, 15060000, 15060000, 15060000, 15060000, 15060000,
+ 15060000, 15060000, 15060000, 15060000, 15060000, 15060000,
+ 15060000, 15060000, 15060000, 15060000, 15060000, 15060000,
+ 15060000, 15060000, 15060000, 15060000, 15060000,
};
static const struct hwmon_channel_info *fp9931_info[] = {
--
2.50.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] regulator: fp9931: Fix Runtime PM usage count underflow in v3p3 ops
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-07-24 10:34 ` robby.cai
2026-07-25 19:50 ` Andreas Kemnade
1 sibling, 1 reply; 6+ messages in thread
From: robby.cai @ 2026-07-24 10:34 UTC (permalink / raw)
To: lgirdwood, broonie, andreas; +Cc: linux-kernel, imx
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] regulator: fp9931: Fix Runtime PM usage count underflow in v3p3 ops
2026-07-24 10:34 ` [PATCH v2 2/2] regulator: fp9931: Fix Runtime PM usage count underflow in v3p3 ops robby.cai
@ 2026-07-25 19:50 ` Andreas Kemnade
2026-07-31 8:35 ` Robby Cai (OSS)
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Kemnade @ 2026-07-25 19:50 UTC (permalink / raw)
To: robby.cai; +Cc: lgirdwood, broonie, linux-kernel, imx
On Fri, 24 Jul 2026 18:34:41 +0800
robby.cai@oss.nxp.com wrote:
> 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);
>
if autosuspend kicks in, the whole chip will
be powered off, so if no vcom/vposneg is enabled, v3p3 will also be
disabled.
Regards,
Andreas
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH v2 2/2] regulator: fp9931: Fix Runtime PM usage count underflow in v3p3 ops
2026-07-25 19:50 ` Andreas Kemnade
@ 2026-07-31 8:35 ` Robby Cai (OSS)
0 siblings, 0 replies; 6+ messages in thread
From: Robby Cai (OSS) @ 2026-07-31 8:35 UTC (permalink / raw)
To: Andreas Kemnade, Robby Cai (OSS); +Cc: lgirdwood, broonie, linux-kernel, imx
>-----Original Message-----
>From: Andreas Kemnade <andreas@kemnade.info>
>Sent: Sunday, July 26, 2026 3:51 AM
>To: Robby Cai (OSS) <robby.cai@oss.nxp.com>
>Cc: lgirdwood@gmail.com; broonie@kernel.org; linux-kernel@vger.kernel.org;
>imx@lists.linux.dev
>Subject: Re: [PATCH v2 2/2] regulator: fp9931: Fix Runtime PM usage count
>underflow in v3p3 ops
>
[...]
>> ---
>> 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);
>>
>if autosuspend kicks in, the whole chip will be powered off, so if no
>vcom/vposneg is enabled, v3p3 will also be disabled.
Thanks for the review. That makes sense. Please disregard this patch for now.
Regards,
Robby
>
>Regards,
>Andreas
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] regulator: fp9931: Fix VPOS/VNEG voltage selector table
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
0 siblings, 0 replies; 6+ messages in thread
From: Andreas Kemnade @ 2026-08-04 22:36 UTC (permalink / raw)
To: robby.cai; +Cc: lgirdwood, broonie, linux-kernel, imx
On Fri, 24 Jul 2026 18:34:40 +0800
robby.cai@oss.nxp.com wrote:
> From: Robby Cai <robby.cai@nxp.com>
>
> The VPOSNEG_table[] mapping does not match the FP9931 datasheet.
>
> The datasheet defines the VPOS/VNEG voltage mapping as:
>
> 00h-04h -> 7.04V (-7.04V)
> 05h -> 7.26V (-7.26V)
> 06h -> 7.49V (-7.49V)
> ...
> 28h-3Fh -> 15.06V (-15.06V)
>
> However, VPOSNEG_table[] has two issues:
>
> 1. Selector 0x00~0x04 should all map to 7.04V (5 entries), but the
> table has 6 entries of 7.04V, causing all subsequent entries to be
> shifted by one position.
>
> 2. Selectors 0x29~0x3F should all clamp to 15.06V (23 entries), but
> the table has only 41 entries. Any selector value above 0x28
> would result in an out-of-bounds table access.
>
> Fix both issues by removing the duplicate 7.04V entry and appending
> the missing 23 clamped 15.06V entries, bringing the table to the
> correct size of 64 entries (0x00~0x3F).
>
> Fixes: 12d821bd13d4 ("regulator: Add FP9931/JD9930 driver")
> Signed-off-by: Robby Cai <robby.cai@nxp.com>
Somehow I missed this.
So also for this:
Reviewed-by: Andreas Kemnade <andreas@kemnade.infe>
> ---
> drivers/regulator/fp9931.c | 54 +++++++++-----------------------------
> 1 file changed, 12 insertions(+), 42 deletions(-)
>
> diff --git a/drivers/regulator/fp9931.c b/drivers/regulator/fp9931.c
> index 002b41f53eff..ff743a8b0dfe 100644
> --- a/drivers/regulator/fp9931.c
> +++ b/drivers/regulator/fp9931.c
> @@ -37,48 +37,18 @@ struct fp9931_data {
> };
>
> static const unsigned int VPOSNEG_table[] = {
> - 7040000,
> - 7040000,
> - 7040000,
> - 7040000,
> - 7040000,
> - 7040000,
> - 7260000,
> - 7490000,
> - 7710000,
> - 7930000,
> - 8150000,
> - 8380000,
> - 8600000,
> - 8820000,
> - 9040000,
> - 9270000,
> - 9490000,
> - 9710000,
> - 9940000,
> - 10160000,
> - 10380000,
> - 10600000,
> - 10830000,
> - 11050000,
> - 11270000,
> - 11490000,
> - 11720000,
> - 11940000,
> - 12160000,
> - 12380000,
> - 12610000,
> - 12830000,
> - 13050000,
> - 13280000,
> - 13500000,
> - 13720000,
> - 13940000,
> - 14170000,
> - 14390000,
> - 14610000,
> - 14830000,
> - 15060000,
> + 7040000, 7040000, 7040000, 7040000, 7040000, /* 00h-04h */
> + 7260000, 7490000, 7710000, 7930000, 8150000, 8380000, /* 05h-0Ah */
> + 8600000, 8820000, 9040000, 9270000, 9490000, 9710000, /* 0Bh-10h */
> + 9940000, 10160000, 10380000, 10600000, 10830000, 11050000, /* 11h-16h */
> + 11270000, 11490000, 11720000, 11940000, 12160000, 12380000, /* 17h-1Ch */
> + 12610000, 12830000, 13050000, 13280000, 13500000, 13720000, /* 1Dh-22h */
> + 13940000, 14170000, 14390000, 14610000, 14830000, 15060000, /* 23h-28h */
> + /* 29h-3Fh: clamped to 15.06V per datasheet */
> + 15060000, 15060000, 15060000, 15060000, 15060000, 15060000,
> + 15060000, 15060000, 15060000, 15060000, 15060000, 15060000,
> + 15060000, 15060000, 15060000, 15060000, 15060000, 15060000,
> + 15060000, 15060000, 15060000, 15060000, 15060000,
> };
>
> static const struct hwmon_channel_info *fp9931_info[] = {
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-08-04 22:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v2 2/2] regulator: fp9931: Fix Runtime PM usage count underflow in v3p3 ops robby.cai
2026-07-25 19:50 ` Andreas Kemnade
2026-07-31 8:35 ` Robby Cai (OSS)
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®