* [PATCH v7 1/3] x86/acpi: Introduce acpi_os_prepare_extended_sleep callback for extended sleep path
2013-07-29 17:14 [PATCH v7 0/3] Xen/ACPI: support sleep state entering on hardware reduced systems Ben Guthro
@ 2013-07-29 17:14 ` Ben Guthro
2013-07-29 17:14 ` [PATCH v7 2/3] x86/tboot: Fail extended mode reduced hardware sleep Ben Guthro
2013-07-29 17:14 ` [PATCH v7 3/3] xen/acpi: notify xen when reduced hardware sleep is available Ben Guthro
2 siblings, 0 replies; 7+ messages in thread
From: Ben Guthro @ 2013-07-29 17:14 UTC (permalink / raw)
To: Konrad Rzeszutek Wilk, Jan Beulich, Rafael J . Wysocki,
linux-kernel, linux-acpi, xen-devel
Cc: 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()
Signed-off-by: Ben Guthro <benjamin.guthro@citrix.com>
---
drivers/acpi/acpica/hwesleep.c | 9 +++++++++
drivers/acpi/osl.c | 24 ++++++++++++++++++++++++
include/linux/acpi.h | 7 +++++++
3 files changed, 40 insertions(+)
diff --git a/drivers/acpi/acpica/hwesleep.c b/drivers/acpi/acpica/hwesleep.c
index 5e5f762..4140768 100644
--- a/drivers/acpi/acpica/hwesleep.c
+++ b/drivers/acpi/acpica/hwesleep.c
@@ -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.
*
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 6ab2c35..a934950 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -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))
{
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 353ba25..a5db4ae 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -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
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v7 2/3] x86/tboot: Fail extended mode reduced hardware sleep
2013-07-29 17:14 [PATCH v7 0/3] Xen/ACPI: support sleep state entering on hardware reduced systems Ben Guthro
2013-07-29 17:14 ` [PATCH v7 1/3] x86/acpi: Introduce acpi_os_prepare_extended_sleep callback for extended sleep path Ben Guthro
@ 2013-07-29 17:14 ` Ben Guthro
2013-07-29 20:21 ` Rafael J. Wysocki
2013-07-29 17:14 ` [PATCH v7 3/3] xen/acpi: notify xen when reduced hardware sleep is available Ben Guthro
2 siblings, 1 reply; 7+ messages in thread
From: Ben Guthro @ 2013-07-29 17:14 UTC (permalink / raw)
To: Konrad Rzeszutek Wilk, Jan Beulich, Rafael J . Wysocki,
linux-kernel, linux-acpi, xen-devel
Cc: Ben Guthro, tboot-devel, Gang Wei
Register for the extended sleep callback from acpi.
As tboot currently does not support the reduced hardware sleep
interface, fail this extended call.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Ben Guthro <benjamin.guthro@citrix.com>
Cc: tboot-devel@lists.sourceforge.net
Cc: Gang Wei <gang.wei@intel.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
arch/x86/kernel/tboot.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
index addf7b5..760f431 100644
--- a/arch/x86/kernel/tboot.c
+++ b/arch/x86/kernel/tboot.c
@@ -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"
+ " tboot-devel@lists.sourceforge.net mailing list.");
+ return -1;
+}
+
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;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v7 2/3] x86/tboot: Fail extended mode reduced hardware sleep
2013-07-29 17:14 ` [PATCH v7 2/3] x86/tboot: Fail extended mode reduced hardware sleep Ben Guthro
@ 2013-07-29 20:21 ` Rafael J. Wysocki
2013-07-29 20:18 ` Ben Guthro
0 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2013-07-29 20:21 UTC (permalink / raw)
To: Ben Guthro
Cc: Konrad Rzeszutek Wilk, Jan Beulich, linux-kernel, linux-acpi,
xen-devel, tboot-devel, Gang Wei
On Monday, July 29, 2013 01:14:14 PM Ben Guthro wrote:
> Register for the extended sleep callback from acpi.
> As tboot currently does not support the reduced hardware sleep
> interface, fail this extended call.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Ben Guthro <benjamin.guthro@citrix.com>
> Cc: tboot-devel@lists.sourceforge.net
> Cc: Gang Wei <gang.wei@intel.com>
> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
> arch/x86/kernel/tboot.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
> index addf7b5..760f431 100644
> --- a/arch/x86/kernel/tboot.c
> +++ b/arch/x86/kernel/tboot.c
> @@ -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"
> + " tboot-devel@lists.sourceforge.net mailing list.");
> + return -1;
Please use a meaningful error code here. For example -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
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v7 2/3] x86/tboot: Fail extended mode reduced hardware sleep
2013-07-29 20:21 ` Rafael J. Wysocki
@ 2013-07-29 20:18 ` Ben Guthro
2013-07-29 20:29 ` Rafael J. Wysocki
0 siblings, 1 reply; 7+ messages in thread
From: Ben Guthro @ 2013-07-29 20:18 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Konrad Rzeszutek Wilk, Jan Beulich, linux-kernel, linux-acpi,
xen-devel, tboot-devel, Gang Wei
On 07/29/2013 04:21 PM, Rafael J. Wysocki wrote:
> On Monday, July 29, 2013 01:14:14 PM Ben Guthro wrote:
>> Register for the extended sleep callback from acpi.
>> As tboot currently does not support the reduced hardware sleep
>> interface, fail this extended call.
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>> Signed-off-by: Ben Guthro <benjamin.guthro@citrix.com>
>> Cc: tboot-devel@lists.sourceforge.net
>> Cc: Gang Wei <gang.wei@intel.com>
>> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>> ---
>> arch/x86/kernel/tboot.c | 12 ++++++++++++
>> 1 file changed, 12 insertions(+)
>>
>> diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
>> index addf7b5..760f431 100644
>> --- a/arch/x86/kernel/tboot.c
>> +++ b/arch/x86/kernel/tboot.c
>> @@ -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"
>> + " tboot-devel@lists.sourceforge.net mailing list.");
>> + return -1;
>
> Please use a meaningful error code here. For example -ENODEV.
Would AE_NOT_IMPLEMENTED be more appropriate?
include/acpi/acexcep.h:
#define AE_NOT_IMPLEMENTED EXCEP_ENV (0x000E)
>
>> +}
>> +
>> 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
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v7 2/3] x86/tboot: Fail extended mode reduced hardware sleep
2013-07-29 20:18 ` Ben Guthro
@ 2013-07-29 20:29 ` Rafael J. Wysocki
0 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2013-07-29 20:29 UTC (permalink / raw)
To: Ben Guthro
Cc: Konrad Rzeszutek Wilk, Jan Beulich, linux-kernel, linux-acpi,
xen-devel, tboot-devel, Gang Wei
On Monday, July 29, 2013 04:18:22 PM Ben Guthro wrote:
>
> On 07/29/2013 04:21 PM, Rafael J. Wysocki wrote:
> > On Monday, July 29, 2013 01:14:14 PM Ben Guthro wrote:
> >> Register for the extended sleep callback from acpi.
> >> As tboot currently does not support the reduced hardware sleep
> >> interface, fail this extended call.
> >>
> >> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> >> Signed-off-by: Ben Guthro <benjamin.guthro@citrix.com>
> >> Cc: tboot-devel@lists.sourceforge.net
> >> Cc: Gang Wei <gang.wei@intel.com>
> >> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> >> ---
> >> arch/x86/kernel/tboot.c | 12 ++++++++++++
> >> 1 file changed, 12 insertions(+)
> >>
> >> diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
> >> index addf7b5..760f431 100644
> >> --- a/arch/x86/kernel/tboot.c
> >> +++ b/arch/x86/kernel/tboot.c
> >> @@ -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"
> >> + " tboot-devel@lists.sourceforge.net mailing list.");
> >> + return -1;
> >
> > Please use a meaningful error code here. For example -ENODEV.
>
> Would AE_NOT_IMPLEMENTED be more appropriate?
>
> include/acpi/acexcep.h:
> #define AE_NOT_IMPLEMENTED EXCEP_ENV (0x000E)
This is not an ACPI error. :-)
Rafael
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v7 3/3] xen/acpi: notify xen when reduced hardware sleep is available
2013-07-29 17:14 [PATCH v7 0/3] Xen/ACPI: support sleep state entering on hardware reduced systems Ben Guthro
2013-07-29 17:14 ` [PATCH v7 1/3] x86/acpi: Introduce acpi_os_prepare_extended_sleep callback for extended sleep path Ben Guthro
2013-07-29 17:14 ` [PATCH v7 2/3] x86/tboot: Fail extended mode reduced hardware sleep Ben Guthro
@ 2013-07-29 17:14 ` Ben Guthro
2 siblings, 0 replies; 7+ messages in thread
From: Ben Guthro @ 2013-07-29 17:14 UTC (permalink / raw)
To: Konrad Rzeszutek Wilk, Jan Beulich, Rafael J . Wysocki,
linux-kernel, linux-acpi, xen-devel
Cc: 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.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Ben Guthro <benjamin.guthro@citrix.com>
Acked-by: Konrad Wilk <konrad.wilk@oracle.com>
---
drivers/xen/acpi.c | 41 ++++++++++++++++++++++++++------------
include/xen/acpi.h | 8 ++++++--
include/xen/interface/platform.h | 7 ++++---
3 files changed, 38 insertions(+), 18 deletions(-)
diff --git a/drivers/xen/acpi.c b/drivers/xen/acpi.c
index 119d42a..90307c0 100644
--- a/drivers/xen/acpi.c
+++ b/drivers/xen/acpi.c
@@ -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 xen-devel@lists.xensource.com 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 xen-devel@lists.xen.org - 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);
+}
diff --git a/include/xen/acpi.h b/include/xen/acpi.h
index 46aa3d1..4ddd7dc 100644
--- a/include/xen/acpi.h
+++ b/include/xen/acpi.h
@@ -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;
}
diff --git a/include/xen/interface/platform.h b/include/xen/interface/platform.h
index c57d5f6..f1331e3 100644
--- a/include/xen/interface/platform.h
+++ b/include/xen/interface/platform.h
@@ -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);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread