Linux Kernel
3.7.1
|
#include <ttm/ttm_bo_api.h>
#include <ttm/ttm_memory.h>
#include <ttm/ttm_module.h>
#include <drm/drm_mm.h>
#include <drm/drm_global.h>
#include <linux/workqueue.h>
#include <linux/fs.h>
#include <linux/spinlock.h>
Go to the source code of this file.
Data Structures | |
struct | ttm_backend_func |
struct | ttm_tt |
struct | ttm_dma_tt |
struct | ttm_mem_type_manager_func |
struct | ttm_mem_type_manager |
struct | ttm_bo_driver |
struct | ttm_bo_global_ref |
struct | ttm_bo_global |
struct | ttm_bo_device |
Macros | |
#define | TTM_PAGE_FLAG_WRITE (1 << 3) |
#define | TTM_PAGE_FLAG_SWAPPED (1 << 4) |
#define | TTM_PAGE_FLAG_PERSISTENT_SWAP (1 << 5) |
#define | TTM_PAGE_FLAG_ZERO_ALLOC (1 << 6) |
#define | TTM_PAGE_FLAG_DMA32 (1 << 7) |
#define | TTM_PAGE_FLAG_SG (1 << 8) |
#define | TTM_MEMTYPE_FLAG_FIXED (1 << 0) /* Fixed (on-card) PCI memory */ |
#define | TTM_MEMTYPE_FLAG_MAPPABLE (1 << 1) /* Memory mappable */ |
#define | TTM_MEMTYPE_FLAG_CMA (1 << 3) /* Can't map aperture */ |
#define | TTM_NUM_MEM_TYPES 8 |
#define | TTM_BO_PRIV_FLAG_MOVING |
#define | TTM_BO_PRIV_FLAG_MAX 1 |
Enumerations | |
enum | ttm_caching_state { tt_uncached, tt_wc, tt_cached } |
Variables | |
struct ttm_mem_type_manager_func | ttm_bo_manager_func |
#define TTM_BO_PRIV_FLAG_MAX 1 |
Definition at line 511 of file ttm_bo_driver.h.
#define TTM_BO_PRIV_FLAG_MOVING |
Definition at line 510 of file ttm_bo_driver.h.
Definition at line 148 of file ttm_bo_driver.h.
Definition at line 146 of file ttm_bo_driver.h.
#define TTM_MEMTYPE_FLAG_MAPPABLE (1 << 1) /* Memory mappable */ |
Definition at line 147 of file ttm_bo_driver.h.
#define TTM_NUM_MEM_TYPES 8 |
Definition at line 508 of file ttm_bo_driver.h.
#define TTM_PAGE_FLAG_DMA32 (1 << 7) |
Definition at line 81 of file ttm_bo_driver.h.
#define TTM_PAGE_FLAG_PERSISTENT_SWAP (1 << 5) |
Definition at line 79 of file ttm_bo_driver.h.
#define TTM_PAGE_FLAG_SG (1 << 8) |
Definition at line 82 of file ttm_bo_driver.h.
#define TTM_PAGE_FLAG_SWAPPED (1 << 4) |
Definition at line 78 of file ttm_bo_driver.h.
#define TTM_PAGE_FLAG_WRITE (1 << 3) |
Definition at line 77 of file ttm_bo_driver.h.
#define TTM_PAGE_FLAG_ZERO_ALLOC (1 << 6) |
Definition at line 80 of file ttm_bo_driver.h.
enum ttm_caching_state |
Definition at line 84 of file ttm_bo_driver.h.
int ttm_bo_device_init | ( | struct ttm_bo_device * | bdev, |
struct ttm_bo_global * | glob, | ||
struct ttm_bo_driver * | driver, | ||
uint64_t | file_page_offset, | ||
bool | need_dma32 | ||
) |
ttm_bo_device_init
: A pointer to a struct ttm_bo_device to initialize. : A pointer to an initialized struct ttm_bo_global. : A pointer to a struct ttm_bo_driver set up by the caller. : Offset into the device address space that is available for buffer data. This ensures compatibility with other users of the address space.
Initializes a struct ttm_bo_device: Returns: !0: Failure.
int ttm_bo_device_release | ( | struct ttm_bo_device * | bdev | ) |
void ttm_bo_free_old_node | ( | struct ttm_buffer_object * | bo | ) |
ttm_bo_free_old_node
: A pointer to a struct ttm_buffer_object.
Utility function to free an old placement after a successful move.
Definition at line 40 of file ttm_bo_util.c.
int ttm_bo_global_init | ( | struct drm_global_reference * | ref | ) |
void ttm_bo_global_release | ( | struct drm_global_reference * | ref | ) |
void ttm_bo_mem_put | ( | struct ttm_buffer_object * | bo, |
struct ttm_mem_reg * | mem | ||
) |
void ttm_bo_mem_put_locked | ( | struct ttm_buffer_object * | bo, |
struct ttm_mem_reg * | mem | ||
) |
int ttm_bo_mem_space | ( | struct ttm_buffer_object * | bo, |
struct ttm_placement * | placement, | ||
struct ttm_mem_reg * | mem, | ||
bool | interruptible, | ||
bool | no_wait_reserve, | ||
bool | no_wait_gpu | ||
) |
ttm_bo_mem_space
: Pointer to a struct ttm_buffer_object. the data of which we want to allocate space for. : Proposed new placement for the buffer object. : A struct ttm_mem_reg. : Sleep interruptible when sliping. : Return immediately if other buffers are busy. : Return immediately if the GPU is busy.
Allocate memory space for the buffer object pointed to by , using the placement flags in , potentially evicting other idle buffer objects. This function may sleep while waiting for space to become available. Returns: -EBUSY: No space available (only if no_wait == 1). -ENOMEM: Could not allocate memory for the buffer object, either due to fragmentation or concurrent allocators. -ERESTARTSYS: An interruptible sleep was interrupted by a signal.
Creates space for memory region according to its type.
This function first searches for free space in compatible memory types in the priority order defined by the driver. If free space isn't found, then ttm_bo_mem_force_space is attempted in priority order to evict and find space.
int ttm_bo_move_accel_cleanup | ( | struct ttm_buffer_object * | bo, |
void * | sync_obj, | ||
void * | sync_obj_arg, | ||
bool | evict, | ||
bool | no_wait_reserve, | ||
bool | no_wait_gpu, | ||
struct ttm_mem_reg * | new_mem | ||
) |
ttm_bo_move_accel_cleanup.
: A pointer to a struct ttm_buffer_object. : A sync object that signals when moving is complete. : An argument to pass to the sync object idle / wait functions. : This is an evict move. Don't return until the buffer is idle. : Return immediately if other buffers are busy. : Return immediately if the GPU is busy. : struct ttm_mem_reg indicating where to move.
Accelerated move function to be called when an accelerated move has been scheduled. The function will create a new temporary buffer object representing the old placement, and put the sync object on both buffer objects. After that the newly created buffer object is unref'd to be destroyed when the move is complete. This will help pipeline buffer moves.
This should help pipeline ordinary buffer moves.
Hang old buffer memory on a new buffer object, and leave it to be released when the GPU operation has completed.
If we're not moving to fixed memory, the TTM object needs to stay alive. Otherwhise hang it on the ghost bo to be unbound and destroyed.
Definition at line 612 of file ttm_bo_util.c.
int ttm_bo_move_memcpy | ( | struct ttm_buffer_object * | bo, |
bool | evict, | ||
bool | no_wait_reserve, | ||
bool | no_wait_gpu, | ||
struct ttm_mem_reg * | new_mem | ||
) |
ttm_bo_move_memcpy
: A pointer to a struct ttm_buffer_object. : 1: This is an eviction. Don't try to pipeline. : Return immediately if other buffers are busy. : Return immediately if the GPU is busy. : struct ttm_mem_reg indicating where to move.
Fallback move function for a mappable buffer object in mappable memory. The function will, if successful, free any old aperture space, and set ()->mm_node to NULL, and update the ()->mem placement flags. If unsuccessful, the old data remains untouched, and it's up to the caller to free the memory space indicated by . Returns: !0: Failure.
Definition at line 316 of file ttm_bo_util.c.
int ttm_bo_move_ttm | ( | struct ttm_buffer_object * | bo, |
bool | evict, | ||
bool | no_wait_reserve, | ||
bool | no_wait_gpu, | ||
struct ttm_mem_reg * | new_mem | ||
) |
ttm_bo_move_ttm
: A pointer to a struct ttm_buffer_object. : 1: This is an eviction. Don't try to pipeline. : Return immediately if other buffers are busy. : Return immediately if the GPU is busy. : struct ttm_mem_reg indicating where to move.
Optimized move function for a buffer object with both old and new placement backed by a TTM. The function will, if successful, free any old aperture space, and set ()->mm_node to NULL, and update the ()->mem placement flags. If unsuccessful, the old data remains untouched, and it's up to the caller to free the memory space indicated by . Returns: !0: Failure.
Definition at line 45 of file ttm_bo_util.c.
int ttm_bo_reserve | ( | struct ttm_buffer_object * | bo, |
bool | interruptible, | ||
bool | no_wait, | ||
bool | use_sequence, | ||
uint32_t | sequence | ||
) |
ttm_bo_reserve:
: A pointer to a struct ttm_buffer_object. : Sleep interruptible if waiting. : Don't sleep while trying to reserve, rather return -EBUSY. : If is already reserved, Only sleep waiting for it to become unreserved if < ()->sequence.
Locks a buffer object for validation. (Or prevents other processes from locking it for validation) and removes it from lru lists, while taking a number of measures to prevent deadlocks.
Deadlocks may occur when two processes try to reserve multiple buffers in different order, either by will or as a result of a buffer being evicted to make room for a buffer already reserved. (Buffers are reserved before they are evicted). The following algorithm prevents such deadlocks from occurring: 1) Buffers are reserved with the lru spinlock held. Upon successful reservation they are removed from the lru list. This stops a reserved buffer from being evicted. However the lru spinlock is released between the time a buffer is selected for eviction and the time it is reserved. Therefore a check is made when a buffer is reserved for eviction, that it is still the first buffer in the lru list, before it is removed from the list. == 1 forces this check. If it fails, the function returns -EINVAL, and the caller should then choose a new buffer to evict and repeat the procedure. 2) Processes attempting to reserve multiple buffers other than for eviction, (typically execbuf), should first obtain a unique 32-bit validation sequence number, and call this function with == 1 and == the unique sequence number. If upon call of this function, the buffer object is already reserved, the validation sequence is checked against the validation sequence of the process currently reserving the buffer, and if the current validation sequence is greater than that of the process holding the reservation, the function returns -EAGAIN. Otherwise it sleeps waiting for the buffer to become unreserved, after which it retries reserving. The caller should, when receiving an -EAGAIN error release all its buffer reservations, wait for to become unreserved, and then rerun the validation with the same validation sequence. This procedure will always guarantee that the process with the lowest validation sequence will eventually succeed, preventing both deadlocks and starvation.
Returns: -EAGAIN: The reservation may cause a deadlock. Release all buffer reservations, wait for to become unreserved and try again. (only if use_sequence == 1). -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by a signal. Release all buffer reservations and return to user-space. -EBUSY: The function needed to sleep, but was true -EDEADLK: Bo already reserved using . This error code will only be returned if is set to true.
int ttm_bo_reserve_locked | ( | struct ttm_buffer_object * | bo, |
bool | interruptible, | ||
bool | no_wait, | ||
bool | use_sequence, | ||
uint32_t | sequence | ||
) |
ttm_bo_reserve_locked:
: A pointer to a struct ttm_buffer_object. : Sleep interruptible if waiting. : Don't sleep while trying to reserve, rather return -EBUSY. : If is already reserved, Only sleep waiting for it to become unreserved if < ()->sequence.
Must be called with struct ttm_bo_global::lru_lock held, and will not remove reserved buffers from the lru lists. The function may release the LRU spinlock if it needs to sleep. Otherwise identical to ttm_bo_reserve.
Returns: -EAGAIN: The reservation may cause a deadlock. Release all buffer reservations, wait for to become unreserved and try again. (only if use_sequence == 1). -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by a signal. Release all buffer reservations and return to user-space. -EBUSY: The function needed to sleep, but was true -EDEADLK: Bo already reserved using . This error code will only be returned if is set to true.
Deadlock avoidance for multi-bo reserving.
We've already reserved this one.
Already reserved by a thread that will not back off for us. We need to back off.
Wake up waiters that may need to recheck for deadlock, if we decreased the sequence number.
void ttm_bo_unmap_virtual | ( | struct ttm_buffer_object * | bo | ) |
void ttm_bo_unmap_virtual_locked | ( | struct ttm_buffer_object * | bo | ) |
void ttm_bo_unreserve | ( | struct ttm_buffer_object * | bo | ) |
void ttm_bo_unreserve_locked | ( | struct ttm_buffer_object * | bo | ) |
ttm_bo_unreserve_locked
: A pointer to a struct ttm_buffer_object.
Unreserve a previous reservation of . Needs to be called with struct ttm_bo_global::lru_lock held.
int ttm_bo_wait_cpu | ( | struct ttm_buffer_object * | bo, |
bool | no_wait | ||
) |
ttm_bo_wait_for_cpu
: Pointer to a struct ttm_buffer_object. : Don't sleep while waiting.
Wait until a buffer object is no longer sync'ed for CPU access. Returns: -EBUSY: Buffer object was sync'ed for CPU access. (only if no_wait == 1). -ERESTARTSYS: An interruptible sleep was interrupted by a signal.
int ttm_bo_wait_unreserved | ( | struct ttm_buffer_object * | bo, |
bool | interruptible | ||
) |
ttm_bo_wait_unreserved
: A pointer to a struct ttm_buffer_object.
Wait for a struct ttm_buffer_object to become unreserved. This is typically used in the execbuf code to relax cpu-usage when a potential deadlock condition backoff.
void ttm_dma_tt_fini | ( | struct ttm_dma_tt * | ttm_dma | ) |
int ttm_dma_tt_init | ( | struct ttm_dma_tt * | ttm_dma, |
struct ttm_bo_device * | bdev, | ||
unsigned long | size, | ||
uint32_t | page_flags, | ||
struct page * | dummy_read_page | ||
) |
ttm_io_prot
: Caching state. : Page protection flag for a normal, cached mapping.
Utility function that returns the pgprot_t that should be used for setting up a PTE with the caching model indicated by .
Definition at line 454 of file ttm_bo_util.c.
void ttm_mem_io_free_vm | ( | struct ttm_buffer_object * | bo | ) |
Definition at line 173 of file ttm_bo_util.c.
int ttm_mem_io_lock | ( | struct ttm_mem_type_manager * | man, |
bool | interruptible | ||
) |
Definition at line 78 of file ttm_bo_util.c.
int ttm_mem_io_reserve_vm | ( | struct ttm_buffer_object * | bo | ) |
Definition at line 153 of file ttm_bo_util.c.
void ttm_mem_io_unlock | ( | struct ttm_mem_type_manager * | man | ) |
Definition at line 90 of file ttm_bo_util.c.
bool ttm_mem_reg_is_pci | ( | struct ttm_bo_device * | bdev, |
struct ttm_mem_reg * | mem | ||
) |
ttm_mem_reg_is_pci
: Pointer to a struct ttm_bo_device. : A valid struct ttm_mem_reg.
Returns true if the memory described by is PCI memory, false otherwise.
int ttm_tt_bind | ( | struct ttm_tt * | ttm, |
struct ttm_mem_reg * | bo_mem | ||
) |
int ttm_tt_init | ( | struct ttm_tt * | ttm, |
struct ttm_bo_device * | bdev, | ||
unsigned long | size, | ||
uint32_t | page_flags, | ||
struct page * | dummy_read_page | ||
) |
ttm_tt_init
: The struct ttm_tt. : pointer to a struct ttm_bo_device: : Size of the data needed backing. : Page flags as identified by TTM_PAGE_FLAG_XX flags. : See struct ttm_bo_device.
Create a struct ttm_tt to back data with system memory pages. No pages are actually allocated. Returns: NULL: Out of memory.
ttm_tt_set_placement_caching:
A struct ttm_tt the backing pages of which will change caching policy. : Flag indicating the desired caching policy.
This function will change caching policy of any default kernel mappings of the pages backing . If changing from cached to uncached or write-combined, all CPU caches will first be flushed to make sure the data of the pages hit RAM. This function may be very costly as it involves global TLB and cache flushes and potential page splitting / combining.
struct ttm_mem_type_manager_func ttm_bo_manager_func |
Definition at line 150 of file ttm_bo_manager.c.