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

1 /* SPDX-License-Identifier: GPL-2.0 */
9 * Wait/Die implementation:
78 * ww_mutex_init - initialize the w/w mutex
90 __mutex_init(&lock->base, ww_class->mutex_name, &ww_class->mutex_key); in ww_mutex_init()
91 lock->ctx = NULL; in ww_mutex_init()
93 lock->ww_class = ww_class; in ww_mutex_init()
98 * ww_acquire_init - initialize a w/w acquire context
104 * Context-based w/w mutex acquiring can be done in any order whatsoever within
106 * wait/die logic.
108 * Mixing of context-based w/w mutex acquiring and single w/w mutex locking can
119 * on the stack.
124 ctx->task = current; in ww_acquire_init()
125 ctx->stamp = atomic_long_inc_return_relaxed(&ww_class->stamp); in ww_acquire_init()
126 ctx->acquired = 0; in ww_acquire_init()
127 ctx->wounded = false; in ww_acquire_init()
128 ctx->is_wait_die = ww_class->is_wait_die; in ww_acquire_init()
130 ctx->ww_class = ww_class; in ww_acquire_init()
131 ctx->done_acquire = 0; in ww_acquire_init()
132 ctx->contending_lock = NULL; in ww_acquire_init()
136 lockdep_init_map(&ctx->dep_map, ww_class->acquire_name, in ww_acquire_init()
137 &ww_class->acquire_key, 0); in ww_acquire_init()
138 mutex_acquire(&ctx->dep_map, 0, 0, _RET_IP_); in ww_acquire_init()
141 ctx->deadlock_inject_interval = 1; in ww_acquire_init()
142 ctx->deadlock_inject_countdown = ctx->stamp & 0xf; in ww_acquire_init()
147 * ww_acquire_done - marks the end of the acquire phase
162 DEBUG_LOCKS_WARN_ON(ctx->done_acquire); in ww_acquire_done()
163 ctx->done_acquire = 1; in ww_acquire_done()
168 * ww_acquire_fini - releases a w/w acquire context
177 mutex_release(&ctx->dep_map, _THIS_IP_); in ww_acquire_fini()
180 DEBUG_LOCKS_WARN_ON(ctx->acquired); in ww_acquire_fini()
186 ctx->done_acquire = 1; in ww_acquire_fini()
190 ctx->acquired = ~0U; in ww_acquire_fini()
195 * ww_mutex_lock - acquire the w/w mutex
202 * wait/die algorithm. If the lock isn't immediately available this function
204 * for backing off by returning -EDEADLK (die case). Trying to acquire the
206 * returning -EALREADY. Returns 0 if the mutex was successfully acquired.
208 * In the die case the caller must release all currently held w/w mutexes for
214 * The mutex must later on be released by the same task that
218 * can be locked. memset()-ing the mutex to 0 is not allowed. The mutex must be
226 * ww_mutex_lock_interruptible - acquire the w/w mutex, interruptible
233 * wait/die algorithm. If the lock isn't immediately available this function
235 * for backing off by returning -EDEADLK (die case). Trying to acquire the
237 * returning -EALREADY. Returns 0 if the mutex was successfully acquired. If a
238 * signal arrives while waiting for the lock then this function returns -EINTR.
240 * In the die case the caller must release all currently held w/w mutexes for
246 * The mutex must later on be released by the same task that
250 * can be locked. memset()-ing the mutex to 0 is not allowed. The mutex must be
259 * ww_mutex_lock_slow - slowpath acquiring of the w/w mutex
263 * Acquires a w/w mutex with the given context after a die case. This function
267 * context and then call this function on the contended lock.
270 * needs with ww_mutex_lock. Note that the -EALREADY return code from
274 * with the context held. It is forbidden to call this on anything else than the
286 DEBUG_LOCKS_WARN_ON(!ctx->contending_lock); in ww_mutex_lock_slow()
293 * ww_mutex_lock_slow_interruptible - slowpath acquiring of the w/w mutex, interruptible
297 * Acquires a w/w mutex with the given context after a die case. This function
300 * function returns -EINTR.
303 * context and then call this function on the contended lock.
306 * needs with ww_mutex_lock. Note that the -EALREADY return code from
310 * with the given context held. It is forbidden to call this on anything else
322 DEBUG_LOCKS_WARN_ON(!ctx->contending_lock); in ww_mutex_lock_slow_interruptible()
330 * ww_mutex_trylock - tries to acquire the w/w mutex without acquire context
338 return mutex_trylock(&lock->base); in ww_mutex_trylock()
342 * ww_mutex_destroy - mark a w/w mutex unusable
351 mutex_destroy(&lock->base); in ww_mutex_destroy()
355 * ww_mutex_is_locked - is the w/w mutex locked
362 return mutex_is_locked(&lock->base); in ww_mutex_is_locked()