[PATCH v5 1/6] drm/amdgpu: Support contiguous VRAM allocation
Felix Kuehling
felix.kuehling at amd.com
Tue Apr 23 22:17:40 UTC 2024
On 2024-04-23 11:28, Philip Yang wrote:
> 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 at amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 ++++
> include/uapi/linux/kfd_ioctl.h | 1 +
> 2 files changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> index 0ae9fd844623..ef9154043757 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> @@ -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_BEST_EFFORT)
> + alloc_flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
> }
> xcp_id = fpriv->xcp_id == AMDGPU_XCP_NO_PARTITION ?
> 0 : fpriv->xcp_id;
> diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h
> index 2040a470ddb4..c1394c162d4e 100644
> --- a/include/uapi/linux/kfd_ioctl.h
> +++ b/include/uapi/linux/kfd_ioctl.h
> @@ -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_BEST_EFFORT (1 << 23)
If I understand it correctly, AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS was
redefined to mean "best effort". Maybe we can drop the explicit
"BEST_EFFORT" from this flag as well to keep the name to a reasonable
length.
Regards,
Felix
>
> /* Allocate memory for later SVM (shared virtual memory) mapping.
> *
More information about the amd-gfx
mailing list