Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / arch / sh64 / kernel / process.c
index 13cec35..1da9c61 100644 (file)
@@ -307,23 +307,19 @@ __setup("hlt", hlt_setup);
 
 static inline void hlt(void)
 {
-       if (hlt_counter)
-               return;
-
        __asm__ __volatile__ ("sleep" : : : "memory");
 }
 
 /*
  * The idle loop on a uniprocessor SH..
  */
-void default_idle(void)
+void cpu_idle(void)
 {
        /* endless idle loop with no priority at all */
        while (1) {
                if (hlt_counter) {
-                       while (1)
-                               if (need_resched())
-                                       break;
+                       while (!need_resched())
+                               cpu_relax();
                } else {
                        local_irq_disable();
                        while (!need_resched()) {
@@ -334,13 +330,11 @@ void default_idle(void)
                        }
                        local_irq_enable();
                }
+               preempt_enable_no_resched();
                schedule();
+               preempt_disable();
        }
-}
 
-void cpu_idle(void *unused)
-{
-       default_idle();
 }
 
 void machine_restart(char * __unused)
@@ -638,7 +632,6 @@ void free_task_struct(struct task_struct *p)
 int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
 {
        /* A bit less processor dependent than older sh ... */
-
        unsigned int reply;
 
 static __inline__ _syscall2(int,clone,unsigned long,flags,unsigned long,newsp)
@@ -671,7 +664,7 @@ void exit_thread(void)
           null it here, there is no other path through which it would get safely
           nulled. */
 
-#ifndef CONFIG_NOFPU_SUPPORT
+#ifdef CONFIG_SH_FPU
        if (last_task_used_math == current) {
                last_task_used_math = NULL;
        }
@@ -683,12 +676,12 @@ void flush_thread(void)
 
        /* Called by fs/exec.c (flush_old_exec) to remove traces of a
         * previously running executable. */
-#ifndef CONFIG_NOFPU_SUPPORT
+#ifdef CONFIG_SH_FPU
        if (last_task_used_math == current) {
                last_task_used_math = NULL;
        }
        /* Force FPU state to be reinitialised after exec */
-       current->used_math = 0;
+       clear_used_math();
 #endif
 
        /* if we are a kernel thread, about to change to user thread,
@@ -709,11 +702,11 @@ void release_thread(struct task_struct *dead_task)
 /* Fill in the fpu structure for a core dump.. */
 int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
 {
-#ifndef CONFIG_NOFPU_SUPPORT
+#ifdef CONFIG_SH_FPU
        int fpvalid;
        struct task_struct *tsk = current;
 
-       fpvalid = tsk->used_math;
+       fpvalid = !!tsk_used_math(tsk);
        if (fpvalid) {
                if (current == last_task_used_math) {
                        grab_fpu();
@@ -741,7 +734,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
        struct pt_regs *childregs;
        unsigned long long se;                  /* Sign extension */
 
-#ifndef CONFIG_NOFPU_SUPPORT
+#ifdef CONFIG_SH_FPU
        if(last_task_used_math == current) {
                grab_fpu();
                fpsave(&current->thread.fpu.hard);
@@ -751,7 +744,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
        }
 #endif
        /* Copy from sh version */
-       childregs = ((struct pt_regs *)(THREAD_SIZE + (unsigned long) p->thread_info )) - 1;
+       childregs = (struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1;
 
        *childregs = *regs;
 
@@ -759,15 +752,12 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
                childregs->regs[15] = usp;
                p->thread.uregs = childregs;
        } else {
-               childregs->regs[15] = (unsigned long)p->thread_info + THREAD_SIZE;
+               childregs->regs[15] = (unsigned long)task_stack_page(p) + THREAD_SIZE;
        }
 
        childregs->regs[9] = 0; /* Set return value for child */
        childregs->sr |= SR_FD; /* Invalidate FPU flag */
 
-       /* From sh */
-       p->set_child_tid = p->clear_child_tid = NULL;
-
        p->thread.sp = (unsigned long) childregs;
        p->thread.pc = (unsigned long) ret_from_fork;
 
@@ -785,26 +775,6 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
        return 0;
 }
 
-/*
- * fill in the user structure for a core dump..
- */
-void dump_thread(struct pt_regs * regs, struct user * dump)
-{
-       dump->magic = CMAGIC;
-       dump->start_code = current->mm->start_code;
-       dump->start_data  = current->mm->start_data;
-       dump->start_stack = regs->regs[15] & ~(PAGE_SIZE - 1);
-       dump->u_tsize = (current->mm->end_code - dump->start_code) >> PAGE_SHIFT;
-       dump->u_dsize = (current->mm->brk + (PAGE_SIZE-1) - dump->start_data) >> PAGE_SHIFT;
-       dump->u_ssize = (current->mm->start_stack - dump->start_stack +
-                        PAGE_SIZE - 1) >> PAGE_SHIFT;
-       /* Debug registers will come here. */
-
-       dump->regs = *regs;
-
-       dump->u_fpvalid = dump_fpu(regs, &dump->fpu);
-}
-
 asmlinkage int sys_fork(unsigned long r2, unsigned long r3,
                        unsigned long r4, unsigned long r5,
                        unsigned long r6, unsigned long r7,
@@ -862,8 +832,11 @@ asmlinkage int sys_execve(char *ufilename, char **uargv,
                          (char __user * __user *)uargv,
                          (char __user * __user *)uenvp,
                          pregs);
-       if (error == 0)
+       if (error == 0) {
+               task_lock(current);
                current->ptrace &= ~PT_DTRACE;
+               task_unlock(current);
+       }
        putname(filename);
 out:
        unlock_kernel();
@@ -933,7 +906,7 @@ asids_proc_info(char *buf, char **start, off_t fpos, int length, int *eof, void
        int len=0;
        struct task_struct *p;
        read_lock(&tasklist_lock);
-       for_each_task(p) {
+       for_each_process(p) {
                int pid = p->pid;
                struct mm_struct *mm;
                if (!pid) continue;
@@ -942,7 +915,7 @@ asids_proc_info(char *buf, char **start, off_t fpos, int length, int *eof, void
                        unsigned long asid, context;
                        context = mm->context;
                        asid = (context & 0xff);
-                       len += sprintf(buf+len, "%5d : %02x\n", pid, asid);
+                       len += sprintf(buf+len, "%5d : %02lx\n", pid, asid);
                } else {
                        len += sprintf(buf+len, "%5d : (none)\n", pid);
                }