From: Florian Fainelli <f.fainelli@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Florian Fainelli <f.fainelli@gmail.com>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
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>, Pavel Machek <pavel@ucw.cz>,
Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: [RFC 1/2] PM / suspend: Add platform_suspend_target_state()
Date: Thu, 22 Jun 2017 18:08:36 -0700 [thread overview]
Message-ID: <20170623010837.11199-2-f.fainelli@gmail.com> (raw)
In-Reply-To: <20170623010837.11199-1-f.fainelli@gmail.com>
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.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
include/linux/suspend.h | 12 ++++++++++++
kernel/power/suspend.c | 15 +++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index d9718378a8be..d998a04a90a2 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -172,6 +172,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 +193,7 @@ struct platform_suspend_ops {
bool (*suspend_again)(void);
void (*end)(void);
void (*recover)(void);
+ int (*target_state)(void);
};
struct platform_freeze_ops {
@@ -200,6 +210,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 int platform_suspend_target_state(void);
extern unsigned int pm_suspend_global_flags;
@@ -279,6 +290,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 int platform_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 15e6baef5c73..d31fe7a08f4a 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -177,6 +177,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.
+ */
+int 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
next prev parent reply other threads:[~2017-06-23 1:08 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20170622085102.mpk7vxodpgxtrlfd@piout.net>
2017-06-23 1:08 ` [RFC 0/2] PM / suspend: Add platform_suspend_target_state() Florian Fainelli
2017-06-23 1:08 ` Florian Fainelli [this message]
2017-06-29 23:00 ` [RFC 1/2] " Rafael J. Wysocki
2017-07-12 18:08 ` Florian Fainelli
2017-07-14 22:16 ` Rafael J. Wysocki
2017-07-15 6:28 ` Pavel Machek
2017-07-15 12:17 ` Rafael J. Wysocki
2017-07-15 16:46 ` Pavel Machek
2017-07-15 17:20 ` Florian Fainelli
2017-07-15 18:33 ` Alexandre Belloni
2017-07-06 3:18 ` Pavel Machek
2017-07-16 13:41 ` Alexandre Belloni
2017-07-16 15:35 ` Florian Fainelli
2017-07-15 23:24 ` Rafael J. Wysocki
2017-07-15 23:34 ` Mason
2017-07-15 23:38 ` Rafael J. Wysocki
2017-07-16 2:36 ` Florian Fainelli
2017-07-16 10:22 ` Rafael J. Wysocki
2017-07-16 13:38 ` Alexandre Belloni
2017-07-16 18:24 ` Pavel Machek
2017-07-16 15:41 ` Florian Fainelli
2017-07-15 23:29 ` Rafael J. Wysocki
2017-07-06 3:17 ` Pavel Machek
2017-07-16 10:28 ` Rafael J. Wysocki
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-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 ` [PATCH 1/2] " Florian Fainelli
2017-07-06 3:18 ` Pavel Machek
2017-07-16 15:41 ` Florian Fainelli
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-17 20:06 ` [PATCH v2] PM / suspend: Add suspend_target_state() Florian Fainelli
2017-07-17 20:16 ` Pavel Machek
2017-07-17 21:03 ` Rafael J. Wysocki
2017-07-17 21:21 ` Florian Fainelli
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 23:24 ` Rafael J. Wysocki
2017-07-18 0:19 ` [PATCH v4] " Florian Fainelli
2017-07-24 20:55 ` 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=20170623010837.11199-2-f.fainelli@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 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).