Lines Matching +full:wakeup +full:- +full:event +full:- +full:action
3 * Copyright (c) 2007-2009 VMware, Inc., Palo Alto, CA., USA
20 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
28 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
50 mtx_init(&lock->lock, "ttmlk", NULL, MTX_DEF); in ttm_lock_init()
51 lock->rw = 0; in ttm_lock_init()
52 lock->flags = 0; in ttm_lock_init()
53 lock->kill_takers = false; in ttm_lock_init()
54 lock->signal = SIGKILL; in ttm_lock_init()
70 mtx_lock(&lock->lock); in ttm_read_unlock()
71 if (--lock->rw == 0) in ttm_read_unlock()
72 wakeup(lock); in ttm_read_unlock()
73 mtx_unlock(&lock->lock); in ttm_read_unlock()
80 if (unlikely(lock->kill_takers)) { in __ttm_read_lock()
81 ttm_lock_send_sig(lock->signal); in __ttm_read_lock()
84 if (lock->rw >= 0 && lock->flags == 0) { in __ttm_read_lock()
85 ++lock->rw; in __ttm_read_lock()
105 mtx_lock(&lock->lock); in ttm_read_lock()
107 ret = -msleep(lock, &lock->lock, flags, wmsg, 0); in ttm_read_lock()
108 if (ret == -EINTR || ret == -ERESTART) in ttm_read_lock()
109 ret = -ERESTARTSYS; in ttm_read_lock()
122 if (unlikely(lock->kill_takers)) { in __ttm_read_trylock()
123 ttm_lock_send_sig(lock->signal); in __ttm_read_trylock()
126 if (lock->rw >= 0 && lock->flags == 0) { in __ttm_read_trylock()
127 ++lock->rw; in __ttm_read_trylock()
130 } else if (lock->flags == 0) { in __ttm_read_trylock()
151 mtx_lock(&lock->lock); in ttm_read_trylock()
153 ret = -msleep(lock, &lock->lock, flags, wmsg, 0); in ttm_read_trylock()
154 if (ret == -EINTR || ret == -ERESTART) in ttm_read_trylock()
155 ret = -ERESTARTSYS; in ttm_read_trylock()
160 mtx_unlock(&lock->lock); in ttm_read_trylock()
162 return (locked) ? 0 : -EBUSY; in ttm_read_trylock()
167 mtx_lock(&lock->lock); in ttm_write_unlock()
168 lock->rw = 0; in ttm_write_unlock()
169 wakeup(lock); in ttm_write_unlock()
170 mtx_unlock(&lock->lock); in ttm_write_unlock()
177 if (unlikely(lock->kill_takers)) { in __ttm_write_lock()
178 ttm_lock_send_sig(lock->signal); in __ttm_write_lock()
181 if (lock->rw == 0 && ((lock->flags & ~TTM_WRITE_LOCK_PENDING) == 0)) { in __ttm_write_lock()
182 lock->rw = -1; in __ttm_write_lock()
183 lock->flags &= ~TTM_WRITE_LOCK_PENDING; in __ttm_write_lock()
186 lock->flags |= TTM_WRITE_LOCK_PENDING; in __ttm_write_lock()
205 mtx_lock(&lock->lock); in ttm_write_lock()
208 ret = -msleep(lock, &lock->lock, flags, wmsg, 0); in ttm_write_lock()
209 if (ret == -EINTR || ret == -ERESTART) in ttm_write_lock()
210 ret = -ERESTARTSYS; in ttm_write_lock()
212 lock->flags &= ~TTM_WRITE_LOCK_PENDING; in ttm_write_lock()
213 wakeup(lock); in ttm_write_lock()
217 mtx_unlock(&lock->lock); in ttm_write_lock()
224 mtx_lock(&lock->lock); in ttm_write_lock_downgrade()
225 lock->rw = 1; in ttm_write_lock_downgrade()
226 wakeup(lock); in ttm_write_lock_downgrade()
227 mtx_unlock(&lock->lock); in ttm_write_lock_downgrade()
234 mtx_lock(&lock->lock); in __ttm_vt_unlock()
235 if (unlikely(!(lock->flags & TTM_VT_LOCK))) in __ttm_vt_unlock()
236 ret = -EINVAL; in __ttm_vt_unlock()
237 lock->flags &= ~TTM_VT_LOCK; in __ttm_vt_unlock()
238 wakeup(lock); in __ttm_vt_unlock()
239 mtx_unlock(&lock->lock); in __ttm_vt_unlock()
259 if (lock->rw == 0) { in __ttm_vt_lock()
260 lock->flags &= ~TTM_VT_LOCK_PENDING; in __ttm_vt_lock()
261 lock->flags |= TTM_VT_LOCK; in __ttm_vt_lock()
264 lock->flags |= TTM_VT_LOCK_PENDING; in __ttm_vt_lock()
284 mtx_lock(&lock->lock); in ttm_vt_lock()
286 ret = -msleep(lock, &lock->lock, flags, wmsg, 0); in ttm_vt_lock()
287 if (ret == -EINTR || ret == -ERESTART) in ttm_vt_lock()
288 ret = -ERESTARTSYS; in ttm_vt_lock()
290 lock->flags &= ~TTM_VT_LOCK_PENDING; in ttm_vt_lock()
291 wakeup(lock); in ttm_vt_lock()
297 * Add a base-object, the destructor of which will in ttm_vt_lock()
302 ret = ttm_base_object_init(tfile, &lock->base, false, in ttm_vt_lock()
307 lock->vt_holder = tfile; in ttm_vt_lock()
314 return ttm_ref_object_base_unref(lock->vt_holder, in ttm_vt_unlock()
315 lock->base.hash.key, TTM_REF_USAGE); in ttm_vt_unlock()
320 mtx_lock(&lock->lock); in ttm_suspend_unlock()
321 lock->flags &= ~TTM_SUSPEND_LOCK; in ttm_suspend_unlock()
322 wakeup(lock); in ttm_suspend_unlock()
323 mtx_unlock(&lock->lock); in ttm_suspend_unlock()
330 if (lock->rw == 0) { in __ttm_suspend_lock()
331 lock->flags &= ~TTM_SUSPEND_LOCK_PENDING; in __ttm_suspend_lock()
332 lock->flags |= TTM_SUSPEND_LOCK; in __ttm_suspend_lock()
335 lock->flags |= TTM_SUSPEND_LOCK_PENDING; in __ttm_suspend_lock()
342 mtx_lock(&lock->lock); in ttm_suspend_lock()
344 msleep(lock, &lock->lock, 0, "ttms", 0); in ttm_suspend_lock()
345 mtx_unlock(&lock->lock); in ttm_suspend_lock()