re MM, scheduler, or unrelated GPU subsystems. - Consistency with mapping rules: mapping requires a non-zero VA. In `kfd_mem_attach` (called during mapping), mapping with `mem->va == 0` is rejected (`drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c:858-930`, check at “if (!va) { ... return -EINVAL; }”). This ensures that skipping the SVM check for VA=0 can’t accidentally permit an overlapping SVM GPU-VA mapping later: mapping at VA=0 is inherently invalid and denied. Thus the change strictly avoids a spurious allocation-time error without enabling unsafe mappings. - Flags behavior matches UAPI: `KFD_IOC_ALLOC_MEM_FLAGS_VRAM` is intended for VRAM allocations (`include/uapi/linux/kfd_ioctl.h:407`). VRAM-only allocations with VA=0 are valid for certain use cases (e.g., export or CPU-visible VRAM on large BAR), and should not be blocked by SVM interval checks. Stable backport criteria - Fixes a real bug affecting users (spurious -EADDRINUSE on valid VRAM- only allocations). - Change is small and contained, with clear intent and low regression risk. - No new features or architectural shifts. - Touches only driver code in a single path (`kfd_ioctl_alloc_memory_of_gpu`), no widespread side effects. Conclusion - This is a clear, minimal bug fix that prevents erroneous allocation failures and aligns with the mapping semantics already enforced elsewhere. It is suitable for stable backport. drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 79ed3be63d0dd..43115a3744694 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -1070,7 +1070,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", -- 2.51.0[PATCH AUTOSEL 6.17-6.1] drm/amdkfd: fix vram allocation failure for a special caseSasha Levin undefinedpatches@lists.linux.dev, stable@vger.kernel.org undefined undefined undefined undefined undefined undefined undefinedNr