Skip to contentSkip to conversation

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

PATCH Superseded Ben Guthro 5 participants 27 messages Jun 27, 2013 – Jul 27, 2013

Subsystems (5)

v4 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
author
#1 lore raw

PATCH v4 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 Rafaell 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
#3 lore raw

PATCH v4 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
author
#4 lore raw

PATCH v4 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
author
#5 lore raw

PATCH v4 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.

---
 drivers/acpi/osl.c   |   16 ++++++++--------
 include/linux/acpi.h |    6 +++---
 2 files changed, 11 insertions(+), 11 deletions(-)
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;
 }
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)
Signature · 1 line
1.7.9.5
author
#16 lore raw

PATCH v4 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.

---
 drivers/acpi/osl.c   |   16 ++++++++--------
 include/linux/acpi.h |    6 +++---
 2 files changed, 11 insertions(+), 11 deletions(-)
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;
 }
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)
Signature · 1 line
1.7.9.5
author
#17 lore raw

PATCH v4 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 |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
arch/x86/kernel/tboot.c +5 -1
index f84fe00..57383b2 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,
@@ -284,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
#18 lore raw

PATCH v4 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 |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
arch/x86/kernel/tboot.c +5 -1
index f84fe00..57383b2 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,
@@ -284,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
#19 lore raw

PATCH v4 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               |   26 +++++++++++++-------------
 include/xen/acpi.h               |    4 ++--
 include/xen/interface/platform.h |    7 ++++---
 3 files changed, 19 insertions(+), 18 deletions(-)
drivers/xen/acpi.c +13 -13
index 119d42a..371dade 100644
@@ -35,27 +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 +2 -2
index 68d73d0..a2d5667 100644
@@ -75,8 +75,8 @@ 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 v4 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               |   26 +++++++++++++-------------
 include/xen/acpi.h               |    4 ++--
 include/xen/interface/platform.h |    7 ++++---
 3 files changed, 19 insertions(+), 18 deletions(-)
drivers/xen/acpi.c +13 -13
index 119d42a..371dade 100644
@@ -35,27 +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 +2 -2
index 68d73d0..a2d5667 100644
@@ -75,8 +75,8 @@ 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

Ben Guthro

author
#0 lore raw

v4 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 Rafaell 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

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
#2 lore raw

PATCH v4 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 Rafaell 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
#6 lore raw

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

In reply to Ben Guthro
Quoted 20 lines
Quoted 1 line
Quoted 1 line · 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.

---
 drivers/acpi/osl.c   |   16 ++++++++--------
 include/linux/acpi.h |    6 +++---
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/acpi/osl.c +0 -0
index e721863..0251c9b 100644

drivers/acpi/osl.c EXPORT_SYMBOL(acpi_in_debugger); · line 81

Quoted 7 lines
drivers/acpi/osl.c +2 -2
@@ -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);

So from here till patch 5 the build will be half broken because of the type mismatches? I think at least the types of the consumers need to be changed in this patch; leaving the meat of the Xen change to patch 4 is perhaps fine.

Jan

Quoted 62 lines
drivers/acpi/osl.c +6 -6
 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;

}

include/linux/acpi.h +2 -2
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

include/linux/acpi.h +1 -1
@@ -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)

Signature · 1 line
1.7.9.5
#7 lore raw

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

In reply to Ben Guthro
Quoted 20 lines
Quoted 1 line
Quoted 1 line · 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.

---
 drivers/acpi/osl.c   |   16 ++++++++--------
 include/linux/acpi.h |    6 +++---
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/acpi/osl.c +0 -0
index e721863..0251c9b 100644

drivers/acpi/osl.c EXPORT_SYMBOL(acpi_in_debugger); · line 81

Quoted 7 lines
drivers/acpi/osl.c +2 -2
@@ -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);

So from here till patch 5 the build will be half broken because of the type mismatches? I think at least the types of the consumers need to be changed in this patch; leaving the meat of the Xen change to patch 4 is perhaps fine.

Jan

Quoted 62 lines
drivers/acpi/osl.c +6 -6
 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;

}

include/linux/acpi.h +2 -2
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

include/linux/acpi.h +1 -1
@@ -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)

Signature · 1 line
1.7.9.5
#8 lore raw

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

I have not seen a discussion of the details on this, so can someone explain to me just why acpi_os_prepare_sleep is needed, what does it do, and why these changes are being made to ACPICA code?

Thanks,
Bob

Quoted 107 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Thursday, June 27, 2013 8:12 AM
To: Ben Guthro
Cc: Moore, Robert; [email protected]; Konrad Rzeszutek Wilk; Rafaell J . Wysocki; [email protected]; [email protected]
Subject: Re: [PATCH v4 3/5] acpi: Adjust linux acpi OS functions to new extended parameter

Quoted 20 lines
Quoted 1 line
Quoted 1 line · 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.

---
 drivers/acpi/osl.c   |   16 ++++++++--------
 include/linux/acpi.h |    6 +++---
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/acpi/osl.c index renamed from drivers/acpi/osl.c +0 -0

e721863..0251c9b 100644

drivers/acpi/osl.c EXPORT_SYMBOL(acpi_in_debugger); extern char · line 80

Quoted 6 lines
drivers/acpi/osl.c +1 -2
@@ -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,

drivers/acpi/osl.c EXPORT_SYMBOL(acpi_in_debugger); · line 81

Quoted 1 line
drivers/acpi/osl.c +1 -0
+				      bool extended);

So from here till patch 5 the build will be half broken because of the type mismatches? I think at least the types of the consumers need to be changed in this patch; leaving the meat of the Xen change to patch 4 is perhaps fine.

Jan

