All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] ACPI / PM: Move _PTS/_WAK invocations out of the noirq stage
@ 2016-06-28  8:04 ` Lv Zheng
  0 siblings, 0 replies; 10+ messages in thread
From: Lv Zheng @ 2016-06-28  8:04 UTC (permalink / raw)
  To: Rafael J. Wysocki, Rafael J. Wysocki, Len Brown
  Cc: Lv Zheng, Lv Zheng, linux-kernel, linux-acpi

Currently _PTS/_WAK are invoked during noirq stages, while in _PTS/_WAK,
there can be EC transactions. Though the EC driver is able to handle
transactions using polling mode, for the performance reason, it is better
to move _PTS/_WAK out of the noirq stage.

Lv Zheng (3):
  PM: Rename prepare_late/wake suspend_ops callbacks to
    prepare_noirq/finish_noirq
  PM: Add prepare_late/finish_early suspend_ops callbacks
  ACPI / PM: Fix EC polling issue by implementing
    prepare_late/finish_early suspend_ops callbacks

 arch/powerpc/platforms/pseries/suspend.c |    6 ++--
 drivers/acpi/sleep.c                     |    9 +++---
 include/linux/suspend.h                  |   50 +++++++++++++++++++++---------
 kernel/power/suspend.c                   |   18 +++++++----
 4 files changed, 55 insertions(+), 28 deletions(-)

-- 
1.7.10


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [RFC PATCH 0/3] ACPI / PM: Move _PTS/_WAK invocations out of the noirq stage
@ 2016-06-28  8:04 ` Lv Zheng
  0 siblings, 0 replies; 10+ messages in thread
From: Lv Zheng @ 2016-06-28  8:04 UTC (permalink / raw)
  To: Rafael J. Wysocki, Rafael J. Wysocki, Len Brown
  Cc: Lv Zheng, Lv Zheng, linux-kernel, linux-acpi

Currently _PTS/_WAK are invoked during noirq stages, while in _PTS/_WAK,
there can be EC transactions. Though the EC driver is able to handle
transactions using polling mode, for the performance reason, it is better
to move _PTS/_WAK out of the noirq stage.

Lv Zheng (3):
  PM: Rename prepare_late/wake suspend_ops callbacks to
    prepare_noirq/finish_noirq
  PM: Add prepare_late/finish_early suspend_ops callbacks
  ACPI / PM: Fix EC polling issue by implementing
    prepare_late/finish_early suspend_ops callbacks

 arch/powerpc/platforms/pseries/suspend.c |    6 ++--
 drivers/acpi/sleep.c                     |    9 +++---
 include/linux/suspend.h                  |   50 +++++++++++++++++++++---------
 kernel/power/suspend.c                   |   18 +++++++----
 4 files changed, 55 insertions(+), 28 deletions(-)

-- 
1.7.10

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [RFC PATCH 1/3] PM: Rename prepare_late/wake suspend_ops callbacks to prepare_noirq/finish_noirq
  2016-06-28  8:04 ` Lv Zheng
@ 2016-06-28  8:04   ` Lv Zheng
  -1 siblings, 0 replies; 10+ messages in thread
From: Lv Zheng @ 2016-06-28  8:04 UTC (permalink / raw)
  To: Rafael J. Wysocki, Rafael J. Wysocki, Len Brown
  Cc: Lv Zheng, Lv Zheng, linux-kernel, linux-acpi

Rename the names of the PM callbacks, making them consistent with their
caller names. Particularly:
  .prepare_late -> .prepare_noirq
  .wake -> .finish_noirq

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
 arch/powerpc/platforms/pseries/suspend.c |    6 +++---
 drivers/acpi/sleep.c                     |    8 ++++----
 include/linux/suspend.h                  |   28 ++++++++++++++--------------
 kernel/power/suspend.c                   |    8 ++++----
 4 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/suspend.c b/arch/powerpc/platforms/pseries/suspend.c
index e76aefa..cc52b0f 100644
--- a/arch/powerpc/platforms/pseries/suspend.c
+++ b/arch/powerpc/platforms/pseries/suspend.c
@@ -112,12 +112,12 @@ static int pseries_suspend_enter(suspend_state_t state)
 }
 
 /**
- * pseries_prepare_late - Prepare to suspend all other CPUs
+ * pseries_prepare_noirq - Prepare to suspend all other CPUs
  *
  * Return value:
  * 	0 on success / other on failure
  **/
