From 3445b516755777d3844cb5fd6fbb5748c95132c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Mon, 14 Jul 2014 18:28:42 +0200 Subject: [PATCH] drm/radeon: fix handling of radeon_vm_bo_rmv MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- drivers/gpu/drm/radeon/radeon_gem.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c index d09650c..5090553 100644 --- a/drivers/gpu/drm/radeon/radeon_gem.c +++ b/drivers/gpu/drm/radeon/radeon_gem.c @@ -168,25 +168,41 @@ void radeon_gem_object_close(struct drm_gem_object *obj, struct radeon_fpriv *fpriv = file_priv->driver_priv; struct radeon_vm *vm = &fpriv->vm; struct radeon_bo_va *bo_va; + struct radeon_cs_reloc *vm_relocs, bo_reloc; + struct ww_acquire_ctx ticket; + struct list_head head; int r; if (rdev->family < CHIP_CAYMAN) { return; } - r = radeon_bo_reserve(rbo, true); + memset(&bo_reloc, 0, sizeof(bo_reloc)); + bo_reloc.robj = rbo; + bo_reloc.tv.bo = &rbo->tbo; + bo_reloc.domain = RADEON_GEM_DOMAIN_VRAM; + bo_reloc.alt_domain = RADEON_GEM_DOMAIN_VRAM; + + INIT_LIST_HEAD(&head); + list_add(&bo_reloc.tv.head, &head); + + vm_relocs = radeon_vm_get_bos(rdev, vm, &head); + r = radeon_bo_list_validate(rdev, &ticket, &head, + RADEON_RING_TYPE_GFX_INDEX); if (r) { dev_err(rdev->dev, "leaking bo va because " "we fail to reserve bo (%d)\n", r); + kfree(vm_relocs); return; } bo_va = radeon_vm_bo_find(vm, rbo); - if (bo_va) { - if (--bo_va->ref_count == 0) { - radeon_vm_bo_rmv(rdev, bo_va); - } + if (bo_va && --bo_va->ref_count == 0) { + radeon_vm_bo_rmv(rdev, bo_va); + ttm_eu_fence_buffer_objects(&ticket, &head, vm->fence); + } else { + ttm_eu_backoff_reservation(&ticket, &head); } - radeon_bo_unreserve(rbo); + kfree(vm_relocs); } static int radeon_gem_handle_lockup(struct radeon_device *rdev, int r) -- 1.9.1