drm/amdgpu: do not use amdgpu_bo_gpu_offset_no_check individually
Subsystems (2)
PATCH 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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c | 2 +- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 10 +++++++++- 2 files changed, 10 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 +9 -1
@@ -93,7 +93,15 @@ 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; + } + + queue->wptr_obj.gpu_addr =amdgpu_bo_gpu_offset (wptr_obj->obj); +amdgpu_bo_unreserve (wptr_obj->obj); +return 0 ; }
Signature · 1 line
2.43.0
Christian König
maintainerQuoted 30 lines · Saleemkhan Jamadar
This should not be used indiviually, use
amdgpu_bo_gpu_offsetwith bo reserved.Signed-off-by Saleemkhan Jamadar <[email protected]>Suggested-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c | 2 +- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 10 +++++++++- 2 files changed, 10 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 +0
-0@@ -93,7 +93,15 @@ mes_userq_create_wptr_mapping(struct amdgpu_userq_mgr *uq_mgr,return ret; }
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c mes_userq_create_wptr_mapping(struct amdgpu_userq_mgr *uq_mgr, · line 103
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +8
-1- 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; + } + + queue->wptr_obj.gpu_addr =amdgpu_bo_gpu_offset (wptr_obj->obj); +amdgpu_bo_unreserve (wptr_obj->obj);
The problem here is that the return value of amdgpu_bo_gpu_offset() can change as soon as you unlock the BO.
So that wptr BO either need to be pinned or fenced for this to work.
Regards,
Christian.
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +1
-0+return 0 ; }
Quoted 47 lines · Christian König
Quoted 30 lines · Saleemkhan Jamadar
This should not be used indiviually, use
amdgpu_bo_gpu_offsetwith bo reserved.Signed-off-by Saleemkhan Jamadar <[email protected]>Suggested-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c | 2 +- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 10 +++++++++- 2 files changed, 10 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 +0
-0@@ -93,7 +93,15 @@ mes_userq_create_wptr_mapping(struct amdgpu_userq_mgr *uq_mgr,return ret; }drivers/gpu/drm/amd/amdgpu/mes_userqueue.c mes_userq_create_wptr_mapping(struct amdgpu_userq_mgr *uq_mgr, · line 103
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +8
-1- 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; + } + + queue->wptr_obj.gpu_addr =amdgpu_bo_gpu_offset (wptr_obj->obj); +amdgpu_bo_unreserve (wptr_obj->obj);The problem here is that the return value of
amdgpu_bo_gpu_offset()can change as soon as you unlock the BO.
Quoted 1 line
So that wptr BO either need to be pinned or fenced for this to work.
amdgpu_amdkfd_map_gtt_bo_to_gart() and mes_userq_map_gtt_bo_to_gart() differ in how they handle this. amdgpu_amdkfd_map_gtt_bo_to_gart() pins the BO while mes_userq_map_gtt_bo_to_gart() does not.
Alex
Quoted 9 lines
Regards,
Christian.Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +1
-0+return 0 ; }