Skip to content

Commit 30837a4

Browse files
Lang Yualexdeucher
authored andcommitted
drm/amdkfd: Map wptr BO to GART unconditionally
For simulation C models that don't run CP FW where adev->mes.sched_version is not populated correctly. This causes NULL dereference in amdgpu_amdkfd_free_gtt_mem(dev->adev, (void **)&pqn->q->wptr_bo_gart) and warning on unpinned BO in amdgpu_bo_gpu_offset(q->properties.wptr_bo). Compared with adding version check here and there, always map wptr BO to GART simplifies things. v2: Add NULL check in amdgpu_amdkfd_free_gtt_mem.(Philip) Signed-off-by: Lang Yu <[email protected]> Reviewed-by: Felix Kuehling <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 6845305 commit 30837a4

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,9 @@ void amdgpu_amdkfd_free_gtt_mem(struct amdgpu_device *adev, void **mem_obj)
368368
{
369369
struct amdgpu_bo **bo = (struct amdgpu_bo **) mem_obj;
370370

371+
if (!bo || !*bo)
372+
return;
373+
371374
(void)amdgpu_bo_reserve(*bo, true);
372375
amdgpu_bo_kunmap(*bo);
373376
amdgpu_bo_unpin(*bo);

drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -279,20 +279,17 @@ static int init_user_queue(struct process_queue_manager *pqm,
279279
/* Starting with GFX11, wptr BOs must be mapped to GART for MES to determine work
280280
* on unmapped queues for usermode queue oversubscription (no aggregated doorbell)
281281
*/
282-
if (((dev->adev->mes.sched_version & AMDGPU_MES_API_VERSION_MASK)
283-
>> AMDGPU_MES_API_VERSION_SHIFT) >= 2) {
284-
if (dev->adev != amdgpu_ttm_adev(q_properties->wptr_bo->tbo.bdev)) {
285-
pr_err("Queue memory allocated to wrong device\n");
286-
retval = -EINVAL;
287-
goto free_gang_ctx_bo;
288-
}
282+
if (dev->adev != amdgpu_ttm_adev(q_properties->wptr_bo->tbo.bdev)) {
283+
pr_err("Queue memory allocated to wrong device\n");
284+
retval = -EINVAL;
285+
goto free_gang_ctx_bo;
286+
}
289287

290-
retval = amdgpu_amdkfd_map_gtt_bo_to_gart(q_properties->wptr_bo,
291-
&(*q)->wptr_bo_gart);
292-
if (retval) {
293-
pr_err("Failed to map wptr bo to GART\n");
294-
goto free_gang_ctx_bo;
295-
}
288+
retval = amdgpu_amdkfd_map_gtt_bo_to_gart(q_properties->wptr_bo,
289+
&(*q)->wptr_bo_gart);
290+
if (retval) {
291+
pr_err("Failed to map wptr bo to GART\n");
292+
goto free_gang_ctx_bo;
296293
}
297294
}
298295

0 commit comments

Comments
 (0)