include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / arch / mips / kernel / process.c
index bd05f5a..463b71b 100644 (file)
 #include <linux/errno.h>
 #include <linux/module.h>
 #include <linux/sched.h>
+#include <linux/tick.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/stddef.h>
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/mman.h>
 #include <linux/personality.h>
 #include <linux/sys.h>
 #include <linux/user.h>
-#include <linux/a.out.h>
 #include <linux/init.h>
 #include <linux/completion.h>
 #include <linux/kallsyms.h>
  */
 void __noreturn cpu_idle(void)
 {
+       int cpu;
+
+       /* CPU is going idle. */
+       cpu = smp_processor_id();
+
        /* endless idle loop with no priority at all */
        while (1) {
-               while (!need_resched()) {
-#ifdef CONFIG_SMTC_IDLE_HOOK_DEBUG
+               tick_nohz_stop_sched_tick(1);
+               while (!need_resched() && cpu_online(cpu)) {
+#ifdef CONFIG_MIPS_MT_SMTC
                        extern void smtc_idle_loop_hook(void);
 
                        smtc_idle_loop_hook();
@@ -61,6 +66,13 @@ void __noreturn cpu_idle(void)
                        if (cpu_wait)
                                (*cpu_wait)();
                }
+#ifdef CONFIG_HOTPLUG_CPU
+               if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map) &&
+                   (system_state == SYSTEM_RUNNING ||
+                    system_state == SYSTEM_BOOTING))
+                       play_dead();
+#endif
+               tick_nohz_restart_sched_tick();
                preempt_enable_no_resched();
                schedule();
                preempt_disable();
@@ -74,10 +86,9 @@ void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
        unsigned long status;
 
        /* New thread loses kernel privileges. */
-       status = regs->cp0_status & ~(ST0_CU0|ST0_CU1|KU_MASK);
+       status = regs->cp0_status & ~(ST0_CU0|ST0_CU1|ST0_FR|KU_MASK);
 #ifdef CONFIG_64BIT
-       status &= ~ST0_FR;
-       status |= (current->thread.mflags & MF_32BIT_REGS) ? 0 : ST0_FR;
+       status |= test_thread_flag(TIF_32BIT_REGS) ? 0 : ST0_FR;
 #endif
        status |= KU_USER;
        regs->cp0_status = status;
@@ -98,12 +109,12 @@ void flush_thread(void)
 {
 }
 
-int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
+int copy_thread(unsigned long clone_flags, unsigned long usp,
        unsigned long unused, struct task_struct *p, struct pt_regs *regs)
 {
        struct thread_info *ti = task_thread_info(p);
        struct pt_regs *childregs;
-       long childksp;
+       unsigned long childksp;
        p->set_child_tid = p->clear_child_tid = NULL;
 
        childksp = (unsigned long)task_stack_page(p) + THREAD_SIZE - 32;
@@ -120,16 +131,11 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
 
        /* set up new TSS. */
        childregs = (struct pt_regs *) childksp - 1;
+       /*  Put the stack after the struct pt_regs.  */
+       childksp = (unsigned long) childregs;
        *childregs = *regs;
        childregs->regs[7] = 0; /* Clear error flag */
 
-#if defined(CONFIG_BINFMT_IRIX)
-       if (current->personality != PER_LINUX) {
-               /* Under IRIX things are a little different. */
-               childregs->regs[3] = 1;
-               regs->regs[3] = 0;
-       }
-#endif
        childregs->regs[2] = 0; /* Child gets zero as return value */
        regs->regs[2] = p->pid;
 
@@ -150,17 +156,18 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
         */
        p->thread.cp0_status = read_c0_status() & ~(ST0_CU2|ST0_CU1);
        childregs->cp0_status &= ~(ST0_CU2|ST0_CU1);
-       clear_tsk_thread_flag(p, TIF_USEDFPU);
 
-#ifdef CONFIG_MIPS_MT_FPAFF
+#ifdef CONFIG_MIPS_MT_SMTC
        /*
-        * FPU affinity support is cleaner if we track the
-        * user-visible CPU affinity from the very beginning.
-        * The generic cpus_allowed mask will already have
-        * been copied from the parent before copy_thread
-        * is invoked.
+        * SMTC restores TCStatus after Status, and the CU bits
+        * are aliased there.
         */
-       p->thread.user_cpus_allowed = p->cpus_allowed;
+       childregs->cp0_tcstatus &= ~(ST0_CU2|ST0_CU1);
+#endif
+       clear_tsk_thread_flag(p, TIF_USEDFPU);
+
+#ifdef CONFIG_MIPS_MT_FPAFF
+       clear_tsk_thread_flag(p, TIF_FPUBOUND);
 #endif /* CONFIG_MIPS_MT_FPAFF */
 
        if (clone_flags & CLONE_SETTLS)
@@ -199,13 +206,13 @@ void elf_dump_regs(elf_greg_t *gp, struct pt_regs *regs)
 #endif
 }
 
-int dump_task_regs (struct task_struct *tsk, elf_gregset_t *regs)
+int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs)
 {
        elf_dump_regs(*regs, task_pt_regs(tsk));
        return 1;
 }
 
-int dump_task_fpu (struct task_struct *t, elf_fpregset_t *fpr)
+int dump_task_fpu(struct task_struct *t, elf_fpregset_t *fpr)
 {
        memcpy(fpr, &t->thread.fpu, sizeof(current->thread.fpu));
 
@@ -231,8 +238,8 @@ long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
        regs.cp0_epc = (unsigned long) kernel_thread_helper;
        regs.cp0_status = read_c0_status();
 #if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
-       regs.cp0_status &= ~(ST0_KUP | ST0_IEC);
-       regs.cp0_status |= ST0_IEP;
+       regs.cp0_status = (regs.cp0_status & ~(ST0_KUP | ST0_IEP | ST0_IEC)) |
+                         ((regs.cp0_status & (ST0_KUC | ST0_IEC)) << 2);
 #else
        regs.cp0_status |= ST0_EXL;
 #endif