drm/amdgpu: do not use amdgpu_bo_gpu_offset_no_check individually
Subsystems (2)
PATCH v2 1/1 drm/amdgpu: do not use amdgpu_bo_gpu_offset_no_check individually
This should not be used indiviually, use amdgpu_bo_gpu_offset with bo reserved.
v2 - pin bo so that offset returned won't change after unresv/unlock (Christian)
Signed-off-by Saleemkhan Jamadar <[email protected]>
Suggested-by Christian König <[email protected]>
--- .../gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c | 2 +- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c +1 -1
@@ -129,7 +129,7 @@ uint32_t amdgpu_doorbell_index_on_bar(struct amdgpu_device *adev, {int db_bo_offset; - db_bo_offset =amdgpu_bo_gpu_offset_no_check (db_bo); + db_bo_offset =amdgpu_bo_gpu_offset (db_bo);/* doorbell index is 32 bit but doorbell's size can be 32 bit * or 64 bit, so *db_size(in byte)/4 for alignment.
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +20 -1
@@ -93,8 +93,27 @@ mes_userq_create_wptr_mapping(struct amdgpu_userq_mgr *uq_mgr,return ret; } - queue->wptr_obj.gpu_addr =amdgpu_bo_gpu_offset_no_check (wptr_obj->obj); + ret =amdgpu_bo_reserve (wptr_obj->obj, true); +if (ret) { +DRM_ERROR ("Failed to reserve wptr bo\n" ); +return ret; + } + + ret =amdgpu_bo_pin (wptr_obj->obj,AMDGPU_GEM_DOMAIN_GTT ); +if (ret) { +drm_file_err (uq_mgr->file,"[Usermode queues] Failed to pin wptr bo\n" ); + goto unresv_bo; + } + + queue->wptr_obj.gpu_addr =amdgpu_bo_gpu_offset (wptr_obj->obj); +amdgpu_bo_unreserve (wptr_obj->obj); +return 0 ; + +unresv_bo: +amdgpu_bo_unreserve (wptr_obj->obj); +return ret; + }static int convert_to_mes_priority (int priority)
Signature · 1 line
2.43.0
Christian König
maintainerQuoted 4 lines · Saleemkhan Jamadar
This should not be used indiviually, use
amdgpu_bo_gpu_offsetwith bo reserved.v2 - pin bo so that offset returned won't change after unresv/unlock (Christian)
Each pin must have a matching unpin or otherwise you run into warnings on destruction.
Regards,
Christian.
Quoted 54 lines
Signed-off-by Saleemkhan Jamadar <[email protected]>Suggested-by Christian König <[email protected]>--- .../gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c | 2 +- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c +1
-1@@ -129,7 +129,7 @@ uint32_t amdgpu_doorbell_index_on_bar(struct amdgpu_device *adev, {int db_bo_offset; - db_bo_offset =amdgpu_bo_gpu_offset_no_check (db_bo); + db_bo_offset =amdgpu_bo_gpu_offset (db_bo);/* doorbell index is 32 bit but doorbell's size can be 32 bit * or 64 bit, so *db_size(in byte)/4 for alignment. drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +20
-1@@ -93,8 +93,27 @@ mes_userq_create_wptr_mapping(struct amdgpu_userq_mgr *uq_mgr,return ret; } - queue->wptr_obj.gpu_addr =amdgpu_bo_gpu_offset_no_check (wptr_obj->obj); + ret =amdgpu_bo_reserve (wptr_obj->obj, true); +if (ret) { +DRM_ERROR ("Failed to reserve wptr bo\n" ); +return ret; + } + + ret =amdgpu_bo_pin (wptr_obj->obj,AMDGPU_GEM_DOMAIN_GTT ); +if (ret) { +drm_file_err (uq_mgr->file,"[Usermode queues] Failed to pin wptr bo\n" ); + goto unresv_bo; + } + + queue->wptr_obj.gpu_addr =amdgpu_bo_gpu_offset (wptr_obj->obj); +amdgpu_bo_unreserve (wptr_obj->obj); +return 0 ; + +unresv_bo: +amdgpu_bo_unreserve (wptr_obj->obj); +return ret; + }static int convert_to_mes_priority (int priority)