-static int pseries_prepare_late(void)
+static int pseries_prepare_noirq(void)
 {
 	atomic_set(&suspending, 1);
 	atomic_set(&suspend_data.working, 0);
@@ -225,7 +225,7 @@ static struct bus_type suspend_subsys = {
 static const struct platform_suspend_ops pseries_suspend_ops = {
 	.valid		= suspend_valid_only_mem,
 	.begin		= pseries_suspend_begin,
-	.prepare_late	= pseries_prepare_late,
+	.prepare_noirq	= pseries_prepare_noirq,
 	.enter		= pseries_suspend_enter,
 };
 
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 7a2e4d4..d30fce7f 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -595,9 +595,9 @@ static int acpi_suspend_state_valid(suspend_state_t pm_state)
 static const struct platform_suspend_ops acpi_suspend_ops = {
 	.valid = acpi_suspend_state_valid,
 	.begin = acpi_suspend_begin,
-	.prepare_late = acpi_pm_prepare,
+	.prepare_noirq = acpi_pm_prepare,
 	.enter = acpi_suspend_enter,
-	.wake = acpi_pm_finish,
+	.finish_noirq = acpi_pm_finish,
 	.end = acpi_pm_end,
 };
 
@@ -623,9 +623,9 @@ static int acpi_suspend_begin_old(suspend_state_t pm_state)
 static const struct platform_suspend_ops acpi_suspend_ops_old = {
 	.valid = acpi_suspend_state_valid,
 	.begin = acpi_suspend_begin_old,
-	.prepare_late = acpi_pm_pre_suspend,
+	.prepare_noirq = acpi_pm_pre_suspend,
 	.enter = acpi_suspend_enter,
-	.wake = acpi_pm_finish,
+	.finish_noirq = acpi_pm_finish,
 	.end = acpi_pm_end,
 	.recover = acpi_pm_finish,
 };
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 7693e39..b5261e3 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -121,13 +121,13 @@ static inline void dpm_save_failed_step(enum suspend_stat_step step)
  *	appropriate .suspend() method has been executed for each device) and
  *	before device drivers' late suspend callbacks are executed.  It returns
  *	0 on success or a negative error code otherwise, in which case the
- *	system cannot enter the desired sleep state (@prepare_late(), @enter(),
- *	and @wake() will not be called in that case).
+ *	system cannot enter the desired sleep state (@prepare_noirq(), @enter(),
+ *	and @finish_noirq() will not be called in that case).
  *
- * @prepare_late: Finish preparing the platform for entering the system sleep
+ * @prepare_noirq: Finish preparing the platform for entering the system sleep
  *	state indicated by @begin().
- *	@prepare_late is called before disabling nonboot CPUs and after
- *	device drivers' late suspend callbacks have been executed.  It returns
+ *	@prepare_noirq is called before disabling nonboot CPUs and after
+ *	device drivers' noirq suspend callbacks have been executed.  It returns
  *	0 on success or a negative error code otherwise, in which case the
  *	system cannot enter the desired sleep state (@enter() will not be
  *	executed).
@@ -138,20 +138,20 @@ static inline void dpm_save_failed_step(enum suspend_stat_step step)
  *	error code otherwise, in which case the system cannot enter the desired
  *	sleep state.
  *
- * @wake: Called when the system has just left a sleep state, right after
- *	the nonboot CPUs have been enabled and before device drivers' early
- *	resume callbacks are executed.
+ * @finish_noirq: Called when the system has just left a sleep state, right
+ *	after the nonboot CPUs have been enabled and before device drivers'
+ *	noirq resume callbacks are executed.
  *	This callback is optional, but should be implemented by the platforms
- *	that implement @prepare_late().  If implemented, it is always called
- *	after @prepare_late and @enter(), even if one of them fails.
+ *	that implement @prepare_noirq().  If implemented, it is always called
+ *	after @prepare_noirq and @enter(), even if one of them fails.
  *
  * @finish: Finish wake-up of the platform.
  *	@finish is called right prior to calling device drivers' regular suspend
  *	callbacks.
  *	This callback is optional, but should be implemented by the platforms
  *	that implement @prepare().  If implemented, it is always called after
- *	@enter() and @wake(), even if any of them fails.  It is executed after
- *	a failing @prepare.
+ *	@enter() and @finish_noirq(), even if any of them fails.  It is executed
+ *	after a failing @prepare.
  *
  * @suspend_again: Returns whether the system should suspend again (true) or
  *	not (false). If the platform wants to poll sensors or execute some
@@ -177,9 +177,9 @@ struct platform_suspend_ops {
 	int (*valid)(suspend_state_t state);
 	int (*begin)(suspend_state_t state);
 	int (*prepare)(void);
-	int (*prepare_late)(void);
+	int (*prepare_noirq)(void);
 	int (*enter)(suspend_state_t state);
-	void (*wake)(void);
+	void (*finish_noirq)(void);
 	void (*finish)(void);
 	bool (*suspend_again)(void);
 	void (*end)(void);
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 5b70d64..f0a5561 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -185,14 +185,14 @@ static int platform_suspend_prepare_late(suspend_state_t state)
 
 static int platform_suspend_prepare_noirq(suspend_state_t state)
 {
-	return state != PM_SUSPEND_FREEZE && suspend_ops->prepare_late ?
-		suspend_ops->prepare_late() : 0;
+	return state != PM_SUSPEND_FREEZE && suspend_ops->prepare_noirq ?
+		suspend_ops->prepare_noirq() : 0;
 }
 
 static void platform_resume_noirq(suspend_state_t state)
 {
-	if (state != PM_SUSPEND_FREEZE && suspend_ops->wake)
-		suspend_ops->wake();
+	if (state != PM_SUSPEND_FREEZE && suspend_ops->finish_noirq)
+		suspend_ops->finish_noirq();
 }
 
 static void platform_resume_early(suspend_state_t state)
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC PATCH 1/3] PM: Rename prepare_late/wake suspend_ops callbacks to prepare_noirq/finish_noirq
@ 2016-06-28  8:04   ` Lv Zheng
  0 siblings, 0 replies; 10+ messages in thread
From: Lv Zheng @ 2016-06-28  8:04 UTC (permalink / raw)
  To: Rafael J. Wysocki, Rafael J. Wysocki, Len Brown
  Cc: Lv Zheng, Lv Zheng, linux-kernel, linux-acpi

Rename the names of the PM callbacks, making them consistent with their
caller names. Particularly:
  .prepare_late -> .prepare_noirq
  .wake -> .finish_noirq

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
 arch/powerpc/platforms/pseries/suspend.c |    6 +++---
 drivers/acpi/sleep.c                     |    8 ++++----
 include/linux/suspend.h                  |   28 ++++++++++++++--------------
 kernel/power/suspend.c                   |    8 ++++----
 4 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/suspend.c b/arch/powerpc/platforms/pseries/suspend.c
index e76aefa..cc52b0f 100644
--- a/arch/powerpc/platforms/pseries/suspend.c
+++ b/arch/powerpc/platforms/pseries/suspend.c
@@ -112,12 +112,12 @@ static int pseries_suspend_enter(suspend_state_t state)
 }
 
 /**
- * pseries_prepare_late - Prepare to suspend all other CPUs
+ * pseries_prepare_noirq - Prepare to suspend all other CPUs
  *
  * Return value:
  * 	0 on success / other on failure
  **/
-static int pseries_prepare_late(void)
+static int pseries_prepare_noirq(void)
 {
 	atomic_set(&suspending, 1);
 	atomic_set(&suspend_data.working, 0);
@@ -225,7 +225,7 @@ static struct bus_type suspend_subsys = {
 static const struct platform_suspend_ops pseries_suspend_ops = {
 	.valid		= suspend_valid_only_mem,
 	.begin		= pseries_suspend_begin,
-	.prepare_late	= pseries_prepare_late,
+	.prepare_noirq	= pseries_prepare_noirq,
 	.enter		= pseries_suspend_enter,
 };
 
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 7a2e4d4..d30fce7f 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -595,9 +595,9 @@ static int acpi_suspend_state_valid(suspend_state_t pm_state)
 static const struct platform_suspend_ops acpi_suspend_ops = {
 	.valid = acpi_suspend_state_valid,
 	.begin = acpi_suspend_begin,
-	.prepare_late = acpi_pm_prepare,
+	.prepare_noirq = acpi_pm_prepare,
 	.enter = acpi_suspend_enter,
-	.wake = acpi_pm_finish,
+	.finish_noirq = acpi_pm_finish,
 	.end = acpi_pm_end,
 };
 
@@ -623,9 +623,9 @@ static int acpi_suspend_begin_old(suspend_state_t pm_state)
 static const struct platform_suspend_ops acpi_suspend_ops_old = {
 	.valid = acpi_suspend_state_valid,
 	.begin = acpi_suspend_begin_old,
-	.prepare_late = acpi_pm_pre_suspend,
+	.prepare_noirq = acpi_pm_pre_suspend,
 	.enter = acpi_suspend_enter,
-	.wake = acpi_pm_finish,
+	.finish_noirq = acpi_pm_finish,
 	.end = acpi_pm_end,
 	.recover = acpi_pm_finish,
 };
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 7693e39..b5261e3 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -121,13 +121,13 @@ static inline void dpm_save_failed_step(enum suspend_stat_step step)
  *	appropriate .suspend() method has been executed for each device) and
  *	before device drivers' late suspend callbacks are executed.  It returns
  *	0 on success or a negative error code otherwise, in which case the
- *	system cannot enter the desired sleep state (@prepare_late(), @enter(),
- *	and @wake() will not be called in that case).
+ *	system cannot enter the desired sleep state (@prepare_noirq(), @enter(),
+ *	and @finish_noirq() will not be called in that case).
  *
- * @prepare_late: Finish preparing the platform for entering the system sleep
+ * @prepare_noirq: Finish preparing the platform for entering the system sleep
  *	state indicated by @begin().
- *	@prepare_late is called before disabling nonboot CPUs and after
- *	device drivers' late suspend callbacks have been executed.  It returns
+ *	@prepare_noirq is called before disabling nonboot CPUs and after
+ *	device drivers' noirq suspend callbacks have been executed.  It returns
  *	0 on success or a negative error code otherwise, in which case the
  *	system cannot enter the desired sleep state (@enter() will not be
  *	executed).
@@ -138,20 +138,20 @@ static inline void dpm_save_failed_step(enum suspend_stat_step step)
  *	error code otherwise, in which case the system cannot enter the desired
  *	sleep state.
  *
- * @wake: Called when the system has just left a sleep state, right after
- *	the nonboot CPUs have been enabled and before device drivers' early
- *	resume callbacks are executed.
+ * @finish_noirq: Called when the system has just left a sleep state, right
+ *	after the nonboot CPUs have been enabled and before device drivers'
+ *	noirq resume callbacks are executed.
  *	This callback is optional, but should be implemented by the platforms
- *	that implement @prepare_late().  If implemented, it is always called
- *	after @prepare_late and @enter(), even if one of them fails.
+ *	that implement @prepare_noirq().  If implemented, it is always called
+ *	after @prepare_noirq and @enter(), even if one of them fails.
  *
  * @finish: Finish wake-up of the platform.
  *	@finish is called right prior to calling device drivers' regular suspend
  *	callbacks.
  *	This callback is optional, but should be implemented by the platforms
  *	that implement @prepare().  If implemented, it is always called after
- *	@enter() and @wake(), even if any of them fails.  It is executed after
- *	a failing @prepare.
+ *	@enter() and @finish_noirq(), even if any of them fails.  It is executed
+ *	after a failing @prepare.
  *
  * @suspend_again: Returns whether the system should suspend again (true) or
  *	not (false). If the platform wants to poll sensors or execute some
@@ -177,9 +177,9 @@ struct platform_suspend_ops {
 	int (*valid)(suspend_state_t state);
 	int (*begin)(suspend_state_t state);
 	int (*prepare)(void);
-	int (*prepare_late)(void);
+	int (*prepare_noirq)(void);
 	int (*enter)(suspend_state_t state);
-	void (*wake)(void);
+	void (*finish_noirq)(void);
 	void (*finish)(void);
 	bool (*suspend_again)(void);
 	void (*end)(void);
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 5b70d64..f0a5561 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -185,14 +185,14 @@ static int platform_suspend_prepare_late(suspend_state_t state)
 
 static int platform_suspend_prepare_noirq(suspend_state_t state)
 {
-	return state != PM_SUSPEND_FREEZE && suspend_ops->prepare_late ?
-		suspend_ops->prepare_late() : 0;
+	return state != PM_SUSPEND_FREEZE && suspend_ops->prepare_noirq ?
+		suspend_ops->prepare_noirq() : 0;
 }
 
 static void platform_resume_noirq(suspend_state_t state)
 {
-	if (state != PM_SUSPEND_FREEZE && suspend_ops->wake)
-		suspend_ops->wake();
+	if (state != PM_SUSPEND_FREEZE && suspend_ops->finish_noirq)
+		suspend_ops->finish_noirq();
 }
 
 static void platform_resume_early(suspend_state_t state)
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC PATCH 2/3] PM: Add prepare_late/finish_early suspend_ops callbacks
  2016-06-28  8:04 ` Lv Zheng
@ 2016-06-28  8:04   ` Lv Zheng
  -1 siblings, 0 replies; 10+ messages in thread
From: Lv Zheng @ 2016-06-28  8:04 UTC (permalink / raw)
  To: Rafael J. Wysocki, Rafael J. Wysocki, Len Brown
  Cc: Lv Zheng, Lv Zheng, linux-kernel, linux-acpi

This patch adds prepare_late/finish_early callbacks for suspend_ops.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
 include/linux/suspend.h |   34 +++++++++++++++++++++++++++-------
 kernel/power/suspend.c  |   10 ++++++++--
 2 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index b5261e3..21e32b8 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -115,14 +115,24 @@ static inline void dpm_save_failed_step(enum suspend_stat_step step)
  *	This callback is optional.  However, if it is implemented, the argument
  *	passed to @enter() is redundant and should be ignored.
  *
- * @prepare: Prepare the platform for entering the system sleep state indicated
- *	by @begin().
+ * @prepare: Early preparing the platform for entering the system sleep state
+ *	indicated by @begin().
  *	@prepare() is called right after devices have been suspended (ie. the
  *	appropriate .suspend() method has been executed for each device) and
  *	before device drivers' late suspend callbacks are executed.  It returns
  *	0 on success or a negative error code otherwise, in which case the
- *	system cannot enter the desired sleep state (@prepare_noirq(), @enter(),
- *	and @finish_noirq() will not be called in that case).
+ *	system cannot enter the desired sleep state (@prepare_late,
+ *	@prepare_noirq(), @enter(), and @finish_noirq() will not be called in
+ *	that case).
+ *
+ * @prepare_late: Late preparing the platform for entering the system sleep
+ *	state indicated by @begin().
+ *	@prepare_late() is called right after device drivers' late suspend
+ *	callbacks have been executed and before device drivers' noirq suspend
+ *	callbacks are executed.  It returns 0 on success or a negative error
+ *	code otherwise, in which case the system cannot enter the desired sleep
+ *	state (@prepare_noirq(), @enter(), and @finish_noirq() will not be
+ *	called in that case).
  *
  * @prepare_noirq: Finish preparing the platform for entering the system sleep
  *	state indicated by @begin().
@@ -145,13 +155,21 @@ static inline void dpm_save_failed_step(enum suspend_stat_step step)
  *	that implement @prepare_noirq().  If implemented, it is always called
  *	after @prepare_noirq and @enter(), even if one of them fails.
  *
- * @finish: Finish wake-up of the platform.
+ * @finish_early: Early finishing wake-up of the platform.
+ *	@finish_early is called right prior to calling device drivers' resume
+ *	early callbacks.
+ *	This callback is optional, but should be implemented by the platforms
+ *	that implement @prepare_late().  If implemented, it is always called
+ *	after @enter() and @finish_noirq(), even if any of them fails.  It is
+ *	executed after a failing @prepare_late.
+ *
+ * @finish: Late finishing wake-up of the platform.
  *	@finish is called right prior to calling device drivers' regular suspend
  *	callbacks.
  *	This callback is optional, but should be implemented by the platforms
  *	that implement @prepare().  If implemented, it is always called after
- *	@enter() and @finish_noirq(), even if any of them fails.  It is executed
- *	after a failing @prepare.
+ *	@enter(), @finish_noirq() and @finish_early, even if any of them fails.
+ *	It is executed after a failing @prepare.
  *
  * @suspend_again: Returns whether the system should suspend again (true) or
  *	not (false). If the platform wants to poll sensors or execute some
@@ -177,9 +195,11 @@ struct platform_suspend_ops {
 	int (*valid)(suspend_state_t state);
 	int (*begin)(suspend_state_t state);
 	int (*prepare)(void);
+	int (*prepare_late)(void);
 	int (*prepare_noirq)(void);
 	int (*enter)(suspend_state_t state);
 	void (*finish_noirq)(void);
+	void (*finish_early)(void);
 	void (*finish)(void);
 	bool (*suspend_again)(void);
 	void (*end)(void);
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index f0a5561..3a36107 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -179,8 +179,12 @@ static int platform_suspend_prepare(suspend_state_t state)
 
 static int platform_suspend_prepare_late(suspend_state_t state)
 {
-	return state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->prepare ?
-		freeze_ops->prepare() : 0;
+	if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->prepare)
+		return freeze_ops->prepare();
+	else if (suspend_ops->prepare_late)
+		return suspend_ops->prepare_late();
+	else
+		return 0;
 }
 
 static int platform_suspend_prepare_noirq(suspend_state_t state)
@@ -199,6 +203,8 @@ static void platform_resume_early(suspend_state_t state)
 {
 	if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->restore)
 		freeze_ops->restore();
+	else if (suspend_ops->finish_early)
+		suspend_ops->finish_early();
 }
 
 static void platform_resume_finish(suspend_state_t state)
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC PATCH 2/3] PM: Add prepare_late/finish_early suspend_ops callbacks
@ 2016-06-28  8:04   ` Lv Zheng
  0 siblings, 0 replies; 10+ messages in thread
From: Lv Zheng @ 2016-06-28  8:04 UTC (permalink / raw)
  To: Rafael J. Wysocki, Rafael J. Wysocki, Len Brown
  Cc: Lv Zheng, Lv Zheng, linux-kernel, linux-acpi

This patch adds prepare_late/finish_early callbacks for suspend_ops.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
 include/linux/suspend.h |   34 +++++++++++++++++++++++++++-------
 kernel/power/suspend.c  |   10 ++++++++--
 2 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index b5261e3..21e32b8 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -115,14 +115,24 @@ static inline void dpm_save_failed_step(enum suspend_stat_step step)
  *	This callback is optional.  However, if it is implemented, the argument
  *	passed to @enter() is redundant and should be ignored.
  *
- * @prepare: Prepare the platform for entering the system sleep state indicated
- *	by @begin().
+ * @prepare: Early preparing the platform for entering the system sleep state
+ *	indicated by @begin().
  *	@prepare() is called right after devices have been suspended (ie. the
  *	appropriate .suspend() method has been executed for each device) and
  *	before device drivers' late suspend callbacks are executed.  It returns
  *	0 on success or a negative error code otherwise, in which case the
- *	system cannot enter the desired sleep state (@prepare_noirq(), @enter(),
- *	and @finish_noirq() will not be called in that case).
+ *	system cannot enter the desired sleep state (@prepare_late,
+ *	@prepare_noirq(), @enter(), and @finish_noirq() will not be called in
+ *	that case).
+ *
+ * @prepare_late: Late preparing the platform for entering the system sleep
+ *	state indicated by @begin().
+ *	@prepare_late() is called right after device drivers' late suspend
+ *	callbacks have been executed and before device drivers' noirq suspend
+ *	callbacks are executed.  It returns 0 on success or a negative error
+ *	code otherwise, in which case the system cannot enter the desired sleep
+ *	state (@prepare_noirq(), @enter(), and @finish_noirq() will not be
+ *	called in that case).
  *
  * @prepare_noirq: Finish preparing the platform for entering the system sleep
  *	state indicated by @begin().
@@ -145,13 +155,21 @@ static inline void dpm_save_failed_step(enum suspend_stat_step step)
  *	that implement @prepare_noirq().  If implemented, it is always called
  *	after @prepare_noirq and @enter(), even if one of them fails.
  *
- * @finish: Finish wake-up of the platform.
+ * @finish_early: Early finishing wake-up of the platform.
+ *	@finish_early is called right prior to calling device drivers' resume
+ *	early callbacks.
+ *	This callback is optional, but should be implemented by the platforms
+ *	that implement @prepare_late().  If implemented, it is always called
+ *	after @enter() and @finish_noirq(), even if any of them fails.  It is
+ *	executed after a failing @prepare_late.
+ *
+ * @finish: Late finishing wake-up of the platform.
  *	@finish is called right prior to calling device drivers' regular suspend
  *	callbacks.
  *	This callback is optional, but should be implemented by the platforms
  *	that implement @prepare().  If implemented, it is always called after
- *	@enter() and @finish_noirq(), even if any of them fails.  It is executed
- *	after a failing @prepare.
+ *	@enter(), @finish_noirq() and @finish_early, even if any of them fails.
+ *	It is executed after a failing @prepare.
  *
  * @suspend_again: Returns whether the system should suspend again (true) or
  *	not (false). If the platform wants to poll sensors or execute some
@@ -177,9 +195,11 @@ struct platform_suspend_ops {
 	int (*valid)(suspend_state_t state);
 	int (*begin)(suspend_state_t state);
 	int (*prepare)(void);
+	int (*prepare_late)(void);
 	int (*prepare_noirq)(void);
 	int (*enter)(suspend_state_t state);
 	void (*finish_noirq)(void);
+	void (*finish_early)(void);
 	void (*finish)(void);
 	bool (*suspend_again)(void);
 	void (*end)(void);
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index f0a5561..3a36107 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -179,8 +179,12 @@ static int platform_suspend_prepare(suspend_state_t state)
 
 static int platform_suspend_prepare_late(suspend_state_t state)
 {
-	return state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->prepare ?
-		freeze_ops->prepare() : 0;
+	if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->prepare)
+		return freeze_ops->prepare();
+	else if (suspend_ops->prepare_late)
+		return suspend_ops->prepare_late();
+	else
+		return 0;
 }
 
 static int platform_suspend_prepare_noirq(suspend_state_t state)
@@ -199,6 +203,8 @@ static void platform_resume_early(suspend_state_t state)
 {
 	if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->restore)
 		freeze_ops->restore();
+	else if (suspend_ops->finish_early)
+		suspend_ops->finish_early();
 }
 
 static void platform_resume_finish(suspend_state_t state)
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC PATCH 3/3] ACPI / PM: Fix EC polling issue by implementing prepare_late/finish_early suspend_ops callbacks
  2016-06-28  8:04 ` Lv Zheng
@ 2016-06-28  8:04   ` Lv Zheng
  -1 siblings, 0 replies; 10+ messages in thread
