drm/amdkfd: Unreserve bo if queue update failed
Subsystems (3)
PATCH 1/1 drm/amdkfd: Unreserve bo if queue update failed
Error handling path should unreserve bo then return failed.
--- drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +1 -0
@@ -592,6 +592,7 @@ int pqm_update_queue_properties(struct process_queue_manager *pqm, p->queue_size)) {pr_debug ("ring buf 0x%llx size 0x%llx not mapped on GPU\n" , p->queue_address, p->queue_size); +amdgpu_bo_unreserve (vm->root.bo);return -EFAULT ; }
Signature · 1 line
2.50.1
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 33 lines
-----Original Message-----
From: Yang, Philip <[email protected]>
Sent: Tuesday, December 9, 2025 2:37 PM
To: [email protected]
Cc: Sierra Guiza, Alejandro (Alex) <[email protected]>; Kuehling, Felix <[email protected]>; Yang, Philip <[email protected]>
Subject: [PATCH] drm/amdkfd: Unreserve bo if queue update failedError handling path should unreserve bo then return failed.
Fixes 305cd109b761 ("drm/amdkfd: Validate user queue update")Signed-off-by Philip Yang <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +1
-0@@ -592,6 +592,7 @@ int pqm_update_queue_properties(struct process_queue_manager *pqm, p->queue_size)) {pr_debug ("ring buf 0x%llx size 0x%llx not mapped on GPU\n", p->queue_address, p->queue_size); +amdgpu_bo_unreserve (vm->root.bo);return -EFAULT ;}--
2.50.1
Quoted 13 lines · Philip Yang
Error handling path should unreserve bo then return failed.
Fixes 305cd109b761 ("drm/amdkfd: Validate user queue update")Signed-off-by Philip Yang <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +0
-0
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c int pqm_update_queue_properties(struct process_queue_manager *pqm, · line 595
Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +1
-0@@ -592,6 +592,7 @@ int pqm_update_queue_properties(struct process_queue_manager *pqm, p->queue_size)) {pr_debug ("ring buf 0x%llx size 0x%llx not mapped on GPU\n" , p->queue_address, p->queue_size); +amdgpu_bo_unreserve (vm->root.bo);
but why need have amdgpu_bo_reserve before call kfd_queue_buffer_get? kfd_queue_buffer_get just check if mapping at addr exist, it adds bo_ref and mapping->bo_va->queue_refcount. Then after immediately call kfd_queue_unref_bo_va and kfd_queue_buffer_put.
Regards
Xiaogang
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +0
-0return -EFAULT ; }
Quoted 10 lines · Xiaogang
Quoted 8 lines · Philip Yang
Error handling path should unreserve bo then return failed.
Fixes 305cd109b761 ("drm/amdkfd: Validate user queue update")Signed-off-by Philip Yang <[email protected]>---
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c| 1 +1 file changed, 1 insertion(+)
Quoted 12 lines
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c int pqm_update_queue_properties(struct · line 596
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +1
-0@@ -592,6 +592,7 @@ int pqm_update_queue_properties(struct process_queue_manager *pqm, p->queue_size)) { pr_debug("ring buf 0x%llx size 0x%llx not mapped on GPU\n", p->queue_address, p->queue_size); + amdgpu_bo_unreserve(vm->root.bo);but why need have
amdgpu_bo_reservebefore callkfd_queue_buffer_get?kfd_queue_buffer_getjust check if mapping at addr exist, it addsbo_refandmapping->bo_va->queue_refcount. Then after immediately callkfd_queue_unref_bo_vaandkfd_queue_buffer_put.
amdgpu_vm_bo_lookup_mapping access vm->va interval tree, this requires to take vm lock.
Regards,
Philip
Quoted 8 lines
Regards
Xiaogang
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +0
-0return -EFAULT; }
Quoted 25 lines · Philip Yang
Quoted 10 lines · Xiaogang
Quoted 8 lines · Philip Yang
Error handling path should unreserve bo then return failed.
Fixes 305cd109b761 ("drm/amdkfd: Validate user queue update")Signed-off-by Philip Yang <[email protected]>---
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c| 1 +1 file changed, 1 insertion(+)Quoted 12 lines
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c int pqm_update_queue_properties(struct · line 596
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +1
-0@@ -592,6 +592,7 @@ int pqm_update_queue_properties(struct process_queue_manager *pqm, p->queue_size)) { pr_debug("ring buf 0x%llx size 0x%llx not mapped on GPU\n", p->queue_address, p->queue_size); + amdgpu_bo_unreserve(vm->root.bo);but why need have
amdgpu_bo_reservebefore callkfd_queue_buffer_get?kfd_queue_buffer_getjust check if mapping at addr exist, it addsbo_refandmapping->bo_va->queue_refcount. Then after immediately callkfd_queue_unref_bo_vaandkfd_queue_buffer_put.
Quoted 1 line
amdgpu_vm_bo_lookup_mappingaccessvm->vainterval tree, this requires to take vm lock.
ok, it locks a vm->root.bo. I sought it locks a general bo. I think the lock/unlock can be inside kfd_queue_buffer_get before and after amdgpu_vm_bo_lookup_mapping because that is what need be protected, then do not have to care unlock after this function call as current case.
For such lock can we use drm_exec_init/amdgpu_vm_lock_pd instead, as it is a more general way?
Regards
Xiaogang
Quoted 12 lines
Regards,
PhilipQuoted 8 lines
Regards
Xiaogang
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +0
-0return -EFAULT; }
Quoted 27 lines · Xiaogang
Quoted 25 lines · Philip Yang
Quoted 22 lines · Xiaogang
Quoted 13 lines · Philip Yang
Error handling path should unreserve bo then return failed.
Fixes 305cd109b761 ("drm/amdkfd: Validate user queue update")Signed-off-by Philip Yang <[email protected]>---
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c| 1 +1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +0
-0drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c int pqm_update_queue_properties(struct · line 596
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +1
-0@@ -592,6 +592,7 @@ int pqm_update_queue_properties(struct process_queue_manager *pqm, p->queue_size)) { pr_debug("ring buf 0x%llx size 0x%llx not mapped on GPU\n", p->queue_address, p->queue_size); + amdgpu_bo_unreserve(vm->root.bo);but why need have
amdgpu_bo_reservebefore callkfd_queue_buffer_get?kfd_queue_buffer_getjust check if mapping at addr exist, it addsbo_refandmapping->bo_va->queue_refcount. Then after immediately callkfd_queue_unref_bo_vaandkfd_queue_buffer_put.
Quoted 4 lines
Quoted 1 line
amdgpu_vm_bo_lookup_mappingaccessvm->vainterval tree, this requires to take vm lock.ok, it locks a
vm->root.bo. I sought it locks a general bo. I think the lock/unlock can be insidekfd_queue_buffer_getbefore and afteramdgpu_vm_bo_lookup_mappingbecause that is what need be protected, then do not have to care unlock after this function call as current case.
create queue path will call kfd_queue_buffer_get many times to validate ring buffer, wptr, rptr, eop, cwsr BOs, so it is better to take the vm lock outside kfd_queue_buffer_get.
Quoted 1 line
For such lock can we use drm_exec_init/amdgpu_vm_lock_pd instead, as it is a more general way?
This is used to take root BO lock and multiple BOs lock to avoid circular lock / deadlock, we only take vm lock here.
Regards,
Philip
Quoted 17 lines
Regards
Xiaogang
Quoted 12 lines
Regards,
PhilipQuoted 8 lines
Regards
Xiaogang
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +0
-0return -EFAULT; }