diff options
author | Jerome Glisse <glisse@freedesktop.org> | 2008-03-20 17:44:32 +0100 |
---|---|---|
committer | John Doe <glisse@freedesktop.org> | 2008-03-20 17:44:32 +0100 |
commit | 71b66b00435a10e762a4bb7abedb263196942da4 (patch) | |
tree | 99bbf149f64f14fdc2cd389ec53188c7ce4e040f /linux-core/drm_bo.c | |
parent | 6ef119abf5d19c85fe039fd19d12e9bd64fd44df (diff) | |
parent | 607964ed9e5f6d86a0960bef2341e7f5de9c71da (diff) |
Merge branch 'modesetting-101' of ssh://git.freedesktop.org/git/mesa/drm into modesetting-101
Diffstat (limited to 'linux-core/drm_bo.c')
-rw-r--r-- | linux-core/drm_bo.c | 70 |
1 files changed, 48 insertions, 22 deletions
diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c index 1d3f87e5..7e82080b 100644 --- a/linux-core/drm_bo.c +++ b/linux-core/drm_bo.c @@ -208,36 +208,35 @@ static int drm_bo_handle_move_mem(struct drm_buffer_object *bo, if (ret) goto out_err; } - } - - if ((bo->mem.mem_type == DRM_BO_MEM_LOCAL) && bo->ttm == NULL) { - - struct drm_bo_mem_reg *old_mem = &bo->mem; - uint64_t save_flags = old_mem->flags; - uint64_t save_proposed_flags = old_mem->proposed_flags; - *old_mem = *mem; - mem->mm_node = NULL; - old_mem->proposed_flags = save_proposed_flags; - DRM_FLAG_MASKED(save_flags, mem->flags, DRM_BO_MASK_MEMTYPE); - - } else if (!(old_man->flags & _DRM_FLAG_MEMTYPE_FIXED) && - !(new_man->flags & _DRM_FLAG_MEMTYPE_FIXED)) { + if (bo->mem.mem_type == DRM_BO_MEM_LOCAL) { + + struct drm_bo_mem_reg *old_mem = &bo->mem; + uint64_t save_flags = old_mem->flags; + uint64_t save_proposed_flags = old_mem->proposed_flags; + + *old_mem = *mem; + mem->mm_node = NULL; + old_mem->proposed_flags = save_proposed_flags; + DRM_FLAG_MASKED(save_flags, mem->flags, + DRM_BO_MASK_MEMTYPE); + goto moved; + } + + } + if (!(old_man->flags & _DRM_FLAG_MEMTYPE_FIXED) && + !(new_man->flags & _DRM_FLAG_MEMTYPE_FIXED)) ret = drm_bo_move_ttm(bo, evict, no_wait, mem); - - } else if (dev->driver->bo_driver->move) { + else if (dev->driver->bo_driver->move) ret = dev->driver->bo_driver->move(bo, evict, no_wait, mem); - - } else { - + else ret = drm_bo_move_memcpy(bo, evict, no_wait, mem); - } - if (ret) goto out_err; +moved: if (old_is_pci || new_is_pci) drm_bo_vm_post_move(bo); @@ -789,6 +788,11 @@ static int drm_bo_mem_force_space(struct drm_device *dev, } node = drm_mm_get_block(node, num_pages, mem->page_alignment); + if (unlikely(!node)) { + mutex_unlock(&dev->struct_mutex); + return -ENOMEM; + } + mutex_unlock(&dev->struct_mutex); mem->mm_node = node; mem->mem_type = mem_type; @@ -974,6 +978,20 @@ static int drm_bo_modify_proposed_flags (struct drm_buffer_object *bo, return -EPERM; } + if (likely(new_mask & DRM_BO_MASK_MEM) && + (bo->mem.flags & DRM_BO_FLAG_NO_EVICT) && + !DRM_SUSER(DRM_CURPROC)) { + if (likely(bo->mem.flags & new_flags & new_mask & + DRM_BO_MASK_MEM)) + new_flags = (new_flags & ~DRM_BO_MASK_MEM) | + (bo->mem.flags & DRM_BO_MASK_MEM); + else { + DRM_ERROR("Incompatible memory type specification " + "for NO_EVICT buffer.\n"); + return -EPERM; + } + } + if ((new_flags & DRM_BO_FLAG_NO_MOVE)) { DRM_ERROR("DRM_BO_FLAG_NO_MOVE is not properly implemented yet.\n"); return -EPERM; @@ -1482,6 +1500,9 @@ static int drm_buffer_object_validate(struct drm_buffer_object *bo, if (ret) { if (ret != -EAGAIN) DRM_ERROR("Failed moving buffer.\n"); + if (ret == -ENOMEM) + DRM_ERROR("Out of aperture space or " + "DRM memory quota.\n"); return ret; } } @@ -2748,7 +2769,7 @@ static int drm_bo_setup_vm_locked(struct drm_buffer_object *bo) list->file_offset_node = drm_mm_search_free(&dev->offset_manager, bo->mem.num_pages, 0, 0); - if (!list->file_offset_node) { + if (unlikely(!list->file_offset_node)) { drm_bo_takedown_vm_locked(bo); return -ENOMEM; } @@ -2756,6 +2777,11 @@ static int drm_bo_setup_vm_locked(struct drm_buffer_object *bo) list->file_offset_node = drm_mm_get_block(list->file_offset_node, bo->mem.num_pages, 0); + if (unlikely(!list->file_offset_node)) { + drm_bo_takedown_vm_locked(bo); + return -ENOMEM; + } + list->hash.key = list->file_offset_node->start; if (drm_ht_insert_item(&dev->map_hash, &list->hash)) { drm_bo_takedown_vm_locked(bo); |