Provide a hint how many BOs we are going to use and prevent unmap from waiting interruptible. Also avoid using fpriv in unmap and work give VM and VA as parameter instead. Signed-off-by: Christian König <christian.koenig@xxxxxxx> --- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c | 31 ++++++++++------------- drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.h | 6 +++-- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index 260cd0ad286d..28a8f13ab8a7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c @@ -1431,7 +1431,7 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev, fpriv->csa_va = NULL; } - amdgpu_seq64_unmap(adev, fpriv); + amdgpu_seq64_unmap(adev, &fpriv->vm, fpriv->seq64_va); pasid = fpriv->vm.pasid; pd = amdgpu_bo_ref(fpriv->vm.root.bo); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c index 8d0a3cce979e..8f8ed152d0d9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c @@ -70,9 +70,9 @@ int amdgpu_seq64_map(struct amdgpu_device *adev, struct amdgpu_vm *vm, bo = adev->seq64.sbo; if (!bo) - return -EINVAL; + return 0; - drm_exec_init(&exec, DRM_EXEC_INTERRUPTIBLE_WAIT, 0); + drm_exec_init(&exec, DRM_EXEC_INTERRUPTIBLE_WAIT, 2); drm_exec_until_all_locked(&exec) { r = amdgpu_vm_lock_pd(vm, &exec, 0); if (likely(!r)) @@ -89,7 +89,8 @@ int amdgpu_seq64_map(struct amdgpu_device *adev, struct amdgpu_vm *vm, } seq64_addr = amdgpu_seq64_get_va_base(adev); - r = amdgpu_vm_bo_map(adev, *bo_va, seq64_addr, 0, AMDGPU_VA_RESERVED_SEQ64_SIZE, + r = amdgpu_vm_bo_map(adev, *bo_va, seq64_addr, 0, + AMDGPU_VA_RESERVED_SEQ64_SIZE, AMDGPU_PTE_READABLE); if (r) { DRM_ERROR("failed to do bo_map on userq sem, err=%d\n", r); @@ -106,39 +107,35 @@ int amdgpu_seq64_map(struct amdgpu_device *adev, struct amdgpu_vm *vm, * amdgpu_seq64_unmap - Unmap the seq64 memory * * @adev: amdgpu_device pointer - * @fpriv: DRM file private + * @vm: vm pointer + * @bo_va: bo_va pointer * * Unmap the seq64 memory from the given VM. */ -void amdgpu_seq64_unmap(struct amdgpu_device *adev, struct amdgpu_fpriv *fpriv) +void amdgpu_seq64_unmap(struct amdgpu_device *adev, struct amdgpu_vm *vm, + struct amdgpu_bo_va *bo_va) { - struct amdgpu_vm *vm; struct amdgpu_bo *bo; struct drm_exec exec; int r; - if (!fpriv->seq64_va) - return; - bo = adev->seq64.sbo; - if (!bo) + if (!bo || !bo_va) return; - vm = &fpriv->vm; - - drm_exec_init(&exec, DRM_EXEC_INTERRUPTIBLE_WAIT, 0); + drm_exec_init(&exec, 0, 2); drm_exec_until_all_locked(&exec) { r = amdgpu_vm_lock_pd(vm, &exec, 0); if (likely(!r)) r = drm_exec_lock_obj(&exec, &bo->tbo.base); drm_exec_retry_on_contention(&exec); - if (unlikely(r)) + if (unlikely(r)) { + DRM_ERROR("Leaking SEQ64 VA (%d)\n", r); goto error; + } } - amdgpu_vm_bo_del(adev, fpriv->seq64_va); - - fpriv->seq64_va = NULL; + amdgpu_vm_bo_del(adev, bo_va); error: drm_exec_fini(&exec); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.h index 4203b2ab318d..3f31f59d5625 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.h @@ -38,11 +38,13 @@ struct amdgpu_seq64 { void amdgpu_seq64_fini(struct amdgpu_device *adev); int amdgpu_seq64_init(struct amdgpu_device *adev); -int amdgpu_seq64_alloc(struct amdgpu_device *adev, u64 *gpu_addr, u64 **cpu_addr); +int amdgpu_seq64_alloc(struct amdgpu_device *adev, u64 *gpu_addr, + u64 **cpu_addr); void amdgpu_seq64_free(struct amdgpu_device *adev, u64 gpu_addr); int amdgpu_seq64_map(struct amdgpu_device *adev, struct amdgpu_vm *vm, struct amdgpu_bo_va **bo_va); -void amdgpu_seq64_unmap(struct amdgpu_device *adev, struct amdgpu_fpriv *fpriv); +void amdgpu_seq64_unmap(struct amdgpu_device *adev, struct amdgpu_vm *vm, + struct amdgpu_bo_va *bo_va); #endif -- 2.34.1