diff options
author | Paul Mundt <lethal@linux-sh.org> | 2008-11-26 01:52:44 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2008-12-22 04:43:50 -0500 |
commit | 1da1180c6e28cf21be356e2701978727558fa198 (patch) | |
tree | 713118e72323eb02f6c231d2c94deb0aa4ffcfa9 /arch/sh/kernel/idle.c | |
parent | eb67cf14ae5c21609c200859d6f3eba71c591569 (diff) |
sh: Split out the idle loop for reuse between _32/_64 variants.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/kernel/idle.c')
-rw-r--r-- | arch/sh/kernel/idle.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/arch/sh/kernel/idle.c b/arch/sh/kernel/idle.c new file mode 100644 index 000000000000..fe59ccfc1152 --- /dev/null +++ b/arch/sh/kernel/idle.c | |||
@@ -0,0 +1,81 @@ | |||
1 | /* | ||
2 | * The idle loop for all SuperH platforms. | ||
3 | * | ||
4 | * Copyright (C) 2002 - 2008 Paul Mundt | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file "COPYING" in the main directory of this archive | ||
8 | * for more details. | ||
9 | */ | ||
10 | #include <linux/module.h> | ||
11 | #include <linux/init.h> | ||
12 | #include <linux/mm.h> | ||
13 | #include <linux/pm.h> | ||
14 | #include <linux/tick.h> | ||
15 | #include <linux/preempt.h> | ||
16 | #include <linux/thread_info.h> | ||
17 | #include <linux/irqflags.h> | ||
18 | #include <asm/pgalloc.h> | ||
19 | #include <asm/system.h> | ||
20 | #include <asm/atomic.h> | ||
21 | |||
22 | static int hlt_counter; | ||
23 | void (*pm_idle)(void); | ||
24 | void (*pm_power_off)(void); | ||
25 | EXPORT_SYMBOL(pm_power_off); | ||
26 | |||
27 | static int __init nohlt_setup(char *__unused) | ||
28 | { | ||
29 | hlt_counter = 1; | ||
30 | return 1; | ||
31 | } | ||
32 | __setup("nohlt", nohlt_setup); | ||
33 | |||
34 | static int __init hlt_setup(char *__unused) | ||
35 | { | ||
36 | hlt_counter = 0; | ||
37 | return 1; | ||
38 | } | ||
39 | __setup("hlt", hlt_setup); | ||
40 | |||
41 | static void default_idle(void) | ||
42 | { | ||
43 | if (!hlt_counter) { | ||
44 | clear_thread_flag(TIF_POLLING_NRFLAG); | ||
45 | smp_mb__after_clear_bit(); | ||
46 | set_bl_bit(); | ||
47 | stop_critical_timings(); | ||
48 | |||
49 | while (!need_resched()) | ||
50 | cpu_sleep(); | ||
51 | |||
52 | start_critical_timings(); | ||
53 | clear_bl_bit(); | ||
54 | set_thread_flag(TIF_POLLING_NRFLAG); | ||
55 | } else | ||
56 | while (!need_resched()) | ||
57 | cpu_relax(); | ||
58 | } | ||
59 | |||
60 | void cpu_idle(void) | ||
61 | { | ||
62 | set_thread_flag(TIF_POLLING_NRFLAG); | ||
63 | |||
64 | /* endless idle loop with no priority at all */ | ||
65 | while (1) { | ||
66 | void (*idle)(void) = pm_idle; | ||
67 | |||
68 | if (!idle) | ||
69 | idle = default_idle; | ||
70 | |||
71 | tick_nohz_stop_sched_tick(1); | ||
72 | while (!need_resched()) | ||
73 | idle(); | ||
74 | tick_nohz_restart_sched_tick(); | ||
75 | |||
76 | preempt_enable_no_resched(); | ||
77 | schedule(); | ||
78 | preempt_disable(); | ||
79 | check_pgt_cache(); | ||
80 | } | ||
81 | } | ||