public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
To: Doug Anderson <dianders@chromium.org>
Cc: Mark Brown <broonie@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] regulator: Only enable disabled regulators on resume
Date: Tue, 03 Mar 2015 20:05:38 +0100	[thread overview]
Message-ID: <54F60602.3030505@collabora.co.uk> (raw)
In-Reply-To: <CAD=FV=WmoYPYpiN40mmgE6VqKxr-VKuY1EtyE1S7iR7s4vr5Uw@mail.gmail.com>

Hello Doug,

On 03/03/2015 06:24 PM, Doug Anderson wrote:
> Javier,
> 
> On Mon, Mar 2, 2015 at 12:40 PM, Javier Martinez Canillas
> <javier.martinez@collabora.co.uk> wrote:
>> After leaving from system wide suspend state, regulator_suspend_finish()
>> turn on regulators that may be turned off by regulator_suspend_prepare()
>> but it tries to enable all regulators that have an enable count > 0 or
>> that were marked as "always-on" regardless if those were disabled or not.
>>
>> Trying to enable an already enabled regulator may cause issues so is
>> better to skip enabling regulators that were not disabled before suspend.
>>
>> Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
>> ---
>>  drivers/regulator/core.c | 8 +++++---
>>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> I've tested this and it also fixes the problem that my patch
> (regulator: core: Fix enable GPIO reference counting -
> https://patchwork.kernel.org/patch/5903071) fixes.
>

Thanks a lot for testing.
 
> As I said in the other conversation I think both patches could land.

Agreed that both patches should land.

> ...but maybe change your commit message to something like:
> 
> The _regulator_do_enable() call ought to be a no-op when called on an
> already-enabled regulator.  However, as an optimization
> _regulator_enable() doesn't call _regulator_do_enable() on an already
> enabled regulator.  That means we never test the case of calling
> _regulator_do_enable() during normal usage and there may be hidden
> bugs or warnings.  We have seen warnings issued by the tps65090 driver
> and bugs when using the GPIO enable pin.
>
> Let's match the same optimization that _regulator_enable() in
> regulator_suspend_finish().  That may speed up suspend/resume and also
> avoids exposing hidden bugs.
>

Right, I'll change the commit message since your suggestion is more clear.

>>
>> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
>> index f2452148c8da..8551400d57e4 100644
>> --- a/drivers/regulator/core.c
>> +++ b/drivers/regulator/core.c
>> @@ -3816,9 +3816,11 @@ int regulator_suspend_finish(void)
>>         list_for_each_entry(rdev, &regulator_list, list) {
>>                 mutex_lock(&rdev->mutex);
>>                 if (rdev->use_count > 0  || rdev->constraints->always_on) {
>> -                       error = _regulator_do_enable(rdev);
>> -                       if (error)
>> -                               ret = error;
>> +                       if (!_regulator_is_enabled(rdev)) {
> 
> Looking at _regulator_enable() I see that _regulator_is_enabled()
> could return an error.  Should we be checking?  Maybe we should have a
> helper function called by both callers?
>

Thanks for pointing that out. I'll change it on v2 as well.

> 
> I have tested this on my system and it works.  Other than the error
> check / updated commit message this looks good to me.
> 
>

I guess that means that I can include your Tested-by tag when
doing a re-spin? Please let me know otherwise.

> -Doug
> 

Best regards,
Javier

  reply	other threads:[~2015-03-03 19:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-02 20:40 [PATCH 1/1] regulator: Only enable disabled regulators on resume Javier Martinez Canillas
2015-03-03 17:24 ` Doug Anderson
2015-03-03 19:05   ` Javier Martinez Canillas [this message]
2015-03-04 13:45     ` Javier Martinez Canillas
2015-03-08 19:38       ` Mark Brown
2015-03-09  7:40         ` Javier Martinez Canillas
2015-03-11 10:57           ` Mark Brown
2015-03-11 11:00             ` Javier Martinez Canillas
2015-03-08 19:38 ` 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=54F60602.3030505@collabora.co.uk \
    --to=javier.martinez@collabora.co.uk \
    --cc=broonie@kernel.org \
    --cc=dianders@chromium.org \
    --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