mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Jishnu Prakash <jishnu.prakash@oss.qualcomm.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,  Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	 Conor Dooley <conor+dt@kernel.org>,
	linux-kernel@vger.kernel.org,  devicetree@vger.kernel.org,
	linux-arm-msm@vger.kernel.org,
	 Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>,
	 Kamal Wadhwa <kamal.wadhwa@oss.qualcomm.com>,
	 Saikiran <bjsaikiran@gmail.com>
Subject: Re: [PATCH v5 4/4] regulator: qcom-rpmh: Add debounce delay before disabling regulator
Date: Fri, 13 Nov 2026 22:36:49 +0000	[thread overview]
Message-ID: <179460940931.590303.9395310796576570677.b4-review@b4> (raw)
In-Reply-To: <20261027-regulator-off-on-delay-v5-4-f9c3b128c6d0@oss.qualcomm.com>

> Some consumers rapidly toggle a regulator off and back on, e.g. a
> driver that disables its supply on -EPROBE_DEFER and re-enables it on
> the next probe attempt. Sending the disable to RPMh immediately causes
> needless power cycling of the rail.

Looking at the code here this doesn't really seem at all driver specific
- we could implement this in the core around any disable and enable
operation.  Is there anything that really ties this to the driver code,
or could it be factored out and available to everything?

There's also a bunch of stuff from Sashiko a lot of which looks valid
but I didn't check it carefully.

> + * @lock:			Serializes disable() against the teardown
> + *				action, since both make a read-then-act decision
> + *				on @debounce_delay that must be atomic to avoid
> + *				queuing @delayed_off_work after teardown has
> + *				swept it.  enable() needs no lock: its only
> + *				shared-state access is cancel_delayed_work_sync(),
> + *				which already serializes against
> + *				@delayed_off_work.  @enabled and @rdev are also
> + *				written by @delayed_off_work without this lock
> + *				held, so they use READ_ONCE()/WRITE_ONCE() there.

The work doesn't seem to write rdev, but does write last_off?

> +static void rpmh_delayed_off_work(struct work_struct *work)
> +{
> +	struct rpmh_vreg *vreg = container_of(work,
> +					struct rpmh_vreg, delayed_off_work.work);
> +
> +	/*
> +	 * No locking needed. cancel_delayed_work_sync() already guarantees
> +	 * this work has either not started or has fully finished by the
> +	 * time enable()/teardown proceed to touch shared state.
> +	 */
> +	if (!_rpmh_regulator_set_enable_state(vreg, READ_ONCE(vreg->rdev), false))
> +		vreg->last_off = ktime_get_boottime();
> +}

There's no reporting if the actual disable fails which seems bad.

>  static int rpmh_regulator_enable(struct regulator_dev *rdev)
>  {
> -	return rpmh_regulator_set_enable_state(rdev, true);
> +	struct rpmh_vreg *vreg = rdev_get_drvdata(rdev);
> +	s64 remaining;
> +
> +	/* See struct rpmh_vreg's @lock for why no lock is needed here. */
> +	if (cancel_delayed_work_sync(&vreg->delayed_off_work)) {
> +		/* Queued disable never reached RPMh, so undo disable()'s flip. */
> +		WRITE_ONCE(vreg->enabled, true);
> +		return 0;
> +	}

Nor do we restore this flag.

-- 
Mark Brown <broonie@kernel.org>

  reply	other threads:[~2026-11-13 22:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 12:34 [PATCH v5 0/4] regulator: qcom-rpmh: Add support for off-on-delay and debounce-delay Jishnu Prakash
2026-10-27 12:34 ` [PATCH v5 1/4] regulator: dt-bindings: Add 'regulator-off-on-delay-us' property Jishnu Prakash
2026-10-27 12:34 ` [PATCH v5 2/4] regulator: core: Parse regulator-off-on-delay-us generically Jishnu Prakash
2026-10-27 12:34 ` [PATCH v5 3/4] regulator: dt-bindings: qcom,rpmh-regulator: Add debounce delay property Jishnu Prakash
2026-10-27 12:34 ` [PATCH v5 4/4] regulator: qcom-rpmh: Add debounce delay before disabling regulator Jishnu Prakash
2026-11-13 22:36   ` Mark Brown [this message]
2026-11-24  8:07     ` Jishnu Prakash

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=179460940931.590303.9395310796576570677.b4-review@b4 \
    --to=broonie@kernel.org \
    --cc=bjsaikiran@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jishnu.prakash@oss.qualcomm.com \
    --cc=kamal.wadhwa@oss.qualcomm.com \
    --cc=krzk+dt@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manivannan.sadhasivam@oss.qualcomm.com \
    --cc=robh@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®