Lines Matching +full:on +full:- +full:die
1 /* SPDX-License-Identifier: GPL-2.0 */
9 * Wait/Die implementation:
86 * ww_mutex_init - initialize the w/w mutex
98 __mutex_init(&lock->base, ww_class->mutex_name, &ww_class->mutex_key); in ww_mutex_init()
99 lock->ctx = NULL; in ww_mutex_init()
101 lock->ww_class = ww_class; in ww_mutex_init()
106 * ww_acquire_init - initialize a w/w acquire context
112 * Context-based w/w mutex acquiring can be done in any order whatsoever within
114 * wait/die logic.
116 * Mixing of context-based w/w mutex acquiring and single w/w mutex locking can
127 * on the stack.
132 ctx->task = current; in ww_acquire_init()
133 ctx->stamp = atomic_long_inc_return_relaxed(&ww_class->stamp); in ww_acquire_init()
134 ctx->acquired = 0; in ww_acquire_init()
135 ctx->wounded = false; in ww_acquire_init()
136 ctx->is_wait_die = ww_class->is_wait_die; in ww_acquire_init()
138 ctx->ww_class = ww_class; in ww_acquire_init()
139 ctx->done_acquire = 0; in ww_acquire_init()
140 ctx->contending_lock = NULL; in ww_acquire_init()
144 lockdep_init_map(&ctx->dep_map, ww_class->acquire_name, in ww_acquire_init()
145 &ww_class->acquire_key, 0); in ww_acquire_init()
146 mutex_acquire(&ctx->dep_map, 0, 0, _RET_IP_); in ww_acquire_init()
149 ctx->deadlock_inject_interval = 1; in ww_acquire_init()
150 ctx->deadlock_inject_countdown = ctx->stamp & 0xf; in ww_acquire_init()
155 * ww_acquire_done - marks the end of the acquire phase
170 DEBUG_LOCKS_WARN_ON(ctx->done_acquire); in ww_acquire_done()
171 ctx->done_acquire = 1; in ww_acquire_done()
176 * ww_acquire_fini - releases a w/w acquire context
185 mutex_release(&ctx->dep_map, 0, _THIS_IP_); in ww_acquire_fini()
187 DEBUG_LOCKS_WARN_ON(ctx->acquired); in ww_acquire_fini()
193 ctx->done_acquire = 1; in ww_acquire_fini()
197 ctx->acquired = ~0U; in ww_acquire_fini()
202 * ww_mutex_lock - acquire the w/w mutex
209 * wait/die algorithm. If the lock isn't immediately available this function
211 * for backing off by returning -EDEADLK (die case). Trying to acquire the
213 * returning -EALREADY. Returns 0 if the mutex was successfully acquired.
215 * In the die case the caller must release all currently held w/w mutexes for
221 * The mutex must later on be released by the same task that
225 * can be locked. memset()-ing the mutex to 0 is not allowed. The mutex must be
233 * ww_mutex_lock_interruptible - acquire the w/w mutex, interruptible
240 * wait/die algorithm. If the lock isn't immediately available this function
242 * for backing off by returning -EDEADLK (die case). Trying to acquire the
244 * returning -EALREADY. Returns 0 if the mutex was successfully acquired. If a
245 * signal arrives while waiting for the lock then this function returns -EINTR.
247 * In the die case the caller must release all currently held w/w mutexes for
253 * The mutex must later on be released by the same task that
257 * can be locked. memset()-ing the mutex to 0 is not allowed. The mutex must be
266 * ww_mutex_lock_slow - slowpath acquiring of the w/w mutex
270 * Acquires a w/w mutex with the given context after a die case. This function
274 * context and then call this function on the contended lock.
277 * needs with ww_mutex_lock. Note that the -EALREADY return code from
281 * with the context held. It is forbidden to call this on anything else than the
293 DEBUG_LOCKS_WARN_ON(!ctx->contending_lock); in ww_mutex_lock_slow()
300 * ww_mutex_lock_slow_interruptible - slowpath acquiring of the w/w mutex, interruptible
304 * Acquires a w/w mutex with the given context after a die case. This function
307 * function returns -EINTR.
310 * context and then call this function on the contended lock.
313 * needs with ww_mutex_lock. Note that the -EALREADY return code from
317 * with the given context held. It is forbidden to call this on anything else
329 DEBUG_LOCKS_WARN_ON(!ctx->contending_lock); in ww_mutex_lock_slow_interruptible()
337 * ww_mutex_trylock - tries to acquire the w/w mutex without acquire context
345 return mutex_trylock(&lock->base); in ww_mutex_trylock()
349 * ww_mutex_destroy - mark a w/w mutex unusable
358 mutex_destroy(&lock->base); in ww_mutex_destroy()
362 * ww_mutex_is_locked - is the w/w mutex locked
369 return mutex_is_locked(&lock->base); in ww_mutex_is_locked()