diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2007-04-30 07:37:15 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-05-02 06:04:30 -0400 |
commit | be9c94dd7776467813419f49fabe8017bc2d4c81 (patch) | |
tree | c5ea55aa69f2d1fcfa554f380f554a314b546288 /arch | |
parent | f88df14b1f15cdeffa060580a40c1ce3e13bb79e (diff) |
[POWERPC] Fix suspend states again
In commit 0fba3a1f39f8b0a50b56c8b068fa52131cbc84c2 (a very long time ago,
May 2006), I fixed a bug that caused powermacs to crash when you tried
entering standby/mem suspend states.
As I'm now getting more familiar with the suspend code I notice a few
more things:
1. we previously misunderstood what pm_ops is for, it isn't supposed to be
for doing platform dependent suspend/resume stuff that needs to be done
for suspend to disk (as we currently try to use it!), it is instead for
entering platform dependent suspend states ("standby", "mem").
2. due to the first point, we never properly save FPU and altivec states
when suspending to disk. It probably hasn't hurt yet because the process
that writes the "disk" to /sys/power/state uses neither and its context
is used.
This patch addresses these points as follows:
1. remove all pm_ops from powermac, powermac suspend to ram isn't currently
usable via /sys/power/state but is done via the PMU instead.
2. move the code responsible for storing FPU/altivec state into
save_processor_state and the set_context() call to restore_processor_state.
3. add a call to kernel_enable_spe()
It may look like there is some code removal missing but that is
actually because the new suspend.h file overrides the ppc/suspend.h
one which was previously used.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/kernel/Makefile | 1 | ||||
-rw-r--r-- | arch/powerpc/kernel/swsusp.c | 34 | ||||
-rw-r--r-- | arch/powerpc/platforms/powermac/setup.c | 65 |
3 files changed, 35 insertions, 65 deletions
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index e0fa80eca366..949f36a62aae 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile | |||
@@ -36,6 +36,7 @@ obj-$(CONFIG_GENERIC_TBSYNC) += smp-tbsync.o | |||
36 | obj-$(CONFIG_CRASH_DUMP) += crash_dump.o | 36 | obj-$(CONFIG_CRASH_DUMP) += crash_dump.o |
37 | obj-$(CONFIG_6xx) += idle_6xx.o l2cr_6xx.o cpu_setup_6xx.o | 37 | obj-$(CONFIG_6xx) += idle_6xx.o l2cr_6xx.o cpu_setup_6xx.o |
38 | obj-$(CONFIG_TAU) += tau_6xx.o | 38 | obj-$(CONFIG_TAU) += tau_6xx.o |
39 | obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o | ||
39 | obj32-$(CONFIG_SOFTWARE_SUSPEND) += swsusp_32.o | 40 | obj32-$(CONFIG_SOFTWARE_SUSPEND) += swsusp_32.o |
40 | obj32-$(CONFIG_MODULES) += module_32.o | 41 | obj32-$(CONFIG_MODULES) += module_32.o |
41 | 42 | ||
diff --git a/arch/powerpc/kernel/swsusp.c b/arch/powerpc/kernel/swsusp.c new file mode 100644 index 000000000000..b89e4f5a0b08 --- /dev/null +++ b/arch/powerpc/kernel/swsusp.c | |||
@@ -0,0 +1,34 @@ | |||
1 | /* | ||
2 | * Common powerpc suspend code for 32 and 64 bits | ||
3 | * | ||
4 | * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <linux/sched.h> | ||
13 | #include <asm/suspend.h> | ||
14 | #include <asm/system.h> | ||
15 | #include <asm/current.h> | ||
16 | #include <asm/mmu_context.h> | ||
17 | |||
18 | void save_processor_state(void) | ||
19 | { | ||
20 | /* | ||
21 | * flush out all the special registers so we don't need | ||
22 | * to save them in the snapshot | ||
23 | */ | ||
24 | flush_fp_to_thread(current); | ||
25 | flush_altivec_to_thread(current); | ||
26 | flush_spe_to_thread(current); | ||
27 | } | ||
28 | |||
29 | void restore_processor_state(void) | ||
30 | { | ||
31 | #ifdef CONFIG_PPC32 | ||
32 | set_context(current->active_mm->context.id, current->active_mm->pgd); | ||
33 | #endif | ||
34 | } | ||
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c index b820cabac697..5ae57e17d2ba 100644 --- a/arch/powerpc/platforms/powermac/setup.c +++ b/arch/powerpc/platforms/powermac/setup.c | |||
@@ -439,76 +439,11 @@ static void __init find_boot_device(void) | |||
439 | #endif | 439 | #endif |
440 | } | 440 | } |
441 | 441 | ||
442 | /* TODO: Merge the suspend-to-ram with the common code !!! | ||
443 | * currently, this is a stub implementation for suspend-to-disk | ||
444 | * only | ||
445 | */ | ||
446 | |||
447 | #ifdef CONFIG_SOFTWARE_SUSPEND | ||
448 | |||
449 | static int pmac_pm_prepare(suspend_state_t state) | ||
450 | { | ||
451 | printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state); | ||
452 | |||
453 | return 0; | ||
454 | } | ||
455 | |||
456 | static int pmac_pm_enter(suspend_state_t state) | ||
457 | { | ||
458 | printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state); | ||
459 | |||
460 | /* Giveup the lazy FPU & vec so we don't have to back them | ||
461 | * up from the low level code | ||
462 | */ | ||
463 | enable_kernel_fp(); | ||
464 | |||
465 | #ifdef CONFIG_ALTIVEC | ||
466 | if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC) | ||
467 | enable_kernel_altivec(); | ||
468 | #endif /* CONFIG_ALTIVEC */ | ||
469 | |||
470 | return 0; | ||
471 | } | ||
472 | |||
473 | static int pmac_pm_finish(suspend_state_t state) | ||
474 | { | ||
475 | printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state); | ||
476 | |||
477 | /* Restore userland MMU context */ | ||
478 | set_context(current->active_mm->context.id, current->active_mm->pgd); | ||
479 | |||
480 | return 0; | ||
481 | } | ||
482 | |||
483 | static int pmac_pm_valid(suspend_state_t state) | ||
484 | { | ||
485 | switch (state) { | ||
486 | case PM_SUSPEND_DISK: | ||
487 | return 1; | ||
488 | /* can't do any other states via generic mechanism yet */ | ||
489 | default: | ||
490 | return 0; | ||
491 | } | ||
492 | } | ||
493 | |||
494 | static struct pm_ops pmac_pm_ops = { | ||
495 | .pm_disk_mode = PM_DISK_SHUTDOWN, | ||
496 | .prepare = pmac_pm_prepare, | ||
497 | .enter = pmac_pm_enter, | ||
498 | .finish = pmac_pm_finish, | ||
499 | .valid = pmac_pm_valid, | ||
500 | }; | ||
501 | |||
502 | #endif /* CONFIG_SOFTWARE_SUSPEND */ | ||
503 | |||
504 | static int initializing = 1; | 442 | static int initializing = 1; |
505 | 443 | ||
506 | static int pmac_late_init(void) | 444 | static int pmac_late_init(void) |
507 | { | 445 | { |
508 | initializing = 0; | 446 | initializing = 0; |
509 | #ifdef CONFIG_SOFTWARE_SUSPEND | ||
510 | pm_set_ops(&pmac_pm_ops); | ||
511 | #endif /* CONFIG_SOFTWARE_SUSPEND */ | ||
512 | return 0; | 447 | return 0; |
513 | } | 448 | } |
514 | 449 | ||