switch (bo->type) {
case drm_bo_type_dc:
- bo->ttm = drm_ttm_init(dev, bo->mem.num_pages << PAGE_SHIFT);
+ bo->ttm = drm_ttm_init(dev, bo->mem.num_pages << PAGE_SHIFT);
if (!bo->ttm)
ret = -ENOMEM;
break;
return ret;
if (!(old_man->flags & _DRM_FLAG_MEMTYPE_FIXED) &&
- !(new_man->flags & _DRM_FLAG_MEMTYPE_FIXED)) {
+ !(new_man->flags & _DRM_FLAG_MEMTYPE_FIXED)) {
ret = drm_bo_move_ttm(dev, bo->ttm, evict, no_wait,
&bo->mem, mem);
- } else if (dev->driver->bo_driver->move) {
+ } else if (dev->driver->bo_driver->move) {
ret = dev->driver->bo_driver->move(dev, bo->ttm, evict,
no_wait, &bo->mem, mem);
} else {
drm_destroy_ttm(bo->ttm);
bo->ttm = NULL;
}
+
atomic_dec(&bm->count);
drm_ctl_free(bo, sizeof(*bo), DRM_MEM_BUFOBJ);
if (bo->priv_flags & _DRM_BO_FLAG_UNFENCED)
goto out;
if (bo->mem.mem_type != mem_type)
+ goto out;
ret = drm_bo_wait(bo, 0, 0, no_wait);
goto out;
}
+ if (bo->type != drm_bo_type_dc)
+ goto out1;
+
evict_mem = bo->mem;
evict_mem.mask = dev->driver->bo_driver->evict_flags(dev, mem_type);
ret = drm_bo_mem_space(dev, &evict_mem, no_wait);
goto out;
}
+out1:
mutex_lock(&dev->struct_mutex);
if (evict_mem.mm_node) {
drm_mm_put_block(evict_mem.mm_node);
uint32_t *res_mask)
{
uint32_t cur_flags = drm_bo_type_flags(mem_type);
+ uint32_t flag_diff;
if (man->flags & _DRM_FLAG_MEMTYPE_CACHED)
cur_flags |= DRM_BO_FLAG_CACHED;
if (man->flags & _DRM_FLAG_MEMTYPE_CSELECT)
DRM_FLAG_MASKED(cur_flags, mask, DRM_BO_FLAG_CACHED);
- if (!(mask & DRM_BO_FLAG_FORCE_CACHING))
- DRM_FLAG_MASKED(mask, cur_flags, DRM_BO_FLAG_CACHED);
- if (!(mask & DRM_BO_FLAG_FORCE_MAPPABLE))
- DRM_FLAG_MASKED(mask, cur_flags, DRM_BO_FLAG_MAPPABLE);
-
- *res_mask = mask;
- return ((cur_flags & mask & DRM_BO_MASK_MEMTYPE) == cur_flags);
+ if ((cur_flags & mask & DRM_BO_MASK_MEM) == 0) {
+ return 0;
+ }
+ flag_diff = (mask ^ cur_flags);
+ if ((flag_diff & DRM_BO_FLAG_CACHED) &&
+ (mask & DRM_BO_FLAG_FORCE_CACHING)) {
+ return 0;
+ }
+ if ((flag_diff & DRM_BO_FLAG_MAPPABLE) &&
+ (mask & DRM_BO_FLAG_FORCE_MAPPABLE)) {
+ return 0;
+ }
+
+ *res_mask = cur_flags;
+ return 1;
}
{
uint32_t new_props;
+ if (bo->type == drm_bo_type_user) {
+ DRM_ERROR("User buffers are not supported yet\n");
+ return -EINVAL;
+ }
+ if (bo->type == drm_bo_type_fake &&
+ !(new_mask & (DRM_BO_FLAG_NO_MOVE | DRM_BO_FLAG_NO_EVICT))) {
+ DRM_ERROR("Fake buffers must be pinned.\n");
+ return -EINVAL;
+ }
+
if ((new_mask & DRM_BO_FLAG_NO_EVICT) && !DRM_SUSER(DRM_CURPROC)) {
DRM_ERROR
("DRM_BO_FLAG_NO_EVICT is only available to priviliged "
return -EPERM;
}
-
new_props = new_mask & (DRM_BO_FLAG_EXE | DRM_BO_FLAG_WRITE |
DRM_BO_FLAG_READ);
return 1;
}
+static int drm_bo_check_fake(drm_device_t *dev, drm_bo_mem_reg_t *mem)
+{
+ drm_buffer_manager_t *bm = &dev->bm;
+ drm_mem_type_manager_t *man;
+ uint32_t num_prios = dev->driver->bo_driver->num_mem_type_prio;
+ const uint32_t *prios = dev->driver->bo_driver->mem_type_prio;
+ uint32_t i;
+ int type_ok = 0;
+ uint32_t mem_type = 0;
+ uint32_t cur_flags;
+
+ if (drm_bo_mem_compat(mem))
+ return 0;
+
+ BUG_ON(mem->mm_node);
+
+ for (i=0; i<num_prios; ++i) {
+ mem_type = prios[i];
+ man = &bm->man[mem_type];
+ type_ok = drm_bo_mt_compatible(man, mem_type, mem->mask,
+ &cur_flags);
+ if (type_ok)
+ break;
+ }
+
+ if (type_ok) {
+ mem->mm_node = NULL;
+ mem->mem_type = mem_type;
+ mem->flags = cur_flags;
+ DRM_FLAG_MASKED(mem->flags, mem->mask, ~DRM_BO_MASK_MEMTYPE);
+ return 0;
+ }
+
+ DRM_ERROR("Illegal fake buffer flags 0x%08x\n", mem->mask);
+ return -EINVAL;
+}
+
/*
* bo locked.
*/
return ret;
}
+ if (bo->type == drm_bo_type_fake) {
+ ret = drm_bo_check_fake(dev, &bo->mem);
+ if (ret)
+ return ret;
+ }
+
/*
* Check whether we dropped no_move policy, and in that case,
* release reserved manager regions, if we're evicted.