accel/amdxdna: Support user space allocated buffer

Enhance DRM_IOCTL_AMDXDNA_CREATE_BO to accept user space allocated
buffer pointer. The buffer pages will be pinned in memory. Unless
the CAP_IPC_LOCK is enabled for the application process, the total
pinned memory can not beyond rlimit_memlock.

Reviewed-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Link: https://lore.kernel.org/r/20250716164414.112091-1-lizhi.hou@amd.com
This commit is contained in:
Lizhi Hou
2025-07-16 09:44:14 -07:00
parent 956f82e529
commit bd72d4acda
5 changed files with 391 additions and 25 deletions

View File

@@ -153,6 +153,31 @@ enum amdxdna_bo_type {
AMDXDNA_BO_CMD,
};
/**
* struct amdxdna_drm_va_entry
* @vaddr: Virtual address.
* @len: Size of entry.
*/
struct amdxdna_drm_va_entry {
__u64 vaddr;
__u64 len;
};
/**
* struct amdxdna_drm_va_tbl
* @dmabuf_fd: The fd of dmabuf.
* @num_entries: Number of va entries.
* @va_entries: Array of va entries.
*
* The input can be either a dmabuf fd or a virtual address entry table.
* When dmabuf_fd is used, num_entries must be zero.
*/
struct amdxdna_drm_va_tbl {
__s32 dmabuf_fd;
__u32 num_entries;
struct amdxdna_drm_va_entry va_entries[];
};
/**
* struct amdxdna_drm_create_bo - Create a buffer object.
* @flags: Buffer flags. MBZ.