diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2010-01-26 04:56:05 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2010-01-26 04:56:05 +0000 |
commit | bcc89a0643aab03595c8abe6985be5adfe940903 (patch) | |
tree | aa9aba2d686a784a30fb147ccc37b46d0cadf546 /sys | |
parent | 61895ce23b915b6c883c24adf7603203c197b358 (diff) |
Sprinkle some write buffer flushes, copied from powerpc; prevents
lock count from becoming negative under bad timing circumstances.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/sgi/sgi/lock_machdep.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/sys/arch/sgi/sgi/lock_machdep.c b/sys/arch/sgi/sgi/lock_machdep.c index 2faa3b38fda..c2f1fc7f8d1 100644 --- a/sys/arch/sgi/sgi/lock_machdep.c +++ b/sys/arch/sgi/sgi/lock_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lock_machdep.c,v 1.1 2009/11/21 23:28:14 syuu Exp $ */ +/* $OpenBSD: lock_machdep.c,v 1.2 2010/01/26 04:56:04 miod Exp $ */ /* * Copyright (c) 2007 Artur Grabowski <art@openbsd.org> @@ -67,6 +67,7 @@ void __mp_lock(struct __mp_lock *mpl) { uint32_t sr; + struct cpu_info *ci = curcpu(); /* * Please notice that mpl_count gets incremented twice for the @@ -81,10 +82,12 @@ __mp_lock(struct __mp_lock *mpl) */ while (1) { sr = disableintr(); - if (__cpu_cas(&mpl->mpl_count, 0, 1) == 0) - mpl->mpl_cpu = curcpu(); + if (__cpu_cas(&mpl->mpl_count, 0, 1) == 0) { + __asm__ __volatile__ ("sync" ::: "memory"); + mpl->mpl_cpu = ci; + } - if (mpl->mpl_cpu == curcpu()) { + if (mpl->mpl_cpu == ci) { mpl->mpl_count++; setsr(sr); break; @@ -110,6 +113,7 @@ __mp_unlock(struct __mp_lock *mpl) sr = disableintr(); if (--mpl->mpl_count == 1) { mpl->mpl_cpu = NULL; + __asm__ __volatile__ ("sync" ::: "memory"); mpl->mpl_count = 0; } @@ -131,6 +135,7 @@ __mp_release_all(struct __mp_lock *mpl) sr = disableintr(); mpl->mpl_cpu = NULL; + __asm__ __volatile__ ("sync" ::: "memory"); mpl->mpl_count = 0; setsr(sr); |