提交 dc97b340 编写于 作者: J Jerome Glisse 提交者: Dave Airlie

drm/ttm: callback move_notify any time bo placement change v4

Previously we were calling back move_notify in error path when the
bo is returned to it's original position or when destroy the bo.
When destroying the bo set the new mem placement as NULL when calling
back in the driver.

Updating nouveau to deal with NULL placement properly.

v2: reserve the object before calling move_notify in bo destroy path
    at that point ttm should be the only piece of code interacting
    with the object so atomic_set is safe here.
v3: callback move notify only once the bo is in its new position
    call move notify want swaping out the buffer
v4:- don't call move_notify when swapin out bo, assume driver should
     do what is appropriate in swap notify
   - move move_notify call back to ttm_bo_cleanup_memtype_use for
     destroy path
Reviewed-by: NJerome Glisse <jglisse@redhat.com>
Reviewed-by: NThomas Hellstrom <thellstrom@vmware.com>
上级 57de4ba9
...@@ -815,10 +815,10 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem) ...@@ -815,10 +815,10 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)
struct nouveau_vma *vma; struct nouveau_vma *vma;
list_for_each_entry(vma, &nvbo->vma_list, head) { list_for_each_entry(vma, &nvbo->vma_list, head) {
if (new_mem->mem_type == TTM_PL_VRAM) { if (new_mem && new_mem->mem_type == TTM_PL_VRAM) {
nouveau_vm_map(vma, new_mem->mm_node); nouveau_vm_map(vma, new_mem->mm_node);
} else } else
if (new_mem->mem_type == TTM_PL_TT && if (new_mem && new_mem->mem_type == TTM_PL_TT &&
nvbo->page_shift == vma->vm->spg_shift) { nvbo->page_shift == vma->vm->spg_shift) {
nouveau_vm_map_sg(vma, 0, new_mem-> nouveau_vm_map_sg(vma, 0, new_mem->
num_pages << PAGE_SHIFT, num_pages << PAGE_SHIFT,
......
...@@ -404,9 +404,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, ...@@ -404,9 +404,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
} }
} }
if (bdev->driver->move_notify)
bdev->driver->move_notify(bo, mem);
if (!(old_man->flags & TTM_MEMTYPE_FLAG_FIXED) && if (!(old_man->flags & TTM_MEMTYPE_FLAG_FIXED) &&
!(new_man->flags & TTM_MEMTYPE_FLAG_FIXED)) !(new_man->flags & TTM_MEMTYPE_FLAG_FIXED))
ret = ttm_bo_move_ttm(bo, evict, no_wait_reserve, no_wait_gpu, mem); ret = ttm_bo_move_ttm(bo, evict, no_wait_reserve, no_wait_gpu, mem);
...@@ -419,6 +416,9 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, ...@@ -419,6 +416,9 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
if (ret) if (ret)
goto out_err; goto out_err;
if (bdev->driver->move_notify)
bdev->driver->move_notify(bo, mem);
moved: moved:
if (bo->evicted) { if (bo->evicted) {
ret = bdev->driver->invalidate_caches(bdev, bo->mem.placement); ret = bdev->driver->invalidate_caches(bdev, bo->mem.placement);
...@@ -457,6 +457,9 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, ...@@ -457,6 +457,9 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
static void ttm_bo_cleanup_memtype_use(struct ttm_buffer_object *bo) static void ttm_bo_cleanup_memtype_use(struct ttm_buffer_object *bo)
{ {
if (bo->bdev->driver->move_notify)
bo->bdev->driver->move_notify(bo, NULL);
if (bo->ttm) { if (bo->ttm) {
ttm_tt_unbind(bo->ttm); ttm_tt_unbind(bo->ttm);
ttm_tt_destroy(bo->ttm); ttm_tt_destroy(bo->ttm);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册