[2.5][5/15] smp_call_function/_on_cpu - mips

[2.5][5/15] smp_call_function/_on_cpu - mips

Post by Zwane Mwaikamb » Mon, 10 Feb 2003 14:20:04



 smp.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 50 insertions(+), 4 deletions(-)

Index: linux-2.5.59-bk/arch/mips/kernel/smp.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.59-bk/arch/mips/kernel/smp.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 smp.c
--- linux-2.5.59-bk/arch/mips/kernel/smp.c      9 Feb 2003 09:08:28 -0000       1.1.1.1

 void FASTCALL(smp_send_reschedule(int cpu))
 {
-       smp_call_function(reschedule_this_cpu, NULL, 0, 0);
+       smp_call_function(reschedule_this_cpu, NULL, 0);
 }

  * You must not call this function with disabled interrupts or from a
  * hardware interrupt handler or from a bottom half handler.
  */
-int smp_call_function (void (*func) (void *info), void *info, int retry,
-                                                               int wait)
+int smp_call_function (void (*func) (void *info), void *info, int wait)
 {
        int cpus = smp_num_cpus - 1;

        return 0;
 }

+/*
+ * smp_call_function_on_cpu - Runs func on all processors in the mask
+ *




+ *
+ * Returns 0 on success, else a negative status code. Does not return until
+ * remote CPUs are nearly ready to execute func or have executed it.
+ *
+ * You must not call this function with disabled interrupts or from a
+ * hardware interrupt handler or from a bottom half handler.
+ */
+
+int smp_call_function_on_cpu (void (*func) (void *info), void *info, int wait,
+                               unsigned long mask)
+{
+       int cpu, i, num_cpus = hweight32(mask);
+
+       cpu = get_cpu();
+       if (((1UL << cpu) & mask) || num_cpus == 0) {
+               put_cpu_no_resched();
+               return -EINVAL;
+       }
+
+       spin_lock(&smp_fn_call.lock);
+
+       atomic_set(&smp_fn_call.finished, 0);
+       smp_fn_call.fn = func;
+       smp_fn_call.data = info;
+
+       for (i = 0; i < NR_CPUS; i++) {
+               if (cpu_online(i) && ((1UL << i) & mask))
+                       /* Call the board specific routine */
+                       core_call_function(i);
+       }
+
+       if (wait) {
+               while(atomic_read(&smp_fn_call.finished) != num_cpus) {}
+       }
+
+       spin_unlock(&smp_fn_call.lock);
+       put_cpu_no_resched();
+       return 0;
+}
+
 void synchronize_irq(void)
 {

 void smp_send_stop(void)
 {
-       smp_call_function(stop_this_cpu, NULL, 1, 0);
+       smp_call_function(stop_this_cpu, NULL, 0);
        smp_num_cpus = 1;
 }

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/