Skip to contentSkip to conversation

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

PATCH In review Ben Guthro 2 participants 17 messages Jul 30, 2013

Subsystems (5)
lore
Share & tools
lore

Ben Guthro

author
#0 lore raw

v8 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 new callback to be added to acpica to be called back during this reduced hardware 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 xen hypervisor change underlying this is commit 62d1a69 ("ACPI: support v5 (reduced HW) sleep interface") on the master branch of
git://xenbits.xen.org/xen.git.

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

v2: Extend description to include reference to hypervisor side change
v3: Split into multiple patches, separating subsystems
Remove bool parameters, in favor of u8
v4: Remove linux/acpi.h dependencies
Further patch split to break out acpica from OSL
More bool vs u8 fixes
v5: Fix build of consumers of acpi_os_prepare_sleep() interface change,
so intermediate builds of partial patch series will not fail.
v6: Rebased to linux-pm linux-next branch
Added warning in tboot early return code
Added Reviewed-by lines
v7: Add separate acpi_os_prepare_extended_sleep() interface
Remove OSL acpica changes introduced in v4
v8: Return meaningful error code in tboot error path

Ben Guthro (3):
x86/acpi: Introduce acpi_os_prepare_extended_sleep callback for
extended sleep path
x86/tboot: Fail extended mode reduced hardware sleep xen/acpi: notify xen when reduced hardware sleep is available

 arch/x86/kernel/tboot.c          |   12 +++++++++++
 drivers/acpi/acpica/hwesleep.c   |    9 +++++++++
 drivers/acpi/osl.c               |   24 ++++++++++++++++++++++
 drivers/xen/acpi.c               |   41 ++++++++++++++++++++++++++------------
 include/linux/acpi.h             |    7 +++++++
 include/xen/acpi.h               |    8 ++++++--
 include/xen/interface/platform.h |    7 ++++---
 7 files changed, 90 insertions(+), 18 deletions(-)
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v8 1/3 x86/acpi: Introduce acpi_os_prepare_extended_sleep callback for extended sleep path

Like acpi_os_prepare_sleep, register a callback for use in systems like tboot, and xen, which have system specific requirements outside of acpica. This mirrors the functionality in acpi_os_prepare_sleep(), called from acpi_hw_sleep()

---
 drivers/acpi/acpica/hwesleep.c |    9 +++++++++
 drivers/acpi/osl.c             |   24 ++++++++++++++++++++++++
 include/linux/acpi.h           |    7 +++++++
 3 files changed, 40 insertions(+)
drivers/acpi/acpica/hwesleep.c +9 -0
index 5e5f762..4140768 100644
@@ -43,6 +43,7 @@
  */
 
 #include <acpi/acpi.h>
+#include <linux/acpi.h>
 #include "accommon.h"
 
 #define _COMPONENT          ACPI_HARDWARE
@@ -128,6 +129,14 @@ acpi_status acpi_hw_extended_sleep(u8 sleep_state)
 
 	ACPI_FLUSH_CPU_CACHE();
 
+	status = acpi_os_prepare_extended_sleep(sleep_state,
+						acpi_gbl_sleep_type_a,
+						acpi_gbl_sleep_type_b);
+	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/osl.c +24 -0
index 6ab2c35..a934950 100644
@@ -79,6 +79,8 @@ extern char line_buf[80];
 
 static int (*__acpi_os_prepare_sleep)(u8 sleep_state, u32 pm1a_ctrl,
 				      u32 pm1b_ctrl);
+static int (*__acpi_os_prepare_extended_sleep)(u8 sleep_state, u32 val_a,
+				      u32 val_b);
 
 static acpi_osd_handler acpi_irq_handler;
 static void *acpi_irq_context;
@@ -1779,6 +1781,28 @@ void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
 	__acpi_os_prepare_sleep = func;
 }
 
+acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state, u32 val_a,
+				  u32 val_b)
+{
+	int rc = 0;
+	if (__acpi_os_prepare_extended_sleep)
+		rc = __acpi_os_prepare_extended_sleep(sleep_state,
+					     val_a, val_b);
+	if (rc < 0)
+		return AE_ERROR;
+	else if (rc > 0)
+		return AE_CTRL_SKIP;
+
+	return AE_OK;
+}
+
+void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state,
+			       u32 val_a, u32 val_b))
+{
+	__acpi_os_prepare_extended_sleep = func;
+}
+
+
 void alloc_acpi_hp_work(acpi_handle handle, u32 type, void *context,
 			void (*func)(struct work_struct *work))
 {
include/linux/acpi.h +7 -0
index 353ba25..a5db4ae 100644
@@ -481,6 +481,13 @@ void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
 
 acpi_status acpi_os_prepare_sleep(u8 sleep_state,
 				  u32 pm1a_control, u32 pm1b_control);
+
+void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state,
+				        u32 val_a,  u32 val_b));
+
+acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state,
+					   u32 val_a, u32 val_b);
+
 #ifdef CONFIG_X86
 void arch_reserve_mem_area(acpi_physical_address addr, size_t size);
 #else
Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH v8 1/3 x86/acpi: Introduce acpi_os_prepare_extended_sleep callback for extended sleep path

In reply to Ben Guthro

Like acpi_os_prepare_sleep, register a callback for use in systems like tboot, and xen, which have system specific requirements outside of acpica. This mirrors the functionality in acpi_os_prepare_sleep(), called from acpi_hw_sleep()

---
 drivers/acpi/acpica/hwesleep.c |    9 +++++++++
 drivers/acpi/osl.c             |   24 ++++++++++++++++++++++++
 include/linux/acpi.h           |    7 +++++++
 3 files changed, 40 insertions(+)
drivers/acpi/acpica/hwesleep.c +9 -0
index 5e5f762..4140768 100644
@@ -43,6 +43,7 @@
  */
 
 #include <acpi/acpi.h>
+#include <linux/acpi.h>
 #include "accommon.h"
 
 #define _COMPONENT          ACPI_HARDWARE
@@ -128,6 +129,14 @@ acpi_status acpi_hw_extended_sleep(u8 sleep_state)
 
 	ACPI_FLUSH_CPU_CACHE();
 
+	status = acpi_os_prepare_extended_sleep(sleep_state,
+						acpi_gbl_sleep_type_a,
+						acpi_gbl_sleep_type_b);
+	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/osl.c +24 -0
index 6ab2c35..a934950 100644
@@ -79,6 +79,8 @@ extern char line_buf[80];
 
 static int (*__acpi_os_prepare_sleep)(u8 sleep_state, u32 pm1a_ctrl,
 				      u32 pm1b_ctrl);
+static int (*__acpi_os_prepare_extended_sleep)(u8 sleep_state, u32 val_a,
+				      u32 val_b);
 
 static acpi_osd_handler acpi_irq_handler;
 static void *acpi_irq_context;
@@ -1779,6 +1781,28 @@ void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
 	__acpi_os_prepare_sleep = func;
 }
 
+acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state, u32 val_a,
+				  u32 val_b)
+{
+	int rc = 0;
+	if (__acpi_os_prepare_extended_sleep)
+		rc = __acpi_os_prepare_extended_sleep(sleep_state,
+					     val_a, val_b);
+	if (rc < 0)
+		return AE_ERROR;
+	else if (rc > 0)
+		return AE_CTRL_SKIP;
+
+	return AE_OK;
+}
+
+void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state,
+			       u32 val_a, u32 val_b))
+{
+	__acpi_os_prepare_extended_sleep = func;
+}
+
+
 void alloc_acpi_hp_work(acpi_handle handle, u32 type, void *context,
 			void (*func)(struct work_struct *work))
 {
include/linux/acpi.h +7 -0
index 353ba25..a5db4ae 100644
@@ -481,6 +481,13 @@ void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
 
 acpi_status acpi_os_prepare_sleep(u8 sleep_state,
 				  u32 pm1a_control, u32 pm1b_control);
+
+void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state,
+				        u32 val_a,  u32 val_b));
+
+acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state,
+					   u32 val_a, u32 val_b);
+
 #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 v8 2/3 x86/tboot: Fail extended mode reduced hardware sleep

In reply to Ben Guthro

Register for the extended sleep callback from acpi. As tboot currently does not support the reduced hardware sleep interface, fail this extended call.

---
 arch/x86/kernel/tboot.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/x86/kernel/tboot.c +12 -0
index addf7b5..ade00c8 100644
@@ -301,6 +301,17 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
 	return 0;
 }
 
+static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
+{
+	if (!tboot_enabled())
+		return 0;
+
+	pr_warning("tboot is not able to suspend on platforms with"
+		   " reduced hardware sleep (ACPIv5). Please contact"
+		   " [email protected] mailing list.");
+	return -ENODEV;
+}
+
 static atomic_t ap_wfs_count;
 
 static int tboot_wait_for_aps(int num_aps)
@@ -422,6 +433,7 @@ static __init int tboot_late_init(void)
 #endif
 
 	acpi_os_set_prepare_sleep(&tboot_sleep);
+	acpi_os_set_prepare_extended_sleep(&tboot_extended_sleep);
 	return 0;
 }
 
Signature · 9 lines
1.7.9.5


------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent 
caught up. So what steps can you take to put your SQL databases under 
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
#4 lore raw

Re: [PATCH v8 2/3] x86/tboot: Fail extended mode reduced hardware sleep

Quoted 19 lines · Ben Guthro

Register for the extended sleep callback from acpi. As tboot currently does not support the reduced hardware sleep interface, fail this extended call.

---
 arch/x86/kernel/tboot.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/x86/kernel/tboot.c +0 -0
index addf7b5..ade00c8 100644
@@ -301,6 +301,17 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
 	return 0;

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

Quoted 10 lines
arch/x86/kernel/tboot.c +8 -0
 }
 
+static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
+{
+	if (!tboot_enabled())
+		return 0;
+
+	pr_warning("tboot is not able to suspend on platforms with"
+		   " reduced hardware sleep (ACPIv5). Please contact"
+		   " [email protected] mailing list.");

I'm told that string literals should be continuous now even if they cross the 80 columns boundary, so let's make that happen here.

Also please drop the "Please contact ..." part, it is unnecessary and unuseful (I forgot about this particular thing last time, sorry about that).

arch/x86/kernel/tboot.c static __init int tboot_late_init(void) · line 438

Quoted 13 lines
arch/x86/kernel/tboot.c +4 -0
+	return -ENODEV;
+}
+
 static atomic_t ap_wfs_count;
 
 static int tboot_wait_for_aps(int num_aps)
@@ -422,6 +433,7 @@ static __init int tboot_late_init(void)
 #endif
 
 	acpi_os_set_prepare_sleep(&tboot_sleep);
+	acpi_os_set_prepare_extended_sleep(&tboot_extended_sleep);
 	return 0;
 }

Thanks,
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
author
#5 lore raw

PATCH 1/1 x86/tboot: Fail extended mode reduced hardware sleep

Register for the extended sleep callback from acpi. As tboot currently does not support the reduced hardware sleep interface, fail this extended call.

---
 arch/x86/kernel/tboot.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
arch/x86/kernel/tboot.c +10 -0
index addf7b5..91a4496 100644
@@ -301,6 +301,15 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
 	return 0;
 }
 
+static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
+{
+	if (!tboot_enabled())
+		return 0;
+
+	pr_warning("tboot is not able to suspend on platforms with reduced hardware sleep (ACPIv5)");
+	return -ENODEV;
+}
+
 static atomic_t ap_wfs_count;
 
 static int tboot_wait_for_aps(int num_aps)
@@ -422,6 +431,7 @@ static __init int tboot_late_init(void)
 #endif
 
 	acpi_os_set_prepare_sleep(&tboot_sleep);
+	acpi_os_set_prepare_extended_sleep(&tboot_extended_sleep);
 	return 0;
 }
 
Signature · 1 line
1.7.9.5
author
#6 lore raw

PATCH 1/1 x86/tboot: Fail extended mode reduced hardware sleep

In reply to Rafael J. Wysocki

Register for the extended sleep callback from acpi. As tboot currently does not support the reduced hardware sleep interface, fail this extended call.

---
 arch/x86/kernel/tboot.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
arch/x86/kernel/tboot.c +10 -0
index addf7b5..91a4496 100644
@@ -301,6 +301,15 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
 	return 0;
 }
 
+static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
+{
+	if (!tboot_enabled())
+		return 0;
+
+	pr_warning("tboot is not able to suspend on platforms with reduced hardware sleep (ACPIv5)");
+	return -ENODEV;
+}
+
 static atomic_t ap_wfs_count;
 
 static int tboot_wait_for_aps(int num_aps)
@@ -422,6 +431,7 @@ static __init int tboot_late_init(void)
 #endif
 
 	acpi_os_set_prepare_sleep(&tboot_sleep);
+	acpi_os_set_prepare_extended_sleep(&tboot_extended_sleep);
 	return 0;
 }
 
Signature · 1 line
1.7.9.5
#7 lore raw

Re: [PATCH v8.1] x86/tboot: Fail extended mode reduced hardware sleep

Quoted 9 lines · Ben Guthro

Register for the extended sleep callback from acpi. As tboot currently does not support the reduced hardware sleep interface, fail this extended call.

Looks OK, thanks!

I'll queue up the patchset for 3.12.

Thanks,
Rafael

Quoted 33 lines
---
 arch/x86/kernel/tboot.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
arch/x86/kernel/tboot.c +10 -0
index addf7b5..91a4496 100644
@@ -301,6 +301,15 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
 	return 0;
 }
 
+static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
+{
+	if (!tboot_enabled())
+		return 0;
+
+	pr_warning("tboot is not able to suspend on platforms with reduced hardware sleep (ACPIv5)");
+	return -ENODEV;
+}
+
 static atomic_t ap_wfs_count;
 
 static int tboot_wait_for_aps(int num_aps)
@@ -422,6 +431,7 @@ static __init int tboot_late_init(void)
 #endif
 
 	acpi_os_set_prepare_sleep(&tboot_sleep);
+	acpi_os_set_prepare_extended_sleep(&tboot_extended_sleep);
 	return 0;
 }
 
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
author
#8 lore raw

Re: [PATCH v8.1] x86/tboot: Fail extended mode reduced hardware sleep

Quoted 11 lines · Rafael J. Wysocki
Quoted 9 lines · Ben Guthro

Register for the extended sleep callback from acpi. As tboot currently does not support the reduced hardware sleep interface, fail this extended call.

Quoted 4 lines

Looks OK, thanks!

I'll queue up the patchset for 3.12.

Great!
Thanks for your patience on so many rounds of this.

Ben

Quoted 34 lines

Thanks,
Rafael

arch/x86/kernel/tboot.c static int tboot_sleep(u8 sleep_state, u32

Quoted 9 lines
---
 arch/x86/kernel/tboot.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
arch/x86/kernel/tboot.c +0 -0
index addf7b5..91a4496 100644
@@ -301,6 +301,15 @@ static int tboot_sleep(u8 sleep_state, u32

pm1a_control, u32 pm1b_control)

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

Quoted 9 lines
arch/x86/kernel/tboot.c +6 -0
      return 0;
 }
 
+static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
+{
+     if (!tboot_enabled())
+             return 0;
+
+     pr_warning("tboot is not able to suspend on platforms with reduced

hardware sleep (ACPIv5)");

Quoted 9 lines
arch/x86/kernel/tboot.c +3 -0
+     return -ENODEV;
+}
+
 static atomic_t ap_wfs_count;
 
 static int tboot_wait_for_aps(int num_aps)
@@ -422,6 +431,7 @@ static __init int tboot_late_init(void)
 #endif
 
Quoted 15 lines

arch/x86/kernel/tboot.c static __init int tboot_late_init(void) · line 437

Quoted 6 lines
arch/x86/kernel/tboot.c +1 -0
      acpi_os_set_prepare_sleep(&tboot_sleep);
+     acpi_os_set_prepare_extended_sleep(&tboot_extended_sleep);
      return 0;
 }
 

--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent caught up. So what steps can you take to put your SQL databases under version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk

_______________________________________________
tboot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tboot-devel

author
#9 lore raw

Re: [PATCH v8.1] x86/tboot: Fail extended mode reduced hardware sleep

In reply to Rafael J. Wysocki
Quoted 11 lines · Rafael J. Wysocki
Quoted 9 lines · Ben Guthro

Register for the extended sleep callback from acpi. As tboot currently does not support the reduced hardware sleep interface, fail this extended call.

Quoted 4 lines

Looks OK, thanks!

I'll queue up the patchset for 3.12.

Great!
Thanks for your patience on so many rounds of this.

Ben

Quoted 34 lines

Thanks,
Rafael

arch/x86/kernel/tboot.c static int tboot_sleep(u8 sleep_state, u32

Quoted 9 lines
---
 arch/x86/kernel/tboot.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
arch/x86/kernel/tboot.c +0 -0
index addf7b5..91a4496 100644
@@ -301,6 +301,15 @@ static int tboot_sleep(u8 sleep_state, u32

pm1a_control, u32 pm1b_control)

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

Quoted 9 lines
arch/x86/kernel/tboot.c +6 -0
      return 0;
 }
 
+static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
+{
+     if (!tboot_enabled())
+             return 0;
+
+     pr_warning("tboot is not able to suspend on platforms with reduced

hardware sleep (ACPIv5)");

Quoted 9 lines
arch/x86/kernel/tboot.c +3 -0
+     return -ENODEV;
+}
+
 static atomic_t ap_wfs_count;
 
 static int tboot_wait_for_aps(int num_aps)
@@ -422,6 +431,7 @@ static __init int tboot_late_init(void)
 #endif
 
Quoted 15 lines

arch/x86/kernel/tboot.c static __init int tboot_late_init(void) · line 437

Quoted 6 lines
arch/x86/kernel/tboot.c +1 -0
      acpi_os_set_prepare_sleep(&tboot_sleep);
+     acpi_os_set_prepare_extended_sleep(&tboot_extended_sleep);
      return 0;
 }
 

--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#10 lore raw

Re: [PATCH v8.1] x86/tboot: Fail extended mode reduced hardware sleep

In reply to Ben Guthro
Quoted 9 lines · Ben Guthro

Register for the extended sleep callback from acpi. As tboot currently does not support the reduced hardware sleep interface, fail this extended call.

Looks OK, thanks!

I'll queue up the patchset for 3.12.

Thanks,
Rafael

Quoted 33 lines
---
 arch/x86/kernel/tboot.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
arch/x86/kernel/tboot.c +10 -0
index addf7b5..91a4496 100644
@@ -301,6 +301,15 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
 	return 0;
 }
 
+static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
+{
+	if (!tboot_enabled())
+		return 0;
+
+	pr_warning("tboot is not able to suspend on platforms with reduced hardware sleep (ACPIv5)");
+	return -ENODEV;
+}
+
 static atomic_t ap_wfs_count;
 
 static int tboot_wait_for_aps(int num_aps)
@@ -422,6 +431,7 @@ static __init int tboot_late_init(void)
 #endif
 
 	acpi_os_set_prepare_sleep(&tboot_sleep);
+	acpi_os_set_prepare_extended_sleep(&tboot_extended_sleep);
 	return 0;
 }
 
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#11 lore raw

Re: [PATCH v8 2/3] x86/tboot: Fail extended mode reduced hardware sleep

In reply to Ben Guthro
Quoted 19 lines · Ben Guthro

Register for the extended sleep callback from acpi. As tboot currently does not support the reduced hardware sleep interface, fail this extended call.

---
 arch/x86/kernel/tboot.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/x86/kernel/tboot.c +0 -0
index addf7b5..ade00c8 100644
@@ -301,6 +301,17 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
 	return 0;

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

Quoted 10 lines
arch/x86/kernel/tboot.c +8 -0
 }
 
+static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
+{
+	if (!tboot_enabled())
+		return 0;
+
+	pr_warning("tboot is not able to suspend on platforms with"
+		   " reduced hardware sleep (ACPIv5). Please contact"
+		   " [email protected] mailing list.");

I'm told that string literals should be continuous now even if they cross the 80 columns boundary, so let's make that happen here.

Also please drop the "Please contact ..." part, it is unnecessary and unuseful (I forgot about this particular thing last time, sorry about that).

arch/x86/kernel/tboot.c static __init int tboot_late_init(void) · line 438

Quoted 13 lines
arch/x86/kernel/tboot.c +4 -0
+	return -ENODEV;
+}
+
 static atomic_t ap_wfs_count;
 
 static int tboot_wait_for_aps(int num_aps)
@@ -422,6 +433,7 @@ static __init int tboot_late_init(void)
 #endif
 
 	acpi_os_set_prepare_sleep(&tboot_sleep);
+	acpi_os_set_prepare_extended_sleep(&tboot_extended_sleep);
 	return 0;
 }

Thanks,
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
author
#12 lore raw

PATCH v8 2/3 x86/tboot: Fail extended mode reduced hardware sleep

In reply to Ben Guthro

Register for the extended sleep callback from acpi. As tboot currently does not support the reduced hardware sleep interface, fail this extended call.

---
 arch/x86/kernel/tboot.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/x86/kernel/tboot.c +12 -0
index addf7b5..ade00c8 100644
@@ -301,6 +301,17 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
 	return 0;
 }
 
+static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
+{
+	if (!tboot_enabled())
+		return 0;
+
+	pr_warning("tboot is not able to suspend on platforms with"
+		   " reduced hardware sleep (ACPIv5). Please contact"
+		   " [email protected] mailing list.");
+	return -ENODEV;
+}
+
 static atomic_t ap_wfs_count;
 
 static int tboot_wait_for_aps(int num_aps)
@@ -422,6 +433,7 @@ static __init int tboot_late_init(void)
 #endif
 
 	acpi_os_set_prepare_sleep(&tboot_sleep);
+	acpi_os_set_prepare_extended_sleep(&tboot_extended_sleep);
 	return 0;
 }
 
Signature · 1 line
1.7.9.5
author
#13 lore raw

PATCH v8 3/3 xen/acpi: notify xen when reduced hardware sleep is available

In reply to Ben Guthro

Make use of acpi_os_prepare_extended_sleep callback to notify xen to make use of the reduced hardware sleep functionality

The xen 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               |   41 ++++++++++++++++++++++++++------------
 include/xen/acpi.h               |    8 ++++++--
 include/xen/interface/platform.h |    7 ++++---
 3 files changed, 38 insertions(+), 18 deletions(-)
drivers/xen/acpi.c +28 -13
index 119d42a..90307c0 100644
@@ -35,28 +35,43 @@
 #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)
+static 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;
 }
+
+int xen_acpi_notify_hypervisor_sleep(u8 sleep_state,
+				     u32 pm1a_cnt, u32 pm1b_cnt)
+{
+	return xen_acpi_notify_hypervisor_state(sleep_state, pm1a_cnt,
+						pm1b_cnt, false);
+}
+
+int xen_acpi_notify_hypervisor_extended_sleep(u8 sleep_state,
+				     u32 val_a, u32 val_b)
+{
+	return xen_acpi_notify_hypervisor_state(sleep_state, val_a,
+						val_b, true);
+}
include/xen/acpi.h +6 -2
index 46aa3d1..4ddd7dc 100644
@@ -75,8 +75,10 @@ static inline int xen_acpi_get_pxm(acpi_handle h)
 	return -ENXIO;
 }
 
-int xen_acpi_notify_hypervisor_state(u8 sleep_state,
+int xen_acpi_notify_hypervisor_sleep(u8 sleep_state,
 				     u32 pm1a_cnt, u32 pm1b_cnd);
+int xen_acpi_notify_hypervisor_extended_sleep(u8 sleep_state,
+				     u32 val_a, u32 val_b);
 
 static inline int xen_acpi_suspend_lowlevel(void)
 {
@@ -93,7 +95,9 @@ static inline void xen_acpi_sleep_register(void)
 {
 	if (xen_initial_domain()) {
 		acpi_os_set_prepare_sleep(
-			&xen_acpi_notify_hypervisor_state);
+			&xen_acpi_notify_hypervisor_sleep);
+		acpi_os_set_prepare_extended_sleep(
+			&xen_acpi_notify_hypervisor_extended_sleep);
 
 		acpi_suspend_lowlevel = xen_acpi_suspend_lowlevel;
 	}
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
#14 lore raw

PATCH v8 3/3 xen/acpi: notify xen when reduced hardware sleep is available

In reply to Ben Guthro

Make use of acpi_os_prepare_extended_sleep callback to notify xen to make use of the reduced hardware sleep functionality

The xen 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               |   41 ++++++++++++++++++++++++++------------
 include/xen/acpi.h               |    8 ++++++--
 include/xen/interface/platform.h |    7 ++++---
 3 files changed, 38 insertions(+), 18 deletions(-)
drivers/xen/acpi.c +28 -13
index 119d42a..90307c0 100644
@@ -35,28 +35,43 @@
 #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)
+static 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;
 }
+
+int xen_acpi_notify_hypervisor_sleep(u8 sleep_state,
+				     u32 pm1a_cnt, u32 pm1b_cnt)
+{
+	return xen_acpi_notify_hypervisor_state(sleep_state, pm1a_cnt,
+						pm1b_cnt, false);
+}
+
+int xen_acpi_notify_hypervisor_extended_sleep(u8 sleep_state,
+				     u32 val_a, u32 val_b)
+{
+	return xen_acpi_notify_hypervisor_state(sleep_state, val_a,
+						val_b, true);
+}
include/xen/acpi.h +6 -2
index 46aa3d1..4ddd7dc 100644
@@ -75,8 +75,10 @@ static inline int xen_acpi_get_pxm(acpi_handle h)
 	return -ENXIO;
 }
 
-int xen_acpi_notify_hypervisor_state(u8 sleep_state,
+int xen_acpi_notify_hypervisor_sleep(u8 sleep_state,
 				     u32 pm1a_cnt, u32 pm1b_cnd);
+int xen_acpi_notify_hypervisor_extended_sleep(u8 sleep_state,
+				     u32 val_a, u32 val_b);
 
 static inline int xen_acpi_suspend_lowlevel(void)
 {
@@ -93,7 +95,9 @@ static inline void xen_acpi_sleep_register(void)
 {
 	if (xen_initial_domain()) {
 		acpi_os_set_prepare_sleep(
-			&xen_acpi_notify_hypervisor_state);
+			&xen_acpi_notify_hypervisor_sleep);
+		acpi_os_set_prepare_extended_sleep(
+			&xen_acpi_notify_hypervisor_extended_sleep);
 
 		acpi_suspend_lowlevel = xen_acpi_suspend_lowlevel;
 	}
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
#15 lore raw
In reply to Ben Guthro
Quoted 46 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 new callback to be added to acpica to be called back during this reduced hardware 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 xen hypervisor change underlying this is commit 62d1a69 ("ACPI: support v5 (reduced HW) sleep interface") on the master branch of
git://xenbits.xen.org/xen.git.

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

v2: Extend description to include reference to hypervisor side change
v3: Split into multiple patches, separating subsystems
Remove bool parameters, in favor of u8
v4: Remove linux/acpi.h dependencies
Further patch split to break out acpica from OSL
More bool vs u8 fixes
v5: Fix build of consumers of acpi_os_prepare_sleep() interface change,
so intermediate builds of partial patch series will not fail.
v6: Rebased to linux-pm linux-next branch
Added warning in tboot early return code
Added Reviewed-by lines
v7: Add separate acpi_os_prepare_extended_sleep() interface
Remove OSL acpica changes introduced in v4
v8: Return meaningful error code in tboot error path

Ben Guthro (3):
x86/acpi: Introduce acpi_os_prepare_extended_sleep callback for
extended sleep path
x86/tboot: Fail extended mode reduced hardware sleep xen/acpi: notify xen when reduced hardware sleep is available

Quoted 8 lines
 arch/x86/kernel/tboot.c          |   12 +++++++++++
 drivers/acpi/acpica/hwesleep.c   |    9 +++++++++
 drivers/acpi/osl.c               |   24 ++++++++++++++++++++++
 drivers/xen/acpi.c               |   41 ++++++++++++++++++++++++++------------
 include/linux/acpi.h             |    7 +++++++
 include/xen/acpi.h               |    8 ++++++--
 include/xen/interface/platform.h |    7 ++++---
 7 files changed, 90 insertions(+), 18 deletions(-)

Please modify [2/3] as requested in the other message, [1/3] and [3/3] are OK and don't need to be resent.

Thanks,
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#16 lore raw
In reply to Ben Guthro
Quoted 46 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 new callback to be added to acpica to be called back during this reduced hardware 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 xen hypervisor change underlying this is commit 62d1a69 ("ACPI: support v5 (reduced HW) sleep interface") on the master branch of
git://xenbits.xen.org/xen.git.

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

v2: Extend description to include reference to hypervisor side change
v3: Split into multiple patches, separating subsystems
Remove bool parameters, in favor of u8
v4: Remove linux/acpi.h dependencies
Further patch split to break out acpica from OSL
More bool vs u8 fixes
v5: Fix build of consumers of acpi_os_prepare_sleep() interface change,
so intermediate builds of partial patch series will not fail.
v6: Rebased to linux-pm linux-next branch
Added warning in tboot early return code
Added Reviewed-by lines
v7: Add separate acpi_os_prepare_extended_sleep() interface
Remove OSL acpica changes introduced in v4
v8: Return meaningful error code in tboot error path

Ben Guthro (3):
x86/acpi: Introduce acpi_os_prepare_extended_sleep callback for
extended sleep path
x86/tboot: Fail extended mode reduced hardware sleep xen/acpi: notify xen when reduced hardware sleep is available

Quoted 8 lines
 arch/x86/kernel/tboot.c          |   12 +++++++++++
 drivers/acpi/acpica/hwesleep.c   |    9 +++++++++
 drivers/acpi/osl.c               |   24 ++++++++++++++++++++++
 drivers/xen/acpi.c               |   41 ++++++++++++++++++++++++++------------
 include/linux/acpi.h             |    7 +++++++
 include/xen/acpi.h               |    8 ++++++--
 include/xen/interface/platform.h |    7 ++++---
 7 files changed, 90 insertions(+), 18 deletions(-)

Please modify [2/3] as requested in the other message, [1/3] and [3/3] are OK and don't need to be resent.

Thanks,
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.