Lines Matching +full:phase +full:- +full:locked

1 /* SPDX-License-Identifier: GPL-2.0 */
35 #define ww_mutex_base_is_locked(b) rt_mutex_base_is_locked(&(b)->rtmutex)
88 * ww_mutex_init - initialize the w/w mutex
96 * It is not allowed to initialize an already locked 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
119 * Mixing of context-based w/w mutex acquiring and single w/w mutex locking can
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
161 * Marks the end of the acquire phase, any further w/w mutex lock calls using
165 * code and clearly designated the acquire phase from actually using the locked
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
215 * for backing off by returning -EDEADLK (die case). Trying to acquire the
217 * returning -EALREADY. Returns 0 if the mutex was successfully acquired.
228 * locked. The mutex must first be initialized (or statically defined) before it
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
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.
260 * locked. The mutex must first be initialized (or statically defined) before it
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
281 * needs with ww_mutex_lock. Note that the -EALREADY return code from
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
311 * function returns -EINTR.
317 * needs with ww_mutex_lock. Note that the -EALREADY return code from
333 DEBUG_LOCKS_WARN_ON(!ctx->contending_lock); in ww_mutex_lock_slow_interruptible()
344 * ww_mutex_destroy - mark a w/w mutex unusable
348 * use of the mutex is forbidden. The mutex must not be locked when
354 mutex_destroy(&lock->base); in ww_mutex_destroy()
359 * ww_mutex_is_locked - is the w/w mutex locked
362 * Returns 1 if the mutex is locked, 0 if unlocked.
366 return ww_mutex_base_is_locked(&lock->base); in ww_mutex_is_locked()