Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b4b2917cc8babe8eaf4bc133bca31b11ed7dac13
Commit:     b4b2917cc8babe8eaf4bc133bca31b11ed7dac13
Parent:     185bcd17a5fb4155fba125332efa498be126aa4e
Author:     Peter Watkins <[EMAIL PROTECTED]>
AuthorDate: Mon Jul 30 18:01:29 2007 -0400
Committer:  Ralf Baechle <[EMAIL PROTECTED]>
CommitDate: Tue Jul 31 21:35:37 2007 +0100

    [MIPS] Add smp_call_function_single()
    
    In the other archs, there is more factoring of smp call code, and more care
    in the use of get_cpu(). That can be a follow-up MIPS patch.
    
    Signed-off-by: Peter Watkins <[EMAIL PROTECTED]>
    Signed-off-by: Ralf Baechle <[EMAIL PROTECTED]>
---
 arch/mips/kernel/smp.c |   55 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 04bbbd8..73b0dab 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -194,6 +194,61 @@ void smp_call_function_interrupt(void)
        }
 }
 
+int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
+                            int retry, int wait)
+{
+       struct call_data_struct data;
+       int me;
+
+       /*
+        * Can die spectacularly if this CPU isn't yet marked online
+        */
+       if (!cpu_online(cpu))
+               return 0;
+
+       me = get_cpu();
+       BUG_ON(!cpu_online(me));
+
+       if (cpu == me) {
+               local_irq_disable();
+               func(info);
+               local_irq_enable();
+               put_cpu();
+               return 0;
+       }
+
+       /* Can deadlock when called with interrupts disabled */
+       WARN_ON(irqs_disabled());
+
+       data.func = func;
+       data.info = info;
+       atomic_set(&data.started, 0);
+       data.wait = wait;
+       if (wait)
+               atomic_set(&data.finished, 0);
+
+       spin_lock(&smp_call_lock);
+       call_data = &data;
+       smp_mb();
+
+       /* Send a message to the other CPU */
+       core_send_ipi(cpu, SMP_CALL_FUNCTION);
+
+       /* Wait for response */
+       /* FIXME: lock-up detection, backtrace on lock-up */
+       while (atomic_read(&data.started) != 1)
+               barrier();
+
+       if (wait)
+               while (atomic_read(&data.finished) != 1)
+                       barrier();
+       call_data = NULL;
+       spin_unlock(&smp_call_lock);
+
+       put_cpu();
+       return 0;
+}
+
 static void stop_this_cpu(void *dummy)
 {
        /*
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to