Linux Kernel
3.7.1
|
#include <drm/drm_hashtab.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/wait.h>
#include <linux/mutex.h>
#include <linux/mm.h>
#include <linux/rbtree.h>
#include <linux/bitmap.h>
Go to the source code of this file.
Data Structures | |
struct | ttm_placement |
struct | ttm_bus_placement |
struct | ttm_mem_reg |
struct | ttm_buffer_object |
struct | ttm_bo_kmap_obj |
Macros | |
#define | TTM_BO_MAP_IOMEM_MASK 0x80 |
Enumerations | |
enum | ttm_bo_type { ttm_bo_type_device, ttm_bo_type_kernel, ttm_bo_type_sg } |
Variables | |
struct ttm_placement * | intel_gtt_get |
#define TTM_BO_MAP_IOMEM_MASK 0x80 |
Definition at line 295 of file ttm_bo_api.h.
enum ttm_bo_type |
enum ttm_bo_type
: These are 'normal' buffers that can be mmapped by user space. Each of these bos occupy a slot in the device address space, that can be used for normal vm operations.
: These buffers are like ttm_bo_type_device buffers, but they cannot be accessed from user-space. For kernel-only use.
: Buffer made from dmabuf sg table shared with another driver.
Definition at line 132 of file ttm_bo_api.h.
size_t ttm_bo_acc_size | ( | struct ttm_bo_device * | bdev, |
unsigned long | bo_size, | ||
unsigned | struct_size | ||
) |
ttm_bo_acc_size
: Pointer to a ttm_bo_device struct. : size of the buffer object in byte. : size of the structure holding buffer object datas
Returns size to account for a buffer object
void ttm_bo_add_to_lru | ( | struct ttm_buffer_object * | bo | ) |
ttm_bo_add_to_lru
: The buffer object.
Add this bo to the relevant mem type lru and, if it's backed by system pages (ttms) to the swap list. This function must be called with struct ttm_bo_global::lru_lock held, and is typically called immediately prior to unreserving a bo.
int ttm_bo_check_placement | ( | struct ttm_buffer_object * | bo, |
struct ttm_placement * | placement | ||
) |
int ttm_bo_clean_mm | ( | struct ttm_bo_device * | bdev, |
unsigned | mem_type | ||
) |
ttm_bo_clean_mm
: Pointer to a ttm_bo_device struct. : The memory type.
Take down a manager for a given memory type after first walking the LRU list to evict any buffers left alive.
Normally, this function is part of lastclose() or unload(), and at that point there shouldn't be any buffers left created by user-space, since there should've been removed by the file descriptor release() method. However, before this function is run, make sure to signal all sync objects, and verify that the delayed delete queue is empty. The driver must also make sure that there are no NO_EVICT buffers present in this memory type when the call is made.
If this function is part of a VT switch, the caller must make sure that there are no appications currently validating buffers before this function is called. The caller can do that by first taking the struct ttm_bo_device::ttm_lock in write mode.
Returns: -EINVAL: invalid or uninitialized memory type. -EBUSY: There are still buffers left in this memory type.
int ttm_bo_create | ( | struct ttm_bo_device * | bdev, |
unsigned long | size, | ||
enum ttm_bo_type | type, | ||
struct ttm_placement * | placement, | ||
uint32_t | page_alignment, | ||
unsigned long | buffer_start, | ||
bool | interruptible, | ||
struct file * | persistent_swap_storage, | ||
struct ttm_buffer_object ** | p_bo | ||
) |
ttm_bo_synccpu_object_init
: Pointer to a ttm_bo_device struct. : Pointer to a ttm_buffer_object to be initialized. : Requested size of buffer object. : Requested type of buffer object. : Initial placement flags. : Data alignment in pages. : Virtual address of user space data backing a user buffer object. : If needing to sleep while waiting for GPU resources, sleep interruptible. : Usually the swap storage is deleted for buffers pinned in physical memory. If this behaviour is not desired, this member holds a pointer to a persistent shmem object. Typically, this would point to the shmem object backing a GEM object if TTM is used to back a GEM user interface. : On successful completion *p_bo points to the created object.
This function allocates a ttm_buffer_object, and then calls ttm_bo_init on that object. The destroy function is set to kfree(). Returns -ENOMEM: Out of memory. -EINVAL: Invalid placement flags. -ERESTARTSYS: Interrupted by signal while waiting for resources.
int ttm_bo_del_from_lru | ( | struct ttm_buffer_object * | bo | ) |
ttm_bo_del_from_lru
: The buffer object.
Remove this bo from all lru lists used to lookup and reserve an object. This function must be called with struct ttm_bo_global::lru_lock held, and is usually called just immediately after the bo has been reserved to avoid recursive reservation from lru lists.
size_t ttm_bo_dma_acc_size | ( | struct ttm_bo_device * | bdev, |
unsigned long | bo_size, | ||
unsigned | struct_size | ||
) |
int ttm_bo_evict_mm | ( | struct ttm_bo_device * | bdev, |
unsigned | mem_type | ||
) |
ttm_bo_evict_mm
: Pointer to a ttm_bo_device struct. : The memory type.
Evicts all buffers on the lru list of the memory type. This is normally part of a VT switch or an out-of-memory-space-due-to-fragmentation handler. The caller must make sure that there are no other processes currently validating buffers, and can do that by taking the struct ttm_bo_device::ttm_lock in write mode.
Returns: -EINVAL: Invalid or uninitialized memory type. -ERESTARTSYS: The call was interrupted by a signal while waiting to evict a buffer.
int ttm_bo_init | ( | struct ttm_bo_device * | bdev, |
struct ttm_buffer_object * | bo, | ||
unsigned long | size, | ||
enum ttm_bo_type | type, | ||
struct ttm_placement * | placement, | ||
uint32_t | page_alignment, | ||
unsigned long | buffer_start, | ||
bool | interrubtible, | ||
struct file * | persistent_swap_storage, | ||
size_t | acc_size, | ||
struct sg_table * | sg, | ||
void(*)(struct ttm_buffer_object *) | destroy | ||
) |
ttm_bo_init
: Pointer to a ttm_bo_device struct. : Pointer to a ttm_buffer_object to be initialized. : Requested size of buffer object. : Requested type of buffer object. : Initial placement flags. : Data alignment in pages. : Virtual address of user space data backing a user buffer object. : If needing to sleep to wait for GPU resources, sleep interruptible. : Usually the swap storage is deleted for buffers pinned in physical memory. If this behaviour is not desired, this member holds a pointer to a persistent shmem object. Typically, this would point to the shmem object backing a GEM object if TTM is used to back a GEM user interface. : Accounted size for this object. : Destroy function. Use NULL for kfree().
This function initializes a pre-allocated struct ttm_buffer_object. As this object may be part of a larger structure, this function, together with the function, enables driver-specific objects derived from a ttm_buffer_object. On successful return, the object kref and list_kref are set to 1. If a failure occurs, the function will call the function, or kfree() if is NULL. Thus, after a failure, dereferencing is illegal and will likely cause memory corruption.
Returns -ENOMEM: Out of memory. -EINVAL: Invalid placement flags. -ERESTARTSYS: Interrupted by signal while sleeping waiting for resources.
int ttm_bo_init_mm | ( | struct ttm_bo_device * | bdev, |
unsigned | type, | ||
unsigned long | p_size | ||
) |
ttm_bo_init_mm
: Pointer to a ttm_bo_device struct. : The memory type. : size managed area in pages.
Initialize a manager for a given memory type. Note: if part of driver firstopen, it must be protected from a potentially racing lastclose. Returns: -EINVAL: invalid size or memory type. -ENOMEM: Not enough memory. May also return driver-specified errors.
ssize_t ttm_bo_io | ( | struct ttm_bo_device * | bdev, |
struct file * | filp, | ||
const char __user * | wbuf, | ||
char __user * | rbuf, | ||
size_t | count, | ||
loff_t * | f_pos, | ||
bool | write | ||
) |
ttm_bo_io
: Pointer to the struct ttm_bo_device. : Pointer to the struct file attempting to read / write. : User-space pointer to address of buffer to write. NULL on read. : User-space pointer to address of buffer to read into. Null on write. : Number of bytes to read / write. : Pointer to current file position. : 1 for read, 0 for write.
This function implements read / write into ttm buffer objects, and is intended to be called from the fops::read and fops::write method. Returns: See man (2) write, man(2) read. In particular, the function may return -ERESTARTSYS if interrupted by a signal.
Definition at line 309 of file ttm_bo_vm.c.
int ttm_bo_kmap | ( | struct ttm_buffer_object * | bo, |
unsigned long | start_page, | ||
unsigned long | num_pages, | ||
struct ttm_bo_kmap_obj * | map | ||
) |
ttm_bo_kmap
: The buffer object. : The first page to map. : Number of pages to map. : pointer to a struct ttm_bo_kmap_obj representing the map.
Sets up a kernel virtual mapping, using ioremap, vmap or kmap to the data in the buffer object. The ttm_kmap_obj_virtual function can then be used to obtain a virtual address to the data.
Returns -ENOMEM: Out of memory. -EINVAL: Invalid range.
Definition at line 546 of file ttm_bo_util.c.
void ttm_bo_kunmap | ( | struct ttm_bo_kmap_obj * | map | ) |
ttm_bo_kunmap
: Object describing the map to unmap.
Unmaps a kernel map set up by ttm_bo_kmap.
Definition at line 581 of file ttm_bo_util.c.
void ttm_bo_list_ref_sub | ( | struct ttm_buffer_object * | bo, |
int | count, | ||
bool | never_free | ||
) |
int ttm_bo_lock_delayed_workqueue | ( | struct ttm_bo_device * | bdev | ) |
int ttm_bo_mmap | ( | struct file * | filp, |
struct vm_area_struct * | vma, | ||
struct ttm_bo_device * | bdev | ||
) |
ttm_bo_mmap - mmap out of the ttm device address space.
: filp as input from the mmap method. : vma as input from the mmap method. : Pointer to the ttm_bo_device with the address space manager.
This function is intended to be called by the device mmap method. if the device address space is to be backed by the bo manager.
Definition at line 252 of file ttm_bo_vm.c.
void ttm_bo_swapout_all | ( | struct ttm_bo_device * | bdev | ) |
int ttm_bo_synccpu_write_grab | ( | struct ttm_buffer_object * | bo, |
bool | no_wait | ||
) |
ttm_bo_synccpu_write_grab
: The buffer object: : Return immediately if buffer is busy.
Synchronizes a buffer object for CPU RW access. This means blocking command submission that affects the buffer and waiting for buffer idle. This lock is recursive. Returns -EBUSY if the buffer is busy and no_wait is true. -ERESTARTSYS if interrupted by a signal.
void ttm_bo_synccpu_write_release | ( | struct ttm_buffer_object * | bo | ) |
void ttm_bo_unlock_delayed_workqueue | ( | struct ttm_bo_device * | bdev, |
int | resched | ||
) |
void ttm_bo_unref | ( | struct ttm_buffer_object ** | bo | ) |
int ttm_bo_validate | ( | struct ttm_buffer_object * | bo, |
struct ttm_placement * | placement, | ||
bool | interruptible, | ||
bool | no_wait_reserve, | ||
bool | no_wait_gpu | ||
) |
ttm_bo_validate
: The buffer object. : Proposed placement for the buffer object. : Sleep interruptible if sleeping. : Return immediately if other buffers are busy. : Return immediately if the GPU is busy.
Changes placement and caching policy of the buffer object according proposed placement. Returns -EINVAL on invalid proposed placement. -ENOMEM on out-of-memory condition. -EBUSY if no_wait is true and buffer busy. -ERESTARTSYS if interrupted by a signal.
ttm_bo_wait - wait for buffer idle.
: The buffer object. : Use interruptible wait. : Return immediately if buffer is busy.
This function must be called with the bo::mutex held, and makes sure any previous rendering to the buffer is completed. Note: It might be necessary to block validations before the wait by reserving the buffer. Returns -EBUSY if no_wait is true and the buffer is busy. Returns -ERESTARTSYS if interrupted by a signal.
int ttm_fbdev_mmap | ( | struct vm_area_struct * | vma, |
struct ttm_buffer_object * | bo | ||
) |
ttm_fbdev_mmap - mmap fbdev memory backed by a ttm buffer object.
: vma as input from the fbdev mmap method. : The bo backing the address space. The address space will have the same size as the bo, and start at offset 0.
This function is intended to be called by the fbdev mmap method if the fbdev address space is to be backed by a bo.
Definition at line 296 of file ttm_bo_vm.c.
struct ttm_placement * intel_gtt_get |