]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
sh: Split out the idle loop for reuse between _32/_64 variants.
authorPaul Mundt <lethal@linux-sh.org>
Wed, 26 Nov 2008 06:52:44 +0000 (15:52 +0900)
committerPaul Mundt <lethal@linux-sh.org>
Mon, 22 Dec 2008 09:43:50 +0000 (18:43 +0900)
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
arch/sh/kernel/Makefile_32
arch/sh/kernel/Makefile_64
arch/sh/kernel/idle.c [new file with mode: 0644]
arch/sh/kernel/process_32.c
arch/sh/kernel/process_64.c

index d3f2726b07dccf8a3333deb6c14bd989341f9338..d9df9e56794698acbcba39544343f7d78d81aaac 100644 (file)
@@ -9,7 +9,7 @@ ifdef CONFIG_FUNCTION_TRACER
 CFLAGS_REMOVE_ftrace.o = -pg
 endif
 
-obj-y  := debugtraps.o disassemble.o io.o io_generic.o irq.o           \
+obj-y  := debugtraps.o disassemble.o idle.o io.o io_generic.o irq.o    \
           machvec.o process_32.o ptrace_32.o setup.o signal_32.o       \
           sys_sh.o sys_sh32.o syscalls_32.o time_32.o topology.o       \
           traps.o traps_32.o
index c97660b2b48d11be65fcf440c80c841acd433bb6..4304b2593c2c80fcf0a4f8fb14b4bb4665e5b6fc 100644 (file)
@@ -1,6 +1,6 @@
 extra-y        := head_64.o init_task.o vmlinux.lds
 
-obj-y  := debugtraps.o io.o io_generic.o irq.o machvec.o process_64.o \
+obj-y  := debugtraps.o idle.o io.o io_generic.o irq.o machvec.o process_64.o \
           ptrace_64.o setup.o signal_64.o sys_sh.o sys_sh64.o \
           syscalls_64.o time_64.o topology.o traps.o traps_64.o
 
diff --git a/arch/sh/kernel/idle.c b/arch/sh/kernel/idle.c
new file mode 100644 (file)
index 0000000..fe59ccf
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * The idle loop for all SuperH platforms.
+ *
+ *  Copyright (C) 2002 - 2008  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/pm.h>
+#include <linux/tick.h>
+#include <linux/preempt.h>
+#include <linux/thread_info.h>
+#include <linux/irqflags.h>
+#include <asm/pgalloc.h>
+#include <asm/system.h>
+#include <asm/atomic.h>
+
+static int hlt_counter;
+void (*pm_idle)(void);
+void (*pm_power_off)(void);
+EXPORT_SYMBOL(pm_power_off);
+
+static int __init nohlt_setup(char *__unused)
+{
+       hlt_counter = 1;
+       return 1;
+}
+__setup("nohlt", nohlt_setup);
+
+static int __init hlt_setup(char *__unused)
+{
+       hlt_counter = 0;
+       return 1;
+}
+__setup("hlt", hlt_setup);
+
+static void default_idle(void)
+{
+       if (!hlt_counter) {
+               clear_thread_flag(TIF_POLLING_NRFLAG);
+               smp_mb__after_clear_bit();
+               set_bl_bit();
+               stop_critical_timings();
+
+               while (!need_resched())
+                       cpu_sleep();
+
+               start_critical_timings();
+               clear_bl_bit();
+               set_thread_flag(TIF_POLLING_NRFLAG);
+       } else
+               while (!need_resched())
+                       cpu_relax();
+}
+
+void cpu_idle(void)
+{
+       set_thread_flag(TIF_POLLING_NRFLAG);
+
+       /* endless idle loop with no priority at all */
+       while (1) {
+               void (*idle)(void) = pm_idle;
+
+               if (!idle)
+                       idle = default_idle;
+
+               tick_nohz_stop_sched_tick(1);
+               while (!need_resched())
+                       idle();
+               tick_nohz_restart_sched_tick();
+
+               preempt_enable_no_resched();
+               schedule();
+               preempt_disable();
+               check_pgt_cache();
+       }
+}
index e781540bd991f4e46681dfb9ef6e908f915ef9d5..130817affa64c65f25a5f9c6c0bb8692f7a69d5e 100644 (file)
 #include <asm/fpu.h>
 #include <asm/syscalls.h>
 
