linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Kevin Hilman <khilman@kernel.org>, Pavel Machek <pavel@ucw.cz>,
	Len Brown <len.brown@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/8] PM / domains: Protect reading loop over list of domains
Date: Mon, 12 Jun 2017 14:57:21 +0200	[thread overview]
Message-ID: <CAPDyKFosxZCVfSHiv5Q2zbkX+PGbGXuxr88rK1eggQO1UXPM0g@mail.gmail.com> (raw)
In-Reply-To: <20170609161649.g5wjn24tm2opyq3h@kozik-lap>

On 9 June 2017 at 18:16, Krzysztof Kozlowski <krzk@kernel.org> wrote:
> On Fri, Jun 09, 2017 at 06:08:47PM +0200, Krzysztof Kozlowski wrote:
>> The pm_genpd_present() iterates over list of domains so grabbing a
>> gpd_list_lock mutex is necessary before calling it.  Otherwise we could
>> end up in iterating over and modifying the list at the same time.
>>
>> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
>> ---
>>  drivers/base/power/domain.c | 7 ++++++-
>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
>> index 2e8d0f423507..2a6935dc0164 100644
>> --- a/drivers/base/power/domain.c
>> +++ b/drivers/base/power/domain.c
>> @@ -1099,8 +1099,13 @@ static void genpd_syscore_switch(struct device *dev, bool suspend)
>>       struct generic_pm_domain *genpd;
>>
>>       genpd = dev_to_genpd(dev);

Actually there may be potential problem here as we may end up trying
to use the container_of() call for a PM domain, not being a genpd but
something else.

>> -     if (!pm_genpd_present(genpd))
>> +
>> +     mutex_lock(&gpd_list_lock);
>> +     if (!pm_genpd_present(genpd)) {
>> +             mutex_unlock(&gpd_list_lock);
>>               return;
>> +     }
>> +     mutex_unlock(&gpd_list_lock);

Perhaps convert the hole thing above to call genpd_lookup_dev() instead?

>
> Eh, I might be too fast as this is not executed on my platform.  The
> genpd_syscore_switch() seems to be called by clocksource_suspend() which
> is called by syscore ops. Should be safe but actually not tested.
>
> Someone with SH hardware is needed...
>
> Best regards,
> Krzysztof
>

Kind regards
Uffe

  reply	other threads:[~2017-06-12 12:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-09 16:08 [PATCH 0/8] PM / Domains: Bunch of small improvements and fixes Krzysztof Kozlowski
2017-06-09 16:08 ` [PATCH 1/8] PM / Domains: Constify genpd pointer Krzysztof Kozlowski
2017-06-09 16:08 ` [PATCH 2/8] PM / domains: Protect reading loop over list of domains Krzysztof Kozlowski
2017-06-09 16:16   ` Krzysztof Kozlowski
2017-06-12 12:57     ` Ulf Hansson [this message]
2017-06-12 13:10       ` Krzysztof Kozlowski
2017-06-09 16:08 ` [PATCH 3/8] PM / domains: Add lockdep asserts for domains list mutex Krzysztof Kozlowski
2017-06-09 16:08 ` [PATCH 4/8] PM / domains: Fix unsafe iteration over modified list of device links Krzysztof Kozlowski
2017-06-09 16:08 ` [PATCH 5/8] PM / domains: Fix unsafe iteration over modified list of domain providers Krzysztof Kozlowski
2017-06-09 16:08 ` [PATCH 6/8] PM / domains: Fix unsafe iteration over modified list of domains Krzysztof Kozlowski
2017-06-09 16:08 ` [PATCH 7/8] PM / domains: Fix missing default_power_down_ok comment Krzysztof Kozlowski
2017-06-09 16:08 ` [RFC 8/8] PM / Domains: Add asserts for PM domain locks Krzysztof Kozlowski

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=CAPDyKFosxZCVfSHiv5Q2zbkX+PGbGXuxr88rK1eggQO1UXPM0g@mail.gmail.com \
    --to=ulf.hansson@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=khilman@kernel.org \
    --cc=krzk@kernel.org \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rjw@rjwysocki.net \
    /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;
as well as URLs for NNTP newsgroup(s).