From: Jishnu Prakash <jishnu.prakash@oss.qualcomm.com>
To: sashiko-reviews@lists.linux.dev
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v4 4/4] regulator: qcom-rpmh: Add debounce delay before disabling regulator
Date: Tue, 27 Oct 2026 18:04:04 +0530 [thread overview]
Message-ID: <5b771fac-68fa-455a-8970-dd42b4e41e8c@oss.qualcomm.com> (raw)
In-Reply-To: <20261001130511.C511F1F000FF@smtp.kernel.org>
On 10/1/2026 6:35 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
> - [High] regulator: qcom-rpmh: Use-After-Free due to devres LIFO ordering
> - [High] regulator: qcom-rpmh: Data race in worker thread bypassing regulator_lock
> - [High] regulator: qcom-rpmh: NULL pointer dereference if delayed disable fires before init completes
> - [Medium] regulator: qcom-rpmh: State desynchronization on driver removal drops pending disable
> --
>
> commit b0211424f1ad79c3af4f67d5c03d4546a1bd442e
> Author: Jishnu Prakash <jishnu.prakash@oss.qualcomm.com>
>
> regulator: qcom-rpmh: Add debounce delay before disabling regulator
>
> This commit adds a debounce delay to the Qualcomm RPMh regulator driver to
> prevent rapid disable/enable cycles. It introduces a delayed work item that
> defers sending disable requests to the hardware. A devres action is also
> added to cancel the delayed work upon driver removal.
>
>> diff --git a/drivers/regulator/qcom-rpmh-regulator.c b/drivers/regulator/qcom-rpmh-regulator.c
>> --- a/drivers/regulator/qcom-rpmh-regulator.c
>> +++ b/drivers/regulator/qcom-rpmh-regulator.c
>
> [ ... ]
>
>> @@ -347 +347,54 @@ static int rpmh_regulator_set_enable_state(struct regulator_dev *rdev,
>> return ret;
>> }
>>
>> +static void rpmh_delayed_off_work(struct work_struct *work)
>> +{
>> + struct rpmh_vreg *vreg = container_of(work,
>> + struct rpmh_vreg, delayed_off_work.work);
>> +
>> + if (!_rpmh_regulator_set_enable_state(vreg, vreg->rdev, false))
>
> [Severity: High]
> Does this worker thread modify the hardware state without holding the
> regulator core lock?
>
> The core consumer APIs execute under the regulator_lock. Running
> _rpmh_regulator_set_enable_state() here asynchronously might cause a data
> race on shared structures like vreg->enabled and vreg->voltage_selector if a
> consumer calls regulator_set_voltage() concurrently.
I checked the driver again and noticed that the check for
(vreg->enabled == -EINVAL && vreg->voltage_selector != -ENOTRECOVERABLE)
in rpmh_regulator_set_enable_state() is only needed to cover the
case where there was a voltage vote before the first enable vote
coming after the regulator's probe. After this first enable vote,
the value of vreg->enabled would always be 0 or 1 and this check
would never pass, so it can be ignored for concurrency concerns
with rpmh_regulator_vrm_set_voltage_sel() which checks
vreg->enabled.
The other comments are valid and I will address them in v5.
Thanks,
Jishnu
>
>> + vreg->last_off = ktime_get_boottime();
>> +}
>
prev parent reply other threads:[~2026-10-27 12:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 12:46 [PATCH v4 0/4] regulator: qcom-rpmh: Add support for off-on-delay and debounce-delay Jishnu Prakash
2026-10-01 12:46 ` [PATCH v4 1/4] regulator: dt-bindings: Add 'regulator-off-on-delay-us' property Jishnu Prakash
2026-10-07 20:36 ` Rob Herring (Arm)
2026-10-01 12:46 ` [PATCH v4 2/4] regulator: qcom-rpmh: Add support for regulator-off-on-delay-us Jishnu Prakash
2026-10-07 16:12 ` Mark Brown
2026-10-13 9:43 ` Jishnu Prakash
2026-10-01 12:46 ` [PATCH v4 3/4] regulator: dt-bindings: qcom,rpmh-regulator: Add debounce delay property Jishnu Prakash
2026-10-07 20:37 ` Rob Herring (Arm)
2026-10-01 12:46 ` [PATCH v4 4/4] regulator: qcom-rpmh: Add debounce delay before disabling regulator Jishnu Prakash
2026-10-01 13:05 ` sashiko-bot
2026-10-13 9:43 ` Jishnu Prakash
2026-10-27 12:34 ` Jishnu Prakash [this message]
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=5b771fac-68fa-455a-8970-dd42b4e41e8c@oss.qualcomm.com \
--to=jishnu.prakash@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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