[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240918084718.958-1-m.masimov@maxima.ru>
Date: Wed, 18 Sep 2024 11:47:16 +0300
From: Murad Masimov <m.masimov@...ima.ru>
To: <stable@...r.kernel.org>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>
CC: Murad Masimov <m.masimov@...ima.ru>, Felix Kuehling
<Felix.Kuehling@....com>, Alex Deucher <alexander.deucher@....com>,
Christian König <christian.koenig@....com>, "Pan, Xinhui"
<Xinhui.Pan@....com>, David Airlie <airlied@...il.com>, Daniel Vetter
<daniel@...ll.ch>, "open list:AMD KFD" <amd-gfx@...ts.freedesktop.org>, "open
list:DRM DRIVERS" <dri-devel@...ts.freedesktop.org>, open list
<linux-kernel@...r.kernel.org>, <lvc-project@...uxtesting.org>, Philip Yang
<Philip.Yang@....com>, Alex Sierra <alex.sierra@....com>
Subject: [PATCH 6.1] drm/amdkfd: Skip handle mapping SVM range with no GPU access
From: Philip Yang <Philip.Yang@....com>
commit 8c45b31909b730f9c7b146588e038f9c6553394d upstream.
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 <Philip.Yang@....com>
Reviewed-by: Alex Sierra <alex.sierra@....com>
Signed-off-by: Alex Deucher <alexander.deucher@....com>
[m.masimov@...ima.ru: In order to adapt this patch to branch 6.1
ctx was treated as a variable and not as a pointer.]
Signed-off-by: Murad Masimov <m.masimov@...ima.ru>
---
drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index 7fa5e70f1aac..a44781b66af9 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -1491,6 +1491,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);
}
@@ -1561,10 +1563,10 @@ static int svm_range_validate_and_map(struct mm_struct *mm,
}
if (bitmap_empty(ctx.bitmap, MAX_GPU_INSTANCE)) {
- if (!prange->mapped_to_gpu)
- return 0;
-
bitmap_copy(ctx.bitmap, prange->bitmap_access, MAX_GPU_INSTANCE);
+ if (!prange->mapped_to_gpu ||
+ bitmap_empty(ctx.bitmap, MAX_GPU_INSTANCE))
+ return 0;
}
if (prange->actual_loc && !prange->ttm_res) {
--
2.39.2
Powered by blists - more mailing lists