Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Functions
ttm_lock.h File Reference
#include <ttm/ttm_object.h>
#include <linux/wait.h>
#include <linux/atomic.h>

Go to the source code of this file.

Data Structures

struct  ttm_lock
 

Functions

void ttm_lock_init (struct ttm_lock *lock)
 
void ttm_read_unlock (struct ttm_lock *lock)
 
int ttm_read_lock (struct ttm_lock *lock, bool interruptible)
 
int ttm_read_trylock (struct ttm_lock *lock, bool interruptible)
 
void ttm_write_unlock (struct ttm_lock *lock)
 
int ttm_write_lock (struct ttm_lock *lock, bool interruptible)
 
void ttm_lock_downgrade (struct ttm_lock *lock)
 
void ttm_suspend_lock (struct ttm_lock *lock)
 
void ttm_suspend_unlock (struct ttm_lock *lock)
 
int ttm_vt_lock (struct ttm_lock *lock, bool interruptible, struct ttm_object_file *tfile)
 
int ttm_vt_unlock (struct ttm_lock *lock)
 

Detailed Description

This file implements a simple replacement for the buffer manager use of the DRM heavyweight hardware lock. The lock is a read-write lock. Taking it in read mode and write mode is relatively fast, and intended for in-kernel use only.

The vt mode is used only when there is a need to block all user-space processes from validating buffers. It's allowed to leave kernel space with the vt lock held. If a user-space process dies while having the vt-lock, it will be released during the file descriptor release. The vt lock excludes write lock and read lock.

The suspend mode is used to lock out all TTM users when preparing for and executing suspend operations.

Definition in file ttm_lock.h.

Function Documentation

void ttm_lock_downgrade ( struct ttm_lock lock)

ttm_lock_downgrade

: Pointer to a struct ttm_lock

Downgrades a write lock to a read lock.

void ttm_lock_init ( struct ttm_lock lock)

ttm_lock_init

: Pointer to a struct ttm_lock Initializes the lock.

Definition at line 45 of file ttm_lock.c.

int ttm_read_lock ( struct ttm_lock lock,
bool  interruptible 
)

ttm_read_lock

: Pointer to a struct ttm_lock : Interruptible sleeping while waiting for a lock.

Takes the lock in read mode. Returns: -ERESTARTSYS If interrupted by a signal and interruptible is true.

Definition at line 83 of file ttm_lock.c.

int ttm_read_trylock ( struct ttm_lock lock,
bool  interruptible 
)

ttm_read_trylock

: Pointer to a struct ttm_lock : Interruptible sleeping while waiting for a lock.

Tries to take the lock in read mode. If the lock is already held in write mode, the function will return -EBUSY. If the lock is held in vt or suspend mode, the function will sleep until these modes are unlocked.

Returns: -EBUSY The lock was already held in write mode. -ERESTARTSYS If interrupted by a signal and interruptible is true.

Definition at line 120 of file ttm_lock.c.

void ttm_read_unlock ( struct ttm_lock lock)

ttm_read_unlock

: Pointer to a struct ttm_lock

Releases a read lock.

Definition at line 56 of file ttm_lock.c.

void ttm_suspend_lock ( struct ttm_lock lock)

ttm_suspend_lock

: Pointer to a struct ttm_lock

Takes the lock in suspend mode. Excludes read and write mode.

Definition at line 306 of file ttm_lock.c.

void ttm_suspend_unlock ( struct ttm_lock lock)

ttm_suspend_unlock

: Pointer to a struct ttm_lock

Releases a suspend lock

Definition at line 281 of file ttm_lock.c.

int ttm_vt_lock ( struct ttm_lock lock,
bool  interruptible,
struct ttm_object_file tfile 
)

ttm_vt_lock

: Pointer to a struct ttm_lock : Interruptible sleeping while waiting for a lock. : Pointer to a struct ttm_object_file to register the lock with.

Takes the lock in vt mode. Returns: -ERESTARTSYS If interrupted by a signal and interruptible is true. -ENOMEM: Out of memory when locking.

Definition at line 238 of file ttm_lock.c.

int ttm_vt_unlock ( struct ttm_lock lock)

ttm_vt_unlock

: Pointer to a struct ttm_lock

Releases a vt lock. Returns: -EINVAL If the lock was not held.

Definition at line 274 of file ttm_lock.c.

int ttm_write_lock ( struct ttm_lock lock,
bool  interruptible 
)

ttm_write_lock

: Pointer to a struct ttm_lock : Interruptible sleeping while waiting for a lock.

Takes the lock in write mode. Returns: -ERESTARTSYS If interrupted by a signal and interruptible is true.

Definition at line 169 of file ttm_lock.c.

void ttm_write_unlock ( struct ttm_lock lock)

ttm_write_unlock

: Pointer to a struct ttm_lock

Releases a write lock.

Definition at line 139 of file ttm_lock.c.