Module: xenomai-2.6
Branch: master
Commit: 546d1fd7d4313394610d830cf0deca12d6eb7721
URL:    
http://git.xenomai.org/?p=xenomai-2.6.git;a=commit;h=546d1fd7d4313394610d830cf0deca12d6eb7721

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sun Sep 21 20:47:26 2014 +0200

xnlock: add missing barriers

and optimize by removing useless barriers on x86

---

 include/asm-generic/system.h |   18 ++++++++++++++----
 include/asm-x86/atomic.h     |    9 ++++++---
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/include/asm-generic/system.h b/include/asm-generic/system.h
index 25bd83f..798eb9d 100644
--- a/include/asm-generic/system.h
+++ b/include/asm-generic/system.h
@@ -93,6 +93,14 @@ static inline unsigned xnarch_current_cpu(void)
        return rthal_processor_id();
 }
 
+#ifndef xnarch_mb_before_unlock
+#define xnarch_mb_before_unlock() xnarch_memory_barrier()
+#endif
+
+#ifndef xnarch_mb_after_unlock
+#define xnarch_mb_after_unlock() xnarch_memory_barrier()
+#endif
+
 #if XENO_DEBUG(XNLOCK)
 
 typedef struct {
@@ -375,9 +383,11 @@ static inline void xnlock_put(xnlock_t *lock)
         * Make sure all data written inside the lock is visible to
         * other CPUs before we release the lock.
         */
-       xnarch_memory_barrier();
+       xnarch_mb_before_unlock();
 
        atomic_set(&lock->owner, ~0);
+
+       xnarch_mb_after_unlock();
 }
 
 static inline spl_t
@@ -456,9 +466,9 @@ static inline int xnarch_remap_io_page_range(struct file 
*filp,
                                             unsigned long size,
                                             pgprot_t prot)
 {
-       return wrap_remap_io_page_range(vma, from, to, size,
-                                       wrap_phys_mem_prot(filp, (to) >> 
PAGE_SHIFT,
-                                                          size, prot));
+       return wrap_remap_io_page_range(vma, from, to, size,
+                                       wrap_phys_mem_prot(filp, (to) >> 
PAGE_SHIFT,
+                                                          size, prot));
 }
 
 static inline int xnarch_remap_kmem_page_range(struct vm_area_struct *vma,
diff --git a/include/asm-x86/atomic.h b/include/asm-x86/atomic.h
index ca6bbdb..f35fd54 100644
--- a/include/asm-x86/atomic.h
+++ b/include/asm-x86/atomic.h
@@ -54,6 +54,9 @@ typedef atomic_long_t xnarch_atomic_t;
 #define xnarch_read_memory_barrier()    rmb()
 #define xnarch_write_memory_barrier()   wmb()
 
+#define xnarch_mb_before_unlock()      barrier()
+#define xnarch_mb_after_unlock()       barrier()
+
 #else /* !__KERNEL__ */
 
 #include <xeno_config.h>
@@ -70,9 +73,9 @@ typedef struct { unsigned long counter; } xnarch_atomic_t;
 #define xnarch_write_memory_barrier() xnarch_memory_barrier()
 
 #define xnarch_atomic_cmpxchg(v, o, n)                  \
-        __sync_val_compare_and_swap(&(v)->counter,      \
-                                    (unsigned long)(o), \
-                                    (unsigned long)(n))
+       __sync_val_compare_and_swap(&(v)->counter,      \
+                                   (unsigned long)(o), \
+                                   (unsigned long)(n))
 
 static inline void cpu_relax(void)
 {


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to