* 2.) Refer to ttm locking orders.
*/
-
#define DRM_FLAG_MASKED(_old, _new, _mask) {\
(_old) ^= (((_old) ^ (_new)) & (_mask)); \
}
-static inline uint32_t drm_flag_masked(uint32_t old, uint32_t new,
+static inline uint32_t drm_flag_masked(uint32_t old, uint32_t new,
uint32_t mask)
{
return old ^ ((old ^ new) & mask);
return 0;
}
-
/*
* bo locked.
*/
return 0;
}
-
-
static void drm_bo_destroy_locked(drm_device_t * dev, drm_buffer_object_t * bo)
{
}
}
-
/*
* Call bo->mutex locked.
* Wait until the buffer is idle.
drm_fence_usage_deref_unlocked(dev, fence);
bo->fence = NULL;
return 0;
- }
+ }
if (no_wait)
return -EBUSY;
bo->fence_flags);
if (ret)
return ret;
-
+
drm_fence_usage_deref_unlocked(dev, fence);
bo->fence = NULL;
static int drm_bo_evict(drm_buffer_object_t * bo, int tt, int no_wait)
{
int ret = 0;
-
+
/*
* Someone might have taken out the buffer before we took the buffer mutex.
*/
-
+
mutex_lock(&bo->mutex);
if (bo->unfenced)
goto out;
- if (tt && !bo->tt)
+ if (tt && !bo->tt)
goto out;
if (!tt && !bo->vram)
goto out;
ret = drm_move_vram_to_local(bo);
}
#endif
-out:
+ out:
mutex_unlock(&bo->mutex);
return ret;
}
break;
bo = list_entry(lru->next, drm_buffer_object_t, head);
-
+
/*
* No need to take dev->struct_mutex here, because bo->usage is at least 1 already,
* since it's on the lru list, and the bm->mutex is held.
return 0;
}
-
-static int drm_move_local_to_tt(drm_buffer_object_t *bo, int no_wait)
+static int drm_move_local_to_tt(drm_buffer_object_t * bo, int no_wait)
{
drm_device_t *dev = bo->dev;
drm_buffer_manager_t *bm = &dev->bm;
int ret;
-
BUG_ON(bo->tt);
ret = drm_bo_alloc_space(bo, 1, no_wait);
return ret;
}
-
-
static int drm_bo_new_flags(drm_bo_driver_t * driver,
uint32_t flags, uint32_t new_mask, uint32_t hint,
int init, uint32_t * n_flags)
uo = drm_lookup_user_object(priv, handle);
if (!uo || (uo->type != drm_buffer_type)) {
- DRM_ERROR("Could not find buffer object 0x%08x\n",
- handle);
+ DRM_ERROR("Could not find buffer object 0x%08x\n", handle);
return NULL;
}
drm_ref_t action)
{
drm_buffer_object_t *bo =
- drm_user_object_entry(uo, drm_buffer_object_t, base);
+ drm_user_object_entry(uo, drm_buffer_object_t, base);
/*
* We DON'T want to take the bo->lock here, because we want to
BUG_ON(action != _DRM_REF_TYPE1);
if (atomic_add_negative(-1, &bo->mapped))
- DRM_WAKEUP(&bo->validate_queue);
+ DRM_WAKEUP(&bo->validate_queue);
}
/*
* bo->mutex locked.
*/
-
-static int drm_bo_move_buffer(drm_buffer_object_t *bo, uint32_t new_flags,
+static int drm_bo_move_buffer(drm_buffer_object_t * bo, uint32_t new_flags,
int no_wait)
{
int ret = 0;
/*
* Make sure we're not mapped.
*/
-
+
if (atomic_read(&bo->mapped) >= 0) {
- if (no_wait)
+ if (no_wait)
return -EBUSY;
else {
- DRM_WAIT_ON(ret, bo->validate_queue, 3*DRM_HZ,
+ DRM_WAIT_ON(ret, bo->validate_queue, 3 * DRM_HZ,
atomic_read(&bo->mapped) == -1);
- if (ret == -EINTR)
+ if (ret == -EINTR)
return -EAGAIN;
- if (ret)
+ if (ret)
return ret;
}
}
} else {
drm_move_tt_to_local(bo);
}
-
+
DRM_FLAG_MASKED(bo->flags, new_flags, DRM_BO_FLAG_MEM_TT);
-
+
return 0;
}
-
/*
* bo locked.
*/
-
static int drm_buffer_object_validate(drm_buffer_object_t * bo,
uint32_t new_flags,
- int move_unfenced,
- int no_wait)
+ int move_unfenced, int no_wait)
{
drm_device_t *dev = bo->dev;
drm_buffer_manager_t *bm = &dev->bm;
mutex_lock(&bm->mutex);
ret = drm_bo_move_buffer(bo, new_flags, no_wait);
mutex_unlock(&bm->mutex);
- if (ret)
+ if (ret)
return ret;
}
-
+
if (flag_diff & DRM_BO_FLAG_NO_EVICT) {
mutex_lock(&bm->mutex);
list_del_init(&bo->head);
/*
* Place on unfenced list.
*/
-
+
mutex_lock(&bm->mutex);
list_del_init(&bo->head);
list_add_tail(&bo->head, &bm->unfenced);
bo->flags = new_flags;
return 0;
}
-
+
/*
* Call bo->mutex locked.
*/
bo->mask = mask;
- ret = drm_buffer_object_validate(bo, new_flags, 0,
+ ret = drm_buffer_object_validate(bo, new_flags, 0,
hint & DRM_BO_HINT_DONT_BLOCK);
if (ret)
goto out_err;
}
-static void drm_bo_clean_mm(drm_file_t *priv)
+static void drm_bo_clean_mm(drm_file_t * priv)
{
}
-
int drm_mm_init_ioctl(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
-
+
int ret = 0;
drm_mm_init_arg_t arg;
drm_buffer_manager_t *bm = &dev->bm;
DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg));
- switch(arg.req.op) {
+ switch (arg.req.op) {
case mm_init:
if (bm->initialized) {
DRM_ERROR("Memory manager already initialized\n");
bm->has_tt = 0;
if (arg.req.vr_p_size) {
- ret = drm_mm_init(&bm->vram_manager,
- arg.req.vr_p_offset,
+ ret = drm_mm_init(&bm->vram_manager,
+ arg.req.vr_p_offset,
arg.req.vr_p_size);
bm->has_vram = 1;
if (ret)
}
if (arg.req.tt_p_size) {
- ret = drm_mm_init(&bm->tt_manager,
- arg.req.tt_p_offset,
+ ret = drm_mm_init(&bm->tt_manager,
+ arg.req.tt_p_offset,
arg.req.tt_p_size);
bm->has_tt = 1;
if (ret) {
default:
return -EINVAL;
}
-
+
mutex_unlock(&bm->mutex);
if (ret)
return ret;
-
+
DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg));
return 0;
}