Skip to contentSkip to conversation

Xen/ACPI: support sleep state entering on hardware reduced systems

PATCH Superseded Ben Guthro 3 participants 23 messages Jun 28, 2013 – Jul 27, 2013

Subsystems (5)

v5 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Ben Guthro

author
#0 lore raw

v5 cover Xen/ACPI: support sleep state entering on hardware reduced systems

In version 3.4 acpi_os_prepare_sleep() got introduced in parallel with reduced hardware sleep support, and the two changes didn't get
synchronized: The new code doesn't call the hook function (if so requested). Fix this, requiring a boolean parameter to be added to the hook function to distinguish "extended" from "legacy" sleep.

This requires adjusting TXT, but the adjustments only go as far as failing the extended mode call (since, looking at the TXT interface, there doesn't even appear to be precautions to deal with that alternative interface).

The hypervisor change underlying this is commit 62d1a69 ("ACPI: support v5 (reduced HW) sleep interface") on the master branch of
git://xenbits.xen.org/xen.git.

Cc Richard L Maliszewski <[email protected]>
Cc Gang Wei <[email protected]>
Cc Shane Wang <[email protected]>
Cc Bob Moore <[email protected]>
Cc Rafael J. Wysocki <[email protected]>

v2: Extend description to include reference to hypervisor side change
v3: Split into multiple patches, separating subsystems
Remove bool parameters, in favor of u8
v4: Remove linux/acpi.h dependencies
Further patch split to break out acpica from OSL
More bool vs u8 fixes
v5: Fix build of consumers of acpi_os_prepare_sleep() interface change,
so intermediate builds of partial patch series will not fail.

Ben Guthro (5):
acpi: Remove need to include linux/acpi.h in common acpica code
acpi: Call acpi_os_prepare_sleep hook in reduced hardware sleep path
acpi: Adjust linux acpi OS functions to new extended parameter x86/tboot: Fail extended mode reduced hardware sleep xen/acpi: notify xen when reduced hardware sleep is available

 arch/x86/kernel/tboot.c          |    6 +++++-
 drivers/acpi/acpica/hwesleep.c   |    7 +++++++
 drivers/acpi/acpica/hwsleep.c    |    3 +--
 drivers/acpi/osl.c               |   16 ++++++++--------
 drivers/xen/acpi.c               |   26 +++++++++++++-------------
 include/acpi/acpiosxf.h          |    6 ++++++
 include/linux/acpi.h             |    9 +++------
 include/xen/acpi.h               |    4 ++--
 include/xen/interface/platform.h |    7 ++++---
 9 files changed, 49 insertions(+), 35 deletions(-)
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v5 1/5 acpi: Remove need to include linux/acpi.h in common acpica code

Move the definition of acpi_os_prepare_sleep into the OS services layer header, and remove the include of linux/acpi.h from common acpica code.

Cc Rafael J. Wysocki <[email protected]>
Cc Bob Moore <[email protected]>
---
 drivers/acpi/acpica/hwsleep.c |    1 -
 include/acpi/acpiosxf.h       |    6 ++++++
 include/linux/acpi.h          |    3 ---
 3 files changed, 6 insertions(+), 4 deletions(-)
drivers/acpi/acpica/hwsleep.c +0 -1
index e3828cc..867b947 100644
@@ -43,7 +43,6 @@
  */
 
 #include <acpi/acpi.h>
-#include <linux/acpi.h>
 #include "accommon.h"
 
 #define _COMPONENT          ACPI_HARDWARE
include/acpi/acpiosxf.h +6 -0
index 5b3d2bd..c68b779 100644
@@ -276,4 +276,10 @@ char *acpi_os_get_next_filename(void *dir_handle);
 
 void acpi_os_close_directory(void *dir_handle);
 
+/*
+ * ACPI sleep preparation
+ */
+acpi_status acpi_os_prepare_sleep(u8 sleep_state,
+				  u32 pm1a_control, u32 pm1b_control);
+
 #endif				/* __ACPIOSXF_H__ */
include/linux/acpi.h +0 -3
index 17b5b59..709a2f2 100644
@@ -479,9 +479,6 @@ static inline bool acpi_driver_match_device(struct device *dev,
 #ifdef CONFIG_ACPI
 void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
 			       u32 pm1a_ctrl,  u32 pm1b_ctrl));
-
-acpi_status acpi_os_prepare_sleep(u8 sleep_state,
-				  u32 pm1a_control, u32 pm1b_control);
 #ifdef CONFIG_X86
 void arch_reserve_mem_area(acpi_physical_address addr, size_t size);
 #else
Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH v5 1/5 acpi: Remove need to include linux/acpi.h in common acpica code

In reply to Ben Guthro

Move the definition of acpi_os_prepare_sleep into the OS services layer header, and remove the include of linux/acpi.h from common acpica code.

Cc Rafael J. Wysocki <[email protected]>
Cc Bob Moore <[email protected]>
---
 drivers/acpi/acpica/hwsleep.c |    1 -
 include/acpi/acpiosxf.h       |    6 ++++++
 include/linux/acpi.h          |    3 ---
 3 files changed, 6 insertions(+), 4 deletions(-)
drivers/acpi/acpica/hwsleep.c +0 -1
index e3828cc..867b947 100644
@@ -43,7 +43,6 @@
  */
 
 #include <acpi/acpi.h>
-#include <linux/acpi.h>
 #include "accommon.h"
 
 #define _COMPONENT          ACPI_HARDWARE
include/acpi/acpiosxf.h +6 -0
index 5b3d2bd..c68b779 100644
@@ -276,4 +276,10 @@ char *acpi_os_get_next_filename(void *dir_handle);
 
 void acpi_os_close_directory(void *dir_handle);
 
+/*
+ * ACPI sleep preparation
+ */
+acpi_status acpi_os_prepare_sleep(u8 sleep_state,
+				  u32 pm1a_control, u32 pm1b_control);
+
 #endif				/* __ACPIOSXF_H__ */
include/linux/acpi.h +0 -3
index 17b5b59..709a2f2 100644
@@ -479,9 +479,6 @@ static inline bool acpi_driver_match_device(struct device *dev,
 #ifdef CONFIG_ACPI
 void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
 			       u32 pm1a_ctrl,  u32 pm1b_ctrl));
-
-acpi_status acpi_os_prepare_sleep(u8 sleep_state,
-				  u32 pm1a_control, u32 pm1b_control);
 #ifdef CONFIG_X86
 void arch_reserve_mem_area(acpi_physical_address addr, size_t size);
 #else
Signature · 1 line
1.7.9.5
Reviewed-by on v5 1/5
#3 lore raw

Re: [PATCH v5 1/5] acpi: Remove need to include linux/acpi.h in common acpica code

Quoted 3 lines · Ben Guthro

Move the definition of acpi_os_prepare_sleep into the OS services layer header, and remove the include of linux/acpi.h from common acpica code.

Thank you.

Quoted 3 lines
Cc Rafael J. Wysocki <[email protected]>
Cc Bob Moore <[email protected]>
Quoted 50 lines
---
 drivers/acpi/acpica/hwsleep.c |    1 -
 include/acpi/acpiosxf.h       |    6 ++++++
 include/linux/acpi.h          |    3 ---
 3 files changed, 6 insertions(+), 4 deletions(-)
drivers/acpi/acpica/hwsleep.c +0 -1
index e3828cc..867b947 100644
@@ -43,7 +43,6 @@
  */
 
 #include <acpi/acpi.h>
-#include <linux/acpi.h>
 #include "accommon.h"
 
 #define _COMPONENT          ACPI_HARDWARE
include/acpi/acpiosxf.h +6 -0
index 5b3d2bd..c68b779 100644
@@ -276,4 +276,10 @@ char *acpi_os_get_next_filename(void *dir_handle);
 
 void acpi_os_close_directory(void *dir_handle);
 
+/*
+ * ACPI sleep preparation
+ */
+acpi_status acpi_os_prepare_sleep(u8 sleep_state,
+				  u32 pm1a_control, u32 pm1b_control);
+
 #endif				/* __ACPIOSXF_H__ */
include/linux/acpi.h +0 -3
index 17b5b59..709a2f2 100644
@@ -479,9 +479,6 @@ static inline bool acpi_driver_match_device(struct device *dev,
 #ifdef CONFIG_ACPI
 void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
 			       u32 pm1a_ctrl,  u32 pm1b_ctrl));
-
-acpi_status acpi_os_prepare_sleep(u8 sleep_state,
-				  u32 pm1a_control, u32 pm1b_control);
 #ifdef CONFIG_X86
 void arch_reserve_mem_area(acpi_physical_address addr, size_t size);
 #else
Signature · 1 line
1.7.9.5
Reviewed-by on v5 1/5
#4 lore raw

Re: [PATCH v5 1/5] acpi: Remove need to include linux/acpi.h in common acpica code

In reply to Ben Guthro
Quoted 3 lines · Ben Guthro

Move the definition of acpi_os_prepare_sleep into the OS services layer header, and remove the include of linux/acpi.h from common acpica code.

Thank you.

Quoted 3 lines
Cc Rafael J. Wysocki <[email protected]>
Cc Bob Moore <[email protected]>
Quoted 50 lines
---
 drivers/acpi/acpica/hwsleep.c |    1 -
 include/acpi/acpiosxf.h       |    6 ++++++
 include/linux/acpi.h          |    3 ---
 3 files changed, 6 insertions(+), 4 deletions(-)
drivers/acpi/acpica/hwsleep.c +0 -1
index e3828cc..867b947 100644
@@ -43,7 +43,6 @@
  */
 
 #include <acpi/acpi.h>
-#include <linux/acpi.h>
 #include "accommon.h"
 
 #define _COMPONENT          ACPI_HARDWARE
include/acpi/acpiosxf.h +6 -0
index 5b3d2bd..c68b779 100644
@@ -276,4 +276,10 @@ char *acpi_os_get_next_filename(void *dir_handle);
 
 void acpi_os_close_directory(void *dir_handle);
 
+/*
+ * ACPI sleep preparation
+ */
+acpi_status acpi_os_prepare_sleep(u8 sleep_state,
+				  u32 pm1a_control, u32 pm1b_control);
+
 #endif				/* __ACPIOSXF_H__ */
include/linux/acpi.h +0 -3
index 17b5b59..709a2f2 100644
@@ -479,9 +479,6 @@ static inline bool acpi_driver_match_device(struct device *dev,
 #ifdef CONFIG_ACPI
 void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
 			       u32 pm1a_ctrl,  u32 pm1b_ctrl));
-
-acpi_status acpi_os_prepare_sleep(u8 sleep_state,
-				  u32 pm1a_control, u32 pm1b_control);
 #ifdef CONFIG_X86
 void arch_reserve_mem_area(acpi_physical_address addr, size_t size);
 #else
Signature · 1 line
1.7.9.5
author
#5 lore raw

PATCH v5 2/5 acpi: Call acpi_os_prepare_sleep hook in reduced hardware sleep path

In reply to Ben Guthro

In version 3.4 acpi_os_prepare_sleep() got introduced in parallel with reduced hardware sleep support, and the two changes didn't get
synchronized: The new code doesn't call the hook function (if so requested). Fix this, requiring a parameter to be added to the hook function to distinguish "extended" from "legacy" sleep.

---
 drivers/acpi/acpica/hwesleep.c |    7 +++++++
 drivers/acpi/acpica/hwsleep.c  |    2 +-
 include/acpi/acpiosxf.h        |    4 ++--
 3 files changed, 10 insertions(+), 3 deletions(-)
drivers/acpi/acpica/hwesleep.c +7 -0
index 5e5f762..69b3e15 100644
@@ -128,6 +128,13 @@ acpi_status acpi_hw_extended_sleep(u8 sleep_state)
 
 	ACPI_FLUSH_CPU_CACHE();
 
+	status = acpi_os_prepare_sleep(sleep_state, acpi_gbl_sleep_type_a,
+				       acpi_gbl_sleep_type_b, TRUE);
+	if (ACPI_SKIP(status))
+		return_ACPI_STATUS(AE_OK);
+	if (ACPI_FAILURE(status))
+		return_ACPI_STATUS(status);
+
 	/*
 	 * Set the SLP_TYP and SLP_EN bits.
 	 *
drivers/acpi/acpica/hwsleep.c +1 -1
index 867b947..cf78157 100644
@@ -152,7 +152,7 @@ acpi_status acpi_hw_legacy_sleep(u8 sleep_state)
 	ACPI_FLUSH_CPU_CACHE();
 
 	status = acpi_os_prepare_sleep(sleep_state, pm1a_control,
-				       pm1b_control);
+				       pm1b_control, FALSE);
 	if (ACPI_SKIP(status))
 		return_ACPI_STATUS(AE_OK);
 	if (ACPI_FAILURE(status))
include/acpi/acpiosxf.h +2 -2
index c68b779..51d0f78 100644
@@ -279,7 +279,7 @@ void acpi_os_close_directory(void *dir_handle);
 /*
  * ACPI sleep preparation
  */
-acpi_status acpi_os_prepare_sleep(u8 sleep_state,
-				  u32 pm1a_control, u32 pm1b_control);
+acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 val_a, u32 val_b,
+				  u8 extended);
 
 #endif				/* __ACPIOSXF_H__ */
Signature · 1 line
1.7.9.5
Reviewed-by on v5 2/5
#6 lore raw

Re: [PATCH v5 2/5] acpi: Call acpi_os_prepare_sleep hook in reduced hardware sleep path

Quoted 11 lines · Ben Guthro

In version 3.4 acpi_os_prepare_sleep() got introduced in parallel with reduced hardware sleep support, and the two changes didn't get
synchronized: The new code doesn't call the hook function (if so requested). Fix this, requiring a parameter to be added to the hook function to distinguish "extended" from "legacy" sleep.

You can also add

Quoted 54 lines
---
 drivers/acpi/acpica/hwesleep.c |    7 +++++++
 drivers/acpi/acpica/hwsleep.c  |    2 +-
 include/acpi/acpiosxf.h        |    4 ++--
 3 files changed, 10 insertions(+), 3 deletions(-)
drivers/acpi/acpica/hwesleep.c +7 -0
index 5e5f762..69b3e15 100644
@@ -128,6 +128,13 @@ acpi_status acpi_hw_extended_sleep(u8 sleep_state)
 
 	ACPI_FLUSH_CPU_CACHE();
 
+	status = acpi_os_prepare_sleep(sleep_state, acpi_gbl_sleep_type_a,
+				       acpi_gbl_sleep_type_b, TRUE);
+	if (ACPI_SKIP(status))
+		return_ACPI_STATUS(AE_OK);
+	if (ACPI_FAILURE(status))
+		return_ACPI_STATUS(status);
+
 	/*
 	 * Set the SLP_TYP and SLP_EN bits.
 	 *
drivers/acpi/acpica/hwsleep.c +1 -1
index 867b947..cf78157 100644
@@ -152,7 +152,7 @@ acpi_status acpi_hw_legacy_sleep(u8 sleep_state)
 	ACPI_FLUSH_CPU_CACHE();
 
 	status = acpi_os_prepare_sleep(sleep_state, pm1a_control,
-				       pm1b_control);
+				       pm1b_control, FALSE);
 	if (ACPI_SKIP(status))
 		return_ACPI_STATUS(AE_OK);
 	if (ACPI_FAILURE(status))
include/acpi/acpiosxf.h +2 -2
index c68b779..51d0f78 100644
@@ -279,7 +279,7 @@ void acpi_os_close_directory(void *dir_handle);
 /*
  * ACPI sleep preparation
  */
-acpi_status acpi_os_prepare_sleep(u8 sleep_state,
-				  u32 pm1a_control, u32 pm1b_control);
+acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 val_a, u32 val_b,
+				  u8 extended);
 
 #endif				/* __ACPIOSXF_H__ */
Signature · 1 line
1.7.9.5
Reviewed-by on v5 2/5
#7 lore raw

Re: [PATCH v5 2/5] acpi: Call acpi_os_prepare_sleep hook in reduced hardware sleep path

In reply to Ben Guthro
Quoted 11 lines · Ben Guthro

In version 3.4 acpi_os_prepare_sleep() got introduced in parallel with reduced hardware sleep support, and the two changes didn't get
synchronized: The new code doesn't call the hook function (if so requested). Fix this, requiring a parameter to be added to the hook function to distinguish "extended" from "legacy" sleep.

You can also add

Quoted 54 lines
---
 drivers/acpi/acpica/hwesleep.c |    7 +++++++
 drivers/acpi/acpica/hwsleep.c  |    2 +-
 include/acpi/acpiosxf.h        |    4 ++--
 3 files changed, 10 insertions(+), 3 deletions(-)
drivers/acpi/acpica/hwesleep.c +7 -0
index 5e5f762..69b3e15 100644
@@ -128,6 +128,13 @@ acpi_status acpi_hw_extended_sleep(u8 sleep_state)
 
 	ACPI_FLUSH_CPU_CACHE();
 
