patch-1.3.93 linux/include/asm-sparc/smp_lock.h

Next file: linux/include/asm-sparc/socket.h
Previous file: linux/include/asm-sparc/smp.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.92/linux/include/asm-sparc/smp_lock.h linux/include/asm-sparc/smp_lock.h
@@ -6,31 +6,33 @@
 #ifndef __SPARC_SMPLOCK_H
 #define __SPARC_SMPLOCK_H
 
-#ifdef __SMP__
+#include <asm/smp.h>
+#include <asm/bitops.h>
+#include <asm/atops.h>
+#include <asm/pgtable.h>
 
-extern _inline_ unsigned char ldstub(klock_t *lock)
-{
-	klock_t retval;
+#ifdef __SMP__
 
-	__asm__ __volatile__("ldstub [%1], %0\n\t" :
-			     "=r" (retval) :
-			     "r" (lock));
-	return retval;
-}
+/*
+ *	Locking the kernel 
+ */
 
 /* Knock knock... */
-extern _inline_ void lock_kernel(void)
+extern __inline void lock_kernel(void)
 {
 	unsigned long flags;
 	int proc = smp_processor_id();
 
 	save_flags(flags); cli(); /* need this on sparc? */
-	while(ldstub(&kernel_lock)) {
+	while(ldstub(&kernel_flag)) {
 		if(proc == active_kernel_processor)
 			break;
-		if(test_bit(proc, (unsigned long *)&smp_invalidate_needed))
-			if(clear_bit(proc, (unsigned long *)&smp_invalidate_needed))
-				local_invalidate();
+		do {
+#ifdef __SMP_PROF__		
+			smp_spins[smp_processor_id()]++;
+#endif			
+			barrier();
+		} while(kernel_flag); /* Don't lock the bus more than we have to. */
 	}
 	active_kernel_processor = proc;
 	kernel_counter++;
@@ -38,18 +40,19 @@
 }
 
 /* I want out... */
-extern _inline_ void unlock_kernel(void)
+extern __inline void unlock_kernel(void)
 {
 	unsigned long flags;
 
 	save_flags(flags); cli(); /* need this on sparc? */
 	if(kernel_counter == 0)
 		panic("Bogus kernel counter.\n");
+
 	if(!--kernel_counter) {
 		active_kernel_processor = NO_PROC_ID;
-		kernel_lock = KLOCK_CLEAR;
+		kernel_flag = KLOCK_CLEAR;
 	}
-	restore_flag(flags);
+	restore_flags(flags);
 }
 
 #endif /* !(__SPARC_SMPLOCK_H) */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this