Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

locking/rwsem, xtensa: Drop superfluous arch specific implementation

Since "locking, rwsem: drop explicit memory barriers" the arch specific
code is basically same as the the generic one so we can drop the
superfluous code.

Suggested-by: Davidlohr Bueso <dave@stgolabs.net>
Signed-off-by: Michal Hocko <mhocko@suse.com>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Chris Zankel <chris@zankel.net>
Cc: David S. Miller <davem@davemloft.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Cc: Signed-off-by: Jason Low <jason.low2@hp.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: linux-alpha@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-ia64@vger.kernel.org
Cc: linux-s390@vger.kernel.org
Cc: linux-sh@vger.kernel.org
Cc: linux-xtensa@linux-xtensa.org
Cc: sparclinux@vger.kernel.org
Link: http://lkml.kernel.org/r/1460041951-22347-4-git-send-email-mhocko@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Michal Hocko and committed by
Ingo Molnar
3aa2591d 2e927c64

+1 -121
+1
arch/xtensa/include/asm/Kbuild
··· 22 22 generic-y += percpu.h 23 23 generic-y += preempt.h 24 24 generic-y += resource.h 25 + generic-y += rwsem.h 25 26 generic-y += sections.h 26 27 generic-y += siginfo.h 27 28 generic-y += statfs.h
-121
arch/xtensa/include/asm/rwsem.h
··· 1 - /* 2 - * include/asm-xtensa/rwsem.h 3 - * 4 - * This file is subject to the terms and conditions of the GNU General Public 5 - * License. See the file "COPYING" in the main directory of this archive 6 - * for more details. 7 - * 8 - * Largely copied from include/asm-ppc/rwsem.h 9 - * 10 - * Copyright (C) 2001 - 2005 Tensilica Inc. 11 - */ 12 - 13 - #ifndef _XTENSA_RWSEM_H 14 - #define _XTENSA_RWSEM_H 15 - 16 - #ifndef _LINUX_RWSEM_H 17 - #error "Please don't include <asm/rwsem.h> directly, use <linux/rwsem.h> instead." 18 - #endif 19 - 20 - #define RWSEM_UNLOCKED_VALUE 0x00000000 21 - #define RWSEM_ACTIVE_BIAS 0x00000001 22 - #define RWSEM_ACTIVE_MASK 0x0000ffff 23 - #define RWSEM_WAITING_BIAS (-0x00010000) 24 - #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS 25 - #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) 26 - 27 - /* 28 - * lock for reading 29 - */ 30 - static inline void __down_read(struct rw_semaphore *sem) 31 - { 32 - if (atomic_add_return(1,(atomic_t *)(&sem->count)) <= 0) 33 - rwsem_down_read_failed(sem); 34 - } 35 - 36 - static inline int __down_read_trylock(struct rw_semaphore *sem) 37 - { 38 - int tmp; 39 - 40 - while ((tmp = sem->count) >= 0) { 41 - if (tmp == cmpxchg(&sem->count, tmp, 42 - tmp + RWSEM_ACTIVE_READ_BIAS)) { 43 - return 1; 44 - } 45 - } 46 - return 0; 47 - } 48 - 49 - /* 50 - * lock for writing 51 - */ 52 - static inline void __down_write(struct rw_semaphore *sem) 53 - { 54 - int tmp; 55 - 56 - tmp = atomic_add_return(RWSEM_ACTIVE_WRITE_BIAS, 57 - (atomic_t *)(&sem->count)); 58 - if (tmp != RWSEM_ACTIVE_WRITE_BIAS) 59 - rwsem_down_write_failed(sem); 60 - } 61 - 62 - static inline int __down_write_trylock(struct rw_semaphore *sem) 63 - { 64 - int tmp; 65 - 66 - tmp = cmpxchg(&sem->count, RWSEM_UNLOCKED_VALUE, 67 - RWSEM_ACTIVE_WRITE_BIAS); 68 - return tmp == RWSEM_UNLOCKED_VALUE; 69 - } 70 - 71 - /* 72 - * unlock after reading 73 - */ 74 - static inline void __up_read(struct rw_semaphore *sem) 75 - { 76 - int tmp; 77 - 78 - tmp = atomic_sub_return(1,(atomic_t *)(&sem->count)); 79 - if (tmp < -1 && (tmp & RWSEM_ACTIVE_MASK) == 0) 80 - rwsem_wake(sem); 81 - } 82 - 83 - /* 84 - * unlock after writing 85 - */ 86 - static inline void __up_write(struct rw_semaphore *sem) 87 - { 88 - if (atomic_sub_return(RWSEM_ACTIVE_WRITE_BIAS, 89 - (atomic_t *)(&sem->count)) < 0) 90 - rwsem_wake(sem); 91 - } 92 - 93 - /* 94 - * implement atomic add functionality 95 - */ 96 - static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem) 97 - { 98 - atomic_add(delta, (atomic_t *)(&sem->count)); 99 - } 100 - 101 - /* 102 - * downgrade write lock to read lock 103 - */ 104 - static inline void __downgrade_write(struct rw_semaphore *sem) 105 - { 106 - int tmp; 107 - 108 - tmp = atomic_add_return(-RWSEM_WAITING_BIAS, (atomic_t *)(&sem->count)); 109 - if (tmp < 0) 110 - rwsem_downgrade_wake(sem); 111 - } 112 - 113 - /* 114 - * implement exchange and add functionality 115 - */ 116 - static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem) 117 - { 118 - return atomic_add_return(delta, (atomic_t *)(&sem->count)); 119 - } 120 - 121 - #endif /* _XTENSA_RWSEM_H */