static inline drm_buffer_object_t *drm_bo_entry(struct list_head *list,
unsigned type)
{
- switch(type) {
+ switch (type) {
case DRM_BO_MEM_LOCAL:
case DRM_BO_MEM_TT:
return list_entry(list, drm_buffer_object_t, lru_ttm);
return NULL;
}
-static inline drm_mm_node_t *drm_bo_mm_node(drm_buffer_object_t *bo,
+static inline drm_mm_node_t *drm_bo_mm_node(drm_buffer_object_t * bo,
unsigned type)
{
- switch(type) {
+ switch (type) {
case DRM_BO_MEM_LOCAL:
case DRM_BO_MEM_TT:
return bo->node_ttm;
}
return NULL;
}
-
+
/*
* bo locked. dev->struct_mutex locked.
*/
-static void drm_bo_add_to_lru(drm_buffer_object_t *buf,
- drm_buffer_manager_t *bm)
+static void drm_bo_add_to_lru(drm_buffer_object_t * buf,
+ drm_buffer_manager_t * bm)
{
struct list_head *list;
unsigned mem_type;
if (buf->flags & DRM_BO_FLAG_MEM_TT) {
mem_type = DRM_BO_MEM_TT;
- list = (buf->flags & (DRM_BO_FLAG_NO_EVICT | DRM_BO_FLAG_NO_MOVE)) ? &bm->pinned[mem_type] : &bm->lru[mem_type];
+ list =
+ (buf->
+ flags & (DRM_BO_FLAG_NO_EVICT | DRM_BO_FLAG_NO_MOVE)) ?
+ &bm->pinned[mem_type] : &bm->lru[mem_type];
list_add_tail(&buf->lru_ttm, list);
} else {
mem_type = DRM_BO_MEM_LOCAL;
- list = (buf->flags & (DRM_BO_FLAG_NO_EVICT | DRM_BO_FLAG_NO_MOVE)) ? &bm->pinned[mem_type] : &bm->lru[mem_type];
+ list =
+ (buf->
+ flags & (DRM_BO_FLAG_NO_EVICT | DRM_BO_FLAG_NO_MOVE)) ?
+ &bm->pinned[mem_type] : &bm->lru[mem_type];
list_add_tail(&buf->lru_ttm, list);
}
if (buf->flags & DRM_BO_FLAG_MEM_VRAM) {
mem_type = DRM_BO_MEM_VRAM;
- list = (buf->flags & (DRM_BO_FLAG_NO_EVICT | DRM_BO_FLAG_NO_MOVE)) ? &bm->pinned[mem_type] : &bm->lru[mem_type];
+ list =
+ (buf->
+ flags & (DRM_BO_FLAG_NO_EVICT | DRM_BO_FLAG_NO_MOVE)) ?
+ &bm->pinned[mem_type] : &bm->lru[mem_type];
list_add_tail(&buf->lru_card, list);
}
}
schedule();
return ret;
}
-
- if (!(buf->flags & DRM_BO_FLAG_NO_MOVE) ||
- force_no_move) {
+
+ if (!(buf->flags & DRM_BO_FLAG_NO_MOVE) || force_no_move) {
drm_mm_put_block(buf->node_ttm);
buf->node_ttm = NULL;
}
drm_buffer_manager_t *bm = &dev->bm;
-
DRM_FLAG_MASKED(bo->priv_flags, 0, _DRM_BO_FLAG_UNFENCED);
/*
* Somone might try to access us through the still active BM lists.
*/
- if (atomic_read(&bo->usage) != 0)
+ if (atomic_read(&bo->usage) != 0)
return;
if (!list_empty(&bo->ddestroy))
return;
/*
* This temporarily unlocks struct_mutex.
*/
-
+
do {
ret = drm_unbind_ttm(bo->ttm);
if (ret == -EAGAIN) {
"Bad. Continuing anyway\n");
}
}
-
+
if (bo->node_ttm) {
drm_mm_put_block(bo->node_ttm);
bo->node_ttm = NULL;
drm_fence_object_t *fence;
mutex_lock(&dev->struct_mutex);
- if (!bm->initialized)
- goto out;
+ if (!bm->initialized)
+ goto out;
list = bm->ddestroy.next;
list_for_each_safe(list, next, &bm->ddestroy) {
if (atomic_read(&entry->usage) != 0)
continue;
-
+
/*
* Since we're the only users, No need to take the
* bo->mutex to watch the fence.
* drm_bo_destroy_locked temporarily releases the
* struct_mutex;
*/
-
- nentry = NULL;
+
+ nentry = NULL;
if (next != &bm->ddestroy) {
- nentry = list_entry(next, drm_buffer_object_t,
+ nentry = list_entry(next, drm_buffer_object_t,
ddestroy);
atomic_inc(&nentry->usage);
}
drm_bo_destroy_locked(dev, entry);
if (next != &bm->ddestroy)
atomic_dec(&nentry->usage);
- }
+ }
}
- out:
+ out:
mutex_unlock(&dev->struct_mutex);
}
-
static void drm_bo_delayed_workqueue(void *data)
{
drm_device_t *dev = (drm_device_t *) data;
}
} else {
mutex_unlock(&dev->struct_mutex);
- ret = drm_fence_object_create(dev, fence_type,
- fence_flags | DRM_FENCE_FLAG_EMIT,
+ ret = drm_fence_object_create(dev, fence_type,
+ fence_flags | DRM_FENCE_FLAG_EMIT,
&fence);
mutex_lock(&dev->struct_mutex);
if (ret)
ret =
drm_fence_object_wait(dev, fence, lazy, ignore_signals,
bo->fence_type);
- if (ret)
- return ret;
-
+ if (ret)
+ return ret;
+
drm_fence_usage_deref_unlocked(dev, fence);
bo->fence = NULL;
* bo->mutex locked
*/
-static int drm_bo_evict(drm_buffer_object_t * bo, unsigned mem_type,
+static int drm_bo_evict(drm_buffer_object_t * bo, unsigned mem_type,
int no_wait, int force_no_move)
{
int ret = 0;
* Someone might have modified the buffer before we took the buffer mutex.
*/
- if (bo->priv_flags & _DRM_BO_FLAG_UNFENCED)
+ if (bo->priv_flags & _DRM_BO_FLAG_UNFENCED)
goto out;
if (!(bo->flags & drm_bo_type_flags(mem_type)))
goto out;
DRM_FLAG_MASKED(bo->priv_flags, _DRM_BO_FLAG_EVICTED,
_DRM_BO_FLAG_EVICTED);
- out:
+ out:
return ret;
}
* buf->mutex locked.
*/
-int drm_bo_alloc_space(drm_buffer_object_t * buf, unsigned mem_type,
+int drm_bo_alloc_space(drm_buffer_object_t * buf, unsigned mem_type,
int no_wait)
{
drm_device_t *dev = buf->dev;
drm_ttm_backend_t *be;
int ret;
- if (!(bo->node_ttm && (bo->flags & DRM_BO_FLAG_NO_MOVE))) {
+ if (!(bo->node_ttm && (bo->flags & DRM_BO_FLAG_NO_MOVE))) {
BUG_ON(bo->node_ttm);
ret = drm_bo_alloc_space(bo, DRM_BO_MEM_TT, no_wait);
if (ret)
* First adjust the mask to take away nonexistant memory types.
*/
- for (i=0; i<DRM_BO_MEM_TYPES; ++i) {
+ for (i = 0; i < DRM_BO_MEM_TYPES; ++i) {
if (!bm->use_type[i])
new_mask &= ~drm_bo_type_flags(i);
}
- if ((new_mask & DRM_BO_FLAG_NO_EVICT ) && !DRM_SUSER(DRM_CURPROC)) {
- DRM_ERROR("DRM_BO_FLAG_NO_EVICT is only available to priviliged "
- "processes\n");
+ if ((new_mask & DRM_BO_FLAG_NO_EVICT) && !DRM_SUSER(DRM_CURPROC)) {
+ DRM_ERROR
+ ("DRM_BO_FLAG_NO_EVICT is only available to priviliged "
+ "processes\n");
return -EPERM;
}
if (new_mask & DRM_BO_FLAG_BIND_CACHED) {
- if (((new_mask & DRM_BO_FLAG_MEM_TT) &&
+ if (((new_mask & DRM_BO_FLAG_MEM_TT) &&
!driver->cached[DRM_BO_MEM_TT]) &&
((new_mask & DRM_BO_FLAG_MEM_VRAM)
&& !driver->cached[DRM_BO_MEM_VRAM])) {
int ret = 0;
BUG_ON(bo->priv_flags & _DRM_BO_FLAG_UNFENCED);
- if (bo->node_card)
+ if (bo->node_card)
ret = drm_bo_evict(bo, DRM_BO_MEM_VRAM, 1, 0);
if (ret)
return ret;
if (bo->node_ttm)
- ret = drm_bo_evict(bo, DRM_BO_MEM_TT, 1, 0);
+ ret = drm_bo_evict(bo, DRM_BO_MEM_TT, 1, 0);
return ret;
}
DRM_ERROR("Driver did not support given buffer permissions\n");
return ret;
}
-
+
/*
* Move out if we need to change caching policy.
*/
- if ((flag_diff & DRM_BO_FLAG_BIND_CACHED) &&
+ if ((flag_diff & DRM_BO_FLAG_BIND_CACHED) &&
!(bo->flags & DRM_BO_FLAG_MEM_LOCAL)) {
if (bo->flags & (DRM_BO_FLAG_NO_EVICT | DRM_BO_FLAG_NO_MOVE)) {
DRM_ERROR("Cannot change caching policy of "
"pinned buffer.\n");
return -EINVAL;
- }
+ }
ret = drm_bo_move_buffer(bo, DRM_BO_FLAG_MEM_LOCAL, no_wait, 0);
if (ret) {
if (ret != -EAGAIN)
* release reserved manager regions.
*/
- if ((flag_diff & DRM_BO_FLAG_NO_MOVE) &&
+ if ((flag_diff & DRM_BO_FLAG_NO_MOVE) &&
!(new_flags & DRM_BO_FLAG_NO_MOVE)) {
mutex_lock(&dev->struct_mutex);
if (bo->node_ttm) {
mutex_unlock(&bo->mutex);
*buf_obj = bo;
return 0;
-
- out_err:
+
+ out_err:
mutex_unlock(&bo->mutex);
- drm_bo_usage_deref_unlocked(dev, bo);
+ drm_bo_usage_deref_unlocked(dev, bo);
return ret;
}
* dev->struct_sem locked.
*/
-static int drm_bo_force_list_clean(drm_device_t *dev,
- struct list_head *head,
+static int drm_bo_force_list_clean(drm_device_t * dev,
+ struct list_head *head,
unsigned mem_type,
- int force_no_move,
- int allow_errors)
+ int force_no_move, int allow_errors)
{
drm_buffer_manager_t *bm = &dev->bm;
struct list_head *list, *next, *prev;
int ret;
int clean;
- retry:
+ retry:
clean = 1;
list_for_each_safe(list, next, head) {
prev = list->prev;
- entry = drm_bo_entry(list, mem_type);
+ entry = drm_bo_entry(list, mem_type);
atomic_inc(&entry->usage);
mutex_unlock(&dev->struct_mutex);
mutex_lock(&entry->mutex);
/*
* Expire the fence.
*/
-
+
mutex_unlock(&dev->struct_mutex);
if (entry->fence && bm->nice_mode) {
- unsigned long _end = jiffies + 3*DRM_HZ;
+ unsigned long _end = jiffies + 3 * DRM_HZ;
do {
ret = drm_bo_wait(entry, 0, 1, 0);
if (ret && allow_errors) {
goto out_err;
}
} while (ret && !time_after_eq(jiffies, _end));
-
+
if (entry->fence) {
bm->nice_mode = 0;
DRM_ERROR("Detected GPU hang or "
}
}
if (entry->fence) {
- drm_fence_usage_deref_unlocked(dev, entry->fence);
+ drm_fence_usage_deref_unlocked(dev,
+ entry->fence);
entry->fence = NULL;
}
- DRM_MASK_VAL(entry->priv_flags, _DRM_BO_FLAG_UNFENCED, 0);
+ DRM_MASK_VAL(entry->priv_flags, _DRM_BO_FLAG_UNFENCED,
+ 0);
if (force_no_move) {
- DRM_MASK_VAL(entry->flags, DRM_BO_FLAG_NO_MOVE, 0);
+ DRM_MASK_VAL(entry->flags, DRM_BO_FLAG_NO_MOVE,
+ 0);
}
if (entry->flags & DRM_BO_FLAG_NO_EVICT) {
DRM_ERROR("A DRM_BO_NO_EVICT buffer present at "
drm_bo_usage_deref_locked(dev, entry);
if (prev != list->prev || next != list->next) {
goto retry;
- }
+ }
}
if (!clean)
goto retry;
return 0;
- out_err:
+ out_err:
mutex_unlock(&entry->mutex);
drm_bo_usage_deref_unlocked(dev, entry);
mutex_lock(&dev->struct_mutex);
if (!bm->has_type[mem_type]) {
DRM_ERROR("Trying to take down uninitialized "
"memory manager type\n");
- return ret;
+ return ret;
}
bm->use_type[mem_type] = 0;
bm->has_type[mem_type] = 0;
* Throw out evicted no-move buffers.
*/
- drm_bo_force_list_clean(dev, &bm->pinned[DRM_BO_MEM_LOCAL],
+ drm_bo_force_list_clean(dev, &bm->pinned[DRM_BO_MEM_LOCAL],
mem_type, 1, 0);
- drm_bo_force_list_clean(dev, &bm->lru[mem_type], mem_type, 1, 0);
- drm_bo_force_list_clean(dev, &bm->pinned[mem_type], mem_type, 1, 0);
+ drm_bo_force_list_clean(dev, &bm->lru[mem_type], mem_type, 1,
+ 0);
+ drm_bo_force_list_clean(dev, &bm->pinned[mem_type], mem_type, 1,
+ 0);
if (drm_mm_clean(&bm->manager[mem_type])) {
drm_mm_takedown(&bm->manager[mem_type]);
return ret;
}
-static int drm_bo_lock_mm(drm_device_t *dev, unsigned mem_type)
+static int drm_bo_lock_mm(drm_device_t * dev, unsigned mem_type)
{
int ret;
drm_buffer_manager_t *bm = &dev->bm;
if (mem_type == 0 || mem_type >= DRM_BO_MEM_TYPES) {
- DRM_ERROR("Illegal memory manager memory type %u,\n",
- mem_type);
+ DRM_ERROR("Illegal memory manager memory type %u,\n", mem_type);
return -EINVAL;
}
-
- ret = drm_bo_force_list_clean(dev, &bm->unfenced, mem_type, 0, 1);
- if (ret)
+
+ ret = drm_bo_force_list_clean(dev, &bm->unfenced, mem_type, 0, 1);
+ if (ret)
return ret;
- ret = drm_bo_force_list_clean(dev, &bm->lru[mem_type], mem_type, 0, 1);
+ ret = drm_bo_force_list_clean(dev, &bm->lru[mem_type], mem_type, 0, 1);
if (ret)
return ret;
- ret = drm_bo_force_list_clean(dev, &bm->pinned[mem_type], mem_type, 0, 1);
+ ret =
+ drm_bo_force_list_clean(dev, &bm->pinned[mem_type], mem_type, 0, 1);
return ret;
}
-
-static int drm_bo_init_mm(drm_device_t *dev,
+static int drm_bo_init_mm(drm_device_t * dev,
unsigned type,
- unsigned long p_offset,
- unsigned long p_size)
+ unsigned long p_offset, unsigned long p_size)
{
drm_buffer_manager_t *bm = &dev->bm;
int ret = -EINVAL;
DRM_ERROR("Zero size memory manager type %d\n", type);
return ret;
}
- ret = drm_mm_init(&bm->manager[type],p_offset, p_size);
+ ret = drm_mm_init(&bm->manager[type], p_offset, p_size);
if (ret)
return ret;
}
return 0;
}
-
-int drm_bo_driver_finish(drm_device_t *dev)
+int drm_bo_driver_finish(drm_device_t * dev)
{
drm_buffer_manager_t *bm = &dev->bm;
int ret = 0;
mutex_lock(&dev->bm.init_mutex);
mutex_lock(&dev->struct_mutex);
- if (!bm->initialized)
+ if (!bm->initialized)
goto out;
- while(i--) {
+ while (i--) {
if (bm->has_type[i]) {
bm->use_type[i] = 0;
if ((i != DRM_BO_MEM_LOCAL) && drm_bo_clean_mm(dev, i)) {
flush_scheduled_work();
}
mutex_lock(&dev->struct_mutex);
- out:
+ out:
mutex_unlock(&dev->struct_mutex);
mutex_unlock(&dev->bm.init_mutex);
return ret;
}
-
-int drm_bo_driver_init(drm_device_t *dev)
+int drm_bo_driver_init(drm_device_t * dev)
{
drm_bo_driver_t *driver = dev->driver->bo_driver;
drm_buffer_manager_t *bm = &dev->bm;
int ret = -EINVAL;
struct sysinfo si;
-
+
mutex_lock(&dev->bm.init_mutex);
mutex_lock(&dev->struct_mutex);
if (!driver)
goto out_unlock;
-
+
/*
* Initialize the system memory buffer type.
* Other types need to be driver / IOCTL initialized.
si_meminfo(&si);
bm->max_pages = si.totalram >> 1;
INIT_LIST_HEAD(&bm->unfenced);
- INIT_LIST_HEAD(&bm->ddestroy);
- out_unlock:
+ INIT_LIST_HEAD(&bm->ddestroy);
+ out_unlock:
mutex_unlock(&dev->struct_mutex);
mutex_unlock(&dev->bm.init_mutex);
return ret;
}
-EXPORT_SYMBOL(drm_bo_driver_init);
+EXPORT_SYMBOL(drm_bo_driver_init);
int drm_mm_init_ioctl(DRM_IOCTL_ARGS)
{
break;
}
if (arg.req.mem_type == 0) {
- DRM_ERROR("System memory buffers already initialized.\n");
+ DRM_ERROR
+ ("System memory buffers already initialized.\n");
break;
}
- ret = drm_bo_init_mm(dev, arg.req.mem_type,
- arg.req.p_offset,
- arg.req.p_size);
+ ret = drm_bo_init_mm(dev, arg.req.mem_type,
+ arg.req.p_offset, arg.req.p_size);
break;
case mm_takedown:
- LOCK_TEST_WITH_RETURN(dev, filp);
+ LOCK_TEST_WITH_RETURN(dev, filp);
mutex_lock(&dev->bm.init_mutex);
mutex_lock(&dev->struct_mutex);
ret = -EINVAL;
"Delaying takedown\n", arg.req.mem_type);
}
break;
- case mm_set_max_pages: {
- struct sysinfo si;
- mutex_lock(&dev->bm.init_mutex);
- mutex_lock(&dev->struct_mutex);
- if (arg.req.p_size < bm->cur_pages) {
- DRM_ERROR("Cannot currently decrease max number of "
- "locked pages below the number currently "
- "locked.\n");
- ret = -EINVAL;
- break;
- }
- si_meminfo(&si);
- if (arg.req.p_size > si.totalram) {
- DRM_ERROR("Cannot set max number of locked pages "
- "to %lu since the total number of RAM pages "
- "is %lu.\n", (unsigned long) arg.req.p_size,
- (unsigned long) si.totalram);
- ret = -EINVAL;
- break;
+ case mm_set_max_pages:{
+ struct sysinfo si;
+ mutex_lock(&dev->bm.init_mutex);
+ mutex_lock(&dev->struct_mutex);
+ if (arg.req.p_size < bm->cur_pages) {
+ DRM_ERROR
+ ("Cannot currently decrease max number of "
+ "locked pages below the number currently "
+ "locked.\n");
+ ret = -EINVAL;
+ break;
+ }
+ si_meminfo(&si);
+ if (arg.req.p_size > si.totalram) {
+ DRM_ERROR
+ ("Cannot set max number of locked pages "
+ "to %lu since the total number of RAM pages "
+ "is %lu.\n", (unsigned long)arg.req.p_size,
+ (unsigned long)si.totalram);
+ ret = -EINVAL;
+ break;
+ }
+ bm->max_pages = arg.req.p_size;
}
- bm->max_pages = arg.req.p_size;
- }
case mm_lock:
- LOCK_TEST_WITH_RETURN(dev, filp);
+ LOCK_TEST_WITH_RETURN(dev, filp);
mutex_lock(&dev->bm.init_mutex);
mutex_lock(&dev->struct_mutex);
ret = drm_bo_lock_mm(dev, arg.req.mem_type);
break;
case mm_unlock:
- LOCK_TEST_WITH_RETURN(dev, filp);
+ LOCK_TEST_WITH_RETURN(dev, filp);
mutex_lock(&dev->bm.init_mutex);
mutex_lock(&dev->struct_mutex);
ret = 0;
#include "drmP.h"
-
/*
* Typically called by the IRQ handler.
*/
}
}
-
+
if (wake) {
DRM_WAKEUP(&fm->fence_queue);
}
mutex_lock(&dev->struct_mutex);
if (atomic_read(&fence->usage) == 0) {
drm_fence_unring(dev, &fence->ring);
- atomic_dec(&fm->count);
- drm_ctl_cache_free(drm_cache.fence_object,
+ atomic_dec(&fm->count);
+ drm_ctl_cache_free(drm_cache.fence_object,
sizeof(*fence), fence);
}
mutex_unlock(&dev->struct_mutex);
drm_fence_usage_deref_locked(dev, fence);
}
-static int fence_signaled(drm_device_t * dev, volatile
+static int fence_signaled(drm_device_t * dev, volatile
drm_fence_object_t * fence,
uint32_t mask, int poke_flush)
{
}
}
-int drm_fence_object_signaled(volatile drm_fence_object_t * fence,
+int drm_fence_object_signaled(volatile drm_fence_object_t * fence,
uint32_t type)
{
return ((fence->signaled & type) == type);
}
int drm_fence_object_flush(drm_device_t * dev,
- volatile drm_fence_object_t * fence,
- uint32_t type)
+ volatile drm_fence_object_t * fence, uint32_t type)
{
drm_fence_manager_t *fm = &dev->fm;
drm_fence_driver_t *driver = dev->driver->fence_driver;
if (type & ~fence->type) {
DRM_ERROR("Flush trying to extend fence type, "
- "0x%x, 0x%x\n", type, fence->type);
+ "0x%x, 0x%x\n", type, fence->type);
return -EINVAL;
}
* wrapped around and reused.
*/
-
void drm_fence_flush_old(drm_device_t * dev, uint32_t sequence)
{
drm_fence_manager_t *fm = &dev->fm;
EXPORT_SYMBOL(drm_fence_flush_old);
-int drm_fence_object_wait(drm_device_t * dev,
+int drm_fence_object_wait(drm_device_t * dev,
volatile drm_fence_object_t * fence,
int lazy, int ignore_signals, uint32_t mask)
{
do {
DRM_WAIT_ON(ret, fm->fence_queue, 3 * DRM_HZ,
- fence_signaled(dev, fence, DRM_FENCE_TYPE_EXE,
- 1));
+ fence_signaled(dev, fence,
+ DRM_FENCE_TYPE_EXE, 1));
if (time_after_eq(jiffies, _end))
break;
} while (ret == -EINTR && ignore_signals);
*/
#if 1
if (!ignore_signals)
- return -EAGAIN;
+ return -EAGAIN;
#endif
- do {
+ do {
schedule();
signaled = fence_signaled(dev, fence, mask, 1);
} while (!signaled && !time_after_eq(jiffies, _end));
return 0;
}
-static int drm_fence_object_init(drm_device_t * dev, uint32_t type,
+static int drm_fence_object_init(drm_device_t * dev, uint32_t type,
uint32_t fence_flags,
drm_fence_object_t * fence)
{
return ret;
}
-
int drm_fence_add_user_object(drm_file_t * priv, drm_fence_object_t * fence,
int shareable)
{
int ret;
drm_fence_manager_t *fm = &dev->fm;
- fence = drm_ctl_cache_alloc(drm_cache.fence_object,
+ fence = drm_ctl_cache_alloc(drm_cache.fence_object,
sizeof(*fence), GFP_KERNEL);
if (!fence)
return -ENOMEM;
fm->initialized = 0;
if (fed) {
fm->initialized = 1;
- atomic_set(&fm->count,0);
+ atomic_set(&fm->count, 0);
for (i = 0; i < fed->no_types; ++i) {
fm->fence_types[i] = &fm->ring;
}
case drm_fence_create:
if (arg.flags & DRM_FENCE_FLAG_EMIT)
LOCK_TEST_WITH_RETURN(dev, filp);
- ret = drm_fence_object_create(dev, arg.type,
- arg.flags,
- &fence);
+ ret = drm_fence_object_create(dev, arg.type, arg.flags, &fence);
if (ret)
return ret;
ret = drm_fence_add_user_object(priv, fence,
return -EINVAL;
}
LOCK_TEST_WITH_RETURN(dev, filp);
- ret = drm_fence_buffer_objects(priv, NULL, arg.flags,
+ ret = drm_fence_buffer_objects(priv, NULL, arg.flags,
NULL, &fence);
if (ret)
return ret;
* Use kmalloc if possible. Otherwise fall back to vmalloc.
*/
-
static void *ttm_alloc(unsigned long size, int type)
{
void *ret = NULL;
static void ttm_free(void *pointer, unsigned long size, int type)
{
-
- if ((unsigned long) pointer >= VMALLOC_START &&
- (unsigned long) pointer <= VMALLOC_END) {
+
+ if ((unsigned long)pointer >= VMALLOC_START &&
+ (unsigned long)pointer <= VMALLOC_END) {
vfree(pointer);
} else {
drm_free(pointer, size, type);
}
drm_free_memctl(size);
-}
+}
/*
* Unmap all vma pages from vmas mapping this ttm.
if (ttm->pages) {
drm_buffer_manager_t *bm = &ttm->dev->bm;
- if (ttm->page_flags & DRM_TTM_PAGE_UNCACHED)
+ if (ttm->page_flags & DRM_TTM_PAGE_UNCACHED)
drm_set_caching(ttm, 0);
for (i = 0; i < ttm->num_pages; ++i) {
--bm->cur_pages;
}
}
- ttm_free(ttm->pages, ttm->num_pages*sizeof(*ttm->pages),
+ ttm_free(ttm->pages, ttm->num_pages * sizeof(*ttm->pages),
DRM_MEM_TTM);
ttm->pages = NULL;
}
return 0;
}
-static int drm_ttm_populate(drm_ttm_t *ttm)
+static int drm_ttm_populate(drm_ttm_t * ttm)
{
struct page *page;
unsigned long i;
drm_buffer_manager_t *bm;
drm_ttm_backend_t *be;
-
- if (ttm->state != ttm_unpopulated)
+ if (ttm->state != ttm_unpopulated)
return 0;
-
+
bm = &ttm->dev->bm;
be = ttm->be;
- for (i=0; i<ttm->num_pages; ++i) {
+ for (i = 0; i < ttm->num_pages; ++i) {
page = ttm->pages[i];
if (!page) {
if (drm_alloc_memctl(PAGE_SIZE)) {
be->populate(be, ttm->num_pages, ttm->pages);
ttm->state = ttm_unbound;
return 0;
-}
-
-
+}
/*
* Initialize a ttm.
* Account also for AGP module memory usage.
*/
- ttm->pages = ttm_alloc(ttm->num_pages * sizeof(*ttm->pages),
+ ttm->pages = ttm_alloc(ttm->num_pages * sizeof(*ttm->pages),
DRM_MEM_TTM);
if (!ttm->pages) {
drm_destroy_ttm(ttm);
ttm->state = ttm_unbound;
}
}
-
int drm_unbind_ttm(drm_ttm_t * ttm)
{
int ret = 0;
- if (ttm->state == ttm_bound)
+ if (ttm->state == ttm_bound)
ret = drm_evict_ttm(ttm);
if (ret)
return 0;
}
-int drm_bind_ttm(drm_ttm_t * ttm, int cached,
- unsigned long aper_offset)
+int drm_bind_ttm(drm_ttm_t * ttm, int cached, unsigned long aper_offset)
{
int ret = 0;
return 0;
be = ttm->be;
-
+
ret = drm_ttm_populate(ttm);
if (ret)
return ret;
drm_set_caching(ttm, DRM_TTM_PAGE_UNCACHED);
}
-#ifdef DRM_ODD_MM_COMPAT
+#ifdef DRM_ODD_MM_COMPAT
else if (ttm->state == ttm_evicted && !cached) {
ret = drm_ttm_lock_mm(ttm);
if (ret)
return ret;
}
-
ttm->aper_offset = aper_offset;
ttm->state = ttm_bound;
#ifdef DRM_ODD_MM_COMPAT
if (be->needs_ub_cache_adjust(be)) {
ret = drm_ttm_remap_bound(ttm);
- if (ret)
+ if (ret)
return ret;
}
#endif
-
+
return 0;
}
*/
int drm_ttm_object_create(drm_device_t * dev, unsigned long size,
- uint32_t flags,
- drm_ttm_object_t ** ttm_object)
+ uint32_t flags, drm_ttm_object_t ** ttm_object)
{
drm_ttm_object_t *object;
drm_map_list_t *list;
return -ENOMEM;
}
- map->offset = (unsigned long) ttm;
+ map->offset = (unsigned long)ttm;
map->type = _DRM_TTM;
map->flags = _DRM_REMOVABLE;
map->size = ttm->num_pages * PAGE_SIZE;
map->handle = (void *)object;
list->file_offset_node = drm_mm_search_free(&dev->offset_manager,
- ttm->num_pages,
- 0,0);
+ ttm->num_pages, 0, 0);
if (!list->file_offset_node) {
drm_ttm_object_remove(dev, object);
return -ENOMEM;
}
list->file_offset_node = drm_mm_get_block(list->file_offset_node,
- ttm->num_pages,0);
+ ttm->num_pages, 0);
list->hash.key = list->file_offset_node->start;