On 24-10-2025 10:43 pm, Kuehling, Felix wrote:
On 2025-10-24 12:55, Khatri, Sunil wrote:
On 24-10-2025 08:41 pm, Philip Yang wrote:
On 2025-10-24 07:45, Khatri, Sunil wrote:
+shirish
On 24-10-2025 04:46 pm, Sunil Khatri wrote:
amdgpu_hmm_range_alloc could fails in case of low
memory condition and hence we should have a check
for the return value.
Signed-off-by: Sunil Khatri <[email protected]>
---
drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index f041643308ca..7f0ab73e2396 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -1738,6 +1738,11 @@ static int
svm_range_validate_and_map(struct mm_struct *mm,
WRITE_ONCE(p->svms.faulting_task, current);
range = amdgpu_hmm_range_alloc(NULL);
+ if (unlikely(!range)) {
+ r = -ENOMEM;
+ goto free_ctx;
Can not goto end from here, this skips the svm_range_unreserve_bos.
Just set r = -ENOMEM, and the loop will exit and cleanup accordingly.
That patch has already been merged now and i have to send another
patch for review. While at it, cannot just set ENOMEM and leave as it
will crash in next step where it access range which is NULL.
This is what i am thinking
range = amdgpu_hmm_range_alloc(NULL);
if (unlikely(!range)) {
r = -ENOMEM;
svm_range_unreserve_bos(ctx);
goto free_ctx;
}
If that is fine i will send a new patch for this ?
I'd recommend
if (unlikely(!range)) {
r = -ENOMEM;
break;
}
Yup, this would work too and is a better approach. Sent the new patch
"[Patch v2] drm/amdkfd: fix the clean up when amdgpu_hmm_range_alloc fails"
Regards
Sunil khatri
Regards,
Felix
Regards
Sunil Khatri
Regards,
Philip
+ }
+
r = amdgpu_hmm_range_get_pages(&prange->notifier,
addr, npages,
readonly, owner,
range);