patch-2.4.0-test7 linux/arch/sparc64/lib/dec_and_lock.S

Next file: linux/arch/sparc64/mm/fault.c
Previous file: linux/arch/sparc64/kernel/systbls.S
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test6/linux/arch/sparc64/lib/dec_and_lock.S linux/arch/sparc64/lib/dec_and_lock.S
@@ -1,4 +1,4 @@
-/* $Id: dec_and_lock.S,v 1.1 2000/07/10 20:57:34 davem Exp $
+/* $Id: dec_and_lock.S,v 1.2 2000/08/13 18:24:12 davem Exp $
  * dec_and_lock.S: Sparc64 version of "atomic_dec_and_lock()"
  *                 using cas and ldstub instructions.
  *
@@ -17,12 +17,10 @@
 	 *     TMP = *(MEM);
 	 *     *(MEM) = REG2;
 	 *     REG2 = TMP;
-	 *   }
+	 *   } else
+	 *     REG2 = *(MEM);
 	 *   END_ATOMIC();
 	 * }
-	 *
-	 * All non-contention cases are handled in 2 I-cache
-	 * lines which is 1 L2 cache line.
 	 */
 
 	.globl	atomic_dec_and_lock
@@ -42,20 +40,24 @@
 	brnz,pn	%g3, spin_on_lock
 	 membar	#StoreLoad | #StoreStore
 loop2:	cas	[%o0], %g5, %g7		/* ASSERT(g7 == 0) */
-	brnz,pt	%g7, out
-	 mov	1, %g1
+	nop
+	cmp	%g5, %g7
 
+	be,pt	%icc, out
+	 mov	1, %g1
 	lduw	[%o0], %g5
 	subcc	%g5, 1, %g7
 	be,pn	%icc, loop2
 	 nop
 	membar	#StoreStore | #LoadStore
 	stb	%g0, [%o1]
+
 	b,pt	%xcc, nzero
 	 nop
-
 spin_on_lock:
 	ldub	[%o1], %g3
 	brnz,pt	%g3, spin_on_lock
 	 membar	#LoadLoad
-	b,a,pt	%xcc, to_zero
+	ba,pt	%xcc, to_zero
+	 nop
+	nop

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)