diff options
author | Lv Zheng <lv.zheng@intel.com> | 2016-12-28 10:28:49 +0300 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2017-01-03 01:18:41 +0300 |
commit | 0fc5e8f4e4b33ddfa1d1d673fcd420d6e13eb076 (patch) | |
tree | 98882708adde1882b7aa110832c85df4b574a307 /drivers | |
parent | fcfb45531d7ef71a19caaa0a983611ca57ec04fe (diff) | |
download | linux-0fc5e8f4e4b33ddfa1d1d673fcd420d6e13eb076.tar.xz |
ACPICA: Hardware: Add sleep register hooks
ACPICA commit ba665dc8e20d9f7730466a659564dd6c557a6cbc
In Linux, para-virtualization implmentation hooks critical register
writes to prevent real hardware operations. This increases divergences
when the sleep registers are cracked in Linux resident ACPICA.
This patch tries to introduce a single OSL to reduce the divergences.
Link: https://github.com/acpica/acpica/commit/ba665dc8
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/acpi/acpica/hwesleep.c | 35 | ||||
-rw-r--r-- | drivers/acpi/acpica/hwsleep.c | 11 | ||||
-rw-r--r-- | drivers/acpi/osl.c | 27 |
3 files changed, 47 insertions, 26 deletions
diff --git a/drivers/acpi/acpica/hwesleep.c b/drivers/acpi/acpica/hwesleep.c index 3f2fb4b31fdc..9023a1b87a54 100644 --- a/drivers/acpi/acpica/hwesleep.c +++ b/drivers/acpi/acpica/hwesleep.c @@ -43,7 +43,6 @@ */ #include <acpi/acpi.h> -#include <linux/acpi.h> #include "accommon.h" #define _COMPONENT ACPI_HARDWARE @@ -103,7 +102,7 @@ void acpi_hw_execute_sleep_method(char *method_pathname, u32 integer_argument) acpi_status acpi_hw_extended_sleep(u8 sleep_state) { acpi_status status; - u8 sleep_type_value; + u8 sleep_control; u64 sleep_status; ACPI_FUNCTION_TRACE(hw_extended_sleep); @@ -125,18 +124,6 @@ acpi_status acpi_hw_extended_sleep(u8 sleep_state) acpi_gbl_system_awake_and_running = FALSE; - /* Flush caches, as per ACPI specification */ - - ACPI_FLUSH_CPU_CACHE(); - - status = acpi_os_prepare_extended_sleep(sleep_state, - acpi_gbl_sleep_type_a, - acpi_gbl_sleep_type_b); - if (ACPI_SKIP(status)) - return_ACPI_STATUS(AE_OK); - if (ACPI_FAILURE(status)) - return_ACPI_STATUS(status); - /* * Set the SLP_TYP and SLP_EN bits. * @@ -146,12 +133,22 @@ acpi_status acpi_hw_extended_sleep(u8 sleep_state) ACPI_DEBUG_PRINT((ACPI_DB_INIT, "Entering sleep state [S%u]\n", sleep_state)); - sleep_type_value = - ((acpi_gbl_sleep_type_a << ACPI_X_SLEEP_TYPE_POSITION) & - ACPI_X_SLEEP_TYPE_MASK); + sleep_control = ((acpi_gbl_sleep_type_a << ACPI_X_SLEEP_TYPE_POSITION) & + ACPI_X_SLEEP_TYPE_MASK) | ACPI_X_SLEEP_ENABLE; + + /* Flush caches, as per ACPI specification */ + + ACPI_FLUSH_CPU_CACHE(); + + status = acpi_os_enter_sleep(sleep_state, sleep_control, 0); + if (status == AE_CTRL_TERMINATE) { + return_ACPI_STATUS(AE_OK); + } + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } - status = acpi_write((u64)(sleep_type_value | ACPI_X_SLEEP_ENABLE), - &acpi_gbl_FADT.sleep_control); + status = acpi_write((u64)sleep_control, &acpi_gbl_FADT.sleep_control); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c index d00c9810845b..563c5d91663f 100644 --- a/drivers/acpi/acpica/hwsleep.c +++ b/drivers/acpi/acpica/hwsleep.c @@ -43,7 +43,6 @@ */ #include <acpi/acpi.h> -#include <linux/acpi.h> #include "accommon.h" #define _COMPONENT ACPI_HARDWARE @@ -152,12 +151,14 @@ acpi_status acpi_hw_legacy_sleep(u8 sleep_state) ACPI_FLUSH_CPU_CACHE(); - status = acpi_os_prepare_sleep(sleep_state, pm1a_control, - pm1b_control); - if (ACPI_SKIP(status)) + status = acpi_os_enter_sleep(sleep_state, pm1a_control, pm1b_control); + if (status == AE_CTRL_TERMINATE) { return_ACPI_STATUS(AE_OK); - if (ACPI_FAILURE(status)) + } + if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); + } + /* Write #2: Write both SLP_TYP + SLP_EN */ status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control); diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 57fb5f468ac2..db78d353bab1 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -1686,7 +1686,7 @@ acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 pm1a_control, if (rc < 0) return AE_ERROR; else if (rc > 0) - return AE_CTRL_SKIP; + return AE_CTRL_TERMINATE; return AE_OK; } @@ -1697,6 +1697,7 @@ void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, __acpi_os_prepare_sleep = func; } +#if (ACPI_REDUCED_HARDWARE) acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b) { @@ -1707,13 +1708,35 @@ acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state, u32 val_a, if (rc < 0) return AE_ERROR; else if (rc > 0) - return AE_CTRL_SKIP; + return AE_CTRL_TERMINATE; return AE_OK; } +#else +acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state, u32 val_a, + u32 val_b) +{ + return AE_OK; +} +#endif void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state, u32 val_a, u32 val_b)) { __acpi_os_prepare_extended_sleep = func; } + +acpi_status acpi_os_enter_sleep(u8 sleep_state, + u32 reg_a_value, u32 reg_b_value) +{ + acpi_status status; + + if (acpi_gbl_reduced_hardware) + status = acpi_os_prepare_extended_sleep(sleep_state, + reg_a_value, + reg_b_value); + else + status = acpi_os_prepare_sleep(sleep_state, + reg_a_value, reg_b_value); + return status; +} |