Skip to content

Commit

Permalink
drm/amdkfd: Skip handle mapping SVM range with no GPU access
Browse files Browse the repository at this point in the history
If the SVM range has no GPU access nor access-in-place attribute,
validate and map to GPU should skip the range.

Add NULL pointer check if find_first_bit(ctx->bitmap, MAX_GPU_INSTANCE)
returns MAX_GPU_INSTANCE as gpuidx if ctx->bitmap is empty.

Signed-off-by: Philip Yang <[email protected]>
Reviewed-by: Alex Sierra <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
  • Loading branch information
PhilipYangA authored and alexdeucher committed Jul 7, 2023
1 parent c4cde73 commit 8c45b31
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/gpu/drm/amd/amdkfd/kfd_svm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,8 @@ static void *kfd_svm_page_owner(struct kfd_process *p, int32_t gpuidx)
struct kfd_process_device *pdd;

pdd = kfd_process_device_from_gpuidx(p, gpuidx);
if (!pdd)
return NULL;

return SVM_ADEV_PGMAP_OWNER(pdd->dev->adev);
}
Expand Down Expand Up @@ -1596,12 +1598,12 @@ static int svm_range_validate_and_map(struct mm_struct *mm,
}

if (bitmap_empty(ctx->bitmap, MAX_GPU_INSTANCE)) {
if (!prange->mapped_to_gpu) {
bitmap_copy(ctx->bitmap, prange->bitmap_access, MAX_GPU_INSTANCE);
if (!prange->mapped_to_gpu ||
bitmap_empty(ctx->bitmap, MAX_GPU_INSTANCE)) {
r = 0;
goto free_ctx;
}

bitmap_copy(ctx->bitmap, prange->bitmap_access, MAX_GPU_INSTANCE);
}

if (prange->actual_loc && !prange->ttm_res) {
Expand Down

0 comments on commit 8c45b31

Please sign in to comment.