Quoted 60 lines
drivers/acpi/osl.c +0 -0
 static acpi_osd_handler acpi_irq_handler;  static void
 *acpi_irq_context; @@ -1757,13 +1757,13 @@ acpi_status
 acpi_os_terminate(void)
drivers/acpi/osl.c +6 -6
 	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;

}

include/linux/acpi.h index renamed from include/linux/acpi.h +0 -0

709a2f2..26f9996 100644

include/linux/acpi.h +2 -2
@@ -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)

include/linux/acpi.h +2 -1
+#define acpi_os_set_prepare_sleep(func, val_a, val_b, ext) do { }
+while (0)
 #endif
 
 #if defined(CONFIG_ACPI) && defined(CONFIG_PM_RUNTIME)
--

1.7.9.5

#9 lore raw

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

In reply to Jan Beulich

I have not seen a discussion of the details on this, so can someone explain to me just why acpi_os_prepare_sleep is needed, what does it do, and why these changes are being made to ACPICA code?

Thanks,
Bob

Quoted 107 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Thursday, June 27, 2013 8:12 AM
To: Ben Guthro
Cc: Moore, Robert; [email protected]; Konrad Rzeszutek Wilk; Rafaell J . Wysocki; [email protected]; [email protected]
Subject: Re: [PATCH v4 3/5] acpi: Adjust linux acpi OS functions to new extended parameter

Quoted 20 lines
Quoted 1 line
Quoted 1 line · 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.

---
 drivers/acpi/osl.c   |   16 ++++++++--------
 include/linux/acpi.h |    6 +++---
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/acpi/osl.c index renamed from drivers/acpi/osl.c +0 -0

e721863..0251c9b 100644

drivers/acpi/osl.c EXPORT_SYMBOL(acpi_in_debugger); extern char · line 80

Quoted 6 lines
drivers/acpi/osl.c +1 -2
@@ -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,

drivers/acpi/osl.c EXPORT_SYMBOL(acpi_in_debugger); · line 81

Quoted 1 line
drivers/acpi/osl.c +1 -0
+				      bool extended);

So from here till patch 5 the build will be half broken because of the type mismatches? I think at least the types of the consumers need to be changed in this patch; leaving the meat of the Xen change to patch 4 is perhaps fine.

Jan

Quoted 60 lines
drivers/acpi/osl.c +0 -0
 static acpi_osd_handler acpi_irq_handler;  static void
 *acpi_irq_context; @@ -1757,13 +1757,13 @@ acpi_status
 acpi_os_terminate(void)
drivers/acpi/osl.c +6 -6
 	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;

}

include/linux/acpi.h index renamed from include/linux/acpi.h +0 -0

709a2f2..26f9996 100644

include/linux/acpi.h +2 -2
@@ -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)

include/linux/acpi.h +2 -1
+#define acpi_os_set_prepare_sleep(func, val_a, val_b, ext) do { }
+while (0)
 #endif
 
 #if defined(CONFIG_ACPI) && defined(CONFIG_PM_RUNTIME)
--

1.7.9.5

author Acked-by Joseph Cihula Acked-by Rafael J. Wysocki
#10 lore raw

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

Quoted 1 line · Robert

I have not seen a discussion of the details on this, so can someone explain to me just why acpi_os_prepare_sleep is needed, what does it do, and why these changes are being made to ACPICA code?

Hi Bob,

I'm not familiar with your background here, so I apologize if I am stating obvious things below.

acpi_os_prepare_sleep() has been in the acpica code for some time now, allowing for OS specific hooks to account for differences between OS architectures.

Specifically, it has been in since:

commit 09f98a825a821f7a3f1b162f9ed023f37213a63b

Author: Tang Liang <[email protected]>
Date:   Fri Dec 9 10:05:54 2011 +0800

x86, acpi, tboot: Have a ACPI os prepare sleep instead of calling tboot_sleep.

The ACPI suspend path makes a call to tboot_sleep right before it writes the PM1A, PM1B values. We replace the direct call to tboot via an registration callback similar to __acpi_register_gsi.

CC Len Brown <[email protected]>
[v1: Added __attribute__ ((unused))]
[v2: Introduced a wrapper instead of changing tboot_sleep return values]
[v3: Added return value AE_CTRL_SKIP for acpi_os_sleep_prepare]
[v1: Fix compile issues on IA64 and PPC64]
[v2: Fix where __acpi_os_prepare_sleep==NULL and did not go in sleep properly]

In this case, the Xen hypervisor, and not linux needs to actually put the system into S3, so this hook gives the architecture to do so.

This change does not introduce this functionality, but simply moves the code around into the proper locations, such that the acpica code no longer need to include linux specific headers.

I hope this helps.
If you have specific questions, please let me know.

Regards,
Ben

Quoted 113 lines

Thanks,
Bob

Quoted 107 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Thursday, June 27, 2013 8:12 AM
To: Ben Guthro
Cc: Moore, Robert; [email protected]; Konrad Rzeszutek Wilk; Rafaell J . Wysocki; [email protected]; [email protected]
Subject: Re: [PATCH v4 3/5] acpi: Adjust linux acpi OS functions to new extended parameter

Quoted 20 lines
Quoted 1 line
Quoted 1 line · 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.

---
  drivers/acpi/osl.c   |   16 ++++++++--------
  include/linux/acpi.h |    6 +++---
  2 files changed, 11 insertions(+), 11 deletions(-)
drivers/acpi/osl.c index renamed from drivers/acpi/osl.c +0 -0

e721863..0251c9b 100644

drivers/acpi/osl.c EXPORT_SYMBOL(acpi_in_debugger); extern char · line 80

Quoted 6 lines
drivers/acpi/osl.c +1 -2
@@ -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,

drivers/acpi/osl.c EXPORT_SYMBOL(acpi_in_debugger); · line 81

Quoted 1 line
drivers/acpi/osl.c +1 -0
+				      bool extended);

So from here till patch 5 the build will be half broken because of the type mismatches? I think at least the types of the consumers need to be changed in this patch; leaving the meat of the Xen change to patch 4 is perhaps fine.

Jan

Quoted 60 lines
drivers/acpi/osl.c +0 -0
  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;
  }
drivers/acpi/osl.c +6 -6
-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;
  }
include/linux/acpi.h index renamed from include/linux/acpi.h +0 -0

709a2f2..26f9996 100644

include/linux/acpi.h +2 -2
@@ -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)

include/linux/acpi.h +2 -1
+#define acpi_os_set_prepare_sleep(func, val_a, val_b, ext) do { }
+while (0)
  #endif
 
  #if defined(CONFIG_ACPI) && defined(CONFIG_PM_RUNTIME)
--

1.7.9.5

author Acked-by Joseph Cihula Acked-by Rafael J. Wysocki
#11 lore raw

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

In reply to Moore, Robert
Quoted 1 line · Robert

I have not seen a discussion of the details on this, so can someone explain to me just why acpi_os_prepare_sleep is needed, what does it do, and why these changes are being made to ACPICA code?

Hi Bob,

I'm not familiar with your background here, so I apologize if I am stating obvious things below.

acpi_os_prepare_sleep() has been in the acpica code for some time now, allowing for OS specific hooks to account for differences between OS architectures.

Specifically, it has been in since:

commit 09f98a825a821f7a3f1b162f9ed023f37213a63b

Author: Tang Liang <[email protected]>
Date:   Fri Dec 9 10:05:54 2011 +0800

x86, acpi, tboot: Have a ACPI os prepare sleep instead of calling tboot_sleep.

The ACPI suspend path makes a call to tboot_sleep right before it writes the PM1A, PM1B values. We replace the direct call to tboot via an registration callback similar to __acpi_register_gsi.

CC Len Brown <[email protected]>
[v1: Added __attribute__ ((unused))]
[v2: Introduced a wrapper instead of changing tboot_sleep return values]
[v3: Added return value AE_CTRL_SKIP for acpi_os_sleep_prepare]
[v1: Fix compile issues on IA64 and PPC64]
[v2: Fix where __acpi_os_prepare_sleep==NULL and did not go in sleep properly]

In this case, the Xen hypervisor, and not linux needs to actually put the system into S3, so this hook gives the architecture to do so.

This change does not introduce this functionality, but simply moves the code around into the proper locations, such that the acpica code no longer need to include linux specific headers.

I hope this helps.
If you have specific questions, please let me know.

Regards,
Ben

Quoted 113 lines

Thanks,
Bob

Quoted 107 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Thursday, June 27, 2013 8:12 AM
To: Ben Guthro
Cc: Moore, Robert; [email protected]; Konrad Rzeszutek Wilk; Rafaell J . Wysocki; [email protected]; [email protected]
Subject: Re: [PATCH v4 3/5] acpi: Adjust linux acpi OS functions to new extended parameter

Quoted 20 lines
Quoted 1 line
Quoted 1 line · 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.

---
  drivers/acpi/osl.c   |   16 ++++++++--------
  include/linux/acpi.h |    6 +++---
  2 files changed, 11 insertions(+), 11 deletions(-)
drivers/acpi/osl.c index renamed from drivers/acpi/osl.c +0 -0

e721863..0251c9b 100644

drivers/acpi/osl.c EXPORT_SYMBOL(acpi_in_debugger); extern char · line 80

Quoted 6 lines
drivers/acpi/osl.c +1 -2
@@ -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,

drivers/acpi/osl.c EXPORT_SYMBOL(acpi_in_debugger); · line 81

Quoted 1 line
drivers/acpi/osl.c +1 -0
+				      bool extended);

So from here till patch 5 the build will be half broken because of the type mismatches? I think at least the types of the consumers need to be changed in this patch; leaving the meat of the Xen change to patch 4 is perhaps fine.

Jan

Quoted 60 lines
drivers/acpi/osl.c +0 -0
  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;
  }
drivers/acpi/osl.c +6 -6
-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;
  }
include/linux/acpi.h index renamed from include/linux/acpi.h +0 -0

709a2f2..26f9996 100644

include/linux/acpi.h +2 -2
@@ -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)

include/linux/acpi.h +2 -1
+#define acpi_os_set_prepare_sleep(func, val_a, val_b, ext) do { }
+while (0)
  #endif
 
  #if defined(CONFIG_ACPI) && defined(CONFIG_PM_RUNTIME)
--

1.7.9.5

#12 lore raw

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

I'm the ACPICA owner.

The issue I have is that acpi_os_prepare_sleep causes a divergence between the raw ACPICA source code and the "linux" version of the ACPICA code.

If it is possible to implement the functionality that is needed without changes to ACPICA, then that would be best. If not, we are willing to integrate this interface into ACPICA. However, this has an impact on all operating systems that use ACPICA, so this is always the last resort.

Bob

Quoted 183 lines

-----Original Message-----
From: Ben Guthro [mailto:[email protected]]
Sent: Thursday, June 27, 2013 9:13 AM
To: Moore, Robert
Cc: Jan Beulich; Zheng, Lv; Box, David E; Brown, Len; xen- [email protected]; Konrad Rzeszutek Wilk; Rafaell J . Wysocki; linux- [email protected]; [email protected]
Subject: Re: [PATCH v4 3/5] acpi: Adjust linux acpi OS functions to new extended parameter

Quoted 1 line · Robert

I have not seen a discussion of the details on this, so can someone

explain to me just why acpi_os_prepare_sleep is needed, what does it do, and why these changes are being made to ACPICA code?

Hi Bob,

I'm not familiar with your background here, so I apologize if I am stating obvious things below.

acpi_os_prepare_sleep() has been in the acpica code for some time now, allowing for OS specific hooks to account for differences between OS architectures.

Specifically, it has been in since:

commit 09f98a825a821f7a3f1b162f9ed023f37213a63b

Author: Tang Liang <[email protected]>
Date:   Fri Dec 9 10:05:54 2011 +0800

x86, acpi, tboot: Have a ACPI os prepare sleep instead of calling
tboot_sleep.

The ACPI suspend path makes a call to tboot_sleep right before it writes the PM1A, PM1B values. We replace the direct call to tboot via an registration callback similar to __acpi_register_gsi.

CC Len Brown <[email protected]>
[v1: Added __attribute__ ((unused))]

[v2: Introduced a wrapper instead of changing tboot_sleep return
values]

[v3: Added return value AE_CTRL_SKIP for acpi_os_sleep_prepare]
[v1: Fix compile issues on IA64 and PPC64]

[v2: Fix where __acpi_os_prepare_sleep==NULL and did not go in sleep
properly]

In this case, the Xen hypervisor, and not linux needs to actually put the system into S3, so this hook gives the architecture to do so.

This change does not introduce this functionality, but simply moves the code around into the proper locations, such that the acpica code no longer need to include linux specific headers.

I hope this helps.
If you have specific questions, please let me know.

Regards,
Ben

Quoted 59 lines

Thanks,
Bob

Quoted 54 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Thursday, June 27, 2013 8:12 AM
To: Ben Guthro
Cc: Moore, Robert; [email protected]; Konrad Rzeszutek Wilk; Rafaell J . Wysocki; [email protected]; [email protected]
Subject: Re: [PATCH v4 3/5] acpi: Adjust linux acpi OS functions to new extended parameter

Quoted 20 lines
Quoted 1 line
Quoted 1 line · 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.

---
  drivers/acpi/osl.c   |   16 ++++++++--------
  include/linux/acpi.h |    6 +++---
  2 files changed, 11 insertions(+), 11 deletions(-)
drivers/acpi/osl.c index renamed from drivers/acpi/osl.c +0 -0

e721863..0251c9b 100644

drivers/acpi/osl.c EXPORT_SYMBOL(acpi_in_debugger); extern char · line 81

Quoted 7 lines
drivers/acpi/osl.c +2 -2
@@ -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,

drivers/acpi/osl.c EXPORT_SYMBOL(acpi_in_debugger); · line 81

Quoted 1 line
drivers/acpi/osl.c +1 -0
+				      bool extended);

So from here till patch 5 the build will be half broken because of the type mismatches? I think at least the types of the consumers need to be changed in this patch; leaving the meat of the Xen change to patch 4 is perhaps fine.

Jan

Quoted 7 lines
drivers/acpi/osl.c +0 -0
  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;
}

Quoted 3 lines
Quoted 3 lines

drivers/acpi/osl.c acpi_status acpi_os_terminate(void)

Quoted 3 lines
drivers/acpi/osl.c +1 -2
-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,

Quoted 53 lines
Quoted 52 lines
Quoted 50 lines
drivers/acpi/osl.c +5 -4
+				  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;
  }
include/linux/acpi.h index renamed from include/linux/acpi.h +0 -0

709a2f2..26f9996 100644

include/linux/acpi.h +2 -2
@@ -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)

include/linux/acpi.h +2 -1
+#define acpi_os_set_prepare_sleep(func, val_a, val_b, ext) do { }
+while (0)
  #endif
 
  #if defined(CONFIG_ACPI) && defined(CONFIG_PM_RUNTIME)
--

1.7.9.5

#15 lore raw

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

In reply to Ben Guthro

I'm the ACPICA owner.

The issue I have is that acpi_os_prepare_sleep causes a divergence between the raw ACPICA source code and the "linux" version of the ACPICA code.

If it is possible to implement the functionality that is needed without changes to ACPICA, then that would be best. If not, we are willing to integrate this interface into ACPICA. However, this has an impact on all operating systems that use ACPICA, so this is always the last resort.

Bob

Quoted 183 lines

-----Original Message-----
From: Ben Guthro [mailto:[email protected]]
Sent: Thursday, June 27, 2013 9:13 AM
To: Moore, Robert
Cc: Jan Beulich; Zheng, Lv; Box, David E; Brown, Len; xen- [email protected]; Konrad Rzeszutek Wilk; Rafaell J . Wysocki; linux- [email protected]; [email protected]
Subject: Re: [PATCH v4 3/5] acpi: Adjust linux acpi OS functions to new extended parameter

Quoted 1 line · Robert

I have not seen a discussion of the details on this, so can someone

explain to me just why acpi_os_prepare_sleep is needed, what does it do, and why these changes are being made to ACPICA code?

Hi Bob,

I'm not familiar with your background here, so I apologize if I am stating obvious things below.

acpi_os_prepare_sleep() has been in the acpica code for some time now, allowing for OS specific hooks to account for differences between OS architectures.

Specifically, it has been in since:

commit 09f98a825a821f7a3f1b162f9ed023f37213a63b

Author: Tang Liang <[email protected]>
Date:   Fri Dec 9 10:05:54 2011 +0800

x86, acpi, tboot: Have a ACPI os prepare sleep instead of calling
tboot_sleep.

The ACPI suspend path makes a call to tboot_sleep right before it writes the PM1A, PM1B values. We replace the direct call to tboot via an registration callback similar to __acpi_register_gsi.

CC Len Brown <[email protected]>
[v1: Added __attribute__ ((unused))]

[v2: Introduced a wrapper instead of changing tboot_sleep return
values]

[v3: Added return value AE_CTRL_SKIP for acpi_os_sleep_prepare]
[v1: Fix compile issues on IA64 and PPC64]

[v2: Fix where __acpi_os_prepare_sleep==NULL and did not go in sleep
properly]

In this case, the Xen hypervisor, and not linux needs to actually put the system into S3, so this hook gives the architecture to do so.

This change does not introduce this functionality, but simply moves the code around into the proper locations, such that the acpica code no longer need to include linux specific headers.

I hope this helps.
If you have specific questions, please let me know.

Regards,
Ben

Quoted 59 lines

Thanks,
Bob

Quoted 54 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Thursday, June 27, 2013 8:12 AM
To: Ben Guthro
Cc: Moore, Robert; [email protected]; Konrad Rzeszutek Wilk; Rafaell J . Wysocki; [email protected]; [email protected]
Subject: Re: [PATCH v4 3/5] acpi: Adjust linux acpi OS functions to new extended parameter

Quoted 20 lines
Quoted 1 line
Quoted 1 line · 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.

---
  drivers/acpi/osl.c   |   16 ++++++++--------
  include/linux/acpi.h |    6 +++---
  2 files changed, 11 insertions(+), 11 deletions(-)
drivers/acpi/osl.c index renamed from drivers/acpi/osl.c +0 -0

e721863..0251c9b 100644

drivers/acpi/osl.c EXPORT_SYMBOL(acpi_in_debugger); extern char · line 81

Quoted 7 lines
drivers/acpi/osl.c +2 -2
@@ -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,

drivers/acpi/osl.c EXPORT_SYMBOL(acpi_in_debugger); · line 81

Quoted 1 line
drivers/acpi/osl.c +1 -0
+				      bool extended);

So from here till patch 5 the build will be half broken because of the type mismatches? I think at least the types of the consumers need to be changed in this patch; leaving the meat of the Xen change to patch 4 is perhaps fine.

Jan

Quoted 7 lines
drivers/acpi/osl.c +0 -0
  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;
}

Quoted 3 lines
Quoted 3 lines

drivers/acpi/osl.c acpi_status acpi_os_terminate(void)

Quoted 3 lines
drivers/acpi/osl.c +1 -2
-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,

Quoted 53 lines
Quoted 52 lines
Quoted 50 lines
drivers/acpi/osl.c +5 -4
+				  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;
  }
include/linux/acpi.h index renamed from include/linux/acpi.h +0 -0

709a2f2..26f9996 100644

include/linux/acpi.h +2 -2
@@ -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)

include/linux/acpi.h +2 -1
+#define acpi_os_set_prepare_sleep(func, val_a, val_b, ext) do { }
+while (0)
  #endif
 
  #if defined(CONFIG_ACPI) && defined(CONFIG_PM_RUNTIME)
--

1.7.9.5

author
#13 lore raw

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

In reply to Moore, Robert
Quoted 2 lines · Robert

I'm the ACPICA owner.

Apologies, I should have looked that up when Rafael asked for you to be CC'ed

Quoted 2 lines

The issue I have is that acpi_os_prepare_sleep causes a divergence between the raw ACPICA source code and the "linux" version of the ACPICA code.

Understood. The v2 version of this patchset was discussed with Jan Beulich here:

http://www.gossamer-threads.com/lists/xen/devel/274507

In this thread, Rafael suggests that these changes be made, and submitted through linux-acpi, with he, and you CC'ed.

This is more of a cleanup effort to existing functionality, that did not get coordinated. That is, as the comment indicates, in linux 3.4, reduced hardware sleep was introduced as part of ACPIv5. In parallel, acpi_os_prepare_sleep() was also introduced, to allow for subsystems such as Xen, and tboot to take advantage of the vast majority of ACPICA, but hook some low level capabilities via function pointer, to do the specific things for those subsystems.

Rafael rightly pointed out that inclusion of linux/acpi.h in ACPICA code is wrong, and we should make efforts to avoid doing so. This patch is to clean this up, and also to extend the functionality to also go down the same path for the reduced hardware sleep path, passing that "extended" flag down to that subsystem, so that it might make use of it at the very low levels.

All efforts are being made to reduce the amount of churn in ACPICA, since it is an upstream project to linux.

Quoted 2 lines

If it is possible to implement the functionality that is needed without changes to ACPICA, then that would be best. If not, we are willing to integrate this interface into ACPICA. However, this has an impact on all operating systems that use ACPICA, so this is always the last resort.

I am unaware of a way to take advantage of the infrastructure that ACPICA provides, and also do that which is necessary to make it work in Xen / tboot without these hooks.

It would be greatly appreciated if you would consider this new interface for inclusion.

Thanks for your time.

Ben

Quoted 186 lines

Bob

Quoted 183 lines

-----Original Message-----
From: Ben Guthro [mailto:[email protected]]
Sent: Thursday, June 27, 2013 9:13 AM
To: Moore, Robert
Cc: Jan Beulich; Zheng, Lv; Box, David E; Brown, Len; xen- [email protected]; Konrad Rzeszutek Wilk; Rafaell J . Wysocki; linux- [email protected]; [email protected]
Subject: Re: [PATCH v4 3/5] acpi: Adjust linux acpi OS functions to new extended parameter

Quoted 1 line · Robert

I have not seen a discussion of the details on this, so can someone

explain to me just why acpi_os_prepare_sleep is needed, what does it do, and why these changes are being made to ACPICA code?

Hi Bob,

I'm not familiar with your background here, so I apologize if I am stating obvious things below.

acpi_os_prepare_sleep() has been in the acpica code for some time now, allowing for OS specific hooks to account for differences between OS architectures.

Specifically, it has been in since:

commit 09f98a825a821f7a3f1b162f9ed023f37213a63b

Author: Tang Liang <[email protected]>
Date:   Fri Dec 9 10:05:54 2011 +0800

x86, acpi, tboot: Have a ACPI os prepare sleep instead of calling
tboot_sleep.

The ACPI suspend path makes a call to tboot_sleep right before it writes the PM1A, PM1B values. We replace the direct call to tboot via an registration callback similar to __acpi_register_gsi.

CC Len Brown <[email protected]>
[v1: Added __attribute__ ((unused))]

[v2: Introduced a wrapper instead of changing tboot_sleep return
values]

[v3: Added return value AE_CTRL_SKIP for acpi_os_sleep_prepare]
[v1: Fix compile issues on IA64 and PPC64]

[v2: Fix where __acpi_os_prepare_sleep==NULL and did not go in sleep
properly]

In this case, the Xen hypervisor, and not linux needs to actually put the system into S3, so this hook gives the architecture to do so.

This change does not introduce this functionality, but simply moves the code around into the proper locations, such that the acpica code no longer need to include linux specific headers.

I hope this helps.
If you have specific questions, please let me know.

Regards,
Ben

Quoted 59 lines

Thanks,
Bob

Quoted 54 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Thursday, June 27, 2013 8:12 AM
To: Ben Guthro
Cc: Moore, Robert; [email protected]; Konrad Rzeszutek Wilk; Rafaell J . Wysocki; [email protected]; [email protected]
Subject: Re: [PATCH v4 3/5] acpi: Adjust linux acpi OS functions to new extended parameter

Quoted 20 lines
Quoted 1 line
Quoted 1 line · 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.

---
   drivers/acpi/osl.c   |   16 ++++++++--------
   include/linux/acpi.h |    6 +++---
   2 files changed, 11 insertions(+), 11 deletions(-)
drivers/acpi/osl.c index renamed from drivers/acpi/osl.c +0 -0

e721863..0251c9b 100644

drivers/acpi/osl.c EXPORT_SYMBOL(acpi_in_debugger); extern char · line 81

Quoted 7 lines
drivers/acpi/osl.c +2 -2
@@ -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,

drivers/acpi/osl.c EXPORT_SYMBOL(acpi_in_debugger); · line 81

Quoted 1 line
drivers/acpi/osl.c +1 -0
+				      bool extended);

So from here till patch 5 the build will be half broken because of the type mismatches? I think at least the types of the consumers need to be changed in this patch; leaving the meat of the Xen change to patch 4 is perhaps fine.

Jan

Quoted 7 lines
drivers/acpi/osl.c +0 -0
   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;
   }
Quoted 3 lines
Quoted 3 lines

drivers/acpi/osl.c acpi_status acpi_os_terminate(void)

Quoted 3 lines
drivers/acpi/osl.c +1 -2
-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,

Quoted 53 lines
Quoted 52 lines
Quoted 50 lines
drivers/acpi/osl.c +5 -4
+				  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;
   }
include/linux/acpi.h index renamed from include/linux/acpi.h +0 -0

709a2f2..26f9996 100644

include/linux/acpi.h +2 -2
@@ -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)

include/linux/acpi.h +2 -1
+#define acpi_os_set_prepare_sleep(func, val_a, val_b, ext) do { }
+while (0)
   #endif
 
   #if defined(CONFIG_ACPI) && defined(CONFIG_PM_RUNTIME)
--

1.7.9.5

author
#14 lore raw

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

In reply to Moore, Robert
Quoted 2 lines · Robert

I'm the ACPICA owner.

Apologies, I should have looked that up when Rafael asked for you to be CC'ed

Quoted 2 lines

The issue I have is that acpi_os_prepare_sleep causes a divergence between the raw ACPICA source code and the "linux" version of the ACPICA code.

Understood. The v2 version of this patchset was discussed with Jan Beulich here:

http://www.gossamer-threads.com/lists/xen/devel/274507

In this thread, Rafael suggests that these changes be made, and submitted through linux-acpi, with he, and you CC'ed.

This is more of a cleanup effort to existing functionality, that did not get coordinated. That is, as the comment indicates, in linux 3.4, reduced hardware sleep was introduced as part of ACPIv5. In parallel, acpi_os_prepare_sleep() was also introduced, to allow for subsystems such as Xen, and tboot to take advantage of the vast majority of ACPICA, but hook some low level capabilities via function pointer, to do the specific things for those subsystems.

Rafael rightly pointed out that inclusion of linux/acpi.h in ACPICA code is wrong, and we should make efforts to avoid doing so. This patch is to clean this up, and also to extend the functionality to also go down the same path for the reduced hardware sleep path, passing that "extended" flag down to that subsystem, so that it might make use of it at the very low levels.

All efforts are being made to reduce the amount of churn in ACPICA, since it is an upstream project to linux.

Quoted 2 lines

If it is possible to implement the functionality that is needed without changes to ACPICA, then that would be best. If not, we are willing to integrate this interface into ACPICA. However, this has an impact on all operating systems that use ACPICA, so this is always the last resort.

I am unaware of a way to take advantage of the infrastructure that ACPICA provides, and also do that which is necessary to make it work in Xen / tboot without these hooks.

It would be greatly appreciated if you would consider this new interface for inclusion.

Thanks for your time.

Ben

Quoted 186 lines

Bob

Quoted 183 lines

-----Original Message-----
From: Ben Guthro [mailto:[email protected]]
Sent: Thursday, June 27, 2013 9:13 AM
To: Moore, Robert
Cc: Jan Beulich; Zheng, Lv; Box, David E; Brown, Len; xen- [email protected]; Konrad Rzeszutek Wilk; Rafaell J . Wysocki; linux- [email protected]; [email protected]
Subject: Re: [PATCH v4 3/5] acpi: Adjust linux acpi OS functions to new extended parameter

Quoted 1 line · Robert

I have not seen a discussion of the details on this, so can someone

explain to me just why acpi_os_prepare_sleep is needed, what does it do, and why these changes are being made to ACPICA code?

Hi Bob,

I'm not familiar with your background here, so I apologize if I am stating obvious things below.

acpi_os_prepare_sleep() has been in the acpica code for some time now, allowing for OS specific hooks to account for differences between OS architectures.

Specifically, it has been in since:

commit 09f98a825a821f7a3f1b162f9ed023f37213a63b

Author: Tang Liang <[email protected]>
Date:   Fri Dec 9 10:05:54 2011 +0800

x86, acpi, tboot: Have a ACPI os prepare sleep instead of calling
tboot_sleep.

The ACPI suspend path makes a call to tboot_sleep right before it writes the PM1A, PM1B values. We replace the direct call to tboot via an registration callback similar to __acpi_register_gsi.

CC Len Brown <[email protected]>
[v1: Added __attribute__ ((unused))]

[v2: Introduced a wrapper instead of changing tboot_sleep return
values]

[v3: Added return value AE_CTRL_SKIP for acpi_os_sleep_prepare]
[v1: Fix compile issues on IA64 and PPC64]

[v2: Fix where __acpi_os_prepare_sleep==NULL and did not go in sleep
properly]

In this case, the Xen hypervisor, and not linux needs to actually put the system into S3, so this hook gives the architecture to do so.

This change does not introduce this functionality, but simply moves the code around into the proper locations, such that the acpica code no longer need to include linux specific headers.

I hope this helps.
If you have specific questions, please let me know.

Regards,
Ben

Quoted 59 lines

Thanks,
Bob

Quoted 54 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Thursday, June 27, 2013 8:12 AM
To: Ben Guthro
Cc: Moore, Robert; [email protected]; Konrad Rzeszutek Wilk; Rafaell J . Wysocki; [email protected]; [email protected]
Subject: Re: [PATCH v4 3/5] acpi: Adjust linux acpi OS functions to new extended parameter

Quoted 20 lines
Quoted 1 line
Quoted 1 line · 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.

---
   drivers/acpi/osl.c   |   16 ++++++++--------
   include/linux/acpi.h |    6 +++---
   2 files changed, 11 insertions(+), 11 deletions(-)
drivers/acpi/osl.c index renamed from drivers/acpi/osl.c +0 -0

e721863..0251c9b 100644

drivers/acpi/osl.c EXPORT_SYMBOL(acpi_in_debugger); extern char · line 81

Quoted 7 lines
drivers/acpi/osl.c +2 -2
@@ -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,

drivers/acpi/osl.c EXPORT_SYMBOL(acpi_in_debugger); · line 81

Quoted 1 line
drivers/acpi/osl.c +1 -0
+				      bool extended);

So from here till patch 5 the build will be half broken because of the type mismatches? I think at least the types of the consumers need to be changed in this patch; leaving the meat of the Xen change to patch 4 is perhaps fine.

Jan

Quoted 7 lines
drivers/acpi/osl.c +0 -0
   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;
   }
Quoted 3 lines
Quoted 3 lines

drivers/acpi/osl.c acpi_status acpi_os_terminate(void)

Quoted 3 lines
drivers/acpi/osl.c +1 -2
-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,

Quoted 53 lines
Quoted 52 lines
Quoted 50 lines
drivers/acpi/osl.c +5 -4
+				  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;
   }
include/linux/acpi.h index renamed from include/linux/acpi.h +0 -0

709a2f2..26f9996 100644

include/linux/acpi.h +2 -2
@@ -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)

include/linux/acpi.h +2 -1
+#define acpi_os_set_prepare_sleep(func, val_a, val_b, ext) do { }
+while (0)
   #endif
 
   #if defined(CONFIG_ACPI) && defined(CONFIG_PM_RUNTIME)
--

1.7.9.5

#21 lore raw
In reply to Ben Guthro
Quoted 32 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 Rafaell 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

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

The ongoing discussion means to me that the ACPICA maintainers don't want acpi_os_prepare_sleep() and quite frankly I understand them, because ACPICA is about implementing the spec and not about things beyond it.

This means that patch [1/5] goes away.

That said, at the same time we need to address the problem at hand, which is to make Xen work with the reduced HW sleep.

For that, I don't honestly think that modifying acpi_os_prepare_sleep() the way the patchset is doing it is appropriate and the change of the meaning of the arguments is simply disgusting.

To me, it would be much cleaner to add acpi_os_prepare_extended_sleep() specifically to be called by acpi_hw_extended_sleep() and make tboot and Xen use that.

This way or another, we'll need to live with one more divergence between the upstream ACPICA and the Linux ACPICA code because of that, but that'd be just a few added lines in acpi_hw_extended_sleep(), so I suppose it wouldn't be such a big deal.

Thanks,
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#26 lore raw
In reply to Ben Guthro
Quoted 32 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 Rafaell 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

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

The ongoing discussion means to me that the ACPICA maintainers don't want acpi_os_prepare_sleep() and quite frankly I understand them, because ACPICA is about implementing the spec and not about things beyond it.

This means that patch [1/5] goes away.

That said, at the same time we need to address the problem at hand, which is to make Xen work with the reduced HW sleep.

For that, I don't honestly think that modifying acpi_os_prepare_sleep() the way the patchset is doing it is appropriate and the change of the meaning of the arguments is simply disgusting.

To me, it would be much cleaner to add acpi_os_prepare_extended_sleep() specifically to be called by acpi_hw_extended_sleep() and make tboot and Xen use that.

This way or another, we'll need to live with one more divergence between the upstream ACPICA and the Linux ACPICA code because of that, but that'd be just a few added lines in acpi_hw_extended_sleep(), so I suppose it wouldn't be such a big deal.

Thanks,
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#22 lore raw
In reply to Rafael J. Wysocki
Quoted 53 lines · Rafael J. Wysocki
Quoted 32 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 Rafaell 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

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

The ongoing discussion means to me that the ACPICA maintainers don't want acpi_os_prepare_sleep() and quite frankly I understand them, because ACPICA is about implementing the spec and not about things beyond it.

This means that patch [1/5] goes away.

That said, at the same time we need to address the problem at hand, which is to make Xen work with the reduced HW sleep.

For that, I don't honestly think that modifying acpi_os_prepare_sleep() the way the patchset is doing it is appropriate and the change of the meaning of the arguments is simply disgusting.

Quoted 9 lines

To me, it would be much cleaner to add acpi_os_prepare_extended_sleep() specifically to be called by acpi_hw_extended_sleep() and make tboot and Xen use that.

This way or another, we'll need to live with one more divergence between the upstream ACPICA and the Linux ACPICA code because of that, but that'd be just a few added lines in acpi_hw_extended_sleep(), so I suppose it wouldn't be such a big deal.

Ok, thank you for the review, and being open to addressing the problem at hand, without a full architecture rework (not to say that that discussion is not also needed)

I will try to make some time next week to rework the patch set to address these concerns, and submit a new series.

Thanks
Ben

Quoted 7 lines

Thanks,
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#23 lore raw
In reply to Rafael J. Wysocki
Quoted 53 lines · Rafael J. Wysocki
Quoted 32 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 Rafaell 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

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

The ongoing discussion means to me that the ACPICA maintainers don't want acpi_os_prepare_sleep() and quite frankly I understand them, because ACPICA is about implementing the spec and not about things beyond it.

This means that patch [1/5] goes away.

That said, at the same time we need to address the problem at hand, which is to make Xen work with the reduced HW sleep.

For that, I don't honestly think that modifying acpi_os_prepare_sleep() the way the patchset is doing it is appropriate and the change of the meaning of the arguments is simply disgusting.

Quoted 9 lines

To me, it would be much cleaner to add acpi_os_prepare_extended_sleep() specifically to be called by acpi_hw_extended_sleep() and make tboot and Xen use that.

This way or another, we'll need to live with one more divergence between the upstream ACPICA and the Linux ACPICA code because of that, but that'd be just a few added lines in acpi_hw_extended_sleep(), so I suppose it wouldn't be such a big deal.

Ok, thank you for the review, and being open to addressing the problem at hand, without a full architecture rework (not to say that that discussion is not also needed)

I will try to make some time next week to rework the patch set to address these concerns, and submit a new series.

Thanks
Ben

Quoted 7 lines

Thanks,
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#24 lore raw
Quoted 60 lines · Ben Guthro
Quoted 57 lines · Rafael J. Wysocki
Quoted 32 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 Rafaell 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

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

The ongoing discussion means to me that the ACPICA maintainers don't want acpi_os_prepare_sleep() and quite frankly I understand them, because ACPICA is about implementing the spec and not about things beyond it.

This means that patch [1/5] goes away.

That said, at the same time we need to address the problem at hand, which is to make Xen work with the reduced HW sleep.

For that, I don't honestly think that modifying acpi_os_prepare_sleep() the way the patchset is doing it is appropriate and the change of the meaning of the arguments is simply disgusting.

To me, it would be much cleaner to add acpi_os_prepare_extended_sleep() specifically to be called by acpi_hw_extended_sleep() and make tboot and Xen use that.

Quoted 8 lines
Quoted 5 lines

This way or another, we'll need to live with one more divergence between the upstream ACPICA and the Linux ACPICA code because of that, but that'd be just a few added lines in acpi_hw_extended_sleep(), so I suppose it wouldn't be such a big deal.

Ok, thank you for the review, and being open to addressing the problem at hand,

No problem, although I'm not exactly happy with it.

Quoted 2 lines

without a full architecture rework (not to say that that discussion is not also needed)

Sure, it is needed.

Quoted 2 lines

I will try to make some time next week to rework the patch set to address these concerns, and submit a new series.

Thanks!

Rafael

#25 lore raw
In reply to Ben Guthro
Quoted 60 lines · Ben Guthro
Quoted 57 lines · Rafael J. Wysocki
Quoted 32 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 Rafaell 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

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

The ongoing discussion means to me that the ACPICA maintainers don't want acpi_os_prepare_sleep() and quite frankly I understand them, because ACPICA is about implementing the spec and not about things beyond it.

This means that patch [1/5] goes away.

That said, at the same time we need to address the problem at hand, which is to make Xen work with the reduced HW sleep.

For that, I don't honestly think that modifying acpi_os_prepare_sleep() the way the patchset is doing it is appropriate and the change of the meaning of the arguments is simply disgusting.

To me, it would be much cleaner to add acpi_os_prepare_extended_sleep() specifically to be called by acpi_hw_extended_sleep() and make tboot and Xen use that.

Quoted 8 lines
Quoted 5 lines

This way or another, we'll need to live with one more divergence between the upstream ACPICA and the Linux ACPICA code because of that, but that'd be just a few added lines in acpi_hw_extended_sleep(), so I suppose it wouldn't be such a big deal.

Ok, thank you for the review, and being open to addressing the problem at hand,

No problem, although I'm not exactly happy with it.

Quoted 2 lines

without a full architecture rework (not to say that that discussion is not also needed)

Sure, it is needed.

Quoted 2 lines

I will try to make some time next week to rework the patch set to address these concerns, and submit a new series.

Thanks!

Rafael