]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdgpu: Support contiguous VRAM allocation
authorPhilip Yang <Philip.Yang@amd.com>
Fri, 5 Apr 2024 19:46:50 +0000 (15:46 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 30 Apr 2024 13:44:46 +0000 (09:44 -0400)
RDMA device with limited scatter-gather ability requires contiguous VRAM
buffer allocation for RDMA peer direct support.

Add a new KFD alloc memory flag and store as bo alloc flag
AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS. When pin this bo to export for RDMA
peerdirect access, this will set TTM_PL_FLAG_CONTIFUOUS flag, and ask
VRAM buddy allocator to get contiguous VRAM.

Signed-off-by: Philip Yang <Philip.Yang@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
include/uapi/linux/kfd_ioctl.h

index e4d4e55c08ad5a3a11b7133e3f717110c958b09f..5c06279c6bef4558af38fb7fbd15b6059bfd0895 100644 (file)
@@ -1712,6 +1712,10 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
                        alloc_flags = AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE;
                        alloc_flags |= (flags & KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC) ?
                        AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED : 0;
+
+                       /* For contiguous VRAM allocation */
+                       if (flags & KFD_IOC_ALLOC_MEM_FLAGS_CONTIGUOUS)
+                               alloc_flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
                }
                xcp_id = fpriv->xcp_id == AMDGPU_XCP_NO_PARTITION ?
                                        0 : fpriv->xcp_id;
index 2040a470ddb41bfe9af0fe2abd4c5b53c4a6687c..d09c4a18e5713adc21fe7d795f90dc24387b3b9e 100644 (file)
@@ -407,6 +407,7 @@ struct kfd_ioctl_acquire_vm_args {
 #define KFD_IOC_ALLOC_MEM_FLAGS_COHERENT       (1 << 26)
 #define KFD_IOC_ALLOC_MEM_FLAGS_UNCACHED       (1 << 25)
 #define KFD_IOC_ALLOC_MEM_FLAGS_EXT_COHERENT   (1 << 24)
+#define KFD_IOC_ALLOC_MEM_FLAGS_CONTIGUOUS     (1 << 23)
 
 /* Allocate memory for later SVM (shared virtual memory) mapping.
  *