diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c index 7b9463f..add0b94 100644 --- a/drivers/gpu/drm/radeon/radeon_gem.c +++ b/drivers/gpu/drm/radeon/radeon_gem.c @@ -167,18 +167,12 @@ void radeon_gem_object_close(struct drm_gem_object *obj, struct radeon_device *rdev = rbo->rdev; struct radeon_fpriv *fpriv = file_priv->driver_priv; struct radeon_vm *vm = &fpriv->vm; - int r; if (rdev->family < CHIP_CAYMAN) { return; } - r = radeon_vm_bo_rmv(rdev, vm, rbo); - if (r) { - dev_err(rdev->dev, "leaking bo va because " - "we fail to reserve bo (%d)\n", r); - return; - } + radeon_vm_bo_rmv(rdev, vm, rbo); } static int radeon_gem_handle_lockup(struct radeon_device *rdev, int r) diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c index d4b6b60..cbb00dd 100644 --- a/drivers/gpu/drm/radeon/radeon_kms.c +++ b/drivers/gpu/drm/radeon/radeon_kms.c @@ -640,14 +640,10 @@ void radeon_driver_postclose_kms(struct drm_device *dev, /* new gpu have virtual address space support */ if (rdev->family >= CHIP_CAYMAN && file_priv->driver_priv) { struct radeon_fpriv *fpriv = file_priv->driver_priv; - int r; - if (rdev->accel_working) { - r = radeon_vm_bo_rmv(rdev, &fpriv->vm, - rdev->ring_tmp_bo.bo); - if (r) - DRM_ERROR("tmp_bo removal failed (%d)!\n", r); - } + if (rdev->accel_working) + radeon_vm_bo_rmv(rdev, &fpriv->vm, + rdev->ring_tmp_bo.bo); radeon_vm_fini(rdev, &fpriv->vm); kfree(fpriv); diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c index 537fed6..522a26c 100644 --- a/drivers/gpu/drm/radeon/radeon_vm.c +++ b/drivers/gpu/drm/radeon/radeon_vm.c @@ -931,6 +931,12 @@ int radeon_vm_bo_rmv(struct radeon_device *rdev, struct list_head head; int r; + bo_va = radeon_vm_bo_find(vm, bo); + if (!bo_va || --bo_va->ref_count > 0) { + /* It's not an error to have more references */ + return 0; + } + memset(&bo_reloc, 0, sizeof(bo_reloc)); bo_reloc.robj = bo; bo_reloc.tv.bo = &bo->tbo; @@ -944,13 +950,9 @@ int radeon_vm_bo_rmv(struct radeon_device *rdev, vm_relocs = radeon_vm_get_bos(rdev, vm, &head); r = radeon_bo_list_validate(rdev, &ticket, &head, RADEON_RING_TYPE_GFX_INDEX); - if (r) - goto release_vm_relocs; - - bo_va = radeon_vm_bo_find(vm, bo); - if (!bo_va || --bo_va->ref_count > 0) { - r = 0; /* It's not an error to have more references */ - ttm_eu_backoff_reservation(&ticket, &head); + if (r) { + dev_err(rdev->dev, "Not clearing BO PTE because " + "radeon_bo_list_validate() failed (%d)\n", r); goto release_vm_relocs; } @@ -960,13 +962,12 @@ int radeon_vm_bo_rmv(struct radeon_device *rdev, if (r) { ttm_eu_backoff_reservation(&ticket, &head); mutex_unlock(&bo_va->vm->mutex); + dev_err(rdev->dev, + "radeon_vm_bo_update() failed (%d)\n", r); goto release_vm_relocs; } } - list_del(&bo_va->vm_list); - list_del(&bo_va->bo_list); - if (bo_va->soffset && vm->fence) ttm_eu_fence_buffer_objects(&ticket, &head, vm->fence); else @@ -978,6 +979,9 @@ int radeon_vm_bo_rmv(struct radeon_device *rdev, r = 0; release_vm_relocs: + list_del(&bo_va->vm_list); + list_del(&bo_va->bo_list); + kfree(vm_relocs); return r; }