diff options
author | Paul Mackerras <paulus@samba.org> | 2006-03-26 23:03:03 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-03-26 23:03:03 -0500 |
commit | a0652fc9a28c3ef8cd59264bfcb089c44d1b0e06 (patch) | |
tree | a28527b65237b3067553a993f5ad06dfb24df044 /arch/powerpc | |
parent | 55aab8cd3a498201b769a19de861c77516bdfd45 (diff) |
powerpc: Unify the 32 and 64 bit idle loops
This unifies the 32-bit (ARCH=ppc and ARCH=powerpc) and 64-bit idle
loops. It brings over the concept of having a ppc_md.power_save
function from 32-bit to ARCH=powerpc, which lets us get rid of
native_idle(). With this we will also be able to simplify the idle
handling for pSeries and cell.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/kernel/Makefile | 6 | ||||
-rw-r--r-- | arch/powerpc/kernel/entry_32.S | 8 | ||||
-rw-r--r-- | arch/powerpc/kernel/idle.c (renamed from arch/powerpc/kernel/idle_64.c) | 79 | ||||
-rw-r--r-- | arch/powerpc/kernel/idle_6xx.S | 15 | ||||
-rw-r--r-- | arch/powerpc/kernel/idle_power4.S | 15 | ||||
-rw-r--r-- | arch/powerpc/kernel/setup_32.c | 7 | ||||
-rw-r--r-- | arch/powerpc/kernel/setup_64.c | 6 | ||||
-rw-r--r-- | arch/powerpc/platforms/maple/setup.c | 2 | ||||
-rw-r--r-- | arch/powerpc/platforms/powermac/setup.c | 2 |
9 files changed, 54 insertions, 86 deletions
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index 80e9fe2632b8..f2c47e907037 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile | |||
@@ -12,12 +12,12 @@ endif | |||
12 | 12 | ||
13 | obj-y := semaphore.o cputable.o ptrace.o syscalls.o \ | 13 | obj-y := semaphore.o cputable.o ptrace.o syscalls.o \ |
14 | irq.o align.o signal_32.o pmc.o vdso.o \ | 14 | irq.o align.o signal_32.o pmc.o vdso.o \ |
15 | init_task.o process.o systbl.o | 15 | init_task.o process.o systbl.o idle.o |
16 | obj-y += vdso32/ | 16 | obj-y += vdso32/ |
17 | obj-$(CONFIG_PPC64) += setup_64.o binfmt_elf32.o sys_ppc32.o \ | 17 | obj-$(CONFIG_PPC64) += setup_64.o binfmt_elf32.o sys_ppc32.o \ |
18 | signal_64.o ptrace32.o \ | 18 | signal_64.o ptrace32.o \ |
19 | paca.o cpu_setup_power4.o \ | 19 | paca.o cpu_setup_power4.o \ |
20 | firmware.o sysfs.o idle_64.o | 20 | firmware.o sysfs.o |
21 | obj-$(CONFIG_PPC64) += vdso64/ | 21 | obj-$(CONFIG_PPC64) += vdso64/ |
22 | obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o | 22 | obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o |
23 | obj-$(CONFIG_POWER4) += idle_power4.o | 23 | obj-$(CONFIG_POWER4) += idle_power4.o |
@@ -34,6 +34,7 @@ obj-$(CONFIG_IBMEBUS) += ibmebus.o | |||
34 | obj-$(CONFIG_GENERIC_TBSYNC) += smp-tbsync.o | 34 | obj-$(CONFIG_GENERIC_TBSYNC) += smp-tbsync.o |
35 | obj64-$(CONFIG_PPC_MULTIPLATFORM) += nvram_64.o | 35 | obj64-$(CONFIG_PPC_MULTIPLATFORM) += nvram_64.o |
36 | obj-$(CONFIG_CRASH_DUMP) += crash_dump.o | 36 | obj-$(CONFIG_CRASH_DUMP) += crash_dump.o |
37 | obj-$(CONFIG_6xx) += idle_6xx.o | ||
37 | 38 | ||
38 | ifeq ($(CONFIG_PPC_MERGE),y) | 39 | ifeq ($(CONFIG_PPC_MERGE),y) |
39 | 40 | ||
@@ -51,7 +52,6 @@ obj-$(CONFIG_PPC64) += misc_64.o dma_64.o iommu.o | |||
51 | obj-$(CONFIG_PPC_MULTIPLATFORM) += prom_init.o | 52 | obj-$(CONFIG_PPC_MULTIPLATFORM) += prom_init.o |
52 | obj-$(CONFIG_MODULES) += ppc_ksyms.o | 53 | obj-$(CONFIG_MODULES) += ppc_ksyms.o |
53 | obj-$(CONFIG_BOOTX_TEXT) += btext.o | 54 | obj-$(CONFIG_BOOTX_TEXT) += btext.o |
54 | obj-$(CONFIG_6xx) += idle_6xx.o | ||
55 | obj-$(CONFIG_SMP) += smp.o | 55 | obj-$(CONFIG_SMP) += smp.o |
56 | obj-$(CONFIG_KPROBES) += kprobes.o | 56 | obj-$(CONFIG_KPROBES) += kprobes.o |
57 | obj-$(CONFIG_PPC_UDBG_16550) += legacy_serial.o udbg_16550.o | 57 | obj-$(CONFIG_PPC_UDBG_16550) += legacy_serial.o udbg_16550.o |
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S index 4827ca1ec89b..b3a979467225 100644 --- a/arch/powerpc/kernel/entry_32.S +++ b/arch/powerpc/kernel/entry_32.S | |||
@@ -135,10 +135,10 @@ transfer_to_handler: | |||
135 | mfspr r11,SPRN_HID0 | 135 | mfspr r11,SPRN_HID0 |
136 | mtcr r11 | 136 | mtcr r11 |
137 | BEGIN_FTR_SECTION | 137 | BEGIN_FTR_SECTION |
138 | bt- 8,power_save_6xx_restore /* Check DOZE */ | 138 | bt- 8,4f /* Check DOZE */ |
139 | END_FTR_SECTION_IFSET(CPU_FTR_CAN_DOZE) | 139 | END_FTR_SECTION_IFSET(CPU_FTR_CAN_DOZE) |
140 | BEGIN_FTR_SECTION | 140 | BEGIN_FTR_SECTION |
141 | bt- 9,power_save_6xx_restore /* Check NAP */ | 141 | bt- 9,4f /* Check NAP */ |
142 | END_FTR_SECTION_IFSET(CPU_FTR_CAN_NAP) | 142 | END_FTR_SECTION_IFSET(CPU_FTR_CAN_NAP) |
143 | #endif /* CONFIG_6xx */ | 143 | #endif /* CONFIG_6xx */ |
144 | .globl transfer_to_handler_cont | 144 | .globl transfer_to_handler_cont |
@@ -157,6 +157,10 @@ transfer_to_handler_cont: | |||
157 | SYNC | 157 | SYNC |
158 | RFI /* jump to handler, enable MMU */ | 158 | RFI /* jump to handler, enable MMU */ |
159 | 159 | ||
160 | #ifdef CONFIG_6xx | ||
161 | 4: b power_save_6xx_restore | ||
162 | #endif | ||
163 | |||
160 | /* | 164 | /* |
161 | * On kernel stack overflow, load up an initial stack pointer | 165 | * On kernel stack overflow, load up an initial stack pointer |
162 | * and call StackOverflow(regs), which should not return. | 166 | * and call StackOverflow(regs), which should not return. |
diff --git a/arch/powerpc/kernel/idle_64.c b/arch/powerpc/kernel/idle.c index b879d3057ef8..e9f321d74d85 100644 --- a/arch/powerpc/kernel/idle_64.c +++ b/arch/powerpc/kernel/idle.c | |||
@@ -2,13 +2,17 @@ | |||
2 | * Idle daemon for PowerPC. Idle daemon will handle any action | 2 | * Idle daemon for PowerPC. Idle daemon will handle any action |
3 | * that needs to be taken when the system becomes idle. | 3 | * that needs to be taken when the system becomes idle. |
4 | * | 4 | * |
5 | * Originally Written by Cort Dougan (cort@cs.nmt.edu) | 5 | * Originally written by Cort Dougan (cort@cs.nmt.edu). |
6 | * Subsequent 32-bit hacking by Tom Rini, Armin Kuster, | ||
7 | * Paul Mackerras and others. | ||
6 | * | 8 | * |
7 | * iSeries supported added by Mike Corrigan <mikejc@us.ibm.com> | 9 | * iSeries supported added by Mike Corrigan <mikejc@us.ibm.com> |
8 | * | 10 | * |
9 | * Additional shared processor, SMT, and firmware support | 11 | * Additional shared processor, SMT, and firmware support |
10 | * Copyright (c) 2003 Dave Engebretsen <engebret@us.ibm.com> | 12 | * Copyright (c) 2003 Dave Engebretsen <engebret@us.ibm.com> |
11 | * | 13 | * |
14 | * 32-bit and 64-bit versions merged by Paul Mackerras <paulus@samba.org> | ||
15 | * | ||
12 | * This program is free software; you can redistribute it and/or | 16 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 17 | * modify it under the terms of the GNU General Public License |
14 | * as published by the Free Software Foundation; either version | 18 | * as published by the Free Software Foundation; either version |
@@ -29,18 +33,43 @@ | |||
29 | #include <asm/machdep.h> | 33 | #include <asm/machdep.h> |
30 | #include <asm/smp.h> | 34 | #include <asm/smp.h> |
31 | 35 | ||
32 | extern void power4_idle(void); | 36 | #ifdef CONFIG_HOTPLUG_CPU |
37 | #define cpu_should_die() (cpu_is_offline(smp_processor_id()) && \ | ||
38 | system_state == SYSTEM_RUNNING) | ||
39 | #else | ||
40 | #define cpu_should_die() 0 | ||
41 | #endif | ||
33 | 42 | ||
34 | void default_idle(void) | 43 | /* |
44 | * The body of the idle task. | ||
45 | */ | ||
46 | void cpu_idle(void) | ||
35 | { | 47 | { |
36 | unsigned int cpu = smp_processor_id(); | 48 | if (ppc_md.idle_loop) |
37 | set_thread_flag(TIF_POLLING_NRFLAG); | 49 | ppc_md.idle_loop(); /* doesn't return */ |
38 | 50 | ||
51 | set_thread_flag(TIF_POLLING_NRFLAG); | ||
39 | while (1) { | 52 | while (1) { |
40 | if (!need_resched()) { | 53 | ppc64_runlatch_off(); |
41 | while (!need_resched() && !cpu_is_offline(cpu)) { | ||
42 | ppc64_runlatch_off(); | ||
43 | 54 | ||
55 | while (!need_resched() && !cpu_should_die()) { | ||
56 | if (ppc_md.power_save) { | ||
57 | clear_thread_flag(TIF_POLLING_NRFLAG); | ||
58 | /* | ||
59 | * smp_mb is so clearing of TIF_POLLING_NRFLAG | ||
60 | * is ordered w.r.t. need_resched() test. | ||
61 | */ | ||
62 | smp_mb(); | ||
63 | local_irq_disable(); | ||
64 | |||
65 | /* check again after disabling irqs */ | ||
66 | if (!need_resched() && !cpu_should_die()) | ||
67 | ppc_md.power_save(); | ||
68 | |||
69 | local_irq_enable(); | ||
70 | set_thread_flag(TIF_POLLING_NRFLAG); | ||
71 | |||
72 | } else { | ||
44 | /* | 73 | /* |
45 | * Go into low thread priority and possibly | 74 | * Go into low thread priority and possibly |
46 | * low power mode. | 75 | * low power mode. |
@@ -48,46 +77,18 @@ void default_idle(void) | |||
48 | HMT_low(); | 77 | HMT_low(); |
49 | HMT_very_low(); | 78 | HMT_very_low(); |
50 | } | 79 | } |
51 | |||
52 | HMT_medium(); | ||
53 | } | 80 | } |
54 | 81 | ||
82 | HMT_medium(); | ||
55 | ppc64_runlatch_on(); | 83 | ppc64_runlatch_on(); |
84 | if (cpu_should_die()) | ||
85 | cpu_die(); | ||
56 | preempt_enable_no_resched(); | 86 | preempt_enable_no_resched(); |
57 | schedule(); | 87 | schedule(); |
58 | preempt_disable(); | 88 | preempt_disable(); |
59 | if (cpu_is_offline(cpu) && system_state == SYSTEM_RUNNING) | ||
60 | cpu_die(); | ||
61 | } | 89 | } |
62 | } | 90 | } |
63 | 91 | ||
64 | void native_idle(void) | ||
65 | { | ||
66 | while (1) { | ||
67 | ppc64_runlatch_off(); | ||
68 | |||
69 | if (!need_resched()) | ||
70 | power4_idle(); | ||
71 | |||
72 | if (need_resched()) { | ||
73 | ppc64_runlatch_on(); | ||
74 | preempt_enable_no_resched(); | ||
75 | schedule(); | ||
76 | preempt_disable(); | ||
77 | } | ||
78 | |||
79 | if (cpu_is_offline(smp_processor_id()) && | ||
80 | system_state == SYSTEM_RUNNING) | ||
81 | cpu_die(); | ||
82 | } | ||
83 | } | ||
84 | |||
85 | void cpu_idle(void) | ||
86 | { | ||
87 | BUG_ON(NULL == ppc_md.idle_loop); | ||
88 | ppc_md.idle_loop(); | ||
89 | } | ||
90 | |||
91 | int powersave_nap; | 92 | int powersave_nap; |
92 | 93 | ||
93 | #ifdef CONFIG_SYSCTL | 94 | #ifdef CONFIG_SYSCTL |
diff --git a/arch/powerpc/kernel/idle_6xx.S b/arch/powerpc/kernel/idle_6xx.S index 444fdcc769f1..1647ea361ef7 100644 --- a/arch/powerpc/kernel/idle_6xx.S +++ b/arch/powerpc/kernel/idle_6xx.S | |||
@@ -87,19 +87,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_CAN_NAP) | |||
87 | cmpwi 0,r3,0 | 87 | cmpwi 0,r3,0 |
88 | beqlr | 88 | beqlr |
89 | 89 | ||
90 | /* Clear MSR:EE */ | ||
91 | mfmsr r7 | ||
92 | rlwinm r0,r7,0,17,15 | ||
93 | mtmsr r0 | ||
94 | |||
95 | /* Check current_thread_info()->flags */ | ||
96 | rlwinm r4,r1,0,0,18 | ||
97 | lwz r4,TI_FLAGS(r4) | ||
98 | andi. r0,r4,_TIF_NEED_RESCHED | ||
99 | beq 1f | ||
100 | mtmsr r7 /* out of line this ? */ | ||
101 | blr | ||
102 | 1: | ||
103 | /* Some pre-nap cleanups needed on some CPUs */ | 90 | /* Some pre-nap cleanups needed on some CPUs */ |
104 | andis. r0,r3,HID0_NAP@h | 91 | andis. r0,r3,HID0_NAP@h |
105 | beq 2f | 92 | beq 2f |
@@ -220,8 +207,6 @@ _GLOBAL(nap_save_msscr0) | |||
220 | _GLOBAL(nap_save_hid1) | 207 | _GLOBAL(nap_save_hid1) |
221 | .space 4*NR_CPUS | 208 | .space 4*NR_CPUS |
222 | 209 | ||
223 | _GLOBAL(powersave_nap) | ||
224 | .long 0 | ||
225 | _GLOBAL(powersave_lowspeed) | 210 | _GLOBAL(powersave_lowspeed) |
226 | .long 0 | 211 | .long 0 |
227 | 212 | ||
diff --git a/arch/powerpc/kernel/idle_power4.S b/arch/powerpc/kernel/idle_power4.S index c16b4afab582..692cf2ebe0f4 100644 --- a/arch/powerpc/kernel/idle_power4.S +++ b/arch/powerpc/kernel/idle_power4.S | |||
@@ -49,21 +49,6 @@ END_FTR_SECTION_IFCLR(CPU_FTR_CAN_NAP) | |||
49 | cmpwi 0,r4,0 | 49 | cmpwi 0,r4,0 |
50 | beqlr | 50 | beqlr |
51 | 51 | ||
52 | /* Clear MSR:EE */ | ||
53 | mfmsr r7 | ||
54 | li r4,0 | ||
55 | ori r4,r4,MSR_EE | ||
56 | andc r0,r7,r4 | ||
57 | mtmsrd r0 | ||
58 | |||
59 | /* Check current_thread_info()->flags */ | ||
60 | clrrdi r4,r1,THREAD_SHIFT | ||
61 | ld r4,TI_FLAGS(r4) | ||
62 | andi. r0,r4,_TIF_NEED_RESCHED | ||
63 | beq 1f | ||
64 | mtmsrd r7 /* out of line this ? */ | ||
65 | blr | ||
66 | 1: | ||
67 | /* Go to NAP now */ | 52 | /* Go to NAP now */ |
68 | BEGIN_FTR_SECTION | 53 | BEGIN_FTR_SECTION |
69 | DSSALL | 54 | DSSALL |
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index 676f894c3380..e39f830317a8 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c | |||
@@ -53,9 +53,6 @@ | |||
53 | extern void platform_init(void); | 53 | extern void platform_init(void); |
54 | extern void bootx_init(unsigned long r4, unsigned long phys); | 54 | extern void bootx_init(unsigned long r4, unsigned long phys); |
55 | 55 | ||
56 | extern void ppc6xx_idle(void); | ||
57 | extern void power4_idle(void); | ||
58 | |||
59 | boot_infos_t *boot_infos; | 56 | boot_infos_t *boot_infos; |
60 | struct ide_machdep_calls ppc_ide_md; | 57 | struct ide_machdep_calls ppc_ide_md; |
61 | 58 | ||
@@ -194,7 +191,9 @@ void __init machine_init(unsigned long dt_ptr, unsigned long phys) | |||
194 | platform_init(); | 191 | platform_init(); |
195 | 192 | ||
196 | #ifdef CONFIG_6xx | 193 | #ifdef CONFIG_6xx |
197 | ppc_md.power_save = ppc6xx_idle; | 194 | if (cpu_has_feature(CPU_FTR_CAN_DOZE) || |
195 | cpu_has_feature(CPU_FTR_CAN_NAP)) | ||
196 | ppc_md.power_save = ppc6xx_idle; | ||
198 | #endif | 197 | #endif |
199 | 198 | ||
200 | if (ppc_md.progress) | 199 | if (ppc_md.progress) |
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index 6c9b093c23a5..5b63a861ef43 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c | |||
@@ -607,12 +607,6 @@ void __init setup_arch(char **cmdline_p) | |||
607 | 607 | ||
608 | ppc_md.setup_arch(); | 608 | ppc_md.setup_arch(); |
609 | 609 | ||
610 | /* Use the default idle loop if the platform hasn't provided one. */ | ||
611 | if (NULL == ppc_md.idle_loop) { | ||
612 | ppc_md.idle_loop = default_idle; | ||
613 | printk(KERN_INFO "Using default idle loop\n"); | ||
614 | } | ||
615 | |||
616 | paging_init(); | 610 | paging_init(); |
617 | ppc64_boot_msg(0x15, "Setup Done"); | 611 | ppc64_boot_msg(0x15, "Setup Done"); |
618 | } | 612 | } |
diff --git a/arch/powerpc/platforms/maple/setup.c b/arch/powerpc/platforms/maple/setup.c index ec5c1e10c407..137d6063182b 100644 --- a/arch/powerpc/platforms/maple/setup.c +++ b/arch/powerpc/platforms/maple/setup.c | |||
@@ -290,7 +290,7 @@ struct machdep_calls __initdata maple_md = { | |||
290 | .get_rtc_time = maple_get_rtc_time, | 290 | .get_rtc_time = maple_get_rtc_time, |
291 | .calibrate_decr = generic_calibrate_decr, | 291 | .calibrate_decr = generic_calibrate_decr, |
292 | .progress = maple_progress, | 292 | .progress = maple_progress, |
293 | .idle_loop = native_idle, | 293 | .power_save = power4_idle, |
294 | #ifdef CONFIG_KEXEC | 294 | #ifdef CONFIG_KEXEC |
295 | .machine_kexec = default_machine_kexec, | 295 | .machine_kexec = default_machine_kexec, |
296 | .machine_kexec_prepare = default_machine_kexec_prepare, | 296 | .machine_kexec_prepare = default_machine_kexec_prepare, |
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c index 385aab90c4d2..c2696d00672a 100644 --- a/arch/powerpc/platforms/powermac/setup.c +++ b/arch/powerpc/platforms/powermac/setup.c | |||
@@ -733,7 +733,7 @@ struct machdep_calls __initdata pmac_md = { | |||
733 | .progress = udbg_progress, | 733 | .progress = udbg_progress, |
734 | #ifdef CONFIG_PPC64 | 734 | #ifdef CONFIG_PPC64 |
735 | .pci_probe_mode = pmac_pci_probe_mode, | 735 | .pci_probe_mode = pmac_pci_probe_mode, |
736 | .idle_loop = native_idle, | 736 | .power_save = power4_idle, |
737 | .enable_pmcs = power4_enable_pmcs, | 737 | .enable_pmcs = power4_enable_pmcs, |
738 | #ifdef CONFIG_KEXEC | 738 | #ifdef CONFIG_KEXEC |
739 | .machine_kexec = default_machine_kexec, | 739 | .machine_kexec = default_machine_kexec, |