+	status = acpi_os_prepare_sleep(sleep_state, acpi_gbl_sleep_type_a,
+				       acpi_gbl_sleep_type_b, TRUE);
+	if (ACPI_SKIP(status))
+		return_ACPI_STATUS(AE_OK);
+	if (ACPI_FAILURE(status))
+		return_ACPI_STATUS(status);
+
 	/*
 	 * Set the SLP_TYP and SLP_EN bits.
 	 *
drivers/acpi/acpica/hwsleep.c +1 -1
index 867b947..cf78157 100644
@@ -152,7 +152,7 @@ acpi_status acpi_hw_legacy_sleep(u8 sleep_state)
 	ACPI_FLUSH_CPU_CACHE();
 
 	status = acpi_os_prepare_sleep(sleep_state, pm1a_control,
-				       pm1b_control);
+				       pm1b_control, FALSE);
 	if (ACPI_SKIP(status))
 		return_ACPI_STATUS(AE_OK);
 	if (ACPI_FAILURE(status))
include/acpi/acpiosxf.h +2 -2
index c68b779..51d0f78 100644
@@ -279,7 +279,7 @@ void acpi_os_close_directory(void *dir_handle);
 /*
  * ACPI sleep preparation
  */
-acpi_status acpi_os_prepare_sleep(u8 sleep_state,
-				  u32 pm1a_control, u32 pm1b_control);
+acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 val_a, u32 val_b,
+				  u8 extended);
 
 #endif				/* __ACPIOSXF_H__ */
Signature · 1 line
1.7.9.5
author
#8 lore raw

PATCH v5 3/5 acpi: Adjust linux acpi OS functions to new extended parameter

In reply to Ben Guthro

Change the function definitions of acpi_os_prepare_sleep() and acpi_os_set_prepare_sleep() to pass along the new extended sleep parameter.

---
 arch/x86/kernel/tboot.c |    3 ++-
 drivers/acpi/osl.c      |   16 ++++++++--------
 drivers/xen/acpi.c      |    3 ++-
 include/linux/acpi.h    |    6 +++---
 include/xen/acpi.h      |    3 ++-
 5 files changed, 17 insertions(+), 14 deletions(-)
arch/x86/kernel/tboot.c +2 -1
index f84fe00..d578c9c 100644
@@ -273,7 +273,8 @@ static void tboot_copy_fadt(const struct acpi_table_fadt *fadt)
 		offsetof(struct acpi_table_facs, firmware_waking_vector);
 }
 
-static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
+static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control,
+		       bool extended)
 {
 	static u32 acpi_shutdown_map[ACPI_S_STATE_COUNT] = {
 		/* S0,1,2: */ -1, -1, -1,
drivers/acpi/osl.c +8 -8
index e721863..0251c9b 100644
@@ -77,8 +77,8 @@ EXPORT_SYMBOL(acpi_in_debugger);
 extern char line_buf[80];
 #endif				/*ENABLE_DEBUGGER */
 
-static int (*__acpi_os_prepare_sleep)(u8 sleep_state, u32 pm1a_ctrl,
-				      u32 pm1b_ctrl);
+static int (*__acpi_os_prepare_sleep)(u8 sleep_state, u32 val_a, u32 val_b,
+				      bool extended);
 
 static acpi_osd_handler acpi_irq_handler;
 static void *acpi_irq_context;
@@ -1757,13 +1757,13 @@ acpi_status acpi_os_terminate(void)
 	return AE_OK;
 }
 
-acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 pm1a_control,
-				  u32 pm1b_control)
+acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 val_a, u32 val_b,
+				  u8 extended)
 {
 	int rc = 0;
 	if (__acpi_os_prepare_sleep)
-		rc = __acpi_os_prepare_sleep(sleep_state,
-					     pm1a_control, pm1b_control);
+		rc = __acpi_os_prepare_sleep(sleep_state, val_a, val_b,
+					     extended);
 	if (rc < 0)
 		return AE_ERROR;
 	else if (rc > 0)
@@ -1772,8 +1772,8 @@ acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 pm1a_control,
 	return AE_OK;
 }
 
-void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
-			       u32 pm1a_ctrl, u32 pm1b_ctrl))
+void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, u32 val_a,
+			       u32 val_b, bool extended))
 {
 	__acpi_os_prepare_sleep = func;
 }
drivers/xen/acpi.c +2 -1
index 119d42a..36d2be1 100644
@@ -36,7 +36,8 @@
 #include <asm/xen/hypervisor.h>
 
 int xen_acpi_notify_hypervisor_state(u8 sleep_state,
-				     u32 pm1a_cnt, u32 pm1b_cnt)
+				     u32 pm1a_cnt, u32 pm1b_cnt,
+				     bool extended)
 {
 	struct xen_platform_op op = {
 		.cmd = XENPF_enter_acpi_sleep,
include/linux/acpi.h +3 -3
index 709a2f2..26f9996 100644
@@ -477,8 +477,8 @@ static inline bool acpi_driver_match_device(struct device *dev,
 #endif	/* !CONFIG_ACPI */
 
 #ifdef CONFIG_ACPI
-void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
-			       u32 pm1a_ctrl,  u32 pm1b_ctrl));
+void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, u32 val_a,
+			       u32 val_b, bool extended));
 #ifdef CONFIG_X86
 void arch_reserve_mem_area(acpi_physical_address addr, size_t size);
 #else
@@ -488,7 +488,7 @@ static inline void arch_reserve_mem_area(acpi_physical_address addr,
 }
 #endif /* CONFIG_X86 */
 #else
-#define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0)
+#define acpi_os_set_prepare_sleep(func, val_a, val_b, ext) do { } while (0)
 #endif
 
 #if defined(CONFIG_ACPI) && defined(CONFIG_PM_RUNTIME)
include/xen/acpi.h +2 -1
index 68d73d0..9f7e2e6 100644
@@ -76,7 +76,8 @@ static inline int xen_acpi_get_pxm(acpi_handle h)
 }
 
 int xen_acpi_notify_hypervisor_state(u8 sleep_state,
-				     u32 pm1a_cnt, u32 pm1b_cnd);
+				     u32 pm1a_cnt, u32 pm1b_cnd,
+				     bool extended);
 
 static inline void xen_acpi_sleep_register(void)
 {
Signature · 1 line
1.7.9.5
Acked-by on v5 3/5
#9 lore raw

Re: [PATCH v5 3/5] acpi: Adjust linux acpi OS functions to new extended parameter

Quoted 9 lines · Ben Guthro

Change the function definitions of acpi_os_prepare_sleep() and acpi_os_set_prepare_sleep() to pass along the new extended sleep parameter.

Quoted 6 lines
---
 arch/x86/kernel/tboot.c |    3 ++-
 drivers/acpi/osl.c      |   16 ++++++++--------
 drivers/xen/acpi.c      |    3 ++-
 include/linux/acpi.h    |    6 +++---
 include/xen/acpi.h      |    3 ++-

Since they touch the Xen files, please also include

thought you should rebase this on top of Rafael's linux-next as it won't apply cleanly on top v3.10-rc7.

Quoted 115 lines
 5 files changed, 17 insertions(+), 14 deletions(-)
arch/x86/kernel/tboot.c +2 -1
index f84fe00..d578c9c 100644
@@ -273,7 +273,8 @@ static void tboot_copy_fadt(const struct acpi_table_fadt *fadt)
 		offsetof(struct acpi_table_facs, firmware_waking_vector);
 }
 
-static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
+static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control,
+		       bool extended)
 {
 	static u32 acpi_shutdown_map[ACPI_S_STATE_COUNT] = {
 		/* S0,1,2: */ -1, -1, -1,
drivers/acpi/osl.c +8 -8
index e721863..0251c9b 100644
@@ -77,8 +77,8 @@ EXPORT_SYMBOL(acpi_in_debugger);
 extern char line_buf[80];
 #endif				/*ENABLE_DEBUGGER */
 
-static int (*__acpi_os_prepare_sleep)(u8 sleep_state, u32 pm1a_ctrl,
-				      u32 pm1b_ctrl);
+static int (*__acpi_os_prepare_sleep)(u8 sleep_state, u32 val_a, u32 val_b,
+				      bool extended);
 
 static acpi_osd_handler acpi_irq_handler;
 static void *acpi_irq_context;
@@ -1757,13 +1757,13 @@ acpi_status acpi_os_terminate(void)
 	return AE_OK;
 }
 
-acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 pm1a_control,
-				  u32 pm1b_control)
+acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 val_a, u32 val_b,
+				  u8 extended)
 {
 	int rc = 0;
 	if (__acpi_os_prepare_sleep)
-		rc = __acpi_os_prepare_sleep(sleep_state,
-					     pm1a_control, pm1b_control);
+		rc = __acpi_os_prepare_sleep(sleep_state, val_a, val_b,
+					     extended);
 	if (rc < 0)
 		return AE_ERROR;
 	else if (rc > 0)
@@ -1772,8 +1772,8 @@ acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 pm1a_control,
 	return AE_OK;
 }
 
