public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Mark Brown <broonie@kernel.org>
Cc: Thierry Reding <treding@nvidia.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: Re: [PATCH v1] regulator: Don't error out fixed regulator in regulator_sync_voltage()
Date: Thu, 21 Oct 2021 16:55:17 +0300	[thread overview]
Message-ID: <89d99367-1f69-a9b8-90ea-7f794c85d5a5@gmail.com> (raw)
In-Reply-To: <7ee0ccd7-8ac5-8a9e-7f55-31fac944a5d2@gmail.com>

21.10.2021 16:46, Dmitry Osipenko пишет:
> 21.10.2021 16:12, Mark Brown пишет:
>> On Thu, Oct 21, 2021 at 02:07:07PM +0300, Dmitry Osipenko wrote:
>>
>>> Fixed regulator can't change voltage and regulator_sync_voltage() returns
>>> -EINVAL in this case. Make regulator_sync_voltage() to succeed for a fixed
>>> regulator.
>>
>>> +++ b/drivers/regulator/core.c
>>> @@ -4249,6 +4249,9 @@ int regulator_sync_voltage(struct regulator *regulator)
>>>  	struct regulator_voltage *voltage = &regulator->voltage[PM_SUSPEND_ON];
>>>  	int ret, min_uV, max_uV;
>>>  
>>> +	if (rdev->desc->fixed_uV && rdev->desc->n_voltages == 1)
>>> +		return 0;
>>> +
>>>  	regulator_lock(rdev);
>>
>> It's unclear why this is checking both fixed_uV and n_voltages.
> 
> It's unclear to me either. I borrowed this variant from the  preexisting
> code [1][2].
> 
> [1]
> https://elixir.bootlin.com/linux/v5.15-rc6/source/drivers/regulator/core.c#L3075
> 
> [2]
> https://elixir.bootlin.com/linux/v5.15-rc6/source/drivers/regulator/core.c#L4319

The alternative could be to check regulator's capabilities:

if (!regulator_ops_is_valid(rdev, REGULATOR_CHANGE_VOLTAGE))
	return 0;

This looks like a better variant, actually.

>>  TBH
>> this feels like a higher level issue - with normal voltage configuration
>> we would have noticed that our constraints prevent the voltage changing
>> and not go as far as trying to actually apply a new configuration.  I
>> would expect a similar thing to be happening here.
>>
> 
> This works for a normal regulator_set_voltage() because it checks
> whether current voltage equals to the requested and then succeeds [3].
> The higher level code relies on this behaviour of the regulator core, in
> particular OPP core won't work without it and that's why voltage changes
> work for a fixed regulator.
> 
> [3]
> https://elixir.bootlin.com/linux/v5.15-rc6/source/drivers/regulator/core.c#L3619
> 
> This doesn't work for the regulator_sync_voltage() because it uses a
> different code path and the whole point is to re-apply the current
> voltage. Hence the extra check is actually needed for the fixed
> regulators in order to be consistent with the behaviour of
> regulator_set_voltage().
> 


  reply	other threads:[~2021-10-21 13:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21 11:07 [PATCH v1] regulator: Don't error out fixed regulator in regulator_sync_voltage() Dmitry Osipenko
2021-10-21 13:12 ` Mark Brown
2021-10-21 13:46   ` Dmitry Osipenko
2021-10-21 13:55     ` Dmitry Osipenko [this message]
2021-10-21 14:33       ` Mark Brown

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=89d99367-1f69-a9b8-90ea-7f794c85d5a5@gmail.com \
    --to=digetx@gmail.com \
    --cc=broonie@kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=treding@nvidia.com \
    /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