All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Pavel Machek <pavel@ucw.cz>, "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: linux-kernel@vger.kernel.org,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	linux-pm <linux-pm@vger.kernel.org>,
	Thibaud Cornic <thibaud_cornic@sigmadesigns.com>,
	JB <jb_lescher@sigmadesigns.com>, Mason <slash.tmp@free.fr>,
	Kevin Hilman <khilman@kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [RFC 1/2] PM / suspend: Add platform_suspend_target_state()
Date: Sat, 15 Jul 2017 10:20:27 -0700	[thread overview]
Message-ID: <1a5ef0ae-16f3-5a61-ae4e-083664cb30c0@gmail.com> (raw)
In-Reply-To: <20170715164626.GA1373@amd>



On 07/15/2017 09:46 AM, Pavel Machek wrote:
> Hi!
> 
>>>> I had an idea of using an enum type encompassing all of the power states
>>>> defined for various platforms and serving both as a registry (to ensure the
>>>> uniqueness of the values assigned to the states) and a common ground
>>>> between platforms and drivers.
>>>>
>>>> Something like:
>>>>
>>>> enum platform_target_state {
>>>> 	PLATFORM_STATE_UNKNOWN = -1,
>>>> 	PLATFORM_STATE_WORKING = 0,
>>>> 	PLATFORM_STATE_ACPI_S1,
>>>> 	PLATFORM_STATE_ACPI_S2,
>>>> 	PLATFORM_STATE_ACPI_S3,
>>>> 	PLATFORM_STATE_MY_BOARD_1_GATE_CLOCKS,
>>>> 	PLATFORM_STATE_MY_BOARD_1_GATE_POWER,
>>>> 	PLATFORM_STATE_ANOTHER_BOARD_DO_CRAZY_STUFF,
>>>> 	...
>>>> };
>>>>
>>>> and define ->target_state to return a value of this type.
>>>>
>>>> Then, if a driver sees one of these and recognizes that value, it should
>>>> know exactly what to do.
>>>
>>> Remind me why this is good idea?
>>
>> Because there are drivers that need to do specific things during
>> suspend on a specific board when it goes into a specific state as a
>> whole.
> 
> We have seen driver that cares about voltage to his device being
> lost. That's reasonable.
> 
> Inquiring what the platform target state is... is not.
> 
>>> If board wants to know if certain regulator stays online during
>>> suspend, it should invent an API for _that_.
>>
>> Ideally, yes.  However, that may be problematic for multiplatform kernels,
>> because they would need to have all of those APIs built in and the driver
>> code to figure out which API to use would be rather nasty.
> 
> Lets do it the right way. Big enum is wrong.

The enum offers the advantage of centralizing how many different states
exist for all the platforms we know about in the kernel, it's easy to
define common values for platforms that have the same semantics, just
like it's simple to add new values for platform specific details.

Is the concern that we could overflow the enum size, or that there is
not a common set of values to describe states?

> 
> We already have
> 
> struct regulator_state {
>        int uV; /* suspend voltage */
>        unsigned int mode; /* suspend regulator operating mode */
>        int enabled; /* is regulator enabled in this suspend state */
>        int disabled; /* is the regulator disabled in this suspend state */
> };
> 
>  * struct regulation_constraints - regulator operating constraints.
>   * @state_disk: State for regulator when system is suspended in disk
>   * mode.
>   * @state_mem: State for regulator when system is suspended in mem
>   * mode.
>   * @state_standby: State for regulator when system is suspended in
>   * standby
>   *                 mode.
>    
> . So it seems that maybe we should tell the drivers if we are entering
> "state_mem" or "state_standby" (something I may have opposed, sorry),
> then the driver can get neccessary information from regulator
> framework.

OK, so what would be the mechanism to tell these drivers about the
system wide suspend state they are entering if it is not via
platform_suspend_target_state()?

Keep in mind that regulators might be one aspect of what could be
causing the platform to behave specifically in one suspend state vs.
another, but there could be pieces of HW within the SoC that can't be
described with power domains, voltage islands etc. that would still have
inherent suspend states properties (like memory retention, pin/pad
controls etc. etc). We still need some mechanism, possibly centralized

> 
> I don't think it should cause problems with multiplatform kernels.

Just like platform_suspend_target_state() with an enum is not creating
problems either. suspend_ops is already a singleton for a given kernel
image so a given kernel running on a given platform will get to see a
subset of the enum values defined.

In any case, just agree and I will be happy to follow-up with patches.
-- 
Florian

WARNING: multiple messages have this Message-ID (diff)
From: f.fainelli@gmail.com (Florian Fainelli)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC 1/2] PM / suspend: Add platform_suspend_target_state()
Date: Sat, 15 Jul 2017 10:20:27 -0700	[thread overview]
Message-ID: <1a5ef0ae-16f3-5a61-ae4e-083664cb30c0@gmail.com> (raw)
In-Reply-To: <20170715164626.GA1373@amd>



On 07/15/2017 09:46 AM, Pavel Machek wrote:
> Hi!
> 
>>>> I had an idea of using an enum type encompassing all of the power states
>>>> defined for various platforms and serving both as a registry (to ensure the
>>>> uniqueness of the values assigned to the states) and a common ground
>>>> between platforms and drivers.
>>>>
>>>> Something like:
>>>>
>>>> enum platform_target_state {
>>>> 	PLATFORM_STATE_UNKNOWN = -1,
>>>> 	PLATFORM_STATE_WORKING = 0,
>>>> 	PLATFORM_STATE_ACPI_S1,
>>>> 	PLATFORM_STATE_ACPI_S2,
>>>> 	PLATFORM_STATE_ACPI_S3,
>>>> 	PLATFORM_STATE_MY_BOARD_1_GATE_CLOCKS,
>>>> 	PLATFORM_STATE_MY_BOARD_1_GATE_POWER,
>>>> 	PLATFORM_STATE_ANOTHER_BOARD_DO_CRAZY_STUFF,
>>>> 	...
>>>> };
>>>>
>>>> and define ->target_state to return a value of this type.
>>>>
>>>> Then, if a driver sees one of these and recognizes that value, it should
>>>> know exactly what to do.
>>>
>>> Remind me why this is good idea?
>>
>> Because there are drivers that need to do specific things during
>> suspend on a specific board when it goes into a specific state as a
>> whole.
> 
> We have seen driver that cares about voltage to his device being
> lost. That's reasonable.
> 
> Inquiring what the platform target state is... is not.
> 
>>> If board wants to know if certain regulator stays online during
>>> suspend, it should invent an API for _that_.
>>
>> Ideally, yes.  However, that may be problematic for multiplatform kernels,
>> because they would need to have all of those APIs built in and the driver
>> code to figure out which API to use would be rather nasty.
> 
> Lets do it the right way. Big enum is wrong.

The enum offers the advantage of centralizing how many different states
exist for all the platforms we know about in the kernel, it's easy to
define common values for platforms that have the same semantics, just
like it's simple to add new values for platform specific details.

Is the concern that we could overflow the enum size, or that there is
not a common set of values to describe states?

> 
> We already have
> 
> struct regulator_state {
>        int uV; /* suspend voltage */
>        unsigned int mode; /* suspend regulator operating mode */
>        int enabled; /* is regulator enabled in this suspend state */
>        int disabled; /* is the regulator disabled in this suspend state */
> };
> 
>  * struct regulation_constraints - regulator operating constraints.
>   * @state_disk: State for regulator when system is suspended in disk
>   * mode.
>   * @state_mem: State for regulator when system is suspended in mem
>   * mode.
>   * @state_standby: State for regulator when system is suspended in
>   * standby
>   *                 mode.
>    
> . So it seems that maybe we should tell the drivers if we are entering
> "state_mem" or "state_standby" (something I may have opposed, sorry),
> then the driver can get neccessary information from regulator
> framework.

OK, so what would be the mechanism to tell these drivers about the
system wide suspend state they are entering if it is not via
platform_suspend_target_state()?

Keep in mind that regulators might be one aspect of what could be
causing the platform to behave specifically in one suspend state vs.
another, but there could be pieces of HW within the SoC that can't be
described with power domains, voltage islands etc. that would still have
inherent suspend states properties (like memory retention, pin/pad
controls etc. etc). We still need some mechanism, possibly centralized

> 
> I don't think it should cause problems with multiplatform kernels.

Just like platform_suspend_target_state() with an enum is not creating
problems either. suspend_ops is already a singleton for a given kernel
image so a given kernel running on a given platform will get to see a
subset of the enum values defined.

In any case, just agree and I will be happy to follow-up with patches.
-- 
Florian

  reply	other threads:[~2017-07-15 17:20 UTC|newest]

Thread overview: 118+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-09 15:20 Drivers taking different actions depending on sleep state Mason
2017-06-09 15:20 ` Mason
2017-06-09 16:27 ` Mason
2017-06-09 16:27   ` Mason
2017-06-09 21:30   ` Pavel Machek
2017-06-09 21:30     ` Pavel Machek
2017-06-10  9:16     ` Mason
2017-06-10  9:16       ` Mason
2017-06-09 22:05 ` Florian Fainelli
2017-06-09 22:05   ` Florian Fainelli
2017-06-09 22:53 ` Rafael J. Wysocki
2017-06-09 22:53   ` Rafael J. Wysocki
2017-06-21 21:16   ` Florian Fainelli
2017-06-21 21:16     ` Florian Fainelli
2017-06-21 21:59     ` Rafael J. Wysocki
2017-06-21 21:59       ` Rafael J. Wysocki
2017-06-21 22:48       ` Florian Fainelli
2017-06-21 22:48         ` Florian Fainelli
2017-06-21 22:57         ` Rafael J. Wysocki
2017-06-21 22:57           ` Rafael J. Wysocki
2017-06-21 23:55           ` Florian Fainelli
2017-06-21 23:55             ` Florian Fainelli
2017-06-22  0:03             ` Rafael J. Wysocki
2017-06-22  0:03               ` Rafael J. Wysocki
2017-06-22 15:18               ` Florian Fainelli
2017-06-22 15:18                 ` Florian Fainelli
2017-06-22 16:09                 ` Rafael J. Wysocki
2017-06-22 16:09                   ` Rafael J. Wysocki
2017-06-22  8:51             ` Alexandre Belloni
2017-06-22  8:51               ` Alexandre Belloni
2017-06-22 16:00               ` Rafael J. Wysocki
2017-06-22 16:00                 ` Rafael J. Wysocki
2017-06-23  1:08               ` [RFC 0/2] PM / suspend: Add platform_suspend_target_state() Florian Fainelli
2017-06-23  1:08                 ` Florian Fainelli
2017-06-23  1:08                 ` [RFC 1/2] " Florian Fainelli
2017-06-23  1:08                   ` Florian Fainelli
2017-06-29 23:00                   ` Rafael J. Wysocki
2017-06-29 23:00                     ` Rafael J. Wysocki
2017-07-12 18:08                     ` Florian Fainelli
2017-07-12 18:08                       ` Florian Fainelli
2017-07-14 22:16                       ` Rafael J. Wysocki
2017-07-14 22:16                         ` Rafael J. Wysocki
2017-07-15  6:28                         ` Pavel Machek
2017-07-15  6:28                           ` Pavel Machek
2017-07-15 12:17                           ` Rafael J. Wysocki
2017-07-15 12:17                             ` Rafael J. Wysocki
2017-07-15 16:46                             ` Pavel Machek
2017-07-15 16:46                               ` Pavel Machek
2017-07-15 17:20                               ` Florian Fainelli [this message]
2017-07-15 17:20                                 ` Florian Fainelli
2017-07-15 18:33                                 ` Alexandre Belloni
2017-07-15 18:33                                   ` Alexandre Belloni
2017-07-06  3:18                                   ` Pavel Machek
2017-07-06  3:18                                     ` Pavel Machek
2017-07-16 13:41                                     ` Alexandre Belloni
2017-07-16 13:41                                       ` Alexandre Belloni
2017-07-16 15:35                                       ` Florian Fainelli
2017-07-16 15:35                                         ` Florian Fainelli
2017-07-15 23:24                                 ` Rafael J. Wysocki
2017-07-15 23:24                                   ` Rafael J. Wysocki
2017-07-15 23:34                                   ` Mason
2017-07-15 23:34                                     ` Mason
2017-07-15 23:38                                     ` Rafael J. Wysocki
2017-07-15 23:38                                       ` Rafael J. Wysocki
2017-07-16  2:36                                       ` Florian Fainelli
2017-07-16  2:36                                         ` Florian Fainelli
2017-07-16 10:22                                         ` Rafael J. Wysocki
2017-07-16 10:22                                           ` Rafael J. Wysocki
2017-07-16 13:38                                           ` Alexandre Belloni
2017-07-16 13:38                                             ` Alexandre Belloni
2017-07-16 18:24                                             ` Pavel Machek
2017-07-16 18:24                                               ` Pavel Machek
2017-07-16 15:41                                           ` Florian Fainelli
2017-07-16 15:41                                             ` Florian Fainelli
2017-07-15 23:29                               ` Rafael J. Wysocki
2017-07-15 23:29                                 ` Rafael J. Wysocki
2017-07-06  3:17                                 ` Pavel Machek
2017-07-06  3:17                                   ` Pavel Machek
2017-07-16 10:28                                   ` Rafael J. Wysocki
2017-07-16 10:28                                     ` Rafael J. Wysocki
2017-07-16 18:22                                     ` Pavel Machek
2017-07-16 18:22                                       ` Pavel Machek
2017-06-23  1:08                 ` [RFC 2/2] soc: bcm: brcmstb: PM: Implement target_state callback Florian Fainelli
2017-06-23  1:08                   ` Florian Fainelli
2017-06-29 23:04                   ` Rafael J. Wysocki
2017-06-29 23:04                     ` Rafael J. Wysocki
2017-07-16  2:36                 ` [PATCH 0/2] PM / suspend: Add platform_suspend_target_state() Florian Fainelli
2017-07-16  2:36                   ` Florian Fainelli
2017-07-16  2:36                   ` [PATCH 1/2] " Florian Fainelli
2017-07-16  2:36                     ` Florian Fainelli
2017-07-06  3:18                     ` Pavel Machek
2017-07-06  3:18                       ` Pavel Machek
2017-07-16 15:41                       ` Florian Fainelli
2017-07-16 15:41                         ` Florian Fainelli
2017-07-16 10:30                     ` Rafael J. Wysocki
2017-07-16 10:30                       ` Rafael J. Wysocki
2017-07-16  2:36                   ` [PATCH 2/2] soc: bcm: brcmstb: PM: Implement target_state callback Florian Fainelli
2017-07-16  2:36                     ` Florian Fainelli
2017-07-17 20:06                   ` [PATCH v2] PM / suspend: Add suspend_target_state() Florian Fainelli
2017-07-17 20:06                     ` Florian Fainelli
2017-07-17 20:16                     ` Pavel Machek
2017-07-17 20:16                       ` Pavel Machek
2017-07-17 21:03                       ` Rafael J. Wysocki
2017-07-17 21:03                         ` Rafael J. Wysocki
2017-07-17 21:21                         ` Florian Fainelli
2017-07-17 21:21                           ` Florian Fainelli
2017-07-20  8:03                     ` Pavel Machek
2017-07-20  8:03                       ` Pavel Machek
2017-07-17 22:10                   ` [PATCH v3] PM / suspend: Export pm_suspend_target_state Florian Fainelli
2017-07-17 22:10                     ` Florian Fainelli
2017-07-17 23:24                     ` Rafael J. Wysocki
2017-07-17 23:24                       ` Rafael J. Wysocki
2017-07-18  0:19                     ` [PATCH v4] " Florian Fainelli
2017-07-18  0:19                       ` Florian Fainelli
2017-07-24 20:55                       ` Rafael J. Wysocki
2017-07-24 20:55                         ` Rafael J. Wysocki
2017-07-13 12:03               ` Drivers taking different actions depending on sleep state Pavel Machek
2017-07-13 12:03                 ` Pavel Machek

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=1a5ef0ae-16f3-5a61-ae4e-083664cb30c0@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=jb_lescher@sigmadesigns.com \
    --cc=khilman@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=slash.tmp@free.fr \
    --cc=thibaud_cornic@sigmadesigns.com \
    --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.