123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- #ifndef _TTM_LOCK_H_
- #define _TTM_LOCK_H_
- #include <linux/wait.h>
- #include <linux/atomic.h>
- #include "ttm_object.h"
- struct ttm_lock {
- struct ttm_base_object base;
- wait_queue_head_t queue;
- spinlock_t lock;
- int32_t rw;
- uint32_t flags;
- bool kill_takers;
- int signal;
- struct ttm_object_file *vt_holder;
- };
- extern void ttm_lock_init(struct ttm_lock *lock);
- extern void ttm_read_unlock(struct ttm_lock *lock);
- extern int ttm_read_lock(struct ttm_lock *lock, bool interruptible);
- extern int ttm_read_trylock(struct ttm_lock *lock, bool interruptible);
- extern void ttm_write_unlock(struct ttm_lock *lock);
- extern int ttm_write_lock(struct ttm_lock *lock, bool interruptible);
- extern void ttm_lock_downgrade(struct ttm_lock *lock);
- extern void ttm_suspend_lock(struct ttm_lock *lock);
- extern void ttm_suspend_unlock(struct ttm_lock *lock);
- extern int ttm_vt_lock(struct ttm_lock *lock, bool interruptible,
- struct ttm_object_file *tfile);
- extern int ttm_vt_unlock(struct ttm_lock *lock);
- extern void ttm_write_unlock(struct ttm_lock *lock);
- extern int ttm_write_lock(struct ttm_lock *lock, bool interruptible);
- static inline void ttm_lock_set_kill(struct ttm_lock *lock, bool val,
- int signal)
- {
- lock->kill_takers = val;
- if (val)
- lock->signal = signal;
- }
- #endif
|