Skip to contentSkip to conversation

ACPI / PM: Move _PTS/_WAK invocations out of the noirq stage

RFC PATCH In review Lv Zheng 2 participants 6 messages Jun 28, 2016 – Jul 19, 2016

Subsystems (4)
lore
Share & tools
lore

Lv Zheng

author
#0 lore raw

cover ACPI / PM: Move _PTS/_WAK invocations out of the noirq stage

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(-)
Signature · 1 line
1.7.10
author
#1 lore raw

RFC PATCH 1/3 PM: Rename prepare_late/wake suspend_ops callbacks to prepare_noirq/finish_noirq

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

---
 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(-)
arch/powerpc/platforms/pseries/suspend.c +3 -3
index e76aefa..cc52b0f 100644
@@ -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,
 };
 
drivers/acpi/sleep.c +4 -4
index 7a2e4d4..d30fce7f 100644
@@ -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,
 };
include/linux/suspend.h +14 -14
index 7693e39..b5261e3 100644
@@ -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);
kernel/power/suspend.c +4 -4
index 5b70d64..f0a5561 100644
@@ -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)
Signature · 1 line
1.7.10
author
#2 lore raw

RFC PATCH 2/3 PM: Add prepare_late/finish_early suspend_ops callbacks

In reply to Lv Zheng

This patch adds prepare_late/finish_early callbacks for suspend_ops.

---
 include/linux/suspend.h |   34 +++++++++++++++++++++++++++-------
 kernel/power/suspend.c  |   10 ++++++++--
 2 files changed, 35 insertions(+), 9 deletions(-)
include/linux/suspend.h +27 -7
index b5261e3..21e32b8 100644
@@ -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);
kernel/power/suspend.c +8 -2
index f0a5561..3a36107 100644
@@ -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)
Signature · 1 line
1.7.10
author
#3 lore raw

RFC PATCH 3/3 ACPI / PM: Fix EC polling issue by implementing prepare_late/finish_early suspend_ops callbacks

In reply to Lv Zheng

_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.

---
 drivers/acpi/sleep.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/acpi/sleep.c +3 -2
index d30fce7f..c5c374c9 100644
@@ -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,
 };
 
Signature · 1 line
1.7.10
#4 lore raw

Re: [RFC PATCH 3/3] ACPI / PM: Fix EC polling issue by implementing prepare_late/finish_early suspend_ops callbacks

Quoted 5 lines · Lv Zheng

_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.

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

Quoted 12 lines
---
 drivers/acpi/sleep.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/acpi/sleep.c +0 -0
index d30fce7f..c5c374c9 100644
@@ -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,

drivers/acpi/sleep.c static int acpi_suspend_state_valid(suspend_state_t pm_state) · line 604

Quoted 10 lines
drivers/acpi/sleep.c +3 -2
 	.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

author
#5 lore raw

RE: [RFC PATCH 3/3] ACPI / PM: Fix EC polling issue by implementing prepare_late/finish_early suspend_ops callbacks

Hi, Rafael

Quoted 8 lines

From: [email protected] [mailto:linux-acpi- [email protected]] 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

Quoted 1 line · Lv Zheng

_PTS/_WAK may contain EC transactions, it is better to have them

handled

Quoted 8 lines
Quoted 1 line

with IRQ enabled. This patch moves the 2 suspend PM ops from noirq

stage

Quoted 3 lines

to late/early stage.

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

Quoted 32 lines

drivers/acpi/sleep.c static int

Quoted 10 lines
---
 drivers/acpi/sleep.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/acpi/sleep.c +0 -0
index d30fce7f..c5c374c9 100644
@@ -595,9 +595,10 @@ static int

acpi_suspend_state_valid(suspend_state_t pm_state)

drivers/acpi/sleep.c static int acpi_suspend_state_valid(suspend_state_t pm_state) · line 604

Quoted 13 lines
drivers/acpi/sleep.c +3 -2
 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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html