All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	"Rafael J . Wysocki" <rjw@rjwysocki.net>,
	Linux PM list <linux-pm@vger.kernel.org>,
	Kevin Hilman <khilman@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Simon Horman <horms@verge.net.au>,
	Niklas Soderlund <niklas.soderlund+renesas@ragnatech.se>,
	Linux-Renesas <linux-renesas-soc@vger.kernel.org>
Subject: Re: [PATCH 0/3] PM / core: Invent a WAKEUP_POWERED driver flag
Date: Thu, 9 Nov 2017 13:02:32 +0100	[thread overview]
Message-ID: <CAJZ5v0hrgyRZ+yqA_J75J8AGycW7DMsT8fnNXFQceLJCER9=fw@mail.gmail.com> (raw)
In-Reply-To: <CAJZ5v0geFEHje039bAgzTxGMfCcOutiZY4LWD+e7s+_7UasX6g@mail.gmail.com>

On Thu, Nov 9, 2017 at 12:59 PM, Rafael J. Wysocki <rafael@kernel.org> wrote:
> On Thu, Nov 9, 2017 at 11:08 AM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>> On 9 November 2017 at 10:02, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>>> Hi Ulf,
>>>
>>> On Thu, Nov 9, 2017 at 9:28 AM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>>>> On 8 November 2017 at 16:41, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>>>>> On Wed, Nov 8, 2017 at 4:15 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>>>>>> The generic problem this series is trying to solve, is that for some bus types
>>>>>> and PM domains, it's not sufficient to only check the return value from
>>>>>> device_may_wakeup(), to fully understand how to treat the device during system
>>>>>> suspend.
>>>>>>
>>>>>> One particular case that suffers from this, is the generic PM domain (aka genpd)
>>>>>> and that is taken care of in the final change in this series.
>>>>>>
>>>>>> The special case this series address, is to enable drivers to instruct bus types
>>>>>> and PM domains, that the device need to stay powered in case wakeup signals
>>>>>> is enabled for it.
>>>
>>>>>> Geert Uytterhoeven, has been working on some related problems for some Renesas
>>>>>> SoCs [1], to be able to properly configure WakeOnLAN, for some ethernet
>>>>>> devices/drivers, which are used together with genpd. My intent is that this
>>>>>> series enables a solution for those problems.
>>>>>>
>>>>>> [1]
>>>>>> https://www.spinics.net/lists/linux-renesas-soc/msg19319.html
>>>>>
>>>>> While your new WAKEUP_POWERED definitely serves a purpose, I don't think
>>>>> it's the right solution for the Renesas SoCs.  I can just set the recently
>>>>> added flag GENPD_FLAG_ACTIVE_WAKEUP in all Renesas clock/power domain
>>>>> drivers to fix the issue for all Renesas drivers.  After all, all devices in
>>>>> the clock/power domain must be kept enabled if they're a wakeup source, or
>>>>> part of the wakeup path.
>>>>
>>>> Right, that would work! However, to me, I don't think it's fine grained enough.
>>>>
>>>> Let's take the Ethernet device/driver using WoL as an example, similar
>>>> to your cases.
>>>>
>>>> First, let's assume device_may_wakeup() returns true, meaning that the
>>>> Ethernet device is wakeup capable and that userspace has requested
>>>> wakeup to be enabled.
>>>>
>>>> Then we have three scenarios to consider when the Ethernet driver
>>>> becomes suspended (typically when its ->suspend() callback gets
>>>> invoked).
>>>> 1) The Ethernet interface is down.
>>>> 2) The Ethernet interface is up, but no connection established.
>>>> 3) The Ethernet interface is up, connection established.
>>>>
>>>> By following your approach, using GENPD_FLAG_ACTIVE_WAKEUP, would mean
>>>> that we can't distinguish between any of the the scenarios above, but
>>>> instead always keep the Ethernet device powered on and thus the PM
>>>> domain also.
>>>>
>>>> In the more fine grained solution, we can change the Ethernet driver
>>>> to consider under what scenario it's being suspended. For 1) and 2),
>>>> there is no need to keep the Ethernet device being powered, but
>>>> instead only enable WoL in 3) - via also using the WAKEUP_POWERED
>>>> flag.
>>>
>>> The Ethernet driver can still call device_set_wakeup_enable(... , false)
>>> to control this.  If WoL is disabled by the user (or deemed not usable, see
>>> below), it already does so.
>>
>> I don't think that API is intended to be used like that and I wonder
>> if it even works as expected.
>>
>> Quoting the doc:
>> "If device wakeup mechanisms are enabled or disabled directly by
>> drivers, they also should use :c:func:`device_may_wakeup()` to decide what to do
>> during a system sleep transition.  Device drivers, however, are not expected to
>> call :c:func:`device_set_wakeup_enable()` directly in any case."
>>
>> Rafael, can you comment on this?
>
> Well, it means what it says.
>
> If you call device_set_wakeup_enable() from a driver, user space will
> see a change in sysfs and may be confused by that and that's why doing
> so is not recommended.
>
> Not that people listen to recommendations too much, though. :-)

But setting up WoL via ethtool from user space is an exception,
because user space actually *does* expect to see a change in sysfs in
this particular case.

It's basically two different ways to change the same setting and both
should result in the same behavior, ideally.

Thanks,
Rafael

      reply	other threads:[~2017-11-09 12:02 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-08 15:15 [PATCH 0/3] PM / core: Invent a WAKEUP_POWERED driver flag Ulf Hansson
2017-11-08 15:15 ` [PATCH 1/3] PM / core: Re-factor some code dealing with parents in __device_suspend() Ulf Hansson
2017-11-08 15:26   ` Geert Uytterhoeven
2017-11-08 15:15 ` [PATCH 2/3] PM / core: Add WAKEUP_POWERED driver flag Ulf Hansson
2017-11-08 15:32   ` Geert Uytterhoeven
2017-11-09  0:24   ` Rafael J. Wysocki
2017-11-09  8:44     ` Ulf Hansson
2017-11-09 11:40       ` Rafael J. Wysocki
2017-11-10  9:44         ` Ulf Hansson
2017-11-09  0:41   ` Rafael J. Wysocki
2017-11-09  8:53     ` Ulf Hansson
2017-11-09 11:51       ` Rafael J. Wysocki
2017-11-08 15:15 ` [PATCH 3/3] PM / Domains: Take WAKEUP_POWERED driver flag into account Ulf Hansson
2017-11-08 15:32   ` Geert Uytterhoeven
2017-11-08 15:41 ` [PATCH 0/3] PM / core: Invent a WAKEUP_POWERED driver flag Geert Uytterhoeven
2017-11-09  8:28   ` Ulf Hansson
2017-11-09  9:02     ` Geert Uytterhoeven
2017-11-09 10:08       ` Ulf Hansson
2017-11-09 10:14         ` Geert Uytterhoeven
2017-11-09 14:28           ` Ulf Hansson
2017-11-09 14:41             ` Geert Uytterhoeven
2017-11-09 16:31               ` Rafael J. Wysocki
2017-11-10  9:28                 ` Ulf Hansson
2017-11-09 11:59         ` Rafael J. Wysocki
2017-11-09 12:02           ` Rafael J. Wysocki [this message]

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='CAJZ5v0hrgyRZ+yqA_J75J8AGycW7DMsT8fnNXFQceLJCER9=fw@mail.gmail.com' \
    --to=rafael@kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=geert@linux-m68k.org \
    --cc=horms@verge.net.au \
    --cc=khilman@kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=rjw@rjwysocki.net \
    --cc=ulf.hansson@linaro.org \
    --cc=viresh.kumar@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.