]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amdkfd: fix vram allocation failure for a special case
authorEric Huang <jinhuieric.huang@amd.com>
Mon, 18 Aug 2025 18:22:53 +0000 (14:22 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:34:16 +0000 (15:34 -0500)
[ Upstream commit 93aa919ca05bec544b17ee9a1bfe394ce6c94bd8 ]

When it only allocates vram without va, which is 0, and a
SVM range allocated stays in this range, the vram allocation
returns failure. It should be skipped for this case from
SVM usage check.

Signed-off-by: Eric Huang <jinhuieric.huang@amd.com>
Reviewed-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c

index fc473e3ba2d00cef696b3ddd04752194ad32ad01..7fbbc67adfd9eb7a6cdfa3b2d4c15fec6117bf18 100644 (file)
@@ -1069,7 +1069,12 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep,
        svm_range_list_lock_and_flush_work(&p->svms, current->mm);
        mutex_lock(&p->svms.lock);
        mmap_write_unlock(current->mm);
-       if (interval_tree_iter_first(&p->svms.objects,
+
+       /* Skip a special case that allocates VRAM without VA,
+        * VA will be invalid of 0.
+        */
+       if (!(!args->va_addr && (flags & KFD_IOC_ALLOC_MEM_FLAGS_VRAM)) &&
+           interval_tree_iter_first(&p->svms.objects,
                                     args->va_addr >> PAGE_SHIFT,
                                     (args->va_addr + args->size - 1) >> PAGE_SHIFT)) {
                pr_err("Address: 0x%llx already allocated by SVM\n",