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)
88 * ww_mutex_init - initialize the w/w mutex
101 ww_mutex_base_init(&lock->base, ww_class->mutex_name, &ww_class->mutex_key); in ww_mutex_init()
102 lock->ctx = NULL; in ww_mutex_init()
104 lock->ww_class = ww_class; in ww_mutex_init()
109 * ww_acquire_init - initialize a w/w acquire context
115 * Context-based w/w mutex acquiring can be done in any order whatsoever within
117 * wait/die logic.
119 * Mixing of context-based w/w mutex acquiring and single w/w mutex locking can
130 * on the stack.
135 ctx->task = current; in ww_acquire_init()
136 ctx->stamp = atomic_long_inc_return_relaxed(&ww_class->stamp); in ww_acquire_init()
137 ctx->acquired = 0; in ww_acquire_init()
138 ctx->wounded = false; in ww_acquire_init()
139 ctx->is_wait_die = ww_class->is_wait_die; in ww_acquire_init()
141 ctx->ww_class = ww_class; in ww_acquire_init()
142 ctx->done_acquire = 0; in ww_acquire_init()
143 ctx->contending_lock = NULL; in ww_acquire_init()
147 lockdep_init_map(&ctx->dep_map, ww_class->acquire_name, in ww_acquire_init()
148 &ww_class->acquire_key, 0); in ww_acquire_init()
149 mutex_acquire(&ctx->dep_map, 0, 0, _RET_IP_); in ww_acquire_init()
152 ctx->deadlock_inject_interval = 1; in ww_acquire_init()
153 ctx->deadlock_inject_countdown = ctx->stamp & 0xf; in ww_acquire_init()
158 * ww_acquire_done - marks the end of the acquire phase
173 DEBUG_LOCKS_WARN_ON(ctx->done_acquire); in ww_acquire_done()
174 ctx->done_acquire = 1; in ww_acquire_done()
179 * ww_acquire_fini - releases a w/w acquire context
188 mutex_release(&ctx->dep_map, _THIS_IP_); in ww_acquire_fini()
191 DEBUG_LOCKS_WARN_ON(ctx->acquired); in ww_acquire_fini()
197 ctx->done_acquire = 1; in ww_acquire_fini()
201 ctx->acquired = ~0U; in ww_acquire_fini()
206 * ww_mutex_lock - acquire the w/w mutex
213 * wait/die algorithm. If the lock isn't immediately available this function
215 * for backing off by returning -EDEADLK (die case). Trying to acquire the
217 * returning -EALREADY. Returns 0 if the mutex was successfully acquired.
219 * In the die case the caller must release all currently held w/w mutexes for
225 * The mutex must later on be released by the same task that
229 * can be locked. memset()-ing the mutex to 0 is not allowed. The mutex must be
237 * ww_mutex_lock_interruptible - acquire the w/w mutex, interruptible
244 * wait/die algorithm. If the lock isn't immediately available this function
246 * for backing off by returning -EDEADLK (die case). Trying to acquire the
248 * returning -EALREADY. Returns 0 if the mutex was successfully acquired. If a
249 * signal arrives while waiting for the lock then this function returns -EINTR.
251 * In the die case the caller must release all currently held w/w mutexes for
257 * The mutex must later on be released by the same task that
261 * can be locked. memset()-ing the mutex to 0 is not allowed. The mutex must be
270 * ww_mutex_lock_slow - slowpath acquiring of the w/w mutex
274 * Acquires a w/w mutex with the given context after a die case. This function
278 * context and then call this function on the contended lock.
281 * needs with ww_mutex_lock. Note that the -EALREADY return code from
285 * with the context held. It is forbidden to call this on anything else than the
297 DEBUG_LOCKS_WARN_ON(!ctx->contending_lock); in ww_mutex_lock_slow()
304 * ww_mutex_lock_slow_interruptible - slowpath acquiring of the w/w mutex, interruptible
308 * Acquires a w/w mutex with the given context after a die case. This function
311 * function returns -EINTR.
314 * context and then call this function on the contended lock.
317 * needs with ww_mutex_lock. Note that the -EALREADY return code from
321 * with the given context held. It is forbidden to call this on anything else
333 DEBUG_LOCKS_WARN_ON(!ctx->contending_lock); in ww_mutex_lock_slow_interruptible()
344 * ww_mutex_destroy - mark a w/w mutex unusable
354 mutex_destroy(&lock->base); in ww_mutex_destroy()
359 * ww_mutex_is_locked - is the w/w mutex locked
366 return ww_mutex_base_is_locked(&lock->base); in ww_mutex_is_locked()