]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/sparc/kernel/sun4d_smp.c
Merge branch 'for-rmk' of git://pasiphae.extern.pengutronix.de/git/imx/linux-2.6.git
[linux-2.6-omap-h63xx.git] / arch / sparc / kernel / sun4d_smp.c
index 3ff4edd32815ca842c5ccd03d4e6909d094f938c..69596402a500092c562b3ec97e7269efcc8981ec 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/sched.h>
 #include <linux/threads.h>
 #include <linux/smp.h>
-#include <linux/smp_lock.h>
 #include <linux/interrupt.h>
 #include <linux/kernel_stat.h>
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/swap.h>
 #include <linux/profile.h>
+#include <linux/delay.h>
 
 #include <asm/ptrace.h>
 #include <asm/atomic.h>
+#include <asm/irq_regs.h>
 
-#include <asm/delay.h>
 #include <asm/irq.h>
 #include <asm/page.h>
 #include <asm/pgalloc.h>
 #include <asm/cacheflush.h>
 #include <asm/cpudata.h>
 
+#include "irq.h"
 #define IRQ_CROSS_CALL         15
 
 extern ctxd_t *srmmu_ctx_table_phys;
 
-extern void calibrate_delay(void);
-
 static volatile int smp_processors_ready = 0;
 static int smp_highest_cpu;
 extern volatile unsigned long cpu_callin_map[NR_CPUS];
@@ -163,7 +162,7 @@ void __init smp4d_boot_cpus(void)
        local_flush_cache_all();
 }
 
-int smp4d_boot_one_cpu(int i)
+int __cpuinit smp4d_boot_one_cpu(int i)
 {
                        extern unsigned long sun4d_cpu_startup;
                        unsigned long *entry = &sun4d_cpu_startup;
@@ -263,8 +262,9 @@ static struct smp_funcall {
 static DEFINE_SPINLOCK(cross_call_lock);
 
 /* Cross calls must be serialized, at least currently. */
-void smp4d_cross_call(smpfunc_t func, unsigned long arg1, unsigned long arg2,
-                   unsigned long arg3, unsigned long arg4, unsigned long arg5)
+static void smp4d_cross_call(smpfunc_t func, cpumask_t mask, unsigned long arg1,
+                            unsigned long arg2, unsigned long arg3,
+                            unsigned long arg4)
 {
        if(smp_processors_ready) {
                register int high = smp_highest_cpu;
@@ -279,7 +279,7 @@ void smp4d_cross_call(smpfunc_t func, unsigned long arg1, unsigned long arg2,
                        register unsigned long a2 asm("i2") = arg2;
                        register unsigned long a3 asm("i3") = arg3;
                        register unsigned long a4 asm("i4") = arg4;
-                       register unsigned long a5 asm("i5") = arg5;
+                       register unsigned long a5 asm("i5") = 0;
 
                        __asm__ __volatile__(
                                "std %0, [%6]\n\t"
@@ -291,11 +291,10 @@ void smp4d_cross_call(smpfunc_t func, unsigned long arg1, unsigned long arg2,
 
                /* Init receive/complete mapping, plus fire the IPI's off. */
                {
-                       cpumask_t mask;
                        register int i;
 
-                       mask = cpumask_of_cpu(hard_smp4d_processor_id());
-                       cpus_andnot(mask, cpu_online_map, mask);
+                       cpu_clear(smp_processor_id(), mask);
+                       cpus_and(mask, cpu_online_map, mask);
                        for(i = 0; i <= high; i++) {
                                if (cpu_isset(i, mask)) {
                                        ccall_info.processors_in[i] = 0;
@@ -310,12 +309,16 @@ void smp4d_cross_call(smpfunc_t func, unsigned long arg1, unsigned long arg2,
 
                        i = 0;
                        do {
+                               if (!cpu_isset(i, mask))
+                                       continue;
                                while(!ccall_info.processors_in[i])
                                        barrier();
                        } while(++i <= high);
 
                        i = 0;
                        do {
+                               if (!cpu_isset(i, mask))
+                                       continue;
                                while(!ccall_info.processors_out[i])
                                        barrier();
                        } while(++i <= high);
@@ -336,43 +339,14 @@ void smp4d_cross_call_irq(void)
        ccall_info.processors_out[i] = 1;
 }
 
-static int smp4d_stop_cpu_sender;
-
-static void smp4d_stop_cpu(void)
-{
-       int me = hard_smp4d_processor_id();
-       
-       if (me != smp4d_stop_cpu_sender)
-               while(1) barrier();
-}
-
-/* Cross calls, in order to work efficiently and atomically do all
- * the message passing work themselves, only stopcpu and reschedule
- * messages come through here.
- */
-void smp4d_message_pass(int target, int msg, unsigned long data, int wait)
-{
-       int me = hard_smp4d_processor_id();
-
-       SMP_PRINTK(("smp4d_message_pass %d %d %08lx %d\n", target, msg, data, wait));
-       if (msg == MSG_STOP_CPU && target == MSG_ALL_BUT_SELF) {
-               unsigned long flags;
-               static DEFINE_SPINLOCK(stop_cpu_lock);
-               spin_lock_irqsave(&stop_cpu_lock, flags);
-               smp4d_stop_cpu_sender = me;
-               smp4d_cross_call((smpfunc_t)smp4d_stop_cpu, 0, 0, 0, 0, 0);
-               spin_unlock_irqrestore(&stop_cpu_lock, flags);
-       }
-       printk("Yeeee, trying to send SMP msg(%d) to %d on cpu %d\n", msg, target, me);
-       panic("Bogon SMP message pass.");
-}
-
 void smp4d_percpu_timer_interrupt(struct pt_regs *regs)
 {
+       struct pt_regs *old_regs;
        int cpu = hard_smp4d_processor_id();
        static int cpu_tick[NR_CPUS];
        static char led_mask[] = { 0xe, 0xd, 0xb, 0x7, 0xb, 0xd };
 
+       old_regs = set_irq_regs(regs);
        bw_get_prof_limit(cpu); 
        bw_clear_intr_mask(0, 1);       /* INTR_TABLE[0] & 1 is Profile IRQ */
 
@@ -384,7 +358,7 @@ void smp4d_percpu_timer_interrupt(struct pt_regs *regs)
                show_leds(cpu);
        }
 
-       profile_tick(CPU_PROFILING, regs);
+       profile_tick(CPU_PROFILING);
 
        if(!--prof_counter(cpu)) {
                int user = user_mode(regs);
@@ -395,6 +369,7 @@ void smp4d_percpu_timer_interrupt(struct pt_regs *regs)
 
                prof_counter(cpu) = prof_multiplier(cpu);
        }
+       set_irq_regs(old_regs);
 }
 
 extern unsigned int lvl14_resolution;
@@ -437,7 +412,6 @@ void __init sun4d_init_smp(void)
        BTFIXUPSET_BLACKBOX(hard_smp_processor_id, smp4d_blackbox_id);
        BTFIXUPSET_BLACKBOX(load_current, smp4d_blackbox_current);
        BTFIXUPSET_CALL(smp_cross_call, smp4d_cross_call, BTFIXUPCALL_NORM);
-       BTFIXUPSET_CALL(smp_message_pass, smp4d_message_pass, BTFIXUPCALL_NORM);
        BTFIXUPSET_CALL(__hard_smp_processor_id, __smp4d_processor_id, BTFIXUPCALL_NORM);
        
        for (i = 0; i < NR_CPUS; i++) {