From: Lv Zheng @ 2016-06-28  8:04 UTC (permalink / raw)
  To: Rafael J. Wysocki, Rafael J. Wysocki, Len Brown
  Cc: Lv Zheng, Lv Zheng, linux-kernel, linux-acpi

_PTS/_WAK may contain EC transactions, it is better to have them handled
with IRQ enabled. This patch moves the 2 suspend PM ops from noirq stage
to late/early stage.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
 drivers/acpi/sleep.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index d30fce7f..c5c374c9 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -595,9 +595,10 @@ static int acpi_suspend_state_valid(suspend_state_t pm_state)
 static const struct platform_suspend_ops acpi_suspend_ops = {
 	.valid = acpi_suspend_state_valid,
 	.begin = acpi_suspend_begin,
-	.prepare_noirq = acpi_pm_prepare,
+	.prepare_late = __acpi_pm_prepare,
+	.prepare_noirq = acpi_pm_pre_suspend,
 	.enter = acpi_suspend_enter,
-	.finish_noirq = acpi_pm_finish,
+	.finish_early = acpi_pm_finish,
 	.end = acpi_pm_end,
 };
 
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC PATCH 3/3] ACPI / PM: Fix EC polling issue by implementing prepare_late/finish_early suspend_ops callbacks
@ 2016-06-28  8:04   ` Lv Zheng
  0 siblings, 0 replies; 10+ messages in thread
From: Lv Zheng @ 2016-06-28  8:04 UTC (permalink / raw)
  To: Rafael J. Wysocki, Rafael J. Wysocki, Len Brown
  Cc: Lv Zheng, Lv Zheng, linux-kernel, linux-acpi

_PTS/_WAK may contain EC transactions, it is better to have them handled
with IRQ enabled. This patch moves the 2 suspend PM ops from noirq stage
to late/early stage.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
 drivers/acpi/sleep.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index d30fce7f..c5c374c9 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -595,9 +595,10 @@ static int acpi_suspend_state_valid(suspend_state_t pm_state)
 static const struct platform_suspend_ops acpi_suspend_ops = {
 	.valid = acpi_suspend_state_valid,
 	.begin = acpi_suspend_begin,
-	.prepare_noirq = acpi_pm_prepare,
+	.prepare_late = __acpi_pm_prepare,
+	.prepare_noirq = acpi_pm_pre_suspend,
 	.enter = acpi_suspend_enter,
-	.finish_noirq = acpi_pm_finish,
+	.finish_early = acpi_pm_finish,
 	.end = acpi_pm_end,
 };
 
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [RFC PATCH 3/3] ACPI / PM: Fix EC polling issue by implementing prepare_late/finish_early suspend_ops callbacks
  2016-06-28  8:04   ` Lv Zheng
  (?)
