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()
179 DEBUG_LOCKS_WARN_ON(ctx->acquired); in ww_acquire_fini()
185 ctx->done_acquire = 1; in ww_acquire_fini()
189 ctx->acquired = ~0U; in ww_acquire_fini()
194 * ww_mutex_lock - acquire the w/w mutex
201 * wait/die algorithm. If the lock isn't immediately available this function
203 * for backing off by returning -EDEADLK (die case). Trying to acquire the
205 * returning -EALREADY. Returns 0 if the mutex was successfully acquired.
207 * In the die case the caller must release all currently held w/w mutexes for
213 * The mutex must later on be released by the same task that
217 * can be locked. memset()-ing the mutex to 0 is not allowed. The mutex must be
225 * ww_mutex_lock_interruptible - acquire the w/w mutex, interruptible
232 * wait/die algorithm. If the lock isn't immediately available this function
234 * for backing off by returning -EDEADLK (die case). Trying to acquire the
236 * returning -EALREADY. Returns 0 if the mutex was successfully acquired. If a
237 * signal arrives while waiting for the lock then this function returns -EINTR.
239 * In the die case the caller must release all currently held w/w mutexes for
245 * The mutex must later on be released by the same task that
249 * can be locked. memset()-ing the mutex to 0 is not allowed. The mutex must be
258 * ww_mutex_lock_slow - slowpath acquiring of the w/w mutex
262 * Acquires a w/w mutex with the given context after a die case. This function
266 * context and then call this function on the contended lock.
269 * needs with ww_mutex_lock. Note that the -EALREADY return code from
273 * with the context held. It is forbidden to call this on anything else than the
285 DEBUG_LOCKS_WARN_ON(!ctx->contending_lock); in ww_mutex_lock_slow()
292 * ww_mutex_lock_slow_interruptible - slowpath acquiring of the w/w mutex, interruptible
296 * Acquires a w/w mutex with the given context after a die case. This function
299 * function returns -EINTR.
302 * context and then call this function on the contended lock.
305 * needs with ww_mutex_lock. Note that the -EALREADY return code from
309 * with the given context held. It is forbidden to call this on anything else
321 DEBUG_LOCKS_WARN_ON(!ctx->contending_lock); in ww_mutex_lock_slow_interruptible()
329 * ww_mutex_trylock - tries to acquire the w/w mutex without acquire context
337 return mutex_trylock(&lock->base); in ww_mutex_trylock()
341 * ww_mutex_destroy - mark a w/w mutex unusable
350 mutex_destroy(&lock->base); in ww_mutex_destroy()
354 * ww_mutex_is_locked - is the w/w mutex locked
361 return mutex_is_locked(&lock->base); in ww_mutex_is_locked()