Jan Beulich
2013-Mar-11 14:06 UTC
[PATCH v2] Xen/ACPI: support sleep state entering on hardware reduced systems
In version 3.4 acpi_os_prepare_sleep() got introduced in parallel with reduced hardware sleep support, and the two changes didn''t get synchronized: The new code doesn''t call the hook function (if so requested). Fix this, requiring a boolean parameter to be added to the hook function to distinguish "extended" from "legacy" sleep. This requires adjusting TXT, but the adjustments only go as far as failing the extended mode call (since, looking at the TXT interface, there doesn''t even appear to be precautions to deal with that alternative interface). The hypervisor change underlying this is commit 62d1a69 ("ACPI: support v5 (reduced HW) sleep interface") on the master branch of git://xenbits.xen.org/xen.git. Signed-off-by: Jan Beulich <jbeulich@suse.com> Cc: Richard L Maliszewski <richard.l.maliszewski@intel.com> Cc: Gang Wei <gang.wei@intel.com> Cc: Shane Wang <shane.wang@intel.com> --- 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(-) --- 3.9-rc2/arch/x86/kernel/tboot.c +++ 3.9-rc2-xen-ACPI-v5-sleep/arch/x86/kernel/tboot.c @@ -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, 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; --- 3.9-rc2/drivers/acpi/acpica/hwesleep.c +++ 3.9-rc2-xen-ACPI-v5-sleep/drivers/acpi/acpica/hwesleep.c @@ -43,6 +43,7 @@ */ #include <acpi/acpi.h> +#include <linux/acpi.h> #include "accommon.h" #define _COMPONENT ACPI_HARDWARE @@ -128,6 +129,13 @@ acpi_status acpi_hw_extended_sleep(u8 sl ACPI_FLUSH_CPU_CACHE(); + status = acpi_os_prepare_sleep(sleep_state, acpi_gbl_sleep_type_a, + acpi_gbl_sleep_type_b, true); + if (ACPI_SKIP(status)) + return_ACPI_STATUS(AE_OK); + if (ACPI_FAILURE(status)) + return_ACPI_STATUS(status); + /* * Set the SLP_TYP and SLP_EN bits. * --- 3.9-rc2/drivers/acpi/acpica/hwsleep.c +++ 3.9-rc2-xen-ACPI-v5-sleep/drivers/acpi/acpica/hwsleep.c @@ -153,7 +153,7 @@ acpi_status acpi_hw_legacy_sleep(u8 slee ACPI_FLUSH_CPU_CACHE(); status = acpi_os_prepare_sleep(sleep_state, pm1a_control, - pm1b_control); + pm1b_control, false); if (ACPI_SKIP(status)) return_ACPI_STATUS(AE_OK); if (ACPI_FAILURE(status)) --- 3.9-rc2/drivers/acpi/osl.c +++ 3.9-rc2-xen-ACPI-v5-sleep/drivers/acpi/osl.c @@ -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 sle return AE_OK; } -void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, - u32 pm1a_ctrl, u32 pm1b_ctrl)) +void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, u32 val_a, + u32 val_b, bool extended)) { __acpi_os_prepare_sleep = func; } --- 3.9-rc2/drivers/xen/acpi.c +++ 3.9-rc2-xen-ACPI-v5-sleep/drivers/xen/acpi.c @@ -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 xen-devel@lists.xensource.com Thank you.\n", \ - pm1a_cnt, pm1b_cnt); + if (WARN((val_a & (~0 << bits)) || (val_b & (~0 << bits)), + "Using more than %u bits of sleep control values %#x/%#x!" + "Email xen-devel@lists.xen.org - Thank you.\n", \ + bits, val_a, val_b)) return -1; - } HYPERVISOR_dom0_op(&op); return 1; --- 3.9-rc2/include/linux/acpi.h +++ 3.9-rc2-xen-ACPI-v5-sleep/include/linux/acpi.h @@ -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) --- 3.9-rc2/include/xen/acpi.h +++ 3.9-rc2-xen-ACPI-v5-sleep/include/xen/acpi.h @@ -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) { --- 3.9-rc2/include/xen/interface/platform.h +++ 3.9-rc2-xen-ACPI-v5-sleep/include/xen/interface/platform.h @@ -152,10 +152,11 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmwar #define XENPF_enter_acpi_sleep 51 struct xenpf_enter_acpi_sleep { /* IN variables */ - uint16_t pm1a_cnt_val; /* PM1a control value. */ - uint16_t pm1b_cnt_val; /* PM1b control value. */ + uint16_t val_a; /* PM1a control / sleep type A. */ + uint16_t val_b; /* PM1b control / sleep type B. */ uint32_t sleep_state; /* Which state to enter (Sn). */ - uint32_t flags; /* Must be zero. */ +#define XENPF_ACPI_SLEEP_EXTENDED 0x00000001 + uint32_t flags; /* XENPF_ACPI_SLEEP_*. */ }; DEFINE_GUEST_HANDLE_STRUCT(xenpf_enter_acpi_sleep_t); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Rafael J. Wysocki
2013-Mar-11 14:51 UTC
Re: [PATCH v2] Xen/ACPI: support sleep state entering on hardware reduced systems
On Monday, March 11, 2013 02:06:51 PM Jan Beulich wrote:> 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 <jbeulich@suse.com> > Cc: Richard L Maliszewski <richard.l.maliszewski@intel.com> > Cc: Gang Wei <gang.wei@intel.com> > Cc: Shane Wang <shane.wang@intel.com> > --- > 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(-)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> --- 3.9-rc2/arch/x86/kernel/tboot.c > +++ 3.9-rc2-xen-ACPI-v5-sleep/arch/x86/kernel/tboot.c > @@ -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, 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; > --- 3.9-rc2/drivers/acpi/acpica/hwesleep.c > +++ 3.9-rc2-xen-ACPI-v5-sleep/drivers/acpi/acpica/hwesleep.c > @@ -43,6 +43,7 @@ > */ > > #include <acpi/acpi.h> > +#include <linux/acpi.h> > #include "accommon.h" > > #define _COMPONENT ACPI_HARDWARE > @@ -128,6 +129,13 @@ acpi_status acpi_hw_extended_sleep(u8 sl > > ACPI_FLUSH_CPU_CACHE(); > > + status = acpi_os_prepare_sleep(sleep_state, acpi_gbl_sleep_type_a, > + acpi_gbl_sleep_type_b, true); > + if (ACPI_SKIP(status)) > + return_ACPI_STATUS(AE_OK); > + if (ACPI_FAILURE(status)) > + return_ACPI_STATUS(status); > + > /* > * Set the SLP_TYP and SLP_EN bits. > * > --- 3.9-rc2/drivers/acpi/acpica/hwsleep.c > +++ 3.9-rc2-xen-ACPI-v5-sleep/drivers/acpi/acpica/hwsleep.c > @@ -153,7 +153,7 @@ acpi_status acpi_hw_legacy_sleep(u8 slee > ACPI_FLUSH_CPU_CACHE(); > > status = acpi_os_prepare_sleep(sleep_state, pm1a_control, > - pm1b_control); > + pm1b_control, false); > if (ACPI_SKIP(status)) > return_ACPI_STATUS(AE_OK); > if (ACPI_FAILURE(status)) > --- 3.9-rc2/drivers/acpi/osl.c > +++ 3.9-rc2-xen-ACPI-v5-sleep/drivers/acpi/osl.c > @@ -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 sle > return AE_OK; > } > > -void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, > - u32 pm1a_ctrl, u32 pm1b_ctrl)) > +void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, u32 val_a, > + u32 val_b, bool extended)) > { > __acpi_os_prepare_sleep = func; > } > --- 3.9-rc2/drivers/xen/acpi.c > +++ 3.9-rc2-xen-ACPI-v5-sleep/drivers/xen/acpi.c > @@ -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 xen-devel@lists.xensource.com Thank you.\n", \ > - pm1a_cnt, pm1b_cnt); > + if (WARN((val_a & (~0 << bits)) || (val_b & (~0 << bits)), > + "Using more than %u bits of sleep control values %#x/%#x!" > + "Email xen-devel@lists.xen.org - Thank you.\n", \ > + bits, val_a, val_b)) > return -1; > - } > > HYPERVISOR_dom0_op(&op); > return 1; > --- 3.9-rc2/include/linux/acpi.h > +++ 3.9-rc2-xen-ACPI-v5-sleep/include/linux/acpi.h > @@ -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) > --- 3.9-rc2/include/xen/acpi.h > +++ 3.9-rc2-xen-ACPI-v5-sleep/include/xen/acpi.h > @@ -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) > { > --- 3.9-rc2/include/xen/interface/platform.h > +++ 3.9-rc2-xen-ACPI-v5-sleep/include/xen/interface/platform.h > @@ -152,10 +152,11 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmwar > #define XENPF_enter_acpi_sleep 51 > struct xenpf_enter_acpi_sleep { > /* IN variables */ > - uint16_t pm1a_cnt_val; /* PM1a control value. */ > - uint16_t pm1b_cnt_val; /* PM1b control value. */ > + uint16_t val_a; /* PM1a control / sleep type A. */ > + uint16_t val_b; /* PM1b control / sleep type B. */ > uint32_t sleep_state; /* Which state to enter (Sn). */ > - uint32_t flags; /* Must be zero. */ > +#define XENPF_ACPI_SLEEP_EXTENDED 0x00000001 > + uint32_t flags; /* XENPF_ACPI_SLEEP_*. */ > }; > DEFINE_GUEST_HANDLE_STRUCT(xenpf_enter_acpi_sleep_t); > > >-- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Jan Beulich
2013-Mar-11 16:12 UTC
Re: [PATCH v2] Xen/ACPI: support sleep state entering on hardware reduced systems
>>> On 11.03.13 at 15:51, "Rafael J. Wysocki" <rjw@sisk.pl> wrote: > On Monday, March 11, 2013 02:06:51 PM Jan Beulich wrote: >> 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 <jbeulich@suse.com> >> Cc: Richard L Maliszewski <richard.l.maliszewski@intel.com> >> Cc: Gang Wei <gang.wei@intel.com> >> Cc: Shane Wang <shane.wang@intel.com> >> --- >> 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(-) > > 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.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
Rafael J. Wysocki
2013-Mar-11 16:58 UTC
Re: [PATCH v2] Xen/ACPI: support sleep state entering on hardware reduced systems
On Monday, March 11, 2013 04:12:42 PM Jan Beulich wrote:> >>> On 11.03.13 at 15:51, "Rafael J. Wysocki" <rjw@sisk.pl> wrote: > > On Monday, March 11, 2013 02:06:51 PM Jan Beulich wrote: > >> 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 <jbeulich@suse.com> > >> Cc: Richard L Maliszewski <richard.l.maliszewski@intel.com> > >> Cc: Gang Wei <gang.wei@intel.com> > >> Cc: Shane Wang <shane.wang@intel.com> > >> --- > >> 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(-) > > > > 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. > > 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.> 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 -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Zheng, Lv
2013-Mar-12 00:59 UTC
Re: [PATCH v2] Xen/ACPI: support sleep state entering on hardware reduced systems
> > +#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.> > > > + 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.> > status = acpi_os_prepare_sleep(sleep_state, pm1a_control, > > - pm1b_control); > > + pm1b_control, false);Likewise.> > -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
Wei, Gang
2013-Mar-12 06:39 UTC
Re: [PATCH v2] Xen/ACPI: support sleep state entering on hardware reduced systems
Jan Beulich wrote onĀ 2013-03-11:> 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 <jbeulich@suse.com> > Cc: Richard L Maliszewski <richard.l.maliszewski@intel.com> > Cc: Gang Wei <gang.wei@intel.com> > Cc: Shane Wang <shane.wang@intel.com> > --- > 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(-) > --- 3.9-rc2/arch/x86/kernel/tboot.c > +++ 3.9-rc2-xen-ACPI-v5-sleep/arch/x86/kernel/tboot.c > @@ -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, u32pm1b_control)> +static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32pm1b_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, > 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 Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Jan Beulich
2013-Mar-12 07:57 UTC
Re: [PATCH v2] Xen/ACPI: support sleep state entering on hardware reduced systems
>>> On 12.03.13 at 01:59, "Zheng, Lv" <lv.zheng@intel.com> wrote: >> > +#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.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.>> > >> > + 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.>> > status = acpi_os_prepare_sleep(sleep_state, pm1a_control, >> > - pm1b_control); >> > + pm1b_control, false); > > Likewise. > >> > -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
Jan Beulich
2013-Mar-12 07:58 UTC
Re: [PATCH v2] Xen/ACPI: support sleep state entering on hardware reduced systems
>>> On 12.03.13 at 07:39, "Wei, Gang" <gang.wei@intel.com> wrote: > Jan Beulich wrote on 2013-03-11: >> 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 <jbeulich@suse.com> >> Cc: Richard L Maliszewski <richard.l.maliszewski@intel.com> >> Cc: Gang Wei <gang.wei@intel.com> >> Cc: Shane Wang <shane.wang@intel.com> >> --- >> 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(-) >> --- 3.9-rc2/arch/x86/kernel/tboot.c >> +++ 3.9-rc2-xen-ACPI-v5-sleep/arch/x86/kernel/tboot.c >> @@ -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, >> 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
Zheng, Lv
2013-Mar-18 01:46 UTC
Re: [PATCH v2] Xen/ACPI: support sleep state entering on hardware reduced systems
Sorry for delayed reply.> >>> On 12.03.13 at 01:59, "Zheng, Lv" <lv.zheng@intel.com> wrote: > >> > +#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. > > 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.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.> >> > + 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);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.> 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. > > >> > status = acpi_os_prepare_sleep(sleep_state, pm1a_control, > >> > - pm1b_control); > >> > + pm1b_control, false); > > > > Likewise. > > > >> > -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).Yes, we may fix this ASAP. Thanks -Lv