Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
ttm_object.c File Reference
#include <drm/ttm/ttm_object.h>
#include <drm/ttm/ttm_module.h>
#include <linux/list.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/atomic.h>

Go to the source code of this file.

Data Structures

struct  ttm_object_file
struct  ttm_object_device
struct  ttm_ref_object


#define pr_fmt(fmt)   "[TTM] " fmt


int ttm_base_object_init (struct ttm_object_file *tfile, struct ttm_base_object *base, bool shareable, enum ttm_object_type object_type, void(*refcount_release)(struct ttm_base_object **), void(*ref_obj_release)(struct ttm_base_object *, enum ttm_ref_type ref_type))
 EXPORT_SYMBOL (ttm_base_object_init)
void ttm_base_object_unref (struct ttm_base_object **p_base)
 EXPORT_SYMBOL (ttm_base_object_unref)
struct ttm_base_objectttm_base_object_lookup (struct ttm_object_file *tfile, uint32_t key)
 EXPORT_SYMBOL (ttm_base_object_lookup)
int ttm_ref_object_add (struct ttm_object_file *tfile, struct ttm_base_object *base, enum ttm_ref_type ref_type, bool *existed)
 EXPORT_SYMBOL (ttm_ref_object_add)
int ttm_ref_object_base_unref (struct ttm_object_file *tfile, unsigned long key, enum ttm_ref_type ref_type)
 EXPORT_SYMBOL (ttm_ref_object_base_unref)
void ttm_object_file_release (struct ttm_object_file **p_tfile)
 EXPORT_SYMBOL (ttm_object_file_release)
struct ttm_object_filettm_object_file_init (struct ttm_object_device *tdev, unsigned int hash_order)
 EXPORT_SYMBOL (ttm_object_file_init)
struct ttm_object_devicettm_object_device_init (struct ttm_mem_global *mem_glob, unsigned int hash_order)
 EXPORT_SYMBOL (ttm_object_device_init)
void ttm_object_device_release (struct ttm_object_device **p_tdev)
 EXPORT_SYMBOL (ttm_object_device_release)

Macro Definition Documentation

#define pr_fmt (   fmt)    "[TTM] " fmt

struct ttm_object_file

: Pointer to the ttm_object_device.

: Lock that protects the ref_list list and the ref_hash hash tables.

: List of ttm_ref_objects to be destroyed at file release.

: Hash tables of ref objects, one per ttm_ref_type, for fast lookup of ref objects given a base object.

Definition at line 52 of file ttm_object.c.

Function Documentation

EXPORT_SYMBOL ( ttm_base_object_init  )
EXPORT_SYMBOL ( ttm_base_object_unref  )
EXPORT_SYMBOL ( ttm_base_object_lookup  )
EXPORT_SYMBOL ( ttm_ref_object_add  )
EXPORT_SYMBOL ( ttm_ref_object_base_unref  )
EXPORT_SYMBOL ( ttm_object_file_release  )
EXPORT_SYMBOL ( ttm_object_file_init  )
EXPORT_SYMBOL ( ttm_object_device_init  )
EXPORT_SYMBOL ( ttm_object_device_release  )
int ttm_base_object_init ( struct ttm_object_file tfile,
struct ttm_base_object base,
bool  shareable,
enum ttm_object_type  object_type,
void(*)(struct ttm_base_object **)  refcount_release,
void(*)(struct ttm_base_object *, enum ttm_ref_type ref_type)  ref_obj_release 

Definition at line 144 of file ttm_object.c.

struct ttm_base_object* ttm_base_object_lookup ( struct ttm_object_file tfile,
uint32_t  key 


: Pointer to a struct ttm_object_file. : Hash key

Looks up a struct ttm_base_object with the key . Also verifies that the object is visible to the application, by comparing the argument and checking the object shareable flag.

Definition at line 216 of file ttm_object.c.

void ttm_base_object_unref ( struct ttm_base_object **  p_base)


: Pointer to a pointer referencing a struct ttm_base_object.

Decrements the base object refcount and clears the pointer pointed to by p_base.

Definition at line 198 of file ttm_object.c.

struct ttm_object_device* ttm_object_device_init ( struct ttm_mem_global mem_glob,
unsigned int  hash_order 

ttm_object device init - initialize a struct ttm_object_device

: Order of hash table used to hash the base objects.

This function is typically called on device initialization to prepare data structures needed for ttm base and ref objects.

Definition at line 418 of file ttm_object.c.

void ttm_object_device_release ( struct ttm_object_device **  p_tdev)

ttm_object_device_release - release data held by a ttm_object_device

: Pointer to pointer to the ttm_object_device object to release. *p_tdev will be set to NULL by this function.

Releases all data associated by a ttm_object_device. Typically called from driver::unload before the destruction of the device private data structure.

Definition at line 441 of file ttm_object.c.

struct ttm_object_file* ttm_object_file_init ( struct ttm_object_device tdev,
unsigned int  hash_order 

ttm_object_file_init - initialize a struct ttm_object file

: A struct ttm_object device this file is initialized on. : Order of the hash table used to hold the reference objects.

This is typically called by the file_ops::open function.

Definition at line 383 of file ttm_object.c.

void ttm_object_file_release ( struct ttm_object_file **  p_tfile)

ttm_object_file_release - release data held by a ttm_object_file

: Pointer to pointer to the ttm_object_file object to release. *p_tfile will be set to NULL by this function.

Releases all data associated by a ttm_object_file. Typically called from file_ops::release. The caller must ensure that there are no concurrent users of tfile.

Definition at line 354 of file ttm_object.c.

int ttm_ref_object_add ( struct ttm_object_file tfile,
struct ttm_base_object base,
enum ttm_ref_type  ref_type,
bool existed 


: A struct ttm_object_file representing the application owning the ref_object. : The base object to reference. : The type of reference. : Upon completion, indicates that an identical reference object already existed, and the refcount was upped on that object instead.

Adding a ref object to a base object is basically like referencing the base object, but a user-space application holds the reference. When the file corresponding to is closed, all its reference objects are deleted. A reference object can have different types depending on what it's intended for. It can be refcounting to prevent object destruction, When user-space takes a lock, it can add a ref object to that lock to make sure the lock is released if the application dies. A ref object will hold a single reference on a base object.

Definition at line 246 of file ttm_object.c.

int ttm_ref_object_base_unref ( struct ttm_object_file tfile,
unsigned long  key,
enum ttm_ref_type  ref_type 


: Key representing the base object. : Ref type of the ref object to be dereferenced.

Unreference a ref object with type on the base object identified by . If there are no duplicate references, the ref object will be destroyed and the base object will be unreferenced.

Definition at line 333 of file ttm_object.c.