Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1688043 > unrolled thread
| Started by | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| First post | 2017-07-16 04:40 +0200 |
| Last post | 2017-07-18 02:20 +0200 |
| Articles | 12 — 4 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 0/2] PM / suspend: Add platform_suspend_target_state() Florian Fainelli <f.fainelli@gmail.com> - 2017-07-16 04:40 +0200
[PATCH 1/2] PM / suspend: Add platform_suspend_target_state() Florian Fainelli <f.fainelli@gmail.com> - 2017-07-16 04:40 +0200
Re: [PATCH 1/2] PM / suspend: Add platform_suspend_target_state() Pavel Machek <pavel@ucw.cz> - 2017-07-16 09:40 +0200
Re: [PATCH 1/2] PM / suspend: Add platform_suspend_target_state() Florian Fainelli <f.fainelli@gmail.com> - 2017-07-16 17:50 +0200
Re: [PATCH 1/2] PM / suspend: Add platform_suspend_target_state() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2017-07-16 12:40 +0200
[PATCH v2] PM / suspend: Add suspend_target_state() Florian Fainelli <f.fainelli@gmail.com> - 2017-07-17 22:10 +0200
Re: [PATCH v2] PM / suspend: Add suspend_target_state() Pavel Machek <pavel@ucw.cz> - 2017-07-17 22:20 +0200
Re: [PATCH v2] PM / suspend: Add suspend_target_state() "Rafael J. Wysocki" <rafael@kernel.org> - 2017-07-17 23:10 +0200
Re: [PATCH v2] PM / suspend: Add suspend_target_state() Florian Fainelli <f.fainelli@gmail.com> - 2017-07-17 23:30 +0200
[PATCH v3] PM / suspend: Export pm_suspend_target_state Florian Fainelli <f.fainelli@gmail.com> - 2017-07-18 00:20 +0200
Re: [PATCH v3] PM / suspend: Export pm_suspend_target_state "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2017-07-18 01:40 +0200
[PATCH v4] PM / suspend: Export pm_suspend_target_state Florian Fainelli <f.fainelli@gmail.com> - 2017-07-18 02:20 +0200
| From | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| Date | 2017-07-16 04:40 +0200 |
| Subject | [PATCH 0/2] PM / suspend: Add platform_suspend_target_state() |
| Message-ID | <u3HDr-1cr-3@gated-at.bofh.it> |
This patch series implements the idea discussed in this thread: https://www.spinics.net/lists/arm-kernel/msg590068.html The last patch is relative to the pending submission of the Broadcom STB S2/S3/S5 suspend/resume code that can be found below, and is provided as an example of how this can be useful. https://lkml.org/lkml/2017/6/16/737 Changes from RFC: - make platform_target_state an enum that platforms can modify to include their own states - updated brcmstb PM code to translate internal states to externally visible platform_target_state Florian Fainelli (2): PM / suspend: Add platform_suspend_target_state() soc: bcm: brcmstb: PM: Implement target_state callback drivers/soc/bcm/brcmstb/pm/pm-arm.c | 22 ++++++++++++++++++++++ include/linux/suspend.h | 26 ++++++++++++++++++++++++++ kernel/power/suspend.c | 15 +++++++++++++++ 3 files changed, 63 insertions(+) -- 2.9.3
[toc] | [next] | [standalone]
| From | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| Date | 2017-07-16 04:40 +0200 |
| Subject | [PATCH 1/2] PM / suspend: Add platform_suspend_target_state() |
| Message-ID | <u3HDr-1cr-7@gated-at.bofh.it> |
| In reply to | #1688043 |
Add an optional platform_suspend_ops callback: target_state, and a
helper function globally visible to get this called:
platform_suspend_target_state().
This is useful for platform specific drivers that may need to take a
slightly different suspend/resume path based on the system's
suspend/resume state being entered.
Although this callback is optional and documented as such, it requires
a platform_suspend_ops::begin callback to be implemented in order to
provide an accurate suspend/resume state within the driver that
implements this platform_suspend_ops.
An enumeration: platform_target_state is defined which currently defines
the standard ACPI_S[1-4] states and can be extended with platform
specific suspend states.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
include/linux/suspend.h | 25 +++++++++++++++++++++++++
kernel/power/suspend.c | 15 +++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 0b1cf32edfd7..6e6cc0778816 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -50,6 +50,16 @@ enum suspend_stat_step {
SUSPEND_RESUME
};
+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_ACPI_S4,
+ /* Add platform specific states here */
+};
+
struct suspend_stats {
int success;
int fail;
@@ -172,6 +182,15 @@ static inline void dpm_save_failed_step(enum suspend_stat_step step)
* Called by the PM core if the suspending of devices fails.
* This callback is optional and should only be implemented by platforms
* which require special recovery actions in that situation.
+ *
+ * @target_state: Returns the suspend state the suspend_ops will be entering.
+ * Called by device drivers that need to know the platform specific suspend
+ * state the system is about to enter.
+ * This callback is optional and should only be implemented by platforms
+ * which require special handling of power management states within
+ * drivers. It does require @begin to be implemented to provide the suspend
+ * state. Return value is platform_suspend_ops specific, and may be a 1:1
+ * mapping to suspend_state_t when relevant.
*/
struct platform_suspend_ops {
int (*valid)(suspend_state_t state);
@@ -184,6 +203,7 @@ struct platform_suspend_ops {
bool (*suspend_again)(void);
void (*end)(void);
void (*recover)(void);
+ enum platform_target_state (*target_state)(void);
};
struct platform_freeze_ops {
@@ -202,6 +222,7 @@ struct platform_freeze_ops {
*/
extern void suspend_set_ops(const struct platform_suspend_ops *ops);
extern int suspend_valid_only_mem(suspend_state_t state);
+extern enum platform_target_state platform_suspend_target_state(void);
extern unsigned int pm_suspend_global_flags;
@@ -281,6 +302,10 @@ static inline bool pm_resume_via_firmware(void) { return false; }
static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {}
static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
+static inline int platform_suspend_target_state(void)
+{
+ return PLATFORM_STATE_UNKNOWN;
+}
static inline bool idle_should_freeze(void) { return false; }
static inline void __init pm_states_init(void) {}
static inline void freeze_set_ops(const struct platform_freeze_ops *ops) {}
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 3ecf275d7e44..cd1b62f23b0e 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -202,6 +202,21 @@ void suspend_set_ops(const struct platform_suspend_ops *ops)
EXPORT_SYMBOL_GPL(suspend_set_ops);
/**
+ * platform_suspend_target_state - Return the platform specific suspend state.
+ * a begin() callback is necessary in order to fill this information correctly
+ * for callers.
+ */
+enum platform_target_state platform_suspend_target_state(void)
+{
+ if (!suspend_ops || !suspend_ops->target_state ||
+ (suspend_ops->target_state && !suspend_ops->begin))
+ return -ENOTSUPP;
+
+ return suspend_ops->target_state();
+}
+EXPORT_SYMBOL_GPL(platform_suspend_target_state);
+
+/**
* suspend_valid_only_mem - Generic memory-only valid callback.
*
* Platform drivers that implement mem suspend only and only need to check for
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Pavel Machek <pavel@ucw.cz> |
|---|---|
| Date | 2017-07-16 09:40 +0200 |
| Subject | Re: [PATCH 1/2] PM / suspend: Add platform_suspend_target_state() |
| Message-ID | <u3MjM-4aC-3@gated-at.bofh.it> |
| In reply to | #1688044 |
Hi!
> Although this callback is optional and documented as such, it requires
> a platform_suspend_ops::begin callback to be implemented in order to
> provide an accurate suspend/resume state within the driver that
> implements this platform_suspend_ops.
>
> An enumeration: platform_target_state is defined which currently defines
> the standard ACPI_S[1-4] states and can be extended with platform
> specific suspend states.
>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
> include/linux/suspend.h | 25 +++++++++++++++++++++++++
> kernel/power/suspend.c | 15 +++++++++++++++
> 2 files changed, 40 insertions(+)
>
> diff --git a/include/linux/suspend.h b/include/linux/suspend.h
> index 0b1cf32edfd7..6e6cc0778816 100644
> --- a/include/linux/suspend.h
> +++ b/include/linux/suspend.h
> @@ -50,6 +50,16 @@ enum suspend_stat_step {
> SUSPEND_RESUME
> };
>
> +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_ACPI_S4,
> + /* Add platform specific states here */
> +};
> +
As I tried to explain in the email thread, having list with all the possible platform
states is no-go. We have about 1000 platforms supported...
NAK.
Pavel
[toc] | [prev] | [next] | [standalone]
| From | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| Date | 2017-07-16 17:50 +0200 |
| Subject | Re: [PATCH 1/2] PM / suspend: Add platform_suspend_target_state() |
| Message-ID | <u3TXY-W2-7@gated-at.bofh.it> |
| In reply to | #1688149 |
On 07/05/2017 08:18 PM, Pavel Machek wrote:
> Hi!
>
>> Although this callback is optional and documented as such, it requires
>> a platform_suspend_ops::begin callback to be implemented in order to
>> provide an accurate suspend/resume state within the driver that
>> implements this platform_suspend_ops.
>>
>> An enumeration: platform_target_state is defined which currently defines
>> the standard ACPI_S[1-4] states and can be extended with platform
>> specific suspend states.
>>
>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>> ---
>> include/linux/suspend.h | 25 +++++++++++++++++++++++++
>> kernel/power/suspend.c | 15 +++++++++++++++
>> 2 files changed, 40 insertions(+)
>>
>> diff --git a/include/linux/suspend.h b/include/linux/suspend.h
>> index 0b1cf32edfd7..6e6cc0778816 100644
>> --- a/include/linux/suspend.h
>> +++ b/include/linux/suspend.h
>> @@ -50,6 +50,16 @@ enum suspend_stat_step {
>> SUSPEND_RESUME
>> };
>>
>> +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_ACPI_S4,
>> + /* Add platform specific states here */
>> +};
>> +
>
> As I tried to explain in the email thread, having list with all the possible platform
> states is no-go. We have about 1000 platforms supported...
FYI, the recent (relatively recent) CPU hotplug conversion from
notifiers to a state machine has a similar pattern whereby pieces of
code needing to hook into the CPU hotplug state machine add their own
enum values as they need. So far it's been working for them, and there
were tons of CPU hotplug notifiers in the kernel.
Anyhow, let me implement Rafael's suggestions and we can see how we move
from there.
--
Florian
[toc] | [prev] | [next] | [standalone]
| From | "Rafael J. Wysocki" <rjw@rjwysocki.net> |
|---|---|
| Date | 2017-07-16 12:40 +0200 |
| Subject | Re: [PATCH 1/2] PM / suspend: Add platform_suspend_target_state() |
| Message-ID | <u3P7X-6d6-1@gated-at.bofh.it> |
| In reply to | #1688044 |
On Saturday, July 15, 2017 07:36:09 PM Florian Fainelli wrote: > Add an optional platform_suspend_ops callback: target_state, and a > helper function globally visible to get this called: > platform_suspend_target_state(). > > This is useful for platform specific drivers that may need to take a > slightly different suspend/resume path based on the system's > suspend/resume state being entered. > > Although this callback is optional and documented as such, it requires > a platform_suspend_ops::begin callback to be implemented in order to > provide an accurate suspend/resume state within the driver that > implements this platform_suspend_ops. > > An enumeration: platform_target_state is defined which currently defines > the standard ACPI_S[1-4] states and can be extended with platform > specific suspend states. This has a couple of problems, but I'm not sure if it is worth to go too much into details here. Let's just take a different approach as I said in the other thread. Thanks, Rafael
[toc] | [prev] | [next] | [standalone]
| From | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| Date | 2017-07-17 22:10 +0200 |
| Subject | [PATCH v2] PM / suspend: Add suspend_target_state() |
| Message-ID | <u4kv7-1bl-17@gated-at.bofh.it> |
| In reply to | #1688043 |
Have the core suspend/resume framework store the system-wide suspend
state (suspend_state_t) we are about to enter, and expose it to drivers
via suspend_target_state() in order to retrieve that. The state is
assigned in suspend_devices_and_enter().
This is useful for platform specific drivers that may need to take a
slightly different suspend/resume path based on the system's
suspend/resume state being entered.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
Changes in v2:
- rename platform_suspend_target_state() -> suspend_target_state()
- directly export the suspend_state_t value and assign it in
suspend_devices_and_enter()
include/linux/suspend.h | 2 ++
kernel/power/suspend.c | 15 +++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 0b1cf32edfd7..7b70e7d6a006 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -202,6 +202,7 @@ struct platform_freeze_ops {
*/
extern void suspend_set_ops(const struct platform_suspend_ops *ops);
extern int suspend_valid_only_mem(suspend_state_t state);
+extern suspend_state_t suspend_target_state(void);
extern unsigned int pm_suspend_global_flags;
@@ -281,6 +282,7 @@ static inline bool pm_resume_via_firmware(void) { return false; }
static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {}
static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
+static inline suspend_state_t suspend_target_state(void) { return -ENOSYS; }
static inline bool idle_should_freeze(void) { return false; }
static inline void __init pm_states_init(void) {}
static inline void freeze_set_ops(const struct platform_freeze_ops *ops) {}
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 3ecf275d7e44..a296d6e25d52 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -47,6 +47,7 @@ const char *mem_sleep_states[PM_SUSPEND_MAX];
suspend_state_t mem_sleep_current = PM_SUSPEND_FREEZE;
static suspend_state_t mem_sleep_default = PM_SUSPEND_MEM;
+static suspend_state_t pm_suspend_target_state;
unsigned int pm_suspend_global_flags;
EXPORT_SYMBOL_GPL(pm_suspend_global_flags);
@@ -202,6 +203,18 @@ void suspend_set_ops(const struct platform_suspend_ops *ops)
EXPORT_SYMBOL_GPL(suspend_set_ops);
/**
+ * suspend_target_state - Return the system wide suspend state.
+ *
+ * The pm_suspend_target_state becomes valid during
+ * suspend_devices_and_enter().
+ */
+suspend_state_t suspend_target_state(void)
+{
+ return pm_suspend_target_state;
+}
+EXPORT_SYMBOL_GPL(suspend_target_state);
+
+/**
* suspend_valid_only_mem - Generic memory-only valid callback.
*
* Platform drivers that implement mem suspend only and only need to check for
@@ -456,6 +469,8 @@ int suspend_devices_and_enter(suspend_state_t state)
if (!sleep_state_supported(state))
return -ENOSYS;
+ pm_suspend_target_state = state;
+
error = platform_suspend_begin(state);
if (error)
goto Close;
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Pavel Machek <pavel@ucw.cz> |
|---|---|
| Date | 2017-07-17 22:20 +0200 |
| Subject | Re: [PATCH v2] PM / suspend: Add suspend_target_state() |
| Message-ID | <u4kEO-1f3-21@gated-at.bofh.it> |
| In reply to | #1689425 |
[Multipart message — attachments visible in raw view] — view raw
Hi!
> Have the core suspend/resume framework store the system-wide suspend
> state (suspend_state_t) we are about to enter, and expose it to drivers
> via suspend_target_state() in order to retrieve that. The state is
> assigned in suspend_devices_and_enter().
Do we really want to have variable + inline functions that just read
that variable?
> +static inline suspend_state_t suspend_target_state(void) { return -ENOSYS; }
I'm pretty sure -ENOSYS is not compatible with suspend_state_t ...
> diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
> index 3ecf275d7e44..a296d6e25d52 100644
> --- a/kernel/power/suspend.c
> +++ b/kernel/power/suspend.c
> @@ -47,6 +47,7 @@ const char *mem_sleep_states[PM_SUSPEND_MAX];
>
> suspend_state_t mem_sleep_current = PM_SUSPEND_FREEZE;
> static suspend_state_t mem_sleep_default = PM_SUSPEND_MEM;
> +static suspend_state_t pm_suspend_target_state;
Is there disadvantage of just having this variable non-static?
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[toc] | [prev] | [next] | [standalone]
| From | "Rafael J. Wysocki" <rafael@kernel.org> |
|---|---|
| Date | 2017-07-17 23:10 +0200 |
| Subject | Re: [PATCH v2] PM / suspend: Add suspend_target_state() |
| Message-ID | <u4lrh-1Mq-97@gated-at.bofh.it> |
| In reply to | #1689436 |
On Mon, Jul 17, 2017 at 10:16 PM, Pavel Machek <pavel@ucw.cz> wrote: > Hi! > >> Have the core suspend/resume framework store the system-wide suspend >> state (suspend_state_t) we are about to enter, and expose it to drivers >> via suspend_target_state() in order to retrieve that. The state is >> assigned in suspend_devices_and_enter(). > > Do we really want to have variable + inline functions that just read > that variable? Florian, Pavel is right, you can simply export the variable. Anything accessing it should go under CONFIG_PM_SLEEP anyway. Thanks, Rafael
[toc] | [prev] | [next] | [standalone]
| From | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| Date | 2017-07-17 23:30 +0200 |
| Subject | Re: [PATCH v2] PM / suspend: Add suspend_target_state() |
| Message-ID | <u4lKy-1Tb-21@gated-at.bofh.it> |
| In reply to | #1689481 |
On 07/17/2017 02:03 PM, Rafael J. Wysocki wrote: > On Mon, Jul 17, 2017 at 10:16 PM, Pavel Machek <pavel@ucw.cz> wrote: >> Hi! >> >>> Have the core suspend/resume framework store the system-wide suspend >>> state (suspend_state_t) we are about to enter, and expose it to drivers >>> via suspend_target_state() in order to retrieve that. The state is >>> assigned in suspend_devices_and_enter(). >> >> Do we really want to have variable + inline functions that just read >> that variable? > > Florian, Pavel is right, you can simply export the variable. > > Anything accessing it should go under CONFIG_PM_SLEEP anyway. Alright then, I will just export it. Stay tuned. -- Florian
[toc] | [prev] | [next] | [standalone]
| From | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| Date | 2017-07-18 00:20 +0200 |
| Subject | [PATCH v3] PM / suspend: Export pm_suspend_target_state |
| Message-ID | <u4mwV-2qT-1@gated-at.bofh.it> |
| In reply to | #1688043 |
Have the core suspend/resume framework store the system-wide suspend state (suspend_state_t) we are about to enter, and expose it to drivers via pm_suspend_target_state in order to retrieve that. The state is assigned in suspend_devices_and_enter(). This is useful for platform specific drivers that may need to take a slightly different suspend/resume path based on the system's suspend/resume state being entered. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> --- Changes in v3: - just export pm_suspend_target_state without a helper function Changes in v2: - rename platform_suspend_target_state() -> suspend_target_state() - directly export the suspend_state_t value and assign it in suspend_devices_and_enter() include/linux/suspend.h | 1 + kernel/power/suspend.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/linux/suspend.h b/include/linux/suspend.h index 0b1cf32edfd7..2159f6841768 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -427,6 +427,7 @@ extern int unregister_pm_notifier(struct notifier_block *nb); /* drivers/base/power/wakeup.c */ extern bool events_check_enabled; extern unsigned int pm_wakeup_irq; +extern suspend_state_t pm_suspend_target_state; extern bool pm_wakeup_pending(void); extern void pm_system_wakeup(void); diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 3ecf275d7e44..1aecdaf22ab5 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -47,6 +47,8 @@ const char *mem_sleep_states[PM_SUSPEND_MAX]; suspend_state_t mem_sleep_current = PM_SUSPEND_FREEZE; static suspend_state_t mem_sleep_default = PM_SUSPEND_MEM; +suspend_state_t pm_suspend_target_state; +EXPORT_SYMBOL_GPL(pm_suspend_target_state); unsigned int pm_suspend_global_flags; EXPORT_SYMBOL_GPL(pm_suspend_global_flags); @@ -456,6 +458,8 @@ int suspend_devices_and_enter(suspend_state_t state) if (!sleep_state_supported(state)) return -ENOSYS; + pm_suspend_target_state = state; + error = platform_suspend_begin(state); if (error) goto Close; -- 2.9.3
[toc] | [prev] | [next] | [standalone]
| From | "Rafael J. Wysocki" <rjw@rjwysocki.net> |
|---|---|
| Date | 2017-07-18 01:40 +0200 |
| Subject | Re: [PATCH v3] PM / suspend: Export pm_suspend_target_state |
| Message-ID | <u4nMl-39c-7@gated-at.bofh.it> |
| In reply to | #1689531 |
On Monday, July 17, 2017 03:10:59 PM Florian Fainelli wrote: > Have the core suspend/resume framework store the system-wide suspend > state (suspend_state_t) we are about to enter, and expose it to drivers > via pm_suspend_target_state in order to retrieve that. The state is > assigned in suspend_devices_and_enter(). > > This is useful for platform specific drivers that may need to take a > slightly different suspend/resume path based on the system's > suspend/resume state being entered. > > Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> > --- > Changes in v3: > > - just export pm_suspend_target_state without a helper function > > Changes in v2: > > - rename platform_suspend_target_state() -> suspend_target_state() > - directly export the suspend_state_t value and assign it in > suspend_devices_and_enter() > > include/linux/suspend.h | 1 + > kernel/power/suspend.c | 4 ++++ > 2 files changed, 5 insertions(+) > > diff --git a/include/linux/suspend.h b/include/linux/suspend.h > index 0b1cf32edfd7..2159f6841768 100644 > --- a/include/linux/suspend.h > +++ b/include/linux/suspend.h > @@ -427,6 +427,7 @@ extern int unregister_pm_notifier(struct notifier_block *nb); > /* drivers/base/power/wakeup.c */ > extern bool events_check_enabled; > extern unsigned int pm_wakeup_irq; > +extern suspend_state_t pm_suspend_target_state; > > extern bool pm_wakeup_pending(void); > extern void pm_system_wakeup(void); > diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c > index 3ecf275d7e44..1aecdaf22ab5 100644 > --- a/kernel/power/suspend.c > +++ b/kernel/power/suspend.c > @@ -47,6 +47,8 @@ const char *mem_sleep_states[PM_SUSPEND_MAX]; > > suspend_state_t mem_sleep_current = PM_SUSPEND_FREEZE; > static suspend_state_t mem_sleep_default = PM_SUSPEND_MEM; > +suspend_state_t pm_suspend_target_state; > +EXPORT_SYMBOL_GPL(pm_suspend_target_state); > > unsigned int pm_suspend_global_flags; > EXPORT_SYMBOL_GPL(pm_suspend_global_flags); > @@ -456,6 +458,8 @@ int suspend_devices_and_enter(suspend_state_t state) > if (!sleep_state_supported(state)) > return -ENOSYS; > > + pm_suspend_target_state = state; > + > error = platform_suspend_begin(state); > if (error) > goto Close; > And please clear pm_suspend_target_state before returning from suspend_devices_and_enter(). Thanks, Rafael
[toc] | [prev] | [next] | [standalone]
| From | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| Date | 2017-07-18 02:20 +0200 |
| Subject | [PATCH v4] PM / suspend: Export pm_suspend_target_state |
| Message-ID | <u4op4-3AZ-15@gated-at.bofh.it> |
| In reply to | #1689531 |
Have the core suspend/resume framework store the system-wide suspend state (suspend_state_t) we are about to enter, and expose it to drivers via pm_suspend_target_state in order to retrieve that. The state is assigned in suspend_devices_and_enter(). This is useful for platform specific drivers that may need to take a slightly different suspend/resume path based on the system's suspend/resume state being entered. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> --- Changes in v4: - clear pm_suspend_target_state in Close label Changes in v3: - just export pm_suspend_target_state without a helper function Changes in v2: - rename platform_suspend_target_state() -> suspend_target_state() - directly export the suspend_state_t value and assign it in suspend_devices_and_enter() include/linux/suspend.h | 1 + kernel/power/suspend.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/linux/suspend.h b/include/linux/suspend.h index 0b1cf32edfd7..2159f6841768 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -427,6 +427,7 @@ extern int unregister_pm_notifier(struct notifier_block *nb); /* drivers/base/power/wakeup.c */ extern bool events_check_enabled; extern unsigned int pm_wakeup_irq; +extern suspend_state_t pm_suspend_target_state; extern bool pm_wakeup_pending(void); extern void pm_system_wakeup(void); diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 3ecf275d7e44..d0c0b96c2383 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -47,6 +47,8 @@ const char *mem_sleep_states[PM_SUSPEND_MAX]; suspend_state_t mem_sleep_current = PM_SUSPEND_FREEZE; static suspend_state_t mem_sleep_default = PM_SUSPEND_MEM; +suspend_state_t pm_suspend_target_state; +EXPORT_SYMBOL_GPL(pm_suspend_target_state); unsigned int pm_suspend_global_flags; EXPORT_SYMBOL_GPL(pm_suspend_global_flags); @@ -456,6 +458,8 @@ int suspend_devices_and_enter(suspend_state_t state) if (!sleep_state_supported(state)) return -ENOSYS; + pm_suspend_target_state = state; + error = platform_suspend_begin(state); if (error) goto Close; @@ -485,6 +489,7 @@ int suspend_devices_and_enter(suspend_state_t state) Close: platform_resume_end(state); + pm_suspend_target_state = PM_SUSPEND_ON; return error; Recover_platform: -- 2.9.3
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web