Lines Matching +full:on +full:- +full:die

1 /* SPDX-License-Identifier: GPL-2.0 */
9 * Wait/Die implementation:
35 #define ww_mutex_base_is_locked(b) rt_mutex_base_is_locked(&(b)->rtmutex)
98 * ww_mutex_init - initialize the w/w mutex
111 ww_mutex_base_init(&lock->base, ww_class->mutex_name, &ww_class->mutex_key); in ww_mutex_init()
112 lock->ctx = NULL; in ww_mutex_init()
114 lock->ww_class = ww_class; in ww_mutex_init()
119 * ww_acquire_init - initialize a w/w acquire context
125 * Context-based w/w mutex acquiring can be done in any order whatsoever within
127 * wait/die logic.
129 * Mixing of context-based w/w mutex acquiring and single w/w mutex locking can
140 * on the stack.
145 ctx->task = current; in ww_acquire_init()
146 ctx->stamp = atomic_long_inc_return_relaxed(&ww_class->stamp); in ww_acquire_init()
147 ctx->acquired = 0; in ww_acquire_init()
148 ctx->wounded = false; in ww_acquire_init()
149 ctx->is_wait_die = ww_class->is_wait_die; in ww_acquire_init()
151 ctx->ww_class = ww_class; in ww_acquire_init()
152 ctx->done_acquire = 0; in ww_acquire_init()
153 ctx->contending_lock = NULL; in ww_acquire_init()
157 lockdep_init_map(&ctx->dep_map, ww_class->acquire_name, in ww_acquire_init()
158 &ww_class->acquire_key, 0); in ww_acquire_init()
159 lockdep_init_map_wait(&ctx->first_lock_dep_map, ww_class->mutex_name, in ww_acquire_init()
160 &ww_class->mutex_key, 0, LD_WAIT_SLEEP); in ww_acquire_init()
161 mutex_acquire(&ctx->dep_map, 0, 0, _RET_IP_); in ww_acquire_init()
162 mutex_acquire_nest(&ctx->first_lock_dep_map, 0, 0, &ctx->dep_map, _RET_IP_); in ww_acquire_init()
165 ctx->deadlock_inject_interval = 1; in ww_acquire_init()
166 ctx->deadlock_inject_countdown = ctx->stamp & 0xf; in ww_acquire_init()
171 * ww_acquire_done - marks the end of the acquire phase
186 DEBUG_LOCKS_WARN_ON(ctx->done_acquire); in ww_acquire_done()
187 ctx->done_acquire = 1; in ww_acquire_done()
192 * ww_acquire_fini - releases a w/w acquire context
201 mutex_release(&ctx->first_lock_dep_map, _THIS_IP_); in ww_acquire_fini()
202 mutex_release(&ctx->dep_map, _THIS_IP_); in ww_acquire_fini()
205 DEBUG_LOCKS_WARN_ON(ctx->acquired); in ww_acquire_fini()
211 ctx->done_acquire = 1; in ww_acquire_fini()
215 ctx->acquired = ~0U; in ww_acquire_fini()
220 * ww_mutex_lock - acquire the w/w mutex
227 * wait/die algorithm. If the lock isn't immediately available this function
229 * for backing off by returning -EDEADLK (die case). Trying to acquire the
231 * returning -EALREADY. Returns 0 if the mutex was successfully acquired.
233 * In the die case the caller must release all currently held w/w mutexes for
239 * The mutex must later on be released by the same task that
243 * can be locked. memset()-ing the mutex to 0 is not allowed. The mutex must be
251 * ww_mutex_lock_interruptible - acquire the w/w mutex, interruptible
258 * wait/die algorithm. If the lock isn't immediately available this function
260 * for backing off by returning -EDEADLK (die case). Trying to acquire the
262 * returning -EALREADY. Returns 0 if the mutex was successfully acquired. If a
263 * signal arrives while waiting for the lock then this function returns -EINTR.
265 * In the die case the caller must release all currently held w/w mutexes for
271 * The mutex must later on be released by the same task that
275 * can be locked. memset()-ing the mutex to 0 is not allowed. The mutex must be
284 * ww_mutex_lock_slow - slowpath acquiring of the w/w mutex
288 * Acquires a w/w mutex with the given context after a die case. This function
292 * context and then call this function on the contended lock.
295 * needs with ww_mutex_lock. Note that the -EALREADY return code from
299 * with the context held. It is forbidden to call this on anything else than the
311 DEBUG_LOCKS_WARN_ON(!ctx->contending_lock); in ww_mutex_lock_slow()
318 * ww_mutex_lock_slow_interruptible - slowpath acquiring of the w/w mutex, interruptible
322 * Acquires a w/w mutex with the given context after a die case. This function
325 * function returns -EINTR.
328 * context and then call this function on the contended lock.
331 * needs with ww_mutex_lock. Note that the -EALREADY return code from
335 * with the given context held. It is forbidden to call this on anything else
347 DEBUG_LOCKS_WARN_ON(!ctx->contending_lock); in ww_mutex_lock_slow_interruptible()
358 * ww_mutex_destroy - mark a w/w mutex unusable
368 mutex_destroy(&lock->base); in ww_mutex_destroy()
373 * ww_mutex_is_locked - is the w/w mutex locked
380 return ww_mutex_base_is_locked(&lock->base); in ww_mutex_is_locked()