Xen/ACPI: support sleep state entering on hardware reduced systems
Subsystems (5)
PATCH 1/1 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).
--- arch/x86/kernel/tboot.c | 6 +++++- drivers/acpi/acpica/hwesleep.c | 8 ++++++++ drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/osl.c | 16 ++++++++-------- drivers/xen/acpi.c | 26 +++++++++++++------------- include/linux/acpi.h | 10 +++++----- include/xen/acpi.h | 4 ++-- include/xen/interface/platform.h | 7 ++++--- 8 files changed, 46 insertions(+), 33 deletions(-)
arch/x86/kernel/tboot.c +5 -1
@@ -273,7 +273,8 @@ static void tboot_copy_fadt(const struct 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, uif (!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;
drivers/acpi/acpica/hwesleep.c +8 -0
@@ -43,6 +43,7 @@*/ #include <acpi/acpi.h> +#include <linux/acpi.h> #include "accommon.h" #define _COMPONENT ACPI_HARDWARE
@@ -128,6 +129,13 @@ acpi_status acpi_hw_extended_sleep(u8 slACPI_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
@@ -153,7 +153,7 @@ acpi_status acpi_hw_legacy_sleep(u8 sleeACPI_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))
drivers/acpi/osl.c +8 -8
@@ -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, +bool 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 slereturn AE_OK ; } -void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state, -u32 pm1a_ctrl,u32 pm1b_ctrl)) +void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state,u32 val_a, +u32 val_b,bool extended)) { __acpi_os_prepare_sleep = func; }
drivers/xen/acpi.c +13 -13
@@ -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/linux/acpi.h +5 -5
@@ -486,11 +486,11 @@ static inline bool acpi_driver_match_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)); -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, +bool extended);#ifdef CONFIG_X86 void arch_reserve_mem_area (acpi_physical_address addr,size_t size);#else
@@ -500,7 +500,7 @@ static inline void arch_reserve_mem_area }#endif /* CONFIG_X86 */ #else -#define acpi_os_set_prepare_sleep (func, pm1a_ctrl, pm1b_ctrl) do { } while (0) +#define acpi_os_set_prepare_sleep (func, val_a, val_b, ext) do { } while (0)#endif #if defined(CONFIG_ACPI ) && defined(CONFIG_PM_RUNTIME )
include/xen/acpi.h +2 -2
@@ -75,8 +75,8 @@ static inline int xen_acpi_get_pxm(acpi_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
@@ -152,10 +152,11 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmwar#define XENPF_enter_acpi_sleep 51struct 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);
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).
--- arch/x86/kernel/tboot.c | 6 +++++- drivers/acpi/acpica/hwesleep.c | 8 ++++++++ drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/osl.c | 16 ++++++++-------- drivers/xen/acpi.c | 26 +++++++++++++------------- include/linux/acpi.h | 10 +++++----- include/xen/acpi.h | 4 ++-- include/xen/interface/platform.h | 7 ++++--- 8 files changed, 46 insertions(+), 33 deletions(-)
arch/x86/kernel/tboot.c +5 -1
@@ -273,7 +273,8 @@ static void tboot_copy_fadt(const struct 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, uif (!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;
drivers/acpi/acpica/hwesleep.c +8 -0
@@ -43,6 +43,7 @@*/ #include <acpi/acpi.h> +#include <linux/acpi.h> #include "accommon.h" #define _COMPONENT ACPI_HARDWARE
@@ -128,6 +129,13 @@ acpi_status acpi_hw_extended_sleep(u8 slACPI_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
@@ -153,7 +153,7 @@ acpi_status acpi_hw_legacy_sleep(u8 sleeACPI_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))
drivers/acpi/osl.c +8 -8
@@ -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, +bool 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 slereturn AE_OK ; } -void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state, -u32 pm1a_ctrl,u32 pm1b_ctrl)) +void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state,u32 val_a, +u32 val_b,bool extended)) { __acpi_os_prepare_sleep = func; }
drivers/xen/acpi.c +13 -13
@@ -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/linux/acpi.h +5 -5
@@ -486,11 +486,11 @@ static inline bool acpi_driver_match_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)); -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, +bool extended);#ifdef CONFIG_X86 void arch_reserve_mem_area (acpi_physical_address addr,size_t size);#else
@@ -500,7 +500,7 @@ static inline void arch_reserve_mem_area }#endif /* CONFIG_X86 */ #else -#define acpi_os_set_prepare_sleep (func, pm1a_ctrl, pm1b_ctrl) do { } while (0) +#define acpi_os_set_prepare_sleep (func, val_a, val_b, ext) do { } while (0)#endif #if defined(CONFIG_ACPI ) && defined(CONFIG_PM_RUNTIME )
include/xen/acpi.h +2 -2
@@ -75,8 +75,8 @@ static inline int xen_acpi_get_pxm(acpi_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
@@ -152,10 +152,11 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmwar#define XENPF_enter_acpi_sleep 51struct 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);
Quoted 5 lines · Jan Beulich
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.
Ooops.
Quoted 8 lines
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).
Signed-off-by Jan Beulich <[email protected]>Cc Richard L Maliszewski <[email protected]>
CC: Rafael since he is the ACPI maintainer nowadays. Len is concentrating on Intel-Idle.
Quoted 200 lines
Cc Gang Wei <[email protected]>Cc Shane Wang <[email protected]>--- arch/x86/kernel/tboot.c | 6 +++++- drivers/acpi/acpica/hwesleep.c | 8 ++++++++ drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/osl.c | 16 ++++++++-------- drivers/xen/acpi.c | 26 +++++++++++++------------- include/linux/acpi.h | 10 +++++----- include/xen/acpi.h | 4 ++-- include/xen/interface/platform.h | 7 ++++--- 8 files changed, 46 insertions(+), 33 deletions(-)arch/x86/kernel/tboot.c +5
-1@@ -273,7 +273,8 @@ static void tboot_copy_fadt(const struct 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, uif (!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;drivers/acpi/acpica/hwesleep.c +8
-0@@ -43,6 +43,7 @@*/ #include <acpi/acpi.h> +#include <linux/acpi.h> #include "accommon.h" #define _COMPONENT ACPI_HARDWARE@@ -128,6 +129,13 @@ acpi_status acpi_hw_extended_sleep(u8 slACPI_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@@ -153,7 +153,7 @@ acpi_status acpi_hw_legacy_sleep(u8 sleeACPI_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))drivers/acpi/osl.c +8
-8@@ -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, +bool 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 slereturn AE_OK ; } -void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state, -u32 pm1a_ctrl,u32 pm1b_ctrl)) +void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state,u32 val_a, +u32 val_b,bool extended)) { __acpi_os_prepare_sleep = func; }drivers/xen/acpi.c +13
-13@@ -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/linux/acpi.h +5
-5@@ -486,11 +486,11 @@ static inline bool acpi_driver_match_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)); -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, +bool extended);#ifdef CONFIG_X86 void arch_reserve_mem_area (acpi_physical_address addr,size_t size);#else @@ -500,7 +500,7 @@ static inline void arch_reserve_mem_area }#endif /* CONFIG_X86 */ #else -#define acpi_os_set_prepare_sleep (func, pm1a_ctrl, pm1b_ctrl) do { } while (0) +#define acpi_os_set_prepare_sleep (func, val_a, val_b, ext) do { } while (0)#endif #if defined(CONFIG_ACPI ) && defined(CONFIG_PM_RUNTIME )include/xen/acpi.h +2
-2@@ -75,8 +75,8 @@ static inline int xen_acpi_get_pxm(acpi_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 +0
-0@@ -152,10 +152,11 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmwar#define XENPF_enter_acpi_sleep 51
include/xen/interface/platform.h DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmwar · line 159
Quoted 10 lines
include/xen/interface/platform.h +4
-3struct 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_*. */
Could the commit should also mention what version of the Xen hypervisor supports this new flag and takes action on it?
Besides that little nit-pick it looks OK to me. Are there any changes neccessary on the IA64 or ARM side for this?
include/xen/interface/platform.h DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmwar · line 162
Quoted 5 lines
include/xen/interface/platform.h +0
-0};DEFINE_GUEST_HANDLE_STRUCT (xenpf_enter_acpi_sleep_t);
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the endpoint security space. For insight on selecting the right partner to tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Could the commit should also mention what version of the Xen hypervisor supports this new flag and takes action on it?
Do you really think this is needed? I generally try to stay away from doing such, since backports can easily invalidate such statements.
Quoted 2 lines
Besides that little nit-pick it looks OK to me. Are there any changes neccessary on the IA64 or ARM side for this?
Xen on IA64 is dead, so I don't see any need for further action there. And I don't think ARM has any ACPI enablement so far (on the Xen side at least).
Jan
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Could the commit should also mention what version of the Xen hypervisor supports this new flag and takes action on it?
Do you really think this is needed? I generally try to stay away from doing such, since backports can easily invalidate such statements.
Quoted 2 lines
Besides that little nit-pick it looks OK to me. Are there any changes neccessary on the IA64 or ARM side for this?
Xen on IA64 is dead, so I don't see any need for further action there. And I don't think ARM has any ACPI enablement so far (on the Xen side at least).
Jan
Quoted 7 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Could the commit should also mention what version of the Xen hypervisor supports this new flag and takes action on it?
Do you really think this is needed? I generally try to stay away from doing such, since backports can easily invalidate such statements.
Perhaps just mention the title of the patch in the Xen tree?
Quoted 5 lines
Quoted 3 lines
Besides that little nit-pick it looks OK to me. Are there any changes neccessary on the IA64 or ARM side for this?
Xen on IA64 is dead, so I don't see any need for further action
You are touching generic ACPI code. My question was in terms of the Linux ACPI IA64 code.
Quoted 2 lines
there. And I don't think ARM has any ACPI enablement so far (on the Xen side at least).
And also on the Linux side by just doing a quick grep. Surely that will change at some point.
Quoted 9 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the endpoint security space. For insight on selecting the right partner to tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 7 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Could the commit should also mention what version of the Xen hypervisor supports this new flag and takes action on it?
Do you really think this is needed? I generally try to stay away from doing such, since backports can easily invalidate such statements.
Perhaps just mention the title of the patch in the Xen tree?
Okay, will send you a v2 with the hypervisor size change referenced. Sigh.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Besides that little nit-pick it looks OK to me. Are there any changes neccessary on the IA64 or ARM side for this?
Xen on IA64 is dead, so I don't see any need for further action
You are touching generic ACPI code. My question was in terms of the Linux ACPI IA64 code.
The changes there are completely benign to IA64.
Jan
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 7 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Could the commit should also mention what version of the Xen hypervisor supports this new flag and takes action on it?
Do you really think this is needed? I generally try to stay away from doing such, since backports can easily invalidate such statements.
Perhaps just mention the title of the patch in the Xen tree?
Okay, will send you a v2 with the hypervisor size change referenced. Sigh.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Besides that little nit-pick it looks OK to me. Are there any changes neccessary on the IA64 or ARM side for this?
Xen on IA64 is dead, so I don't see any need for further action
You are touching generic ACPI code. My question was in terms of the Linux ACPI IA64 code.
The changes there are completely benign to IA64.
Jan
PATCH v2 1/1 Xen/ACPI: support sleep state entering on hardware reduced systems
In reply to Konrad Rzeszutek WilkIn 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 ofgit://xenbits.xen.org/xen.git.
---
v2: Extend description to include reference to hypervisor side change.
--- arch/x86/kernel/tboot.c | 6 +++++- drivers/acpi/acpica/hwesleep.c | 8 ++++++++ drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/osl.c | 16 ++++++++-------- drivers/xen/acpi.c | 26 +++++++++++++------------- include/linux/acpi.h | 10 +++++----- include/xen/acpi.h | 4 ++-- include/xen/interface/platform.h | 7 ++++--- 8 files changed, 46 insertions(+), 33 deletions(-)
arch/x86/kernel/tboot.c +5 -1
@@ -273,7 +273,8 @@ static void tboot_copy_fadt(const struct 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, uif (!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;
drivers/acpi/acpica/hwesleep.c +8 -0
@@ -43,6 +43,7 @@*/ #include <acpi/acpi.h> +#include <linux/acpi.h> #include "accommon.h" #define _COMPONENT ACPI_HARDWARE
@@ -128,6 +129,13 @@ acpi_status acpi_hw_extended_sleep(u8 slACPI_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
@@ -153,7 +153,7 @@ acpi_status acpi_hw_legacy_sleep(u8 sleeACPI_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))
drivers/acpi/osl.c +8 -8
@@ -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, +bool 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 slereturn AE_OK ; } -void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state, -u32 pm1a_ctrl,u32 pm1b_ctrl)) +void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state,u32 val_a, +u32 val_b,bool extended)) { __acpi_os_prepare_sleep = func; }
drivers/xen/acpi.c +13 -13
@@ -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/linux/acpi.h +5 -5
@@ -486,11 +486,11 @@ static inline bool acpi_driver_match_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)); -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, +bool extended);#ifdef CONFIG_X86 void arch_reserve_mem_area (acpi_physical_address addr,size_t size);#else
@@ -500,7 +500,7 @@ static inline void arch_reserve_mem_area }#endif /* CONFIG_X86 */ #else -#define acpi_os_set_prepare_sleep (func, pm1a_ctrl, pm1b_ctrl) do { } while (0) +#define acpi_os_set_prepare_sleep (func, val_a, val_b, ext) do { } while (0)#endif #if defined(CONFIG_ACPI ) && defined(CONFIG_PM_RUNTIME )
include/xen/acpi.h +2 -2
@@ -75,8 +75,8 @@ static inline int xen_acpi_get_pxm(acpi_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
@@ -152,10 +152,11 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmwar#define XENPF_enter_acpi_sleep 51struct 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);
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 ofgit://xenbits.xen.org/xen.git.
---
v2: Extend description to include reference to hypervisor side change.
--- arch/x86/kernel/tboot.c | 6 +++++- drivers/acpi/acpica/hwesleep.c | 8 ++++++++ drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/osl.c | 16 ++++++++-------- drivers/xen/acpi.c | 26 +++++++++++++------------- include/linux/acpi.h | 10 +++++----- include/xen/acpi.h | 4 ++-- include/xen/interface/platform.h | 7 ++++--- 8 files changed, 46 insertions(+), 33 deletions(-)
arch/x86/kernel/tboot.c +5 -1
@@ -273,7 +273,8 @@ static void tboot_copy_fadt(const struct 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, uif (!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;
drivers/acpi/acpica/hwesleep.c +8 -0
@@ -43,6 +43,7 @@*/ #include <acpi/acpi.h> +#include <linux/acpi.h> #include "accommon.h" #define _COMPONENT ACPI_HARDWARE
@@ -128,6 +129,13 @@ acpi_status acpi_hw_extended_sleep(u8 slACPI_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
@@ -153,7 +153,7 @@ acpi_status acpi_hw_legacy_sleep(u8 sleeACPI_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))
drivers/acpi/osl.c +8 -8
@@ -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, +bool 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 slereturn AE_OK ; } -void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state, -u32 pm1a_ctrl,u32 pm1b_ctrl)) +void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state,u32 val_a, +u32 val_b,bool extended)) { __acpi_os_prepare_sleep = func; }
drivers/xen/acpi.c +13 -13
@@ -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/linux/acpi.h +5 -5
@@ -486,11 +486,11 @@ static inline bool acpi_driver_match_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)); -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, +bool extended);#ifdef CONFIG_X86 void arch_reserve_mem_area (acpi_physical_address addr,size_t size);#else
@@ -500,7 +500,7 @@ static inline void arch_reserve_mem_area }#endif /* CONFIG_X86 */ #else -#define acpi_os_set_prepare_sleep (func, pm1a_ctrl, pm1b_ctrl) do { } while (0) +#define acpi_os_set_prepare_sleep (func, val_a, val_b, ext) do { } while (0)#endif #if defined(CONFIG_ACPI ) && defined(CONFIG_PM_RUNTIME )
include/xen/acpi.h +2 -2
@@ -75,8 +75,8 @@ static inline int xen_acpi_get_pxm(acpi_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
@@ -152,10 +152,11 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmwar#define XENPF_enter_acpi_sleep 51struct 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);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v2 1/1 Xen/ACPI: support sleep state entering on hardware reduced systems
In reply to Konrad Rzeszutek WilkIn 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 ofgit://xenbits.xen.org/xen.git.
---
v2: Extend description to include reference to hypervisor side change.
--- arch/x86/kernel/tboot.c | 6 +++++- drivers/acpi/acpica/hwesleep.c | 8 ++++++++ drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/osl.c | 16 ++++++++-------- drivers/xen/acpi.c | 26 +++++++++++++------------- include/linux/acpi.h | 10 +++++----- include/xen/acpi.h | 4 ++-- include/xen/interface/platform.h | 7 ++++--- 8 files changed, 46 insertions(+), 33 deletions(-)
arch/x86/kernel/tboot.c +5 -1
@@ -273,7 +273,8 @@ static void tboot_copy_fadt(const struct 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, uif (!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;
drivers/acpi/acpica/hwesleep.c +8 -0
@@ -43,6 +43,7 @@*/ #include <acpi/acpi.h> +#include <linux/acpi.h> #include "accommon.h" #define _COMPONENT ACPI_HARDWARE
@@ -128,6 +129,13 @@ acpi_status acpi_hw_extended_sleep(u8 slACPI_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
@@ -153,7 +153,7 @@ acpi_status acpi_hw_legacy_sleep(u8 sleeACPI_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))
drivers/acpi/osl.c +8 -8
@@ -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, +bool 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 slereturn AE_OK ; } -void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state, -u32 pm1a_ctrl,u32 pm1b_ctrl)) +void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state,u32 val_a, +u32 val_b,bool extended)) { __acpi_os_prepare_sleep = func; }
drivers/xen/acpi.c +13 -13
@@ -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/linux/acpi.h +5 -5
@@ -486,11 +486,11 @@ static inline bool acpi_driver_match_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)); -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, +bool extended);#ifdef CONFIG_X86 void arch_reserve_mem_area (acpi_physical_address addr,size_t size);#else
@@ -500,7 +500,7 @@ static inline void arch_reserve_mem_area }#endif /* CONFIG_X86 */ #else -#define acpi_os_set_prepare_sleep (func, pm1a_ctrl, pm1b_ctrl) do { } while (0) +#define acpi_os_set_prepare_sleep (func, val_a, val_b, ext) do { } while (0)#endif #if defined(CONFIG_ACPI ) && defined(CONFIG_PM_RUNTIME )
include/xen/acpi.h +2 -2
@@ -75,8 +75,8 @@ static inline int xen_acpi_get_pxm(acpi_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
@@ -152,10 +152,11 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmwar#define XENPF_enter_acpi_sleep 51struct 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);
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 ofgit://xenbits.xen.org/xen.git.
---
v2: Extend description to include reference to hypervisor side change.
--- arch/x86/kernel/tboot.c | 6 +++++- drivers/acpi/acpica/hwesleep.c | 8 ++++++++ drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/osl.c | 16 ++++++++-------- drivers/xen/acpi.c | 26 +++++++++++++------------- include/linux/acpi.h | 10 +++++----- include/xen/acpi.h | 4 ++-- include/xen/interface/platform.h | 7 ++++--- 8 files changed, 46 insertions(+), 33 deletions(-)
arch/x86/kernel/tboot.c +5 -1
@@ -273,7 +273,8 @@ static void tboot_copy_fadt(const struct 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, uif (!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;
drivers/acpi/acpica/hwesleep.c +8 -0
@@ -43,6 +43,7 @@*/ #include <acpi/acpi.h> +#include <linux/acpi.h> #include "accommon.h" #define _COMPONENT ACPI_HARDWARE
@@ -128,6 +129,13 @@ acpi_status acpi_hw_extended_sleep(u8 slACPI_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
@@ -153,7 +153,7 @@ acpi_status acpi_hw_legacy_sleep(u8 sleeACPI_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))
drivers/acpi/osl.c +8 -8
@@ -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, +bool 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 slereturn AE_OK ; } -void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state, -u32 pm1a_ctrl,u32 pm1b_ctrl)) +void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state,u32 val_a, +u32 val_b,bool extended)) { __acpi_os_prepare_sleep = func; }
drivers/xen/acpi.c +13 -13
@@ -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/linux/acpi.h +5 -5
@@ -486,11 +486,11 @@ static inline bool acpi_driver_match_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)); -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, +bool extended);#ifdef CONFIG_X86 void arch_reserve_mem_area (acpi_physical_address addr,size_t size);#else
@@ -500,7 +500,7 @@ static inline void arch_reserve_mem_area }#endif /* CONFIG_X86 */ #else -#define acpi_os_set_prepare_sleep (func, pm1a_ctrl, pm1b_ctrl) do { } while (0) +#define acpi_os_set_prepare_sleep (func, val_a, val_b, ext) do { } while (0)#endif #if defined(CONFIG_ACPI ) && defined(CONFIG_PM_RUNTIME )
include/xen/acpi.h +2 -2
@@ -75,8 +75,8 @@ static inline int xen_acpi_get_pxm(acpi_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
@@ -152,10 +152,11 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmwar#define XENPF_enter_acpi_sleep 51struct 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);
Quoted 22 lines · Jan Beulich
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.Signed-off-by Jan Beulich <[email protected]>Cc Richard L Maliszewski <[email protected]>Cc Gang Wei <[email protected]>Cc Shane Wang <[email protected]>---
v2: Extend description to include reference to hypervisor side change.
Quoted 10 lines
--- arch/x86/kernel/tboot.c | 6 +++++- drivers/acpi/acpica/hwesleep.c | 8 ++++++++ drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/osl.c | 16 ++++++++-------- drivers/xen/acpi.c | 26 +++++++++++++------------- include/linux/acpi.h | 10 +++++----- include/xen/acpi.h | 4 ++-- include/xen/interface/platform.h | 7 ++++--- 8 files changed, 46 insertions(+), 33 deletions(-)
ACPICA changes (hwesleep.c and hwsleep.c) need to go separately and through the upstream ACPICA before we can take them into the kernel. Sorry about that.
Thanks,
Rafael
Quoted 201 lines
arch/x86/kernel/tboot.c +5
-1@@ -273,7 +273,8 @@ static void tboot_copy_fadt(const struct 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, uif (!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;drivers/acpi/acpica/hwesleep.c +8
-0@@ -43,6 +43,7 @@*/ #include <acpi/acpi.h> +#include <linux/acpi.h> #include "accommon.h" #define _COMPONENT ACPI_HARDWARE@@ -128,6 +129,13 @@ acpi_status acpi_hw_extended_sleep(u8 slACPI_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@@ -153,7 +153,7 @@ acpi_status acpi_hw_legacy_sleep(u8 sleeACPI_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))drivers/acpi/osl.c +8
-8@@ -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, +bool 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 slereturn AE_OK ; } -void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state, -u32 pm1a_ctrl,u32 pm1b_ctrl)) +void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state,u32 val_a, +u32 val_b,bool extended)) { __acpi_os_prepare_sleep = func; }drivers/xen/acpi.c +13
-13@@ -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/linux/acpi.h +5
-5@@ -486,11 +486,11 @@ static inline bool acpi_driver_match_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)); -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, +bool extended);#ifdef CONFIG_X86 void arch_reserve_mem_area (acpi_physical_address addr,size_t size);#else @@ -500,7 +500,7 @@ static inline void arch_reserve_mem_area }#endif /* CONFIG_X86 */ #else -#define acpi_os_set_prepare_sleep (func, pm1a_ctrl, pm1b_ctrl) do { } while (0) +#define acpi_os_set_prepare_sleep (func, val_a, val_b, ext) do { } while (0)#endif #if defined(CONFIG_ACPI ) && defined(CONFIG_PM_RUNTIME )include/xen/acpi.h +2
-2@@ -75,8 +75,8 @@ static inline int xen_acpi_get_pxm(acpi_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@@ -152,10 +152,11 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmwar#define XENPF_enter_acpi_sleep 51struct 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 · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Quoted 35 lines
Quoted 1 line
Quoted 1 line · Rafael J. Wysocki
Quoted 22 lines · Jan Beulich
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.Signed-off-by Jan Beulich <[email protected]>Cc Richard L Maliszewski <[email protected]>Cc Gang Wei <[email protected]>Cc Shane Wang <[email protected]>---
v2: Extend description to include reference to hypervisor side change.Quoted 10 lines
--- arch/x86/kernel/tboot.c | 6 +++++- drivers/acpi/acpica/hwesleep.c | 8 ++++++++ drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/osl.c | 16 ++++++++-------- drivers/xen/acpi.c | 26 +++++++++++++------------- include/linux/acpi.h | 10 +++++----- include/xen/acpi.h | 4 ++-- include/xen/interface/platform.h | 7 ++++--- 8 files changed, 46 insertions(+), 33 deletions(-)
Quoted 3 lines
ACPICA changes (
hwesleep.candhwsleep.c) need to go separately and through the
upstream ACPICA before we can take them into the kernel. Sorry about that.
Looking at 09f98a8 (the change originally introducing the hook) and comparing with the rest of the changes to hwsleep.c, I would think this one didn't come from the ACPICA tree either.
But anyway - if I really need to do that, are there any pointers as to where to submit this to, and how to make sure it gets picked up rather sooner than later?
Jan
Quoted 35 lines
Quoted 1 line
Quoted 1 line · Rafael J. Wysocki
Quoted 22 lines · Jan Beulich
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.Signed-off-by Jan Beulich <[email protected]>Cc Richard L Maliszewski <[email protected]>Cc Gang Wei <[email protected]>Cc Shane Wang <[email protected]>---
v2: Extend description to include reference to hypervisor side change.Quoted 10 lines
--- arch/x86/kernel/tboot.c | 6 +++++- drivers/acpi/acpica/hwesleep.c | 8 ++++++++ drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/osl.c | 16 ++++++++-------- drivers/xen/acpi.c | 26 +++++++++++++------------- include/linux/acpi.h | 10 +++++----- include/xen/acpi.h | 4 ++-- include/xen/interface/platform.h | 7 ++++--- 8 files changed, 46 insertions(+), 33 deletions(-)
Quoted 3 lines
ACPICA changes (
hwesleep.candhwsleep.c) need to go separately and through the
upstream ACPICA before we can take them into the kernel. Sorry about that.
Looking at 09f98a8 (the change originally introducing the hook) and comparing with the rest of the changes to hwsleep.c, I would think this one didn't come from the ACPICA tree either.
But anyway - if I really need to do that, are there any pointers as to where to submit this to, and how to make sure it gets picked up rather sooner than later?
Jan
Quoted 35 lines · Jan Beulich
Quoted 35 lines
Quoted 1 line
Quoted 1 line · Rafael J. Wysocki
Quoted 32 lines · Jan Beulich
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.Signed-off-by Jan Beulich <[email protected]>Cc Richard L Maliszewski <[email protected]>Cc Gang Wei <[email protected]>Cc Shane Wang <[email protected]>---
v2: Extend description to include reference to hypervisor side change.--- arch/x86/kernel/tboot.c | 6 +++++- drivers/acpi/acpica/hwesleep.c | 8 ++++++++ drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/osl.c | 16 ++++++++-------- drivers/xen/acpi.c | 26 +++++++++++++------------- include/linux/acpi.h | 10 +++++----- include/xen/acpi.h | 4 ++-- include/xen/interface/platform.h | 7 ++++--- 8 files changed, 46 insertions(+), 33 deletions(-)
Quoted 7 lines
Quoted 3 lines
ACPICA changes (
hwesleep.candhwsleep.c) need to go separately and through the
upstream ACPICA before we can take them into the kernel. Sorry about that.Looking at 09f98a8 (the change originally introducing the hook) and comparing with the rest of the changes to
hwsleep.c, I would think this one didn't come from the ACPICA tree either.
No, it didn't, but the policy has changed since then.
Quoted 3 lines
But anyway - if I really need to do that, are there any pointers as to where to submit this to, and how to make sure it gets picked up rather sooner than later?
You can submit it to linux-acpi as before, but as separate patches and please CC me and Bob Moore on that submission.
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Quoted 35 lines · Jan Beulich
Quoted 35 lines
Quoted 1 line
Quoted 1 line · Rafael J. Wysocki
Quoted 32 lines · Jan Beulich
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.Signed-off-by Jan Beulich <[email protected]>Cc Richard L Maliszewski <[email protected]>Cc Gang Wei <[email protected]>Cc Shane Wang <[email protected]>---
v2: Extend description to include reference to hypervisor side change.--- arch/x86/kernel/tboot.c | 6 +++++- drivers/acpi/acpica/hwesleep.c | 8 ++++++++ drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/osl.c | 16 ++++++++-------- drivers/xen/acpi.c | 26 +++++++++++++------------- include/linux/acpi.h | 10 +++++----- include/xen/acpi.h | 4 ++-- include/xen/interface/platform.h | 7 ++++--- 8 files changed, 46 insertions(+), 33 deletions(-)
Quoted 7 lines
Quoted 3 lines
ACPICA changes (
hwesleep.candhwsleep.c) need to go separately and through the
upstream ACPICA before we can take them into the kernel. Sorry about that.Looking at 09f98a8 (the change originally introducing the hook) and comparing with the rest of the changes to
hwsleep.c, I would think this one didn't come from the ACPICA tree either.
No, it didn't, but the policy has changed since then.
Quoted 3 lines
But anyway - if I really need to do that, are there any pointers as to where to submit this to, and how to make sure it gets picked up rather sooner than later?
You can submit it to linux-acpi as before, but as separate patches and please CC me and Bob Moore on that submission.
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Quoted 1 line
Quoted 1 line
+#include <
linux/acpi.h>
This line shouldn't appear in ACPICA codes (drivers/acpi/acpica). Please try to declare OSL interfaces via include/acpi/platform/aclinux.h.
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ status = acpi_os_prepare_sleep(sleep_state, acpi_gbl_sleep_type_a, + acpi_gbl_sleep_type_b, true);
bool is not used in ACPICA, please try u8 instead.
Quoted 3 lines
drivers/acpi/acpica/hwsleep.c acpi_status acpi_hw_legacy_sleep(u8 slee · line 156
Quoted 3 lines
drivers/acpi/acpica/hwsleep.c +1
-1status =acpi_os_prepare_sleep (sleep_state, pm1a_control, - pm1b_control); + pm1b_control, false);
Likewise.
Quoted 4 lines
drivers/acpi/osl.c acpi_status acpi_os_terminate(void) · line 1761
Quoted 4 lines
drivers/acpi/osl.c +2
-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, +bool extended)
Is this an ACPICA OSL interface? Then it should not include bool parameter.
Thanks
-Lv
Quoted 1 line
Quoted 1 line
+#include <
linux/acpi.h>
This line shouldn't appear in ACPICA codes (drivers/acpi/acpica). Please try to declare OSL interfaces via include/acpi/platform/aclinux.h.
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ status = acpi_os_prepare_sleep(sleep_state, acpi_gbl_sleep_type_a, + acpi_gbl_sleep_type_b, true);
bool is not used in ACPICA, please try u8 instead.
Quoted 3 lines
drivers/acpi/acpica/hwsleep.c acpi_status acpi_hw_legacy_sleep(u8 slee · line 156
Quoted 3 lines
drivers/acpi/acpica/hwsleep.c +1
-1status =acpi_os_prepare_sleep (sleep_state, pm1a_control, - pm1b_control); + pm1b_control, false);
Likewise.
Quoted 4 lines
drivers/acpi/osl.c acpi_status acpi_os_terminate(void) · line 1761
Quoted 4 lines
drivers/acpi/osl.c +2
-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, +bool extended)
Is this an ACPICA OSL interface? Then it should not include bool parameter.
Thanks
-Lv
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines · Lv
+#include <
linux/acpi.h>This line shouldn't appear in ACPICA codes (
drivers/acpi/acpica). Please try to declare OSL interfaces viainclude/acpi/platform/aclinux.h.
I'm sorry, but why am I not permitted to follow code that's already there:
- hwsleep.c already includes linux/acpi.h
- acpi_os_set_prepare_sleep() and acpi_os_prepare_sleep() are both declared/stubbed out in linux/acpi.h
I'm particularly not intending to do cleanup work on ACPICA just so that I can subsequently fix incomplete code.
Rafael, with that in mind, your request to submit the ACPICA changes separately is impossible: The hook functions just can't have a declaration in the non-Linux ACPI headers (or else they wouldn't currently live in linux/acpi.h). Hence breaking up the patch in the way you asked me to will not even compile without first cleaning up the existing code. And again - I'm sorry, no, that's not something I was looking forward to do.
Quoted 5 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ status = acpi_os_prepare_sleep(sleep_state, acpi_gbl_sleep_type_a, + acpi_gbl_sleep_type_b, true);bool is not used in ACPICA, please try u8 instead.
Can do, but again - why am I not permitted to follow what's already there? acglobal.h has
bool ACPI_INIT_GLOBAL(acpi_gbl_enable_aml_debug_object, FALSE);
The more that the declaration, as pointed out above, lives in linux/acpi.h (and did so even _before_ this patch), i.e. isn't an ACPICA one.
Quoted 6 lines
Quoted 3 lines
drivers/acpi/acpica/hwsleep.c acpi_status acpi_hw_legacy_sleep(u8 slee · line 156
Quoted 3 lines
drivers/acpi/acpica/hwsleep.c +1
-1status =acpi_os_prepare_sleep (sleep_state, pm1a_control, - pm1b_control); + pm1b_control, false);Likewise.
Quoted 6 lines
Quoted 4 lines
drivers/acpi/osl.c acpi_status acpi_os_terminate(void) · line 1761
Quoted 4 lines
drivers/acpi/osl.c +2
-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, +bool extended)Is this an ACPICA OSL interface? Then it should not include bool parameter.
Returning the question: Given the current placement of declarations, it isn't. But if the current layout is wrong, than that needs fixing first. Which in turn likely means that the inconsistency will continue to persist for the next (or the next few) kernel version(s).
Jan
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines · Lv
+#include <
linux/acpi.h>This line shouldn't appear in ACPICA codes (
drivers/acpi/acpica). Please try to declare OSL interfaces viainclude/acpi/platform/aclinux.h.
I'm sorry, but why am I not permitted to follow code that's already there:
- hwsleep.c already includes linux/acpi.h
- acpi_os_set_prepare_sleep() and acpi_os_prepare_sleep() are both declared/stubbed out in linux/acpi.h
I'm particularly not intending to do cleanup work on ACPICA just so that I can subsequently fix incomplete code.
Rafael, with that in mind, your request to submit the ACPICA changes separately is impossible: The hook functions just can't have a declaration in the non-Linux ACPI headers (or else they wouldn't currently live in linux/acpi.h). Hence breaking up the patch in the way you asked me to will not even compile without first cleaning up the existing code. And again - I'm sorry, no, that's not something I was looking forward to do.
Quoted 5 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ status = acpi_os_prepare_sleep(sleep_state, acpi_gbl_sleep_type_a, + acpi_gbl_sleep_type_b, true);bool is not used in ACPICA, please try u8 instead.
Can do, but again - why am I not permitted to follow what's already there? acglobal.h has
bool ACPI_INIT_GLOBAL(acpi_gbl_enable_aml_debug_object, FALSE);
The more that the declaration, as pointed out above, lives in linux/acpi.h (and did so even _before_ this patch), i.e. isn't an ACPICA one.
Quoted 6 lines
Quoted 3 lines
drivers/acpi/acpica/hwsleep.c acpi_status acpi_hw_legacy_sleep(u8 slee · line 156
Quoted 3 lines
drivers/acpi/acpica/hwsleep.c +1
-1status =acpi_os_prepare_sleep (sleep_state, pm1a_control, - pm1b_control); + pm1b_control, false);Likewise.
Quoted 6 lines
Quoted 4 lines
drivers/acpi/osl.c acpi_status acpi_os_terminate(void) · line 1761
Quoted 4 lines
drivers/acpi/osl.c +2
-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, +bool extended)Is this an ACPICA OSL interface? Then it should not include bool parameter.
Returning the question: Given the current placement of declarations, it isn't. But if the current layout is wrong, than that needs fixing first. Which in turn likely means that the inconsistency will continue to persist for the next (or the next few) kernel version(s).
Jan
Sorry for delayed reply.
Quoted 14 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines · Lv
+#include <
linux/acpi.h>This line shouldn't appear in ACPICA codes (
drivers/acpi/acpica). Please try to declare OSL interfaces viainclude/acpi/platform/aclinux.h.I'm sorry, but why am I not permitted to follow code that's already there:
-hwsleep.calready includeslinux/acpi.h
-acpi_os_set_prepare_sleep()andacpi_os_prepare_sleep()are both declared/stubbed out inlinux/acpi.hI'm particularly not intending to do cleanup work on ACPICA just so that I can subsequently fix incomplete code.
Quoted 6 lines
Rafael, with that in mind, your request to submit the ACPICA changes separately is impossible: The hook functions just can't have a declaration in the non-Linux ACPI headers (or else they wouldn't currently live in
linux/acpi.h). Hence breaking up the patch in the way you asked me to will not even compile without first cleaning up the existing code. And again - I'm sorry, no, that's not something I was looking forward to do.
Yes, you can try to use codes already there, but you still can find a way not introducing a new inclusion of <linux/acpi.h> in an ACPICA file. Sorry for the inconvenience.
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ status = acpi_os_prepare_sleep(sleep_state, acpi_gbl_sleep_type_a, + acpi_gbl_sleep_type_b, true);bool is not used in ACPICA, please try u8 instead.
Can do, but again - why am I not permitted to follow what's already there?
acglobal.hhasbool
ACPI_INIT_GLOBAL(acpi_gbl_enable_aml_debug_object, FALSE);
ACPICA is a portable ACPI implementation, where there might be users using compilers not compatible with c99.
This difference is there for another reason:
It is exported as a sysfs entry, it could not be converted back to u8 without introducing new warnings during the current kernel compilation process. At least for now, it is a committed difference.
Or you could wait until the "bool" portable layer to be implemented in the ACPICA.
Quoted 16 lines
The more that the declaration, as pointed out above, lives in
linux/acpi.h(and did so even _before_ this patch), i.e. isn't an ACPICA one.Quoted 6 lines
Quoted 3 lines
drivers/acpi/acpica/hwsleep.c acpi_status acpi_hw_legacy_sleep(u8 slee · line 156
Quoted 3 lines
drivers/acpi/acpica/hwsleep.c +1
-1status =acpi_os_prepare_sleep (sleep_state, pm1a_control, - pm1b_control); + pm1b_control, false);Likewise.
Quoted 6 lines
Quoted 4 lines
drivers/acpi/osl.c acpi_status acpi_os_terminate(void) · line 1761
Quoted 4 lines
drivers/acpi/osl.c +2
-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, +bool extended)Is this an ACPICA OSL interface? Then it should not include bool parameter.
Quoted 4 lines
Returning the question: Given the current placement of declarations, it isn't. But if the current layout is wrong, than that needs fixing first. Which in turn likely means that the inconsistency will continue to persist for the next (or the next few) kernel version(s).
Yes, we may fix this ASAP.
Thanks
-Lv
Sorry for delayed reply.
Quoted 14 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines · Lv
+#include <
linux/acpi.h>This line shouldn't appear in ACPICA codes (
drivers/acpi/acpica). Please try to declare OSL interfaces viainclude/acpi/platform/aclinux.h.I'm sorry, but why am I not permitted to follow code that's already there:
-hwsleep.calready includeslinux/acpi.h
-acpi_os_set_prepare_sleep()andacpi_os_prepare_sleep()are both declared/stubbed out inlinux/acpi.hI'm particularly not intending to do cleanup work on ACPICA just so that I can subsequently fix incomplete code.
Quoted 6 lines
Rafael, with that in mind, your request to submit the ACPICA changes separately is impossible: The hook functions just can't have a declaration in the non-Linux ACPI headers (or else they wouldn't currently live in
linux/acpi.h). Hence breaking up the patch in the way you asked me to will not even compile without first cleaning up the existing code. And again - I'm sorry, no, that's not something I was looking forward to do.
Yes, you can try to use codes already there, but you still can find a way not introducing a new inclusion of <linux/acpi.h> in an ACPICA file. Sorry for the inconvenience.
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ status = acpi_os_prepare_sleep(sleep_state, acpi_gbl_sleep_type_a, + acpi_gbl_sleep_type_b, true);bool is not used in ACPICA, please try u8 instead.
Can do, but again - why am I not permitted to follow what's already there?
acglobal.hhasbool
ACPI_INIT_GLOBAL(acpi_gbl_enable_aml_debug_object, FALSE);
ACPICA is a portable ACPI implementation, where there might be users using compilers not compatible with c99.
This difference is there for another reason:
It is exported as a sysfs entry, it could not be converted back to u8 without introducing new warnings during the current kernel compilation process. At least for now, it is a committed difference.
Or you could wait until the "bool" portable layer to be implemented in the ACPICA.
Quoted 16 lines
The more that the declaration, as pointed out above, lives in
linux/acpi.h(and did so even _before_ this patch), i.e. isn't an ACPICA one.Quoted 6 lines
Quoted 3 lines
drivers/acpi/acpica/hwsleep.c acpi_status acpi_hw_legacy_sleep(u8 slee · line 156
Quoted 3 lines
drivers/acpi/acpica/hwsleep.c +1
-1status =acpi_os_prepare_sleep (sleep_state, pm1a_control, - pm1b_control); + pm1b_control, false);Likewise.
Quoted 6 lines
Quoted 4 lines
drivers/acpi/osl.c acpi_status acpi_os_terminate(void) · line 1761
Quoted 4 lines
drivers/acpi/osl.c +2
-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, +bool extended)Is this an ACPICA OSL interface? Then it should not include bool parameter.
Quoted 4 lines
Returning the question: Given the current placement of declarations, it isn't. But if the current layout is wrong, than that needs fixing first. Which in turn likely means that the inconsistency will continue to persist for the next (or the next few) kernel version(s).
Yes, we may fix this ASAP.
Thanks
-Lv
Quoted 22 lines · Jan Beulich
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.Signed-off-by Jan Beulich <[email protected]>Cc Richard L Maliszewski <[email protected]>Cc Gang Wei <[email protected]>Cc Shane Wang <[email protected]>---
v2: Extend description to include reference to hypervisor side change.
Quoted 10 lines
--- arch/x86/kernel/tboot.c | 6 +++++- drivers/acpi/acpica/hwesleep.c | 8 ++++++++ drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/osl.c | 16 ++++++++-------- drivers/xen/acpi.c | 26 +++++++++++++------------- include/linux/acpi.h | 10 +++++----- include/xen/acpi.h | 4 ++-- include/xen/interface/platform.h | 7 ++++--- 8 files changed, 46 insertions(+), 33 deletions(-)
ACPICA changes (hwesleep.c and hwsleep.c) need to go separately and through the upstream ACPICA before we can take them into the kernel. Sorry about that.
Thanks,
Rafael
Quoted 201 lines
arch/x86/kernel/tboot.c +5
-1@@ -273,7 +273,8 @@ static void tboot_copy_fadt(const struct 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, uif (!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;drivers/acpi/acpica/hwesleep.c +8
-0@@ -43,6 +43,7 @@*/ #include <acpi/acpi.h> +#include <linux/acpi.h> #include "accommon.h" #define _COMPONENT ACPI_HARDWARE@@ -128,6 +129,13 @@ acpi_status acpi_hw_extended_sleep(u8 slACPI_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@@ -153,7 +153,7 @@ acpi_status acpi_hw_legacy_sleep(u8 sleeACPI_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))drivers/acpi/osl.c +8
-8@@ -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, +bool 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 slereturn AE_OK ; } -void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state, -u32 pm1a_ctrl,u32 pm1b_ctrl)) +void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state,u32 val_a, +u32 val_b,bool extended)) { __acpi_os_prepare_sleep = func; }drivers/xen/acpi.c +13
-13@@ -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/linux/acpi.h +5
-5@@ -486,11 +486,11 @@ static inline bool acpi_driver_match_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)); -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, +bool extended);#ifdef CONFIG_X86 void arch_reserve_mem_area (acpi_physical_address addr,size_t size);#else @@ -500,7 +500,7 @@ static inline void arch_reserve_mem_area }#endif /* CONFIG_X86 */ #else -#define acpi_os_set_prepare_sleep (func, pm1a_ctrl, pm1b_ctrl) do { } while (0) +#define acpi_os_set_prepare_sleep (func, val_a, val_b, ext) do { } while (0)#endif #if defined(CONFIG_ACPI ) && defined(CONFIG_PM_RUNTIME )include/xen/acpi.h +2
-2@@ -75,8 +75,8 @@ static inline int xen_acpi_get_pxm(acpi_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@@ -152,10 +152,11 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmwar#define XENPF_enter_acpi_sleep 51struct 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 · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Jan Beulich wrote on 2013-03-11:
Quoted 35 lines
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.Signed-off-by Jan Beulich <[email protected]>Cc Richard L Maliszewski <[email protected]>Cc Gang Wei <[email protected]>Cc Shane Wang <[email protected]>---
v2: Extend description to include reference to hypervisor side change.--- arch/x86/kernel/tboot.c | 6 +++++- drivers/acpi/acpica/hwesleep.c | 8 ++++++++ drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/osl.c | 16 ++++++++-------- drivers/xen/acpi.c | 26 +++++++++++++------------- include/linux/acpi.h | 10 +++++----- include/xen/acpi.h | 4 ++-- include/xen/interface/platform.h | 7 ++++--- 8 files changed, 46 insertions(+), 33 deletions(-)
arch/x86/kernel/tboot.c static void tboot_copy_fadt(const struct · line 275
Quoted 3 lines
arch/x86/kernel/tboot.c +0
-1@@ -273,7 +273,8 @@ static void tboot_copy_fadt(const struct offsetof(struct acpi_table_facs , firmware_waking_vector); } -static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32
pm1b_control)
arch/x86/kernel/tboot.c static void tboot_copy_fadt(const struct · line 275
Quoted 1 line
arch/x86/kernel/tboot.c +1
-0+static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32
pm1b_control,
arch/x86/kernel/tboot.c static void tboot_copy_fadt(const struct · line 277
Quoted 2 lines
arch/x86/kernel/tboot.c +1
-0+ bool extended) {static u32 acpi_shutdown_map[ACPI_S_STATE_COUNT ] = {/*
S0,1,2: */
arch/x86/kernel/tboot.c static int tboot_sleep(u8 sleep_state, u · line 293
Quoted 8 lines
arch/x86/kernel/tboot.c +3
-0-1, -1, -1, @@ -284,6 +285,9 @@ static int tboot_sleep(u8 sleep_state, u 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;
So looks like to make the extended way go further with TXT case other than failing, tboot & its' interface have to be modified to support Reduced Hardware sleeping first, is that true?
Jimmy
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Jan Beulich wrote on 2013-03-11:
Quoted 35 lines
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.Signed-off-by Jan Beulich <[email protected]>Cc Richard L Maliszewski <[email protected]>Cc Gang Wei <[email protected]>Cc Shane Wang <[email protected]>---
v2: Extend description to include reference to hypervisor side change.--- arch/x86/kernel/tboot.c | 6 +++++- drivers/acpi/acpica/hwesleep.c | 8 ++++++++ drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/osl.c | 16 ++++++++-------- drivers/xen/acpi.c | 26 +++++++++++++------------- include/linux/acpi.h | 10 +++++----- include/xen/acpi.h | 4 ++-- include/xen/interface/platform.h | 7 ++++--- 8 files changed, 46 insertions(+), 33 deletions(-)
arch/x86/kernel/tboot.c static void tboot_copy_fadt(const struct · line 275
Quoted 3 lines
arch/x86/kernel/tboot.c +0
-1@@ -273,7 +273,8 @@ static void tboot_copy_fadt(const struct offsetof(struct acpi_table_facs , firmware_waking_vector); } -static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32
pm1b_control)
arch/x86/kernel/tboot.c static void tboot_copy_fadt(const struct · line 275
Quoted 1 line
arch/x86/kernel/tboot.c +1
-0+static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32
pm1b_control,
arch/x86/kernel/tboot.c static void tboot_copy_fadt(const struct · line 277
Quoted 2 lines
arch/x86/kernel/tboot.c +1
-0+ bool extended) {static u32 acpi_shutdown_map[ACPI_S_STATE_COUNT ] = {/*
S0,1,2: */
arch/x86/kernel/tboot.c static int tboot_sleep(u8 sleep_state, u · line 293
Quoted 8 lines
arch/x86/kernel/tboot.c +3
-0-1, -1, -1, @@ -284,6 +285,9 @@ static int tboot_sleep(u8 sleep_state, u 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;
So looks like to make the extended way go further with TXT case other than failing, tboot & its' interface have to be modified to support Reduced Hardware sleeping first, is that true?
Jimmy
Quoted 46 lines
Quoted 1 line
Quoted 1 line · Gang
Jan Beulich wrote on 2013-03-11:
Quoted 35 lines
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.Signed-off-by Jan Beulich <[email protected]>Cc Richard L Maliszewski <[email protected]>Cc Gang Wei <[email protected]>Cc Shane Wang <[email protected]>---
v2: Extend description to include reference to hypervisor side change.--- arch/x86/kernel/tboot.c | 6 +++++- drivers/acpi/acpica/hwesleep.c | 8 ++++++++ drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/osl.c | 16 ++++++++-------- drivers/xen/acpi.c | 26 +++++++++++++------------- include/linux/acpi.h | 10 +++++----- include/xen/acpi.h | 4 ++-- include/xen/interface/platform.h | 7 ++++--- 8 files changed, 46 insertions(+), 33 deletions(-)arch/x86/kernel/tboot.c static void tboot_copy_fadt(const struct · line 275
Quoted 3 lines
arch/x86/kernel/tboot.c +0
-1@@ -273,7 +273,8 @@ static void tboot_copy_fadt(const struct offsetof(struct acpi_table_facs , firmware_waking_vector); } -static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32
pm1b_control)arch/x86/kernel/tboot.c static void tboot_copy_fadt(const struct · line 275
Quoted 1 line
arch/x86/kernel/tboot.c +1
-0+static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32
pm1b_control,arch/x86/kernel/tboot.c static void tboot_copy_fadt(const struct · line 277
Quoted 2 lines
arch/x86/kernel/tboot.c +1
-0+ bool extended) {static u32 acpi_shutdown_map[ACPI_S_STATE_COUNT ] = {/* S0,1,2: */
Quoted 12 lines
arch/x86/kernel/tboot.c static int tboot_sleep(u8 sleep_state, u · line 293
Quoted 8 lines
arch/x86/kernel/tboot.c +3
-0-1, -1, -1, @@ -284,6 +285,9 @@ static int tboot_sleep(u8 sleep_state, u 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;So looks like to make the extended way go further with TXT case other than failing, tboot & its' interface have to be modified to support Reduced Hardware sleeping first, is that true?
Yes, afaict.
Jan
Quoted 46 lines
Quoted 1 line
Quoted 1 line · Gang
Jan Beulich wrote on 2013-03-11:
Quoted 35 lines
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.Signed-off-by Jan Beulich <[email protected]>Cc Richard L Maliszewski <[email protected]>Cc Gang Wei <[email protected]>Cc Shane Wang <[email protected]>---
v2: Extend description to include reference to hypervisor side change.--- arch/x86/kernel/tboot.c | 6 +++++- drivers/acpi/acpica/hwesleep.c | 8 ++++++++ drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/osl.c | 16 ++++++++-------- drivers/xen/acpi.c | 26 +++++++++++++------------- include/linux/acpi.h | 10 +++++----- include/xen/acpi.h | 4 ++-- include/xen/interface/platform.h | 7 ++++--- 8 files changed, 46 insertions(+), 33 deletions(-)arch/x86/kernel/tboot.c static void tboot_copy_fadt(const struct · line 275
Quoted 3 lines
arch/x86/kernel/tboot.c +0
-1@@ -273,7 +273,8 @@ static void tboot_copy_fadt(const struct offsetof(struct acpi_table_facs , firmware_waking_vector); } -static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32
pm1b_control)arch/x86/kernel/tboot.c static void tboot_copy_fadt(const struct · line 275
Quoted 1 line
arch/x86/kernel/tboot.c +1
-0+static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32
pm1b_control,arch/x86/kernel/tboot.c static void tboot_copy_fadt(const struct · line 277
Quoted 2 lines
arch/x86/kernel/tboot.c +1
-0+ bool extended) {static u32 acpi_shutdown_map[ACPI_S_STATE_COUNT ] = {/* S0,1,2: */
Quoted 12 lines
arch/x86/kernel/tboot.c static int tboot_sleep(u8 sleep_state, u · line 293
Quoted 8 lines
arch/x86/kernel/tboot.c +3
-0-1, -1, -1, @@ -284,6 +285,9 @@ static int tboot_sleep(u8 sleep_state, u 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;So looks like to make the extended way go further with TXT case other than failing, tboot & its' interface have to be modified to support Reduced Hardware sleeping first, is that true?
Yes, afaict.
Jan
Quoted 7 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Could the commit should also mention what version of the Xen hypervisor supports this new flag and takes action on it?
Do you really think this is needed? I generally try to stay away from doing such, since backports can easily invalidate such statements.
Perhaps just mention the title of the patch in the Xen tree?
Quoted 5 lines
Quoted 3 lines
Besides that little nit-pick it looks OK to me. Are there any changes neccessary on the IA64 or ARM side for this?
Xen on IA64 is dead, so I don't see any need for further action
You are touching generic ACPI code. My question was in terms of the Linux ACPI IA64 code.
Quoted 2 lines
there. And I don't think ARM has any ACPI enablement so far (on the Xen side at least).
And also on the Linux side by just doing a quick grep. Surely that will change at some point.
Quoted 9 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 5 lines · Jan Beulich
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.
Ooops.
Quoted 8 lines
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).
Signed-off-by Jan Beulich <[email protected]>Cc Richard L Maliszewski <[email protected]>
CC: Rafael since he is the ACPI maintainer nowadays. Len is concentrating on Intel-Idle.
Quoted 200 lines
Cc Gang Wei <[email protected]>Cc Shane Wang <[email protected]>--- arch/x86/kernel/tboot.c | 6 +++++- drivers/acpi/acpica/hwesleep.c | 8 ++++++++ drivers/acpi/acpica/hwsleep.c | 2 +- drivers/acpi/osl.c | 16 ++++++++-------- drivers/xen/acpi.c | 26 +++++++++++++------------- include/linux/acpi.h | 10 +++++----- include/xen/acpi.h | 4 ++-- include/xen/interface/platform.h | 7 ++++--- 8 files changed, 46 insertions(+), 33 deletions(-)arch/x86/kernel/tboot.c +5
-1@@ -273,7 +273,8 @@ static void tboot_copy_fadt(const struct 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, uif (!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;drivers/acpi/acpica/hwesleep.c +8
-0@@ -43,6 +43,7 @@*/ #include <acpi/acpi.h> +#include <linux/acpi.h> #include "accommon.h" #define _COMPONENT ACPI_HARDWARE@@ -128,6 +129,13 @@ acpi_status acpi_hw_extended_sleep(u8 slACPI_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@@ -153,7 +153,7 @@ acpi_status acpi_hw_legacy_sleep(u8 sleeACPI_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))drivers/acpi/osl.c +8
-8@@ -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, +bool 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 slereturn AE_OK ; } -void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state, -u32 pm1a_ctrl,u32 pm1b_ctrl)) +void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state,u32 val_a, +u32 val_b,bool extended)) { __acpi_os_prepare_sleep = func; }drivers/xen/acpi.c +13
-13@@ -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/linux/acpi.h +5
-5@@ -486,11 +486,11 @@ static inline bool acpi_driver_match_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)); -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, +bool extended);#ifdef CONFIG_X86 void arch_reserve_mem_area (acpi_physical_address addr,size_t size);#else @@ -500,7 +500,7 @@ static inline void arch_reserve_mem_area }#endif /* CONFIG_X86 */ #else -#define acpi_os_set_prepare_sleep (func, pm1a_ctrl, pm1b_ctrl) do { } while (0) +#define acpi_os_set_prepare_sleep (func, val_a, val_b, ext) do { } while (0)#endif #if defined(CONFIG_ACPI ) && defined(CONFIG_PM_RUNTIME )include/xen/acpi.h +2
-2@@ -75,8 +75,8 @@ static inline int xen_acpi_get_pxm(acpi_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 +0
-0@@ -152,10 +152,11 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmwar#define XENPF_enter_acpi_sleep 51
include/xen/interface/platform.h DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmwar · line 159
Quoted 10 lines
include/xen/interface/platform.h +4
-3struct 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_*. */
Could the commit should also mention what version of the Xen hypervisor supports this new flag and takes action on it?
Besides that little nit-pick it looks OK to me. Are there any changes neccessary on the IA64 or ARM side for this?
Quoted 5 lines
include/xen/interface/platform.h +0
-0};DEFINE_GUEST_HANDLE_STRUCT (xenpf_enter_acpi_sleep_t);