LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Cc: Doug Anderson <dianders@chromium.org>,
	milo.kim@ti.com, axel.lin@ingics.com,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	olof@lixom.net, Paul Stewart <pstew@chromium.org>,
	stable@vger.kernel.org, lgirdwood@gmail.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] regulator: core: Fix enable GPIO reference counting
Date: Mon, 2 Mar 2015 18:57:13 +0000	[thread overview]
Message-ID: <20150302185713.GF21293@sirena.org.uk> (raw)
In-Reply-To: <54F0DB23.3010203@collabora.co.uk>

[-- Attachment #1: Type: text/plain, Size: 1441 bytes --]

On Fri, Feb 27, 2015 at 10:01:23PM +0100, Javier Martinez Canillas wrote:

> I noticed the same problem in regulator_suspend_finish() when I was working
> on S2R for Exynos a couple of months ago and had patch [0] on my local tree
> but never found the time to do extensive testing so I never posted it.

Please don't bury patches in the middle of mails where they're hard to
apply if they're useful.

> I see that the check is already in _regulator_enable() so another option
> is to call _regulator_enable() instead of _regulator_do_enable() in
> regulator_suspend_finish().

I'm not entirely sure what "the check" is?

> Trying to enable an already enabled regulator may cause issues so is
> better to skip enabling regulators that were not disabled before suspend.

>  		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)) {
> +			    error = _regulator_do_enable(rdev);
> +			    if (error)
> +				    ret = error;
> +			}

This seems like a better fix or at least a better approach - essentially
the assumption in most of the code is that regulator enables are just
register writes so repeated updates don't have any effect.  We may need
a specific per client count here...  I've not looked at the code and I
only got back to the UK this morning so I'm not going to start now.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2015-03-02 18:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-27 19:41 Doug Anderson
2015-02-27 20:08 ` Greg KH
2015-02-27 21:01 ` Javier Martinez Canillas
2015-03-02 18:57   ` Mark Brown [this message]
2015-03-02 20:21     ` Javier Martinez Canillas
2015-03-03 14:24       ` Mark Brown
2015-03-02 18:47 ` Mark Brown
2015-03-02 21:13   ` Doug Anderson
2015-03-03 14:23     ` Mark Brown
2015-03-03 23:21       ` Doug Anderson
2015-03-04 11:27         ` Mark Brown
2015-03-04 17:13           ` Doug Anderson

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=20150302185713.GF21293@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=axel.lin@ingics.com \
    --cc=dianders@chromium.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=javier.martinez@collabora.co.uk \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=milo.kim@ti.com \
    --cc=olof@lixom.net \
    --cc=pstew@chromium.org \
    --cc=stable@vger.kernel.org \
    --subject='Re: [PATCH] regulator: core: Fix enable GPIO reference counting' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).