Lines Matching +full:on +full:- +full:die
1 /* SPDX-License-Identifier: GPL-2.0 */
9 * Wait/Die implementation:
37 #define ww_mutex_base_is_locked(b) rt_mutex_base_is_locked(&(b)->rtmutex)
90 * ww_mutex_init - initialize the w/w mutex
103 ww_mutex_base_init(&lock->base, ww_class->mutex_name, &ww_class->mutex_key); in ww_mutex_init()
104 lock->ctx = NULL; in ww_mutex_init()
106 lock->ww_class = ww_class; in ww_mutex_init()
111 * ww_acquire_init - initialize a w/w acquire context
117 * Context-based w/w mutex acquiring can be done in any order whatsoever within
119 * wait/die logic.
121 * Mixing of context-based w/w mutex acquiring and single w/w mutex locking can
132 * on the stack.
137 ctx->task = current; in ww_acquire_init()
138 ctx->stamp = atomic_long_inc_return_relaxed(&ww_class->stamp); in ww_acquire_init()
139 ctx->acquired = 0; in ww_acquire_init()
140 ctx->wounded = false; in ww_acquire_init()
141 ctx->is_wait_die = ww_class->is_wait_die; in ww_acquire_init()
143 ctx->ww_class = ww_class; in ww_acquire_init()
144 ctx->done_acquire = 0; in ww_acquire_init()
145 ctx->contending_lock = NULL; in ww_acquire_init()
149 lockdep_init_map(&ctx->dep_map, ww_class->acquire_name, in ww_acquire_init()
150 &ww_class->acquire_key, 0); in ww_acquire_init()
151 mutex_acquire(&ctx->dep_map, 0, 0, _RET_IP_); in ww_acquire_init()
154 ctx->deadlock_inject_interval = 1; in ww_acquire_init()
155 ctx->deadlock_inject_countdown = ctx->stamp & 0xf; in ww_acquire_init()
160 * ww_acquire_done - marks the end of the acquire phase
175 DEBUG_LOCKS_WARN_ON(ctx->done_acquire); in ww_acquire_done()
176 ctx->done_acquire = 1; in ww_acquire_done()
181 * ww_acquire_fini - releases a w/w acquire context
190 mutex_release(&ctx->dep_map, _THIS_IP_); in ww_acquire_fini()
193 DEBUG_LOCKS_WARN_ON(ctx->acquired); in ww_acquire_fini()
199 ctx->done_acquire = 1; in ww_acquire_fini()
203 ctx->acquired = ~0U; in ww_acquire_fini()
208 * ww_mutex_lock - acquire the w/w mutex
215 * wait/die algorithm. If the lock isn't immediately available this function
217 * for backing off by returning -EDEADLK (die case). Trying to acquire the
219 * returning -EALREADY. Returns 0 if the mutex was successfully acquired.
221 * In the die case the caller must release all currently held w/w mutexes for
227 * The mutex must later on be released by the same task that
231 * can be locked. memset()-ing the mutex to 0 is not allowed. The mutex must be
239 * ww_mutex_lock_interruptible - acquire the w/w mutex, interruptible
246 * wait/die algorithm. If the lock isn't immediately available this function
248 * for backing off by returning -EDEADLK (die case). Trying to acquire the
250 * returning -EALREADY. Returns 0 if the mutex was successfully acquired. If a
251 * signal arrives while waiting for the lock then this function returns -EINTR.
253 * In the die case the caller must release all currently held w/w mutexes for
259 * The mutex must later on be released by the same task that
263 * can be locked. memset()-ing the mutex to 0 is not allowed. The mutex must be
272 * ww_mutex_lock_slow - slowpath acquiring of the w/w mutex
276 * Acquires a w/w mutex with the given context after a die case. This function
280 * context and then call this function on the contended lock.
283 * needs with ww_mutex_lock. Note that the -EALREADY return code from
287 * with the context held. It is forbidden to call this on anything else than the
299 DEBUG_LOCKS_WARN_ON(!ctx->contending_lock); in ww_mutex_lock_slow()
306 * ww_mutex_lock_slow_interruptible - slowpath acquiring of the w/w mutex, interruptible
310 * Acquires a w/w mutex with the given context after a die case. This function
313 * function returns -EINTR.
316 * context and then call this function on the contended lock.
319 * needs with ww_mutex_lock. Note that the -EALREADY return code from
323 * with the given context held. It is forbidden to call this on anything else
335 DEBUG_LOCKS_WARN_ON(!ctx->contending_lock); in ww_mutex_lock_slow_interruptible()
343 * ww_mutex_trylock - tries to acquire the w/w mutex without acquire context
351 return ww_mutex_base_trylock(&lock->base); in ww_mutex_trylock()
355 * ww_mutex_destroy - mark a w/w mutex unusable
365 mutex_destroy(&lock->base); in ww_mutex_destroy()
370 * ww_mutex_is_locked - is the w/w mutex locked
377 return ww_mutex_base_is_locked(&lock->base); in ww_mutex_is_locked()