@ 2016-07-16  0:51   ` Rafael J. Wysocki
  2016-07-19  4:40     ` Zheng, Lv
  -1 siblings, 1 reply; 10+ messages in thread
From: Rafael J. Wysocki @ 2016-07-16  0:51 UTC (permalink / raw)
  To: Lv Zheng; +Cc: Rafael J. Wysocki, Len Brown, Lv Zheng, linux-kernel, linux-acpi

On Tuesday, June 28, 2016 04:04:46 PM Lv Zheng wrote:
> _PTS/_WAK may contain EC transactions, it is better to have them handled
> with IRQ enabled. This patch moves the 2 suspend PM ops from noirq stage
> to late/early stage.
> 
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>

There are systems that won't work with this patch applied, so I don't
see a point in applying the other two.

> ---
>  drivers/acpi/sleep.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
> index d30fce7f..c5c374c9 100644
> --- a/drivers/acpi/sleep.c
> +++ b/drivers/acpi/sleep.c
> @@ -595,9 +595,10 @@ static int acpi_suspend_state_valid(suspend_state_t pm_state)
>  static const struct platform_suspend_ops acpi_suspend_ops = {
>  	.valid = acpi_suspend_state_valid,
>  	.begin = acpi_suspend_begin,
> -	.prepare_noirq = acpi_pm_prepare,
> +	.prepare_late = __acpi_pm_prepare,
> +	.prepare_noirq = acpi_pm_pre_suspend,
>  	.enter = acpi_suspend_enter,
> -	.finish_noirq = acpi_pm_finish,
> +	.finish_early = acpi_pm_finish,
>  	.end = acpi_pm_end,
>  };
>  
> 

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [RFC PATCH 3/3] ACPI / PM: Fix EC polling issue by implementing prepare_late/finish_early suspend_ops callbacks
  2016-07-16  0:51   ` Rafael J. Wysocki
@ 2016-07-19  4:40     ` Zheng, Lv
  0 siblings, 0 replies; 10+ messages in thread
From: Zheng, Lv @ 2016-07-19  4:40 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Wysocki, Rafael J, Brown, Len, Lv Zheng, linux-kernel, linux-acpi

Hi, Rafael

> From: linux-acpi-owner@vger.kernel.org [mailto:linux-acpi-
> owner@vger.kernel.org] On Behalf Of Rafael J. Wysocki
> Subject: Re: [RFC PATCH 3/3] ACPI / PM: Fix EC polling issue by
> implementing prepare_late/finish_early suspend_ops callbacks
> 
> On Tuesday, June 28, 2016 04:04:46 PM Lv Zheng wrote:
> > _PTS/_WAK may contain EC transactions, it is better to have them
> handled
> > with IRQ enabled. This patch moves the 2 suspend PM ops from noirq
> stage
> > to late/early stage.
> >
> > Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> 
> There are systems that won't work with this patch applied, so I don't
> see a point in applying the other two.
[Lv Zheng] 
I see.
Then instead of moving _WAK/_PTS out of noirq stage, we need to think about tuning the performance of the EC polling mode.

Thanks and best regards
-Lv

> 
> > ---
> >  drivers/acpi/sleep.c |    5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
> > index d30fce7f..c5c374c9 100644
> > --- a/drivers/acpi/sleep.c
> > +++ b/drivers/acpi/sleep.c
> > @@ -595,9 +595,10 @@ static int
> acpi_suspend_state_valid(suspend_state_t pm_state)
> >  static const struct platform_suspend_ops acpi_suspend_ops = {
> >  	.valid = acpi_suspend_state_valid,
> >  	.begin = acpi_suspend_begin,
> > -	.prepare_noirq = acpi_pm_prepare,
> > +	.prepare_late = __acpi_pm_prepare,
> > +	.prepare_noirq = acpi_pm_pre_suspend,
> >  	.enter = acpi_suspend_enter,
> > -	.finish_noirq = acpi_pm_finish,
> > +	.finish_early = acpi_pm_finish,
> >  	.end = acpi_pm_end,
> >  };
> >
> >
> 
> Thanks,
> Rafael
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-07-19  4:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-28  8:04 [RFC PATCH 0/3] ACPI / PM: Move _PTS/_WAK invocations out of the noirq stage Lv Zheng
2016-06-28  8:04 ` Lv Zheng
2016-06-28  8:04 ` [RFC PATCH 1/3] PM: Rename prepare_late/wake suspend_ops callbacks to prepare_noirq/finish_noirq Lv Zheng
2016-06-28  8:04   ` Lv Zheng
2016-06-28  8:04 ` [RFC PATCH 2/3] PM: Add prepare_late/finish_early suspend_ops callbacks Lv Zheng
2016-06-28  8:04   ` Lv Zheng
2016-06-28  8:04 ` [RFC PATCH 3/3] ACPI / PM: Fix EC polling issue by implementing " Lv Zheng
2016-06-28  8:04   ` Lv Zheng
2016-07-16  0:51   ` Rafael J. Wysocki
2016-07-19  4:40     ` Zheng, Lv

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.