Lines Matching refs:sem

37 static noinline void __down(struct semaphore *sem);
38 static noinline int __down_interruptible(struct semaphore *sem);
39 static noinline int __down_killable(struct semaphore *sem);
40 static noinline int __down_timeout(struct semaphore *sem, long timeout);
41 static noinline void __up(struct semaphore *sem);
54 void __sched down(struct semaphore *sem) in down() argument
59 raw_spin_lock_irqsave(&sem->lock, flags); in down()
60 if (likely(sem->count > 0)) in down()
61 sem->count--; in down()
63 __down(sem); in down()
64 raw_spin_unlock_irqrestore(&sem->lock, flags); in down()
77 int __sched down_interruptible(struct semaphore *sem) in down_interruptible() argument
83 raw_spin_lock_irqsave(&sem->lock, flags); in down_interruptible()
84 if (likely(sem->count > 0)) in down_interruptible()
85 sem->count--; in down_interruptible()
87 result = __down_interruptible(sem); in down_interruptible()
88 raw_spin_unlock_irqrestore(&sem->lock, flags); in down_interruptible()
104 int __sched down_killable(struct semaphore *sem) in down_killable() argument
110 raw_spin_lock_irqsave(&sem->lock, flags); in down_killable()
111 if (likely(sem->count > 0)) in down_killable()
112 sem->count--; in down_killable()
114 result = __down_killable(sem); in down_killable()
115 raw_spin_unlock_irqrestore(&sem->lock, flags); in down_killable()
134 int __sched down_trylock(struct semaphore *sem) in down_trylock() argument
139 raw_spin_lock_irqsave(&sem->lock, flags); in down_trylock()
140 count = sem->count - 1; in down_trylock()
142 sem->count = count; in down_trylock()
143 raw_spin_unlock_irqrestore(&sem->lock, flags); in down_trylock()
159 int __sched down_timeout(struct semaphore *sem, long timeout) in down_timeout() argument
165 raw_spin_lock_irqsave(&sem->lock, flags); in down_timeout()
166 if (likely(sem->count > 0)) in down_timeout()
167 sem->count--; in down_timeout()
169 result = __down_timeout(sem, timeout); in down_timeout()
170 raw_spin_unlock_irqrestore(&sem->lock, flags); in down_timeout()
183 void __sched up(struct semaphore *sem) in up() argument
187 raw_spin_lock_irqsave(&sem->lock, flags); in up()
188 if (likely(list_empty(&sem->wait_list))) in up()
189 sem->count++; in up()
191 __up(sem); in up()
192 raw_spin_unlock_irqrestore(&sem->lock, flags); in up()
209 static inline int __sched ___down_common(struct semaphore *sem, long state, in ___down_common() argument
214 list_add_tail(&waiter.list, &sem->wait_list); in ___down_common()
224 raw_spin_unlock_irq(&sem->lock); in ___down_common()
226 raw_spin_lock_irq(&sem->lock); in ___down_common()
240 static inline int __sched __down_common(struct semaphore *sem, long state, in __down_common() argument
245 trace_contention_begin(sem, 0); in __down_common()
246 ret = ___down_common(sem, state, timeout); in __down_common()
247 trace_contention_end(sem, ret); in __down_common()
252 static noinline void __sched __down(struct semaphore *sem) in __down() argument
254 __down_common(sem, TASK_UNINTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT); in __down()
257 static noinline int __sched __down_interruptible(struct semaphore *sem) in __down_interruptible() argument
259 return __down_common(sem, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT); in __down_interruptible()
262 static noinline int __sched __down_killable(struct semaphore *sem) in __down_killable() argument
264 return __down_common(sem, TASK_KILLABLE, MAX_SCHEDULE_TIMEOUT); in __down_killable()
267 static noinline int __sched __down_timeout(struct semaphore *sem, long timeout) in __down_timeout() argument
269 return __down_common(sem, TASK_UNINTERRUPTIBLE, timeout); in __down_timeout()
272 static noinline void __sched __up(struct semaphore *sem) in __up() argument
274 struct semaphore_waiter *waiter = list_first_entry(&sem->wait_list, in __up()