This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]