34 #include <linux/errno.h>
35 #include <linux/wait.h>
36 #include <linux/sched.h>
37 #include <linux/module.h>
39 #define TTM_WRITE_LOCK_PENDING (1 << 0)
40 #define TTM_VT_LOCK_PENDING (1 << 1)
41 #define TTM_SUSPEND_LOCK_PENDING (1 << 2)
42 #define TTM_VT_LOCK (1 << 3)
43 #define TTM_SUSPEND_LOCK (1 << 4)
58 spin_lock(&lock->
lock);
61 spin_unlock(&lock->
lock);
65 static bool __ttm_read_lock(
struct ttm_lock *lock)
69 spin_lock(&lock->
lock);
72 spin_unlock(&lock->
lock);
75 if (lock->
rw >= 0 && lock->
flags == 0) {
79 spin_unlock(&lock->
lock);
89 __ttm_read_lock(lock));
96 static bool __ttm_read_trylock(
struct ttm_lock *lock,
bool *locked)
102 spin_lock(&lock->
lock);
105 spin_unlock(&lock->
lock);
108 if (lock->
rw >= 0 && lock->
flags == 0) {
112 }
else if (lock->
flags == 0) {
115 spin_unlock(&lock->
lock);
127 (lock->
queue, __ttm_read_trylock(lock, &locked));
136 return (locked) ? 0 : -
EBUSY;
141 spin_lock(&lock->
lock);
144 spin_unlock(&lock->
lock);
148 static bool __ttm_write_lock(
struct ttm_lock *lock)
152 spin_lock(&lock->
lock);
155 spin_unlock(&lock->
lock);
165 spin_unlock(&lock->
lock);
175 __ttm_write_lock(lock));
177 spin_lock(&lock->
lock);
180 spin_unlock(&lock->
lock);
191 spin_lock(&lock->
lock);
194 spin_unlock(&lock->
lock);
197 static int __ttm_vt_unlock(
struct ttm_lock *lock)
201 spin_lock(&lock->
lock);
206 spin_unlock(&lock->
lock);
218 ret = __ttm_vt_unlock(lock);
222 static bool __ttm_vt_lock(
struct ttm_lock *lock)
226 spin_lock(&lock->
lock);
234 spin_unlock(&lock->
lock);
246 __ttm_vt_lock(lock));
248 spin_lock(&lock->
lock);
251 spin_unlock(&lock->
lock);
266 (
void)__ttm_vt_unlock(lock);
283 spin_lock(&lock->
lock);
286 spin_unlock(&lock->
lock);
290 static bool __ttm_suspend_lock(
struct ttm_lock *lock)
294 spin_lock(&lock->
lock);
302 spin_unlock(&lock->
lock);