All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Lukas Wunner <lukas@wunner.de>
Cc: Linux PM <linux-pm@vger.kernel.org>,
	Kevin Hilman <khilman@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>
Subject: Re: [PATCH] PM / runtime: Rework pm_runtime_force_suspend/resume()
Date: Wed, 3 Jan 2018 00:21:36 +0100	[thread overview]
Message-ID: <CAJZ5v0gp_CJJZk7MwLtErqmM=iXxsxK5-mMA-w_4DYmtBBih0w@mail.gmail.com> (raw)
In-Reply-To: <2760744.Zsn8Ys48yq@aspire.rjw.lan>

On Tue, Jan 2, 2018 at 8:07 PM, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> On Tuesday, January 2, 2018 2:04:04 PM CET Lukas Wunner wrote:
>> On Tue, Jan 02, 2018 at 12:02:18PM +0100, Rafael J. Wysocki wrote:
>> > On Tue, Jan 2, 2018 at 11:51 AM, Lukas Wunner <lukas@wunner.de> wrote:
>> > > On Tue, Jan 02, 2018 at 01:56:28AM +0100, Rafael J. Wysocki wrote:
>> > >> +     if (atomic_read(&dev->power.usage_count) <= 1 &&
>> > >> +         atomic_read(&dev->power.child_count) == 0)
>> > >> +             pm_runtime_set_suspended(dev);
>> > >>
>> > >> -     pm_runtime_set_suspended(dev);
>> > >
>> > > The ->runtime_suspend callback *has* been executed at this point.
>> > > If the status is only updated conditionally, it may not reflect
>> > > the device's actual power state correctly.  That doesn't seem to
>> > > be a good idea.
>> >
>> > It doesn't matter, because this is done with runtime PM disabled, isn't it?
>>
>> It might not make a difference for the use case I have in mind, but
>> pm_runtime_status_suspended() will return an incorrect result and is
>> called from 47 files in 4.15-rc6 according to lxr.free-electrons.com.
>
> Generally, the runtime PM status is only meaningful for devices with runtime PM
> enabled.
>
> There is an exception, which is during system suspend/resume, when runtime PM
> is automatically disabled by the core, but that only under certain assumptions.
>
> Basically, you have to assume that no one else will mess up with the device
> between the times you call pm_runtime_status_suspended() to check its runtime
> PM status (or between the first time you do that and the last time runtime PM
> has been enabled for the device).
>
> This patch doesn't change the situation in that respect.

BTW, I'm not sure why you are worrying about the "status" field alone
and not about the usage counter that can be greater than 0 after
pm_runtime_force_suspend() which is inconsistent with the device's
physical state (and with the "status" field too for that matter -
always without the patch and in some cases with it) then.  As a matter
of fact, the information left by the runtime PM framework is messed up
with here this way or another and so anyway the only party that can
make sense of it after pm_runtime_force_suspend() is the subsequent
pm_runtime_force_resume().

Thanks,
Rafael

  reply	other threads:[~2018-01-02 23:21 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-02  0:56 [PATCH] PM / runtime: Rework pm_runtime_force_suspend/resume() Rafael J. Wysocki
2018-01-02 10:51 ` Lukas Wunner
2018-01-02 11:02   ` Rafael J. Wysocki
2018-01-02 11:21     ` Rafael J. Wysocki
2018-01-02 13:04     ` Lukas Wunner
2018-01-02 19:07       ` Rafael J. Wysocki
2018-01-02 23:21         ` Rafael J. Wysocki [this message]
2018-01-03 11:01           ` Rafael J. Wysocki
2018-01-03 11:06 ` [PATCH v2] " Rafael J. Wysocki
2018-01-09  6:08   ` Ulf Hansson
2018-01-09 12:34     ` Rafael J. Wysocki
2018-01-09 14:13       ` Ulf Hansson
2018-01-12  1:55     ` Rafael J. Wysocki
2018-01-12 13:46       ` Ulf Hansson
2018-01-13  1:23         ` Rafael J. Wysocki
2018-01-09 13:37   ` Geert Uytterhoeven
2018-01-09 14:27     ` Ulf Hansson
2018-01-09 14:34       ` Geert Uytterhoeven
2018-01-09 15:00     ` Rafael J. Wysocki
2018-01-09 15:30       ` Geert Uytterhoeven
2018-01-09 16:03         ` Rafael J. Wysocki
2018-01-09 16:03           ` Rafael J. Wysocki
2018-01-09 16:28           ` Rafael J. Wysocki
2018-01-09 16:28             ` [v2] " Rafael J. Wysocki
2018-01-10  9:26             ` [PATCH v2] " Ulf Hansson
2018-01-10  9:26               ` [v2] " Ulf Hansson
2018-01-11  0:46               ` [PATCH v2] " Rafael J. Wysocki
2018-01-11  0:46                 ` [v2] " Rafael J. Wysocki
2018-01-11 12:32                 ` [PATCH v2] " Ulf Hansson
2018-01-11 12:32                   ` [v2] " Ulf Hansson
2018-01-11 18:44                   ` [PATCH v2] " Rafael J. Wysocki
2018-01-11 18:44                     ` [v2] " Rafael J. Wysocki
2018-01-12 11:26             ` [PATCH v2] " Geert Uytterhoeven
2018-01-12 11:26               ` Geert Uytterhoeven
2018-01-12 11:26               ` [v2] " Geert Uytterhoeven
2018-01-12 12:09               ` [PATCH v2] " Rafael J. Wysocki
2018-01-12 12:09                 ` [v2] " Rafael J. Wysocki
2018-01-09 16:25       ` [PATCH v2] " Rafael J. Wysocki
2018-01-12 11:20         ` Geert Uytterhoeven
2018-01-09 18:46     ` Rafael J. Wysocki
2018-01-09 19:02       ` Rafael J. Wysocki

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='CAJZ5v0gp_CJJZk7MwLtErqmM=iXxsxK5-mMA-w_4DYmtBBih0w@mail.gmail.com' \
    --to=rafael@kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=khilman@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=ulf.hansson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.