This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] ARM: fix __sync_lock_release for linux
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: gcc patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 03 Dec 2009 14:28:43 +0000
- Subject: [PATCH] ARM: fix __sync_lock_release for linux
When releasing a lock the key memory barrier is there to protect the
writes that occur earlier from being seen after the release of the lock
itself. In order to do that the dmb instruction needs to appear before
the unlock write not after it.
Fixed thusly.
R.
2009-12-03 Richard Earnshaw <rearnsha@arm.com>
* arm/linux-atomic.c (SYNC_LOCK_RELEASE): Place memory barrier
before the lock release.
*** linux-atomic.c (revision 154931)
--- linux-atomic.c (local)
*************** SUBWORD_TEST_AND_SET (char, 1)
*** 266,273 ****
void HIDDEN \
__sync_lock_release_##WIDTH (TYPE *ptr) \
{ \
! *ptr = 0; \
__kernel_dmb (); \
}
SYNC_LOCK_RELEASE (int, 4)
--- 266,275 ----
void HIDDEN \
__sync_lock_release_##WIDTH (TYPE *ptr) \
{ \
! /* All writes before this point must be seen before we release \
! the lock itself. */ \
__kernel_dmb (); \
+ *ptr = 0; \
}
SYNC_LOCK_RELEASE (int, 4)