2 * The idle loop for all SuperH platforms.
4 * Copyright (C) 2002 - 2009 Paul Mundt
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
10 #include <linux/module.h>
11 #include <linux/init.h>
14 #include <linux/tick.h>
15 #include <linux/preempt.h>
16 #include <linux/thread_info.h>
17 #include <linux/irqflags.h>
18 #include <linux/smp.h>
19 #include <asm/pgalloc.h>
20 #include <asm/system.h>
21 #include <asm/atomic.h>
23 static int hlt_counter
;
24 void (*pm_idle
)(void);
25 void (*pm_power_off
)(void);
26 EXPORT_SYMBOL(pm_power_off
);
28 static int __init
nohlt_setup(char *__unused
)
33 __setup("nohlt", nohlt_setup
);
35 static int __init
hlt_setup(char *__unused
)
40 __setup("hlt", hlt_setup
);
42 void default_idle(void)
45 clear_thread_flag(TIF_POLLING_NRFLAG
);
46 smp_mb__after_clear_bit();
48 stop_critical_timings();
50 while (!need_resched())
53 start_critical_timings();
55 set_thread_flag(TIF_POLLING_NRFLAG
);
57 while (!need_resched())
63 set_thread_flag(TIF_POLLING_NRFLAG
);
65 /* endless idle loop with no priority at all */
67 void (*idle
)(void) = pm_idle
;
72 tick_nohz_stop_sched_tick(1);
73 while (!need_resched())
75 tick_nohz_restart_sched_tick();
77 preempt_enable_no_resched();
84 static void do_nothing(void *unused
)
89 * cpu_idle_wait - Used to ensure that all the CPUs discard old value of
90 * pm_idle and update to new pm_idle value. Required while changing pm_idle
91 * handler on SMP systems.
93 * Caller must have changed pm_idle to the new value before the call. Old
94 * pm_idle value will not be used by any CPU after the return of this function.
96 void cpu_idle_wait(void)
99 /* kick all the CPUs so that they exit out of pm_idle */
100 smp_call_function(do_nothing
, NULL
, 1);
102 EXPORT_SYMBOL_GPL(cpu_idle_wait
);