-void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
-			       u32 pm1a_ctrl, u32 pm1b_ctrl))
+void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, u32 val_a,
+			       u32 val_b, bool extended))
 {
 	__acpi_os_prepare_sleep = func;
 }
drivers/xen/acpi.c +2 -1
index 119d42a..36d2be1 100644
@@ -36,7 +36,8 @@
 #include <asm/xen/hypervisor.h>
 
 int xen_acpi_notify_hypervisor_state(u8 sleep_state,
-				     u32 pm1a_cnt, u32 pm1b_cnt)
+				     u32 pm1a_cnt, u32 pm1b_cnt,
+				     bool extended)
 {
 	struct xen_platform_op op = {
 		.cmd = XENPF_enter_acpi_sleep,
include/linux/acpi.h +3 -3
index 709a2f2..26f9996 100644
@@ -477,8 +477,8 @@ static inline bool acpi_driver_match_device(struct device *dev,
 #endif	/* !CONFIG_ACPI */
 
 #ifdef CONFIG_ACPI
-void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
-			       u32 pm1a_ctrl,  u32 pm1b_ctrl));
+void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, u32 val_a,
+			       u32 val_b, bool extended));
 #ifdef CONFIG_X86
 void arch_reserve_mem_area(acpi_physical_address addr, size_t size);
 #else
@@ -488,7 +488,7 @@ static inline void arch_reserve_mem_area(acpi_physical_address addr,
 }
 #endif /* CONFIG_X86 */
 #else
-#define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0)
+#define acpi_os_set_prepare_sleep(func, val_a, val_b, ext) do { } while (0)
 #endif
 
 #if defined(CONFIG_ACPI) && defined(CONFIG_PM_RUNTIME)
include/xen/acpi.h +2 -1
index 68d73d0..9f7e2e6 100644
@@ -76,7 +76,8 @@ static inline int xen_acpi_get_pxm(acpi_handle h)
 }
 
 int xen_acpi_notify_hypervisor_state(u8 sleep_state,
-				     u32 pm1a_cnt, u32 pm1b_cnd);
+				     u32 pm1a_cnt, u32 pm1b_cnd,
+				     bool extended);
 
 static inline void xen_acpi_sleep_register(void)
 {
Signature · 1 line
1.7.9.5
author
#10 lore raw

Re: [PATCH v5 3/5] acpi: Adjust linux acpi OS functions to new extended parameter

Quoted 17 lines · Konrad Rzeszutek Wilk
Quoted 9 lines · Ben Guthro

Change the function definitions of acpi_os_prepare_sleep() and acpi_os_set_prepare_sleep() to pass along the new extended sleep parameter.

Quoted 6 lines
---
  arch/x86/kernel/tboot.c |    3 ++-
  drivers/acpi/osl.c      |   16 ++++++++--------
  drivers/xen/acpi.c      |    3 ++-
  include/linux/acpi.h    |    6 +++---
  include/xen/acpi.h      |    3 ++-
Quoted 6 lines

Since they touch the Xen files, please also include

thought you should rebase this on top of Rafael's linux-next as it won't apply cleanly on top v3.10-rc7.

Actually, it does apply cleanly on top of v3.10-rc7.

However, I'll pull Rafael's linux-next, and rebase on that.

Quoted 117 lines
Quoted 117 lines

  5 files changed, 17 insertions(+), 14 deletions(-)
arch/x86/kernel/tboot.c +2 -1
index f84fe00..d578c9c 100644
@@ -273,7 +273,8 @@ static void tboot_copy_fadt(const struct acpi_table_fadt *fadt)
  		offsetof(struct acpi_table_facs, firmware_waking_vector);
  }
 
-static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
+static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control,
+		       bool extended)
  {
  	static u32 acpi_shutdown_map[ACPI_S_STATE_COUNT] = {
  		/* S0,1,2: */ -1, -1, -1,
drivers/acpi/osl.c +8 -8
index e721863..0251c9b 100644
@@ -77,8 +77,8 @@ EXPORT_SYMBOL(acpi_in_debugger);
  extern char line_buf[80];
  #endif				/*ENABLE_DEBUGGER */
 
-static int (*__acpi_os_prepare_sleep)(u8 sleep_state, u32 pm1a_ctrl,
-				      u32 pm1b_ctrl);
+static int (*__acpi_os_prepare_sleep)(u8 sleep_state, u32 val_a, u32 val_b,
+				      bool extended);
 
  static acpi_osd_handler acpi_irq_handler;
  static void *acpi_irq_context;
@@ -1757,13 +1757,13 @@ acpi_status acpi_os_terminate(void)
  	return AE_OK;
  }
 
-acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 pm1a_control,
-				  u32 pm1b_control)
+acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 val_a, u32 val_b,
+				  u8 extended)
  {
  	int rc = 0;
  	if (__acpi_os_prepare_sleep)
-		rc = __acpi_os_prepare_sleep(sleep_state,
-					     pm1a_control, pm1b_control);
+		rc = __acpi_os_prepare_sleep(sleep_state, val_a, val_b,
+					     extended);
  	if (rc < 0)
  		return AE_ERROR;
  	else if (rc > 0)
@@ -1772,8 +1772,8 @@ acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 pm1a_control,
  	return AE_OK;
  }
 
-void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
-			       u32 pm1a_ctrl, u32 pm1b_ctrl))
+void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, u32 val_a,
+			       u32 val_b, bool extended))
  {
  	__acpi_os_prepare_sleep = func;
  }
drivers/xen/acpi.c +2 -1
index 119d42a..36d2be1 100644
@@ -36,7 +36,8 @@
  #include <asm/xen/hypervisor.h>
 
  int xen_acpi_notify_hypervisor_state(u8 sleep_state,
-				     u32 pm1a_cnt, u32 pm1b_cnt)
+				     u32 pm1a_cnt, u32 pm1b_cnt,
+				     bool extended)
  {
  	struct xen_platform_op op = {
  		.cmd = XENPF_enter_acpi_sleep,
include/linux/acpi.h +3 -3
index 709a2f2..26f9996 100644
@@ -477,8 +477,8 @@ static inline bool acpi_driver_match_device(struct device *dev,
  #endif	/* !CONFIG_ACPI */
 
  #ifdef CONFIG_ACPI
-void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
-			       u32 pm1a_ctrl,  u32 pm1b_ctrl));
+void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, u32 val_a,
+			       u32 val_b, bool extended));
  #ifdef CONFIG_X86
  void arch_reserve_mem_area(acpi_physical_address addr, size_t size);
  #else
@@ -488,7 +488,7 @@ static inline void arch_reserve_mem_area(acpi_physical_address addr,
  }
  #endif /* CONFIG_X86 */
  #else
-#define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0)
+#define acpi_os_set_prepare_sleep(func, val_a, val_b, ext) do { } while (0)
  #endif
 
  #if defined(CONFIG_ACPI) && defined(CONFIG_PM_RUNTIME)
include/xen/acpi.h +2 -2
index 68d73d0..9f7e2e6 100644
@@ -76,7 +76,8 @@ static inline int xen_acpi_get_pxm(acpi_handle h)
  }
 
  int xen_acpi_notify_hypervisor_state(u8 sleep_state,
-				     u32 pm1a_cnt, u32 pm1b_cnd);
+				     u32 pm1a_cnt, u32 pm1b_cnd,
+				     bool extended);
 
  static inline void xen_acpi_sleep_register(void)
  {
--

1.7.9.5

author
#11 lore raw

Re: [PATCH v5 3/5] acpi: Adjust linux acpi OS functions to new extended parameter

In reply to Konrad Rzeszutek Wilk
Quoted 17 lines · Konrad Rzeszutek Wilk
Quoted 9 lines · Ben Guthro

Change the function definitions of acpi_os_prepare_sleep() and acpi_os_set_prepare_sleep() to pass along the new extended sleep parameter.

Quoted 6 lines
---
  arch/x86/kernel/tboot.c |    3 ++-
  drivers/acpi/osl.c      |   16 ++++++++--------
  drivers/xen/acpi.c      |    3 ++-
  include/linux/acpi.h    |    6 +++---
  include/xen/acpi.h      |    3 ++-
Quoted 6 lines

Since they touch the Xen files, please also include

thought you should rebase this on top of Rafael's linux-next as it won't apply cleanly on top v3.10-rc7.

Actually, it does apply cleanly on top of v3.10-rc7.

However, I'll pull Rafael's linux-next, and rebase on that.

Quoted 117 lines
Quoted 117 lines

  5 files changed, 17 insertions(+), 14 deletions(-)
arch/x86/kernel/tboot.c +2 -1
index f84fe00..d578c9c 100644
@@ -273,7 +273,8 @@ static void tboot_copy_fadt(const struct acpi_table_fadt *fadt)
  		offsetof(struct acpi_table_facs, firmware_waking_vector);
  }
 
-static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
+static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control,
+		       bool extended)
  {
  	static u32 acpi_shutdown_map[ACPI_S_STATE_COUNT] = {
  		/* S0,1,2: */ -1, -1, -1,
drivers/acpi/osl.c +8 -8
index e721863..0251c9b 100644
@@ -77,8 +77,8 @@ EXPORT_SYMBOL(acpi_in_debugger);
  extern char line_buf[80];
  #endif				/*ENABLE_DEBUGGER */
 
-static int (*__acpi_os_prepare_sleep)(u8 sleep_state, u32 pm1a_ctrl,
-				      u32 pm1b_ctrl);
+static int (*__acpi_os_prepare_sleep)(u8 sleep_state, u32 val_a, u32 val_b,
+				      bool extended);
 
  static acpi_osd_handler acpi_irq_handler;
  static void *acpi_irq_context;
@@ -1757,13 +1757,13 @@ acpi_status acpi_os_terminate(void)
  	return AE_OK;
  }
 
-acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 pm1a_control,
-				  u32 pm1b_control)
+acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 val_a, u32 val_b,
+				  u8 extended)
  {
  	int rc = 0;
  	if (__acpi_os_prepare_sleep)
-		rc = __acpi_os_prepare_sleep(sleep_state,
-					     pm1a_control, pm1b_control);
+		rc = __acpi_os_prepare_sleep(sleep_state, val_a, val_b,
+					     extended);
  	if (rc < 0)
  		return AE_ERROR;
  	else if (rc > 0)
@@ -1772,8 +1772,8 @@ acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 pm1a_control,
  	return AE_OK;
  }
 
-void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
-			       u32 pm1a_ctrl, u32 pm1b_ctrl))
+void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, u32 val_a,
+			       u32 val_b, bool extended))
  {
  	__acpi_os_prepare_sleep = func;
  }
drivers/xen/acpi.c +2 -1
index 119d42a..36d2be1 100644
@@ -36,7 +36,8 @@
  #include <asm/xen/hypervisor.h>
 
  int xen_acpi_notify_hypervisor_state(u8 sleep_state,
-				     u32 pm1a_cnt, u32 pm1b_cnt)
+				     u32 pm1a_cnt, u32 pm1b_cnt,
+				     bool extended)
  {
  	struct xen_platform_op op = {
  		.cmd = XENPF_enter_acpi_sleep,
include/linux/acpi.h +3 -3
index 709a2f2..26f9996 100644
@@ -477,8 +477,8 @@ static inline bool acpi_driver_match_device(struct device *dev,
  #endif	/* !CONFIG_ACPI */
 
  #ifdef CONFIG_ACPI
-void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
-			       u32 pm1a_ctrl,  u32 pm1b_ctrl));
+void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, u32 val_a,
+			       u32 val_b, bool extended));
  #ifdef CONFIG_X86
  void arch_reserve_mem_area(acpi_physical_address addr, size_t size);
  #else
@@ -488,7 +488,7 @@ static inline void arch_reserve_mem_area(acpi_physical_address addr,
  }
  #endif /* CONFIG_X86 */
  #else
-#define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0)
+#define acpi_os_set_prepare_sleep(func, val_a, val_b, ext) do { } while (0)
  #endif
 
  #if defined(CONFIG_ACPI) && defined(CONFIG_PM_RUNTIME)
include/xen/acpi.h +2 -2
index 68d73d0..9f7e2e6 100644
@@ -76,7 +76,8 @@ static inline int xen_acpi_get_pxm(acpi_handle h)
  }
 
  int xen_acpi_notify_hypervisor_state(u8 sleep_state,
-				     u32 pm1a_cnt, u32 pm1b_cnd);
+				     u32 pm1a_cnt, u32 pm1b_cnd,
+				     bool extended);
 
  static inline void xen_acpi_sleep_register(void)
  {
--

1.7.9.5

Acked-by on v5 3/5
#12 lore raw

Re: [PATCH v5 3/5] acpi: Adjust linux acpi OS functions to new extended parameter

In reply to Ben Guthro
Quoted 9 lines · Ben Guthro

Change the function definitions of acpi_os_prepare_sleep() and acpi_os_set_prepare_sleep() to pass along the new extended sleep parameter.

Quoted 6 lines
---
 arch/x86/kernel/tboot.c |    3 ++-
 drivers/acpi/osl.c      |   16 ++++++++--------
 drivers/xen/acpi.c      |    3 ++-
 include/linux/acpi.h    |    6 +++---
 include/xen/acpi.h      |    3 ++-

Since they touch the Xen files, please also include

thought you should rebase this on top of Rafael's linux-next as it won't apply cleanly on top v3.10-rc7.

Quoted 115 lines
 5 files changed, 17 insertions(+), 14 deletions(-)
arch/x86/kernel/tboot.c +2 -1
index f84fe00..d578c9c 100644
@@ -273,7 +273,8 @@ static void tboot_copy_fadt(const struct acpi_table_fadt *fadt)
 		offsetof(struct acpi_table_facs, firmware_waking_vector);
 }
 
-static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
+static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control,
+		       bool extended)
 {
 	static u32 acpi_shutdown_map[ACPI_S_STATE_COUNT] = {
 		/* S0,1,2: */ -1, -1, -1,
drivers/acpi/osl.c +8 -8
index e721863..0251c9b 100644
@@ -77,8 +77,8 @@ EXPORT_SYMBOL(acpi_in_debugger);
 extern char line_buf[80];
 #endif				/*ENABLE_DEBUGGER */
 
-static int (*__acpi_os_prepare_sleep)(u8 sleep_state, u32 pm1a_ctrl,
-				      u32 pm1b_ctrl);
+static int (*__acpi_os_prepare_sleep)(u8 sleep_state, u32 val_a, u32 val_b,
+				      bool extended);
 
 static acpi_osd_handler acpi_irq_handler;
 static void *acpi_irq_context;
@@ -1757,13 +1757,13 @@ acpi_status acpi_os_terminate(void)
 	return AE_OK;
 }
 
-acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 pm1a_control,
-				  u32 pm1b_control)
+acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 val_a, u32 val_b,
+				  u8 extended)
 {
 	int rc = 0;
 	if (__acpi_os_prepare_sleep)
-		rc = __acpi_os_prepare_sleep(sleep_state,
-					     pm1a_control, pm1b_control);
+		rc = __acpi_os_prepare_sleep(sleep_state, val_a, val_b,
+					     extended);
 	if (rc < 0)
 		return AE_ERROR;
 	else if (rc > 0)
@@ -1772,8 +1772,8 @@ acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 pm1a_control,
 	return AE_OK;
 }
 
-void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
-			       u32 pm1a_ctrl, u32 pm1b_ctrl))
+void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, u32 val_a,
+			       u32 val_b, bool extended))
 {
 	__acpi_os_prepare_sleep = func;
 }
drivers/xen/acpi.c +2 -1
index 119d42a..36d2be1 100644
@@ -36,7 +36,8 @@
 #include <asm/xen/hypervisor.h>
 
 int xen_acpi_notify_hypervisor_state(u8 sleep_state,
-				     u32 pm1a_cnt, u32 pm1b_cnt)
+				     u32 pm1a_cnt, u32 pm1b_cnt,
+				     bool extended)
 {
 	struct xen_platform_op op = {
 		.cmd = XENPF_enter_acpi_sleep,
include/linux/acpi.h +3 -3
index 709a2f2..26f9996 100644
@@ -477,8 +477,8 @@ static inline bool acpi_driver_match_device(struct device *dev,
 #endif	/* !CONFIG_ACPI */
 
 #ifdef CONFIG_ACPI
-void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
-			       u32 pm1a_ctrl,  u32 pm1b_ctrl));
+void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, u32 val_a,
+			       u32 val_b, bool extended));
 #ifdef CONFIG_X86
 void arch_reserve_mem_area(acpi_physical_address addr, size_t size);
 #else
@@ -488,7 +488,7 @@ static inline void arch_reserve_mem_area(acpi_physical_address addr,
 }
 #endif /* CONFIG_X86 */
 #else
-#define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0)
+#define acpi_os_set_prepare_sleep(func, val_a, val_b, ext) do { } while (0)
 #endif
 
 #if defined(CONFIG_ACPI) && defined(CONFIG_PM_RUNTIME)
include/xen/acpi.h +2 -1
index 68d73d0..9f7e2e6 100644
@@ -76,7 +76,8 @@ static inline int xen_acpi_get_pxm(acpi_handle h)
 }
 
 int xen_acpi_notify_hypervisor_state(u8 sleep_state,
-				     u32 pm1a_cnt, u32 pm1b_cnd);
+				     u32 pm1a_cnt, u32 pm1b_cnd,
+				     bool extended);
 
 static inline void xen_acpi_sleep_register(void)
 {
Signature · 1 line
1.7.9.5
author
#13 lore raw

PATCH v5 4/5 x86/tboot: Fail extended mode reduced hardware sleep

In reply to Ben Guthro

As tboot currently does not support the reduced hardware sleep interface, fail this extended call.

---
 arch/x86/kernel/tboot.c |    3 +++
 1 file changed, 3 insertions(+)
arch/x86/kernel/tboot.c +3 -0
index d578c9c..57383b2 100644
@@ -285,6 +285,9 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control,
 	if (!tboot_enabled())
 		return 0;
 
+	if (extended)
+		return -1;
+
 	tboot_copy_fadt(&acpi_gbl_FADT);
 	tboot->acpi_sinfo.pm1a_cnt_val = pm1a_control;
 	tboot->acpi_sinfo.pm1b_cnt_val = pm1b_control;
Signature · 9 lines
1.7.9.5


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
Reviewed-by on v5 4/5
#14 lore raw

Re: [PATCH v5 4/5] x86/tboot: Fail extended mode reduced hardware sleep

Quoted 16 lines · Ben Guthro

As tboot currently does not support the reduced hardware sleep interface, fail this extended call.

---
 arch/x86/kernel/tboot.c |    3 +++
 1 file changed, 3 insertions(+)
arch/x86/kernel/tboot.c +0 -0
index d578c9c..57383b2 100644

arch/x86/kernel/tboot.c static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control, · line 289

Quoted 5 lines
arch/x86/kernel/tboot.c +2 -0
@@ -285,6 +285,9 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control,
 	if (!tboot_enabled())
 		return 0;
 
+	if (extended)
+		return -1;

I would add WARN_ON just so that the user is aware of. Perhaps

if (WARN(extended,"tboot is not able to suspend on ACPI extended platforms. Contact
tboot-something mailing list please."))
return -1

Otherwise

Quoted 7 lines
arch/x86/kernel/tboot.c +1 -0
+
 	tboot_copy_fadt(&acpi_gbl_FADT);
 	tboot->acpi_sinfo.pm1a_cnt_val = pm1a_control;
 	tboot->acpi_sinfo.pm1b_cnt_val = pm1b_control;
Signature · 1 line
1.7.9.5

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev

Reviewed-by on v5 4/5
#15 lore raw

Re: [PATCH v5 4/5] x86/tboot: Fail extended mode reduced hardware sleep

In reply to Ben Guthro
Quoted 16 lines · Ben Guthro

As tboot currently does not support the reduced hardware sleep interface, fail this extended call.

---
 arch/x86/kernel/tboot.c |    3 +++
 1 file changed, 3 insertions(+)
arch/x86/kernel/tboot.c +0 -0
index d578c9c..57383b2 100644

arch/x86/kernel/tboot.c static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control, · line 289

Quoted 5 lines
arch/x86/kernel/tboot.c +2 -0
@@ -285,6 +285,9 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control,
 	if (!tboot_enabled())
 		return 0;
 
+	if (extended)
+		return -1;

I would add WARN_ON just so that the user is aware of. Perhaps

if (WARN(extended,"tboot is not able to suspend on ACPI extended platforms. Contact
tboot-something mailing list please."))
return -1

Otherwise

Quoted 7 lines
arch/x86/kernel/tboot.c +1 -0
+
 	tboot_copy_fadt(&acpi_gbl_FADT);
 	tboot->acpi_sinfo.pm1a_cnt_val = pm1a_control;
 	tboot->acpi_sinfo.pm1b_cnt_val = pm1b_control;
Signature · 1 line
1.7.9.5
author
#16 lore raw

PATCH v5 4/5 x86/tboot: Fail extended mode reduced hardware sleep

In reply to Ben Guthro

As tboot currently does not support the reduced hardware sleep interface, fail this extended call.

---
 arch/x86/kernel/tboot.c |    3 +++
 1 file changed, 3 insertions(+)
arch/x86/kernel/tboot.c +3 -0
index d578c9c..57383b2 100644
@@ -285,6 +285,9 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control,
 	if (!tboot_enabled())
 		return 0;
 
+	if (extended)
+		return -1;
+
 	tboot_copy_fadt(&acpi_gbl_FADT);
 	tboot->acpi_sinfo.pm1a_cnt_val = pm1a_control;
 	tboot->acpi_sinfo.pm1b_cnt_val = pm1b_control;
Signature · 1 line
1.7.9.5
author
#17 lore raw

PATCH v5 5/5 xen/acpi: notify xen when reduced hardware sleep is available

In reply to Ben Guthro

Make use of acpi_os_prepare_sleep extended parameter to notify xen to make use of the reduced hardware sleep functionality

The hypervisor change underlying this is commit 62d1a69 ("ACPI: support v5 (reduced HW) sleep interface") on the master branch of
git://xenbits.xen.org/xen.git.

---
 drivers/xen/acpi.c               |   25 ++++++++++++-------------
 include/xen/acpi.h               |    3 +--
 include/xen/interface/platform.h |    7 ++++---
 3 files changed, 17 insertions(+), 18 deletions(-)
drivers/xen/acpi.c +12 -13
index 36d2be1..371dade 100644
@@ -35,28 +35,27 @@
 #include <asm/xen/hypercall.h>
 #include <asm/xen/hypervisor.h>
 
-int xen_acpi_notify_hypervisor_state(u8 sleep_state,
-				     u32 pm1a_cnt, u32 pm1b_cnt,
+int xen_acpi_notify_hypervisor_state(u8 sleep_state, u32 val_a, u32 val_b,
 				     bool extended)
 {
+	unsigned int bits = extended ? 8 : 16;
+
 	struct xen_platform_op op = {
 		.cmd = XENPF_enter_acpi_sleep,
 		.interface_version = XENPF_INTERFACE_VERSION,
-		.u = {
-			.enter_acpi_sleep = {
-				.pm1a_cnt_val = (u16)pm1a_cnt,
-				.pm1b_cnt_val = (u16)pm1b_cnt,
-				.sleep_state = sleep_state,
-			},
+		.u.enter_acpi_sleep = {
+			.val_a = (u16)val_a,
+			.val_b = (u16)val_b,
+			.sleep_state = sleep_state,
+			.flags = extended ? XENPF_ACPI_SLEEP_EXTENDED : 0,
 		},
 	};
 
-	if ((pm1a_cnt & 0xffff0000) || (pm1b_cnt & 0xffff0000)) {
-		WARN(1, "Using more than 16bits of PM1A/B 0x%x/0x%x!"
-		     "Email [email protected]  Thank you.\n", \
-		     pm1a_cnt, pm1b_cnt);
+	if (WARN((val_a & (~0 << bits)) || (val_b & (~0 << bits)),
+		 "Using more than %u bits of sleep control values %#x/%#x!"
+		 "Email [email protected] - Thank you.\n", \
+		 bits, val_a, val_b))
 		return -1;
-	}
 
 	HYPERVISOR_dom0_op(&op);
 	return 1;
include/xen/acpi.h +1 -2
index 9f7e2e6..a2d5667 100644
@@ -75,8 +75,7 @@ static inline int xen_acpi_get_pxm(acpi_handle h)
 	return -ENXIO;
 }
 
-int xen_acpi_notify_hypervisor_state(u8 sleep_state,
-				     u32 pm1a_cnt, u32 pm1b_cnd,
+int xen_acpi_notify_hypervisor_state(u8 sleep_state, u32 val_a, u32 val_b,
 				     bool extended);
 
 static inline void xen_acpi_sleep_register(void)
include/xen/interface/platform.h +4 -3
index c57d5f6..f1331e3 100644
@@ -152,10 +152,11 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmware_info_t);
 #define XENPF_enter_acpi_sleep    51
 struct xenpf_enter_acpi_sleep {
 	/* IN variables */
-	uint16_t pm1a_cnt_val;      /* PM1a control value. */
-	uint16_t pm1b_cnt_val;      /* PM1b control value. */
+	uint16_t val_a;             /* PM1a control / sleep type A. */
+	uint16_t val_b;             /* PM1b control / sleep type B. */
 	uint32_t sleep_state;       /* Which state to enter (Sn). */
-	uint32_t flags;             /* Must be zero. */
+#define XENPF_ACPI_SLEEP_EXTENDED 0x00000001
+	uint32_t flags;             /* XENPF_ACPI_SLEEP_*. */
 };
 DEFINE_GUEST_HANDLE_STRUCT(xenpf_enter_acpi_sleep_t);
 
Signature · 1 line
1.7.9.5
Acked-by on v5 5/5
#18 lore raw

Re: [PATCH v5 5/5] xen/acpi: notify xen when reduced hardware sleep is available

Quoted 10 lines · Ben Guthro

Make use of acpi_os_prepare_sleep extended parameter to notify xen to make use of the reduced hardware sleep functionality

The hypervisor change underlying this is commit 62d1a69 ("ACPI: support v5 (reduced HW) sleep interface") on the master branch of
git://xenbits.xen.org/xen.git.

Quoted 87 lines
---
 drivers/xen/acpi.c               |   25 ++++++++++++-------------
 include/xen/acpi.h               |    3 +--
 include/xen/interface/platform.h |    7 ++++---
 3 files changed, 17 insertions(+), 18 deletions(-)
drivers/xen/acpi.c +12 -13
index 36d2be1..371dade 100644
@@ -35,28 +35,27 @@
 #include <asm/xen/hypercall.h>
 #include <asm/xen/hypervisor.h>
 
-int xen_acpi_notify_hypervisor_state(u8 sleep_state,
-				     u32 pm1a_cnt, u32 pm1b_cnt,
+int xen_acpi_notify_hypervisor_state(u8 sleep_state, u32 val_a, u32 val_b,
 				     bool extended)
 {
+	unsigned int bits = extended ? 8 : 16;
+
 	struct xen_platform_op op = {
 		.cmd = XENPF_enter_acpi_sleep,
 		.interface_version = XENPF_INTERFACE_VERSION,
-		.u = {
-			.enter_acpi_sleep = {
-				.pm1a_cnt_val = (u16)pm1a_cnt,
-				.pm1b_cnt_val = (u16)pm1b_cnt,
-				.sleep_state = sleep_state,
-			},
+		.u.enter_acpi_sleep = {
+			.val_a = (u16)val_a,
+			.val_b = (u16)val_b,
+			.sleep_state = sleep_state,
+			.flags = extended ? XENPF_ACPI_SLEEP_EXTENDED : 0,
 		},
 	};
 
-	if ((pm1a_cnt & 0xffff0000) || (pm1b_cnt & 0xffff0000)) {
-		WARN(1, "Using more than 16bits of PM1A/B 0x%x/0x%x!"
-		     "Email [email protected]  Thank you.\n", \
-		     pm1a_cnt, pm1b_cnt);
+	if (WARN((val_a & (~0 << bits)) || (val_b & (~0 << bits)),
+		 "Using more than %u bits of sleep control values %#x/%#x!"
+		 "Email [email protected] - Thank you.\n", \
+		 bits, val_a, val_b))
 		return -1;
-	}
 
 	HYPERVISOR_dom0_op(&op);
 	return 1;
include/xen/acpi.h +1 -2
index 9f7e2e6..a2d5667 100644
@@ -75,8 +75,7 @@ static inline int xen_acpi_get_pxm(acpi_handle h)
 	return -ENXIO;
 }
 
-int xen_acpi_notify_hypervisor_state(u8 sleep_state,
-				     u32 pm1a_cnt, u32 pm1b_cnd,
+int xen_acpi_notify_hypervisor_state(u8 sleep_state, u32 val_a, u32 val_b,
 				     bool extended);
 
 static inline void xen_acpi_sleep_register(void)
include/xen/interface/platform.h +4 -3
index c57d5f6..f1331e3 100644
@@ -152,10 +152,11 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmware_info_t);
 #define XENPF_enter_acpi_sleep    51
 struct xenpf_enter_acpi_sleep {
 	/* IN variables */
-	uint16_t pm1a_cnt_val;      /* PM1a control value. */
-	uint16_t pm1b_cnt_val;      /* PM1b control value. */
+	uint16_t val_a;             /* PM1a control / sleep type A. */
+	uint16_t val_b;             /* PM1b control / sleep type B. */
 	uint32_t sleep_state;       /* Which state to enter (Sn). */
-	uint32_t flags;             /* Must be zero. */
+#define XENPF_ACPI_SLEEP_EXTENDED 0x00000001
+	uint32_t flags;             /* XENPF_ACPI_SLEEP_*. */
 };
 DEFINE_GUEST_HANDLE_STRUCT(xenpf_enter_acpi_sleep_t);
 
Signature · 1 line
1.7.9.5
Acked-by on v5 5/5
#19 lore raw

Re: [PATCH v5 5/5] xen/acpi: notify xen when reduced hardware sleep is available

In reply to Ben Guthro
Quoted 10 lines · Ben Guthro

Make use of acpi_os_prepare_sleep extended parameter to notify xen to make use of the reduced hardware sleep functionality

The hypervisor change underlying this is commit 62d1a69 ("ACPI: support v5 (reduced HW) sleep interface") on the master branch of
git://xenbits.xen.org/xen.git.

Quoted 87 lines
---
 drivers/xen/acpi.c               |   25 ++++++++++++-------------
 include/xen/acpi.h               |    3 +--
 include/xen/interface/platform.h |    7 ++++---
 3 files changed, 17 insertions(+), 18 deletions(-)
drivers/xen/acpi.c +12 -13
index 36d2be1..371dade 100644
@@ -35,28 +35,27 @@
 #include <asm/xen/hypercall.h>
 #include <asm/xen/hypervisor.h>
 
-int xen_acpi_notify_hypervisor_state(u8 sleep_state,
-				     u32 pm1a_cnt, u32 pm1b_cnt,
+int xen_acpi_notify_hypervisor_state(u8 sleep_state, u32 val_a, u32 val_b,
 				     bool extended)
 {
+	unsigned int bits = extended ? 8 : 16;
+
 	struct xen_platform_op op = {
 		.cmd = XENPF_enter_acpi_sleep,
 		.interface_version = XENPF_INTERFACE_VERSION,
-		.u = {
-			.enter_acpi_sleep = {
-				.pm1a_cnt_val = (u16)pm1a_cnt,
-				.pm1b_cnt_val = (u16)pm1b_cnt,
-				.sleep_state = sleep_state,
-			},
+		.u.enter_acpi_sleep = {
+			.val_a = (u16)val_a,
+			.val_b = (u16)val_b,
+			.sleep_state = sleep_state,
+			.flags = extended ? XENPF_ACPI_SLEEP_EXTENDED : 0,
 		},
 	};
 
-	if ((pm1a_cnt & 0xffff0000) || (pm1b_cnt & 0xffff0000)) {
-		WARN(1, "Using more than 16bits of PM1A/B 0x%x/0x%x!"
-		     "Email [email protected]  Thank you.\n", \
-		     pm1a_cnt, pm1b_cnt);
+	if (WARN((val_a & (~0 << bits)) || (val_b & (~0 << bits)),
+		 "Using more than %u bits of sleep control values %#x/%#x!"
+		 "Email [email protected] - Thank you.\n", \
+		 bits, val_a, val_b))
 		return -1;
-	}
 
 	HYPERVISOR_dom0_op(&op);
 	return 1;
include/xen/acpi.h +1 -2
index 9f7e2e6..a2d5667 100644
@@ -75,8 +75,7 @@ static inline int xen_acpi_get_pxm(acpi_handle h)
 	return -ENXIO;
 }
 
-int xen_acpi_notify_hypervisor_state(u8 sleep_state,
-				     u32 pm1a_cnt, u32 pm1b_cnd,
+int xen_acpi_notify_hypervisor_state(u8 sleep_state, u32 val_a, u32 val_b,
 				     bool extended);
 
 static inline void xen_acpi_sleep_register(void)
include/xen/interface/platform.h +4 -3
index c57d5f6..f1331e3 100644
@@ -152,10 +152,11 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmware_info_t);
 #define XENPF_enter_acpi_sleep    51
 struct xenpf_enter_acpi_sleep {
 	/* IN variables */
-	uint16_t pm1a_cnt_val;      /* PM1a control value. */
-	uint16_t pm1b_cnt_val;      /* PM1b control value. */
+	uint16_t val_a;             /* PM1a control / sleep type A. */
+	uint16_t val_b;             /* PM1b control / sleep type B. */
 	uint32_t sleep_state;       /* Which state to enter (Sn). */
-	uint32_t flags;             /* Must be zero. */
+#define XENPF_ACPI_SLEEP_EXTENDED 0x00000001
+	uint32_t flags;             /* XENPF_ACPI_SLEEP_*. */
 };
 DEFINE_GUEST_HANDLE_STRUCT(xenpf_enter_acpi_sleep_t);
 
Signature · 1 line
1.7.9.5
author
#20 lore raw

PATCH v5 5/5 xen/acpi: notify xen when reduced hardware sleep is available

In reply to Ben Guthro

Make use of acpi_os_prepare_sleep extended parameter to notify xen to make use of the reduced hardware sleep functionality

The hypervisor change underlying this is commit 62d1a69 ("ACPI: support v5 (reduced HW) sleep interface") on the master branch of
git://xenbits.xen.org/xen.git.

---
 drivers/xen/acpi.c               |   25 ++++++++++++-------------
 include/xen/acpi.h               |    3 +--
 include/xen/interface/platform.h |    7 ++++---
 3 files changed, 17 insertions(+), 18 deletions(-)
drivers/xen/acpi.c +12 -13
index 36d2be1..371dade 100644
@@ -35,28 +35,27 @@
 #include <asm/xen/hypercall.h>
 #include <asm/xen/hypervisor.h>
 
-int xen_acpi_notify_hypervisor_state(u8 sleep_state,
-				     u32 pm1a_cnt, u32 pm1b_cnt,
+int xen_acpi_notify_hypervisor_state(u8 sleep_state, u32 val_a, u32 val_b,
 				     bool extended)
 {
+	unsigned int bits = extended ? 8 : 16;
+
 	struct xen_platform_op op = {
 		.cmd = XENPF_enter_acpi_sleep,
 		.interface_version = XENPF_INTERFACE_VERSION,
-		.u = {
-			.enter_acpi_sleep = {
-				.pm1a_cnt_val = (u16)pm1a_cnt,
-				.pm1b_cnt_val = (u16)pm1b_cnt,
-				.sleep_state = sleep_state,
-			},
+		.u.enter_acpi_sleep = {
+			.val_a = (u16)val_a,
+			.val_b = (u16)val_b,
+			.sleep_state = sleep_state,
+			.flags = extended ? XENPF_ACPI_SLEEP_EXTENDED : 0,
 		},
 	};
 
-	if ((pm1a_cnt & 0xffff0000) || (pm1b_cnt & 0xffff0000)) {
-		WARN(1, "Using more than 16bits of PM1A/B 0x%x/0x%x!"
-		     "Email [email protected]  Thank you.\n", \
-		     pm1a_cnt, pm1b_cnt);
+	if (WARN((val_a & (~0 << bits)) || (val_b & (~0 << bits)),
+		 "Using more than %u bits of sleep control values %#x/%#x!"
+		 "Email [email protected] - Thank you.\n", \
+		 bits, val_a, val_b))
 		return -1;
-	}
 
 	HYPERVISOR_dom0_op(&op);
 	return 1;
include/xen/acpi.h +1 -2
index 9f7e2e6..a2d5667 100644
@@ -75,8 +75,7 @@ static inline int xen_acpi_get_pxm(acpi_handle h)
 	return -ENXIO;
 }
 
-int xen_acpi_notify_hypervisor_state(u8 sleep_state,
-				     u32 pm1a_cnt, u32 pm1b_cnd,
+int xen_acpi_notify_hypervisor_state(u8 sleep_state, u32 val_a, u32 val_b,
 				     bool extended);
 
 static inline void xen_acpi_sleep_register(void)
include/xen/interface/platform.h +4 -3
index c57d5f6..f1331e3 100644
@@ -152,10 +152,11 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmware_info_t);
 #define XENPF_enter_acpi_sleep    51
 struct xenpf_enter_acpi_sleep {
 	/* IN variables */
-	uint16_t pm1a_cnt_val;      /* PM1a control value. */
-	uint16_t pm1b_cnt_val;      /* PM1b control value. */
+	uint16_t val_a;             /* PM1a control / sleep type A. */
+	uint16_t val_b;             /* PM1b control / sleep type B. */
 	uint32_t sleep_state;       /* Which state to enter (Sn). */
-	uint32_t flags;             /* Must be zero. */
+#define XENPF_ACPI_SLEEP_EXTENDED 0x00000001
+	uint32_t flags;             /* XENPF_ACPI_SLEEP_*. */
 };
 DEFINE_GUEST_HANDLE_STRUCT(xenpf_enter_acpi_sleep_t);
 
Signature · 1 line
1.7.9.5
#21 lore raw
In reply to Ben Guthro
Quoted 34 lines · Ben Guthro

In version 3.4 acpi_os_prepare_sleep() got introduced in parallel with reduced hardware sleep support, and the two changes didn't get
synchronized: The new code doesn't call the hook function (if so requested). Fix this, requiring a boolean parameter to be added to the hook function to distinguish "extended" from "legacy" sleep.

This requires adjusting TXT, but the adjustments only go as far as failing the extended mode call (since, looking at the TXT interface, there doesn't even appear to be precautions to deal with that alternative interface).

The hypervisor change underlying this is commit 62d1a69 ("ACPI: support v5 (reduced HW) sleep interface") on the master branch of
git://xenbits.xen.org/xen.git.

Cc Richard L Maliszewski <[email protected]>
Cc Gang Wei <[email protected]>
Cc Shane Wang <[email protected]>
Cc Bob Moore <[email protected]>
Cc Rafael J. Wysocki <[email protected]>

v2: Extend description to include reference to hypervisor side change
v3: Split into multiple patches, separating subsystems
Remove bool parameters, in favor of u8
v4: Remove linux/acpi.h dependencies
Further patch split to break out acpica from OSL
More bool vs u8 fixes
v5: Fix build of consumers of acpi_os_prepare_sleep() interface change,
so intermediate builds of partial patch series will not fail.

Quoted 6 lines

Ben Guthro (5):
acpi: Remove need to include linux/acpi.h in common acpica code
acpi: Call acpi_os_prepare_sleep hook in reduced hardware sleep path
acpi: Adjust linux acpi OS functions to new extended parameter x86/tboot: Fail extended mode reduced hardware sleep xen/acpi: notify xen when reduced hardware sleep is available

I've just replied to [0/5] from the previous series, here:

http://marc.info/?l=linux-acpi&m=137493312722239&w=2

Thanks,
Rafael

#22 lore raw
In reply to Ben Guthro
Quoted 34 lines · Ben Guthro

In version 3.4 acpi_os_prepare_sleep() got introduced in parallel with reduced hardware sleep support, and the two changes didn't get
synchronized: The new code doesn't call the hook function (if so requested). Fix this, requiring a boolean parameter to be added to the hook function to distinguish "extended" from "legacy" sleep.

This requires adjusting TXT, but the adjustments only go as far as failing the extended mode call (since, looking at the TXT interface, there doesn't even appear to be precautions to deal with that alternative interface).

The hypervisor change underlying this is commit 62d1a69 ("ACPI: support v5 (reduced HW) sleep interface") on the master branch of
git://xenbits.xen.org/xen.git.

Cc Richard L Maliszewski <[email protected]>
Cc Gang Wei <[email protected]>
Cc Shane Wang <[email protected]>
Cc Bob Moore <[email protected]>
Cc Rafael J. Wysocki <[email protected]>

v2: Extend description to include reference to hypervisor side change
v3: Split into multiple patches, separating subsystems
Remove bool parameters, in favor of u8
v4: Remove linux/acpi.h dependencies
Further patch split to break out acpica from OSL
More bool vs u8 fixes
v5: Fix build of consumers of acpi_os_prepare_sleep() interface change,
so intermediate builds of partial patch series will not fail.

Quoted 6 lines

Ben Guthro (5):
acpi: Remove need to include linux/acpi.h in common acpica code
acpi: Call acpi_os_prepare_sleep hook in reduced hardware sleep path
acpi: Adjust linux acpi OS functions to new extended parameter x86/tboot: Fail extended mode reduced hardware sleep xen/acpi: notify xen when reduced hardware sleep is available

I've just replied to [0/5] from the previous series, here:

http://marc.info/?l=linux-acpi&m=137493312722239&w=2

Thanks,
Rafael