diff options
Diffstat (limited to 'drivers/acpi/sleep.c')
| -rw-r--r-- | drivers/acpi/sleep.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 3fb4bdea7e06..5b7c52e4a00f 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c | |||
| @@ -114,6 +114,8 @@ static int __acpi_pm_prepare(void) | |||
| 114 | { | 114 | { |
| 115 | int error = acpi_sleep_prepare(acpi_target_sleep_state); | 115 | int error = acpi_sleep_prepare(acpi_target_sleep_state); |
| 116 | 116 | ||
| 117 | suspend_nvs_save(); | ||
| 118 | |||
| 117 | if (error) | 119 | if (error) |
| 118 | acpi_target_sleep_state = ACPI_STATE_S0; | 120 | acpi_target_sleep_state = ACPI_STATE_S0; |
| 119 | return error; | 121 | return error; |
| @@ -143,6 +145,9 @@ static void acpi_pm_finish(void) | |||
| 143 | { | 145 | { |
| 144 | u32 acpi_state = acpi_target_sleep_state; | 146 | u32 acpi_state = acpi_target_sleep_state; |
| 145 | 147 | ||
| 148 | suspend_nvs_free(); | ||
| 149 | acpi_ec_unblock_transactions(); | ||
| 150 | |||
| 146 | if (acpi_state == ACPI_STATE_S0) | 151 | if (acpi_state == ACPI_STATE_S0) |
| 147 | return; | 152 | return; |
| 148 | 153 | ||
| @@ -192,6 +197,11 @@ static int acpi_suspend_begin(suspend_state_t pm_state) | |||
| 192 | u32 acpi_state = acpi_suspend_states[pm_state]; | 197 | u32 acpi_state = acpi_suspend_states[pm_state]; |
| 193 | int error = 0; | 198 | int error = 0; |
| 194 | 199 | ||
| 200 | error = suspend_nvs_alloc(); | ||
| 201 | |||
| 202 | if (error) | ||
| 203 | return error; | ||
| 204 | |||
| 195 | if (sleep_states[acpi_state]) { | 205 | if (sleep_states[acpi_state]) { |
| 196 | acpi_target_sleep_state = acpi_state; | 206 | acpi_target_sleep_state = acpi_state; |
| 197 | acpi_sleep_tts_switch(acpi_target_sleep_state); | 207 | acpi_sleep_tts_switch(acpi_target_sleep_state); |
| @@ -269,12 +279,13 @@ static int acpi_suspend_enter(suspend_state_t pm_state) | |||
| 269 | if (acpi_state == ACPI_STATE_S3) | 279 | if (acpi_state == ACPI_STATE_S3) |
| 270 | acpi_restore_state_mem(); | 280 | acpi_restore_state_mem(); |
| 271 | 281 | ||
| 282 | suspend_nvs_restore(); | ||
| 283 | |||
| 272 | return ACPI_SUCCESS(status) ? 0 : -EFAULT; | 284 | return ACPI_SUCCESS(status) ? 0 : -EFAULT; |
| 273 | } | 285 | } |
| 274 | 286 | ||
| 275 | static void acpi_suspend_finish(void) | 287 | static void acpi_suspend_finish(void) |
| 276 | { | 288 | { |
| 277 | acpi_ec_unblock_transactions(); | ||
| 278 | acpi_pm_finish(); | 289 | acpi_pm_finish(); |
| 279 | } | 290 | } |
| 280 | 291 | ||
| @@ -404,7 +415,7 @@ static int acpi_hibernation_begin(void) | |||
| 404 | { | 415 | { |
| 405 | int error; | 416 | int error; |
| 406 | 417 | ||
| 407 | error = s4_no_nvs ? 0 : hibernate_nvs_alloc(); | 418 | error = s4_no_nvs ? 0 : suspend_nvs_alloc(); |
| 408 | if (!error) { | 419 | if (!error) { |
| 409 | acpi_target_sleep_state = ACPI_STATE_S4; | 420 | acpi_target_sleep_state = ACPI_STATE_S4; |
| 410 | acpi_sleep_tts_switch(acpi_target_sleep_state); | 421 | acpi_sleep_tts_switch(acpi_target_sleep_state); |
| @@ -418,7 +429,7 @@ static int acpi_hibernation_pre_snapshot(void) | |||
| 418 | int error = acpi_pm_prepare(); | 429 | int error = acpi_pm_prepare(); |
| 419 | 430 | ||
| 420 | if (!error) | 431 | if (!error) |
| 421 | hibernate_nvs_save(); | 432 | suspend_nvs_save(); |
| 422 | 433 | ||
| 423 | return error; | 434 | return error; |
| 424 | } | 435 | } |
| @@ -441,13 +452,6 @@ static int acpi_hibernation_enter(void) | |||
| 441 | return ACPI_SUCCESS(status) ? 0 : -EFAULT; | 452 | return ACPI_SUCCESS(status) ? 0 : -EFAULT; |
| 442 | } | 453 | } |
| 443 | 454 | ||
| 444 | static void acpi_hibernation_finish(void) | ||
| 445 | { | ||
| 446 | hibernate_nvs_free(); | ||
| 447 | acpi_ec_unblock_transactions(); | ||
| 448 | acpi_pm_finish(); | ||
| 449 | } | ||
| 450 | |||
| 451 | static void acpi_hibernation_leave(void) | 455 | static void acpi_hibernation_leave(void) |
| 452 | { | 456 | { |
| 453 | /* | 457 | /* |
| @@ -464,7 +468,7 @@ static void acpi_hibernation_leave(void) | |||
| 464 | panic("ACPI S4 hardware signature mismatch"); | 468 | panic("ACPI S4 hardware signature mismatch"); |
| 465 | } | 469 | } |
| 466 | /* Restore the NVS memory area */ | 470 | /* Restore the NVS memory area */ |
| 467 | hibernate_nvs_restore(); | 471 | suspend_nvs_restore(); |
| 468 | /* Allow EC transactions to happen. */ | 472 | /* Allow EC transactions to happen. */ |
| 469 | acpi_ec_unblock_transactions_early(); | 473 | acpi_ec_unblock_transactions_early(); |
| 470 | } | 474 | } |
| @@ -479,7 +483,7 @@ static struct platform_hibernation_ops acpi_hibernation_ops = { | |||
| 479 | .begin = acpi_hibernation_begin, | 483 | .begin = acpi_hibernation_begin, |
| 480 | .end = acpi_pm_end, | 484 | .end = acpi_pm_end, |
| 481 | .pre_snapshot = acpi_hibernation_pre_snapshot, | 485 | .pre_snapshot = acpi_hibernation_pre_snapshot, |
| 482 | .finish = acpi_hibernation_finish, | 486 | .finish = acpi_pm_finish, |
| 483 | .prepare = acpi_pm_prepare, | 487 | .prepare = acpi_pm_prepare, |
| 484 | .enter = acpi_hibernation_enter, | 488 | .enter = acpi_hibernation_enter, |
| 485 | .leave = acpi_hibernation_leave, | 489 | .leave = acpi_hibernation_leave, |
| @@ -507,7 +511,7 @@ static int acpi_hibernation_begin_old(void) | |||
| 507 | 511 | ||
| 508 | if (!error) { | 512 | if (!error) { |
| 509 | if (!s4_no_nvs) | 513 | if (!s4_no_nvs) |
| 510 | error = hibernate_nvs_alloc(); | 514 | error = suspend_nvs_alloc(); |
| 511 | if (!error) | 515 | if (!error) |
| 512 | acpi_target_sleep_state = ACPI_STATE_S4; | 516 | acpi_target_sleep_state = ACPI_STATE_S4; |
| 513 | } | 517 | } |
| @@ -517,7 +521,7 @@ static int acpi_hibernation_begin_old(void) | |||
| 517 | static int acpi_hibernation_pre_snapshot_old(void) | 521 | static int acpi_hibernation_pre_snapshot_old(void) |
| 518 | { | 522 | { |
| 519 | acpi_pm_freeze(); | 523 | acpi_pm_freeze(); |
| 520 | hibernate_nvs_save(); | 524 | suspend_nvs_save(); |
| 521 | return 0; | 525 | return 0; |
| 522 | } | 526 | } |
| 523 | 527 | ||
| @@ -529,8 +533,8 @@ static struct platform_hibernation_ops acpi_hibernation_ops_old = { | |||
| 529 | .begin = acpi_hibernation_begin_old, | 533 | .begin = acpi_hibernation_begin_old, |
| 530 | .end = acpi_pm_end, | 534 | .end = acpi_pm_end, |
| 531 | .pre_snapshot = acpi_hibernation_pre_snapshot_old, | 535 | .pre_snapshot = acpi_hibernation_pre_snapshot_old, |
| 532 | .finish = acpi_hibernation_finish, | ||
| 533 | .prepare = acpi_pm_freeze, | 536 | .prepare = acpi_pm_freeze, |
| 537 | .finish = acpi_pm_finish, | ||
| 534 | .enter = acpi_hibernation_enter, | 538 | .enter = acpi_hibernation_enter, |
| 535 | .leave = acpi_hibernation_leave, | 539 | .leave = acpi_hibernation_leave, |
| 536 | .pre_restore = acpi_pm_freeze, | 540 | .pre_restore = acpi_pm_freeze, |
