linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][2.5][11/15] smp_call_function/_on_cpu - s390x
@ 2003-02-09 12:07 Zwane Mwaikambo
  0 siblings, 0 replies; only message in thread
From: Zwane Mwaikambo @ 2003-02-09 12:07 UTC (permalink / raw)
  To: Linux Kernel

 smp.c |   69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 61 insertions(+), 8 deletions(-)

Index: linux-2.5.59-bk/arch/s390x/kernel/smp.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.59-bk/arch/s390x/kernel/smp.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 smp.c
--- linux-2.5.59-bk/arch/s390x/kernel/smp.c	9 Feb 2003 09:08:34 -0000	1.1.1.1
+++ linux-2.5.59-bk/arch/s390x/kernel/smp.c	9 Feb 2003 09:23:30 -0000
@@ -101,13 +101,10 @@
  * in the system.
  */
 
-int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
-			int wait)
 /*
  * [SUMMARY] Run a function on all other CPUs.
  * <func> The function to run. This must be fast and non-blocking.
  * <info> An arbitrary pointer to pass to the function.
- * <nonatomic> currently unused.
  * <wait> If true, wait (atomically) until function has completed on other CPUs.
  * [RETURNS] 0 on success, else a negative status code. Does not return until
  * remote CPUs are nearly ready to execute <<func>> or are or have executed.
@@ -115,6 +112,8 @@
  * 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 wait)
 {
 	struct call_data_struct data;
 	int cpus = num_online_cpus()-1;
@@ -147,6 +146,60 @@
 	return 0;
 }
 
+/*
+ * smp_call_function_on_cpu - Runs func on all processors in the mask
+ *
+ * @func: The function to run. This must be fast and non-blocking.
+ * @info: An arbitrary pointer to pass to the function.
+ * @wait: If true, wait (atomically) until function has completed on other CPUs.
+ * @mask The bitmask of CPUs to call the function
+ * 
+ * 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)
+{
+	struct call_data_struct data;
+	int cpu, i, num_cpus = hweight64(mask);
+
+	/* FIXME: get cpu lock -hc */
+	if (num_cpus == 0)
+		return 0;
+
+	cpu = get_cpu();
+	data.func = func;
+	data.info = info;
+	atomic_set(&data.started, 0);
+	data.wait = wait;
+	if (wait)
+		atomic_set(&data.finished, 0);
+
+	spin_lock(&call_lock);
+	call_data = &data;
+	/* Send a message to all other CPUs and wait for them to respond */
+	for (i = 0; i < NR_CPUS; i++) {
+		if (cpu_online(i) && ((1UL << i) & mask))
+			smp_ext_bitcall(i, ec_call_function);
+	}
+
+	/* Wait for response */
+	while (atomic_read(&data.started) != num_cpus)
+		barrier();
+
+	if (wait)
+		while (atomic_read(&data.finished) != num_cpus)
+			barrier();
+
+	spin_unlock(&call_lock);
+	put_cpu_no_resched();
+	return 0;
+}
+
 static inline void do_send_stop(void)
 {
         u32 dummy;
@@ -227,7 +280,7 @@
 void machine_restart_smp(char * __unused) 
 {
 	cpu_restart_map = cpu_online_map;
-        smp_call_function(do_machine_restart, NULL, 0, 0);
+        smp_call_function(do_machine_restart, NULL, 0);
 	do_machine_restart(NULL);
 }
 
@@ -246,7 +299,7 @@
 
 void machine_halt_smp(void)
 {
-        smp_call_function(do_machine_halt, NULL, 0, 0);
+        smp_call_function(do_machine_halt, NULL, 0);
 	do_machine_halt(NULL);
 }
 
@@ -265,7 +318,7 @@
 
 void machine_power_off_smp(void)
 {
-        smp_call_function(do_machine_power_off, NULL, 0, 0);
+        smp_call_function(do_machine_power_off, NULL, 0);
 	do_machine_power_off(NULL);
 }
 
@@ -383,7 +436,7 @@
 	parms.end_ctl = cr;
 	parms.orvals[cr] = 1 << bit;
 	parms.andvals[cr] = -1L;
-	smp_call_function(smp_ctl_bit_callback, &parms, 0, 1);
+	smp_call_function(smp_ctl_bit_callback, &parms, 1);
         __ctl_set_bit(cr, bit);
 }
 
@@ -397,7 +450,7 @@
 	parms.end_ctl = cr;
 	parms.orvals[cr] = 0;
 	parms.andvals[cr] = ~(1L << bit);
-	smp_call_function(smp_ctl_bit_callback, &parms, 0, 1);
+	smp_call_function(smp_ctl_bit_callback, &parms, 1);
         __ctl_clear_bit(cr, bit);
 }
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-02-09 12:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-09 12:07 [PATCH][2.5][11/15] smp_call_function/_on_cpu - s390x Zwane Mwaikambo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).