drm/amdgpu: Add entity's check when alloc sdma jobs
Subsystems (2)
PATCH 1/1 drm/amdgpu: Add entity's check when alloc sdma jobs
issue:When one of multiple processes sharing the same amdgpu device fd is killed, amdgpu_flush runs but amdgpu_drm_release does not, so the vm's entitys have been stopped but bos still alive. Later, when the KFD fd is closed, the driver unmaps BOs from the GPU VM, clears the freed BO list, and normally submits SDMA jobs plus an amdgpu_tlb_fence_work to wait on the job's finished fences which will not be signaled.
add check if entity is NULL or has been stopped, if so, don't submit sdma jobs and create amdgpu_tlb_fence_work
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c +7 -0
@@ -49,6 +49,13 @@ static int amdgpu_vm_sdma_alloc_job(struct amdgpu_vm_update_params *p,unsigned int ndw;int r; +spin_lock (&entity->lock); +if (entity->stopped) { +spin_unlock (&entity->lock); +return -EINVAL ; + } +spin_unlock (&entity->lock); +/* estimate how many dw we need */ ndw =AMDGPU_VM_SDMA_MIN_NUM_DW ;if (p->pages_addr)
Signature · 1 line
2.43.0
Christian König
maintainerQuoted 1 line · Bingxi Guo
issue:When one of multiple processes sharing the same amdgpu device
That is illegal to begin with. Multiple processes shouldn't share the same device fd.
Quoted 6 lines
fd is killed,
amdgpu_flushruns butamdgpu_drm_releasedoes not, so the vm's entitys have been stopped but bos still alive. Later, when the KFD fd is closed, the driver unmaps BOs from the GPU VM, clears the freed BO list, and normally submits SDMA jobs plus anamdgpu_tlb_fence_workto wait on the job's finished fences which will not be signaled.
The problem is the KFD code and not the SDMA backend, this check here is especially racy since the entity status can change as soon as you drop the lock.
So clear NAK to that.
Regards,
Christian.
Quoted 27 lines
add check if entity is NULL or has been stopped, if so, don't submit sdma jobs and create
amdgpu_tlb_fence_workSigned-off-by Bingxi Guo <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c +7
-0@@ -49,6 +49,13 @@ static int amdgpu_vm_sdma_alloc_job(struct amdgpu_vm_update_params *p,unsigned int ndw;int r; +spin_lock (&entity->lock); +if (entity->stopped) { +spin_unlock (&entity->lock); +return -EINVAL ; + } +spin_unlock (&entity->lock); +/* estimate how many dw we need */ ndw =AMDGPU_VM_SDMA_MIN_NUM_DW ;if (p->pages_addr)