-static int hlt_counter;
 int ubc_usercnt = 0;
 
-void (*pm_idle)(void);
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
-
-static int __init nohlt_setup(char *__unused)
-{
-       hlt_counter = 1;
-       return 1;
-}
-__setup("nohlt", nohlt_setup);
-
-static int __init hlt_setup(char *__unused)
-{
-       hlt_counter = 0;
-       return 1;
-}
-__setup("hlt", hlt_setup);
-
-static void default_idle(void)
-{
-       if (!hlt_counter) {
-               clear_thread_flag(TIF_POLLING_NRFLAG);
-               smp_mb__after_clear_bit();
-               set_bl_bit();
-               stop_critical_timings();
-
-               while (!need_resched())
-                       cpu_sleep();
-
-               start_critical_timings();
-               clear_bl_bit();
-               set_thread_flag(TIF_POLLING_NRFLAG);
-       } else
-               while (!need_resched())
-                       cpu_relax();
-}
-
-void cpu_idle(void)
-{
-       set_thread_flag(TIF_POLLING_NRFLAG);
-
-       /* endless idle loop with no priority at all */
-       while (1) {
-               void (*idle)(void) = pm_idle;
-
-               if (!idle)
-                       idle = default_idle;
-
-               tick_nohz_stop_sched_tick(1);
-               while (!need_resched())
-                       idle();
-               tick_nohz_restart_sched_tick();
-
-               preempt_enable_no_resched();
-               schedule();
-               preempt_disable();
-               check_pgt_cache();
-       }
-}
-
 void machine_restart(char * __unused)
 {
        /* SR.BL=1 and invoke address error to let CPU reset (manual reset) */
index b7aa09235b51a65202119a5afaa324549d172b35..597cf02db3fc1b757fd3eb49e73ffc6508c30251 100644 (file)
 
 struct task_struct *last_task_used_math = NULL;
 
-static int hlt_counter = 1;
-
-#define HARD_IDLE_TIMEOUT (HZ / 3)
-
-static int __init nohlt_setup(char *__unused)
-{
-       hlt_counter = 1;
-       return 1;
-}
-
-static int __init hlt_setup(char *__unused)
-{
-       hlt_counter = 0;
-       return 1;
-}
-
-__setup("nohlt", nohlt_setup);
-__setup("hlt", hlt_setup);
-
-static inline void hlt(void)
-{
-       __asm__ __volatile__ ("sleep" : : : "memory");
-}
-
-/*
- * The idle loop on a uniprocessor SH..
- */
-void cpu_idle(void)
-{
-       /* endless idle loop with no priority at all */
-       while (1) {
-               if (hlt_counter) {
-                       while (!need_resched())
-                               cpu_relax();
-               } else {
-                       local_irq_disable();
-                       while (!need_resched()) {
-                               local_irq_enable();
-                               hlt();
-                               local_irq_disable();
-                       }
-                       local_irq_enable();
-               }
-               preempt_enable_no_resched();
-               schedule();
-               preempt_disable();
-       }
-
-}
-
 void machine_restart(char * __unused)
 {
        extern void phys_stext(void);
@@ -97,13 +47,6 @@ void machine_halt(void)
 
 void machine_power_off(void)
 {
-#if 0
-       /* Disable watchdog timer */
-       ctrl_outl(0xa5000000, WTCSR);
-       /* Configure deep standby on sleep */
-       ctrl_outl(0x03, STBCR);
-#endif
-
        __asm__ __volatile__ (
                "sleep\n\t"
                "synci\n\t"
@@ -113,9 +56,6 @@ void machine_power_off(void)
        panic("Unexpected wakeup!\n");
 }
 
-void (*pm_power_off)(void) = machine_power_off;
-EXPORT_SYMBOL(pm_power_off);
-
 void show_regs(struct pt_regs * regs)
 {
        unsigned long long ah, al, bh, bl, ch, cl;