Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH] [MIPS] Add smp_call_function_single.
@ 2007-06-13 23:02 pwatkins
  2007-07-27 17:26 ` Ralf Baechle
  0 siblings, 1 reply; 2+ messages in thread
From: pwatkins @ 2007-06-13 23:02 UTC (permalink / raw)
  To: linux-mips, ralf, pwatkins; +Cc: Peter Watkins

From: Peter Watkins <pwatkins@gsrv020.sicortex.com>

Signed-off-by: Peter Watkins <pwatkins@gsrv020.sicortex.com>
---
 arch/mips/kernel/smp.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/asm-mips/smp.h |    2 ++
 2 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 67edfa7..26f0f55 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -203,6 +203,56 @@ 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 = smp_processor_id();
+
+	/*
+	 * Can die spectacularly if this CPU isn't yet marked online
+	 */
+	BUG_ON(!cpu_online(me));
+
+	if (cpu == me) {
+		WARN_ON(1);
+		return -EBUSY;
+	}
+
+	if (!cpu_online(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);
+
+	return 0;
+}
+
 static void stop_this_cpu(void *dummy)
 {
 	/*
diff --git a/include/asm-mips/smp.h b/include/asm-mips/smp.h
index 1608fd7..1aa6bb4 100644
--- a/include/asm-mips/smp.h
+++ b/include/asm-mips/smp.h
@@ -109,6 +109,8 @@ static inline void smp_send_reschedule(i
 	core_send_ipi(cpu, SMP_RESCHEDULE_YOURSELF);
 }
 
+extern int smp_call_function_single(int cpuid, void (*func) (void *info),
+				void *info, int retry, int wait);
 extern asmlinkage void smp_call_function_interrupt(void);
 
 #endif /* CONFIG_SMP */
-- 
1.4.2.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] [MIPS] Add smp_call_function_single.
  2007-06-13 23:02 [PATCH] [MIPS] Add smp_call_function_single pwatkins
@ 2007-07-27 17:26 ` Ralf Baechle
  0 siblings, 0 replies; 2+ messages in thread
From: Ralf Baechle @ 2007-07-27 17:26 UTC (permalink / raw)
  To: pwatkins; +Cc: linux-mips, Peter Watkins

On Wed, Jun 13, 2007 at 07:02:01PM -0400, pwatkins@sicortex.com wrote:

Applied.  Thanks for the reminder.

  Ralf

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-07-27 17:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-13 23:02 [PATCH] [MIPS] Add smp_call_function_single pwatkins
2007-07-27 17:26 ` Ralf Baechle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox