summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorKonsta Holtta <kholtta@nvidia.com>2016-07-15 08:52:52 -0400
committerVijayakumar Subbu <vsubbu@nvidia.com>2016-07-21 08:55:26 -0400
commit13231006671a1da11cfaf7a67e69430199820788 (patch)
tree6b4053838d672b158fe636b60768240585a21eb0 /include
parent83071083d779b67ad73172675a6dfa34ed19b414 (diff)
gpu: nvgpu: add vidmem allocation ioctl
Add NVGPU_GPU_IOCTL_ALLOC_VIDMEM to the ctrl fd for letting userspace allocate on-board GPU memory (aka vidmem). The allocations are returned as dmabuf fds. Also, report the amount of local video memory in the gpu characteristics. Jira DNVGPU-19 Jira DNVGPU-38 Change-Id: I28e361d31bb630b96d06bb1c86d022d91c7592bc Signed-off-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-on: http://git-master/r/1181152 GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Diffstat (limited to 'include')
-rw-r--r--include/uapi/linux/nvgpu.h73
1 files changed, 72 insertions, 1 deletions
diff --git a/include/uapi/linux/nvgpu.h b/include/uapi/linux/nvgpu.h
index aa950dfa..66ea05b3 100644
--- a/include/uapi/linux/nvgpu.h
+++ b/include/uapi/linux/nvgpu.h
@@ -196,6 +196,8 @@ struct nvgpu_gpu_characteristics {
196 __u32 default_graphics_preempt_mode; /* NVGPU_GRAPHICS_PREEMPTION_MODE_* */ 196 __u32 default_graphics_preempt_mode; /* NVGPU_GRAPHICS_PREEMPTION_MODE_* */
197 __u32 default_compute_preempt_mode; /* NVGPU_COMPUTE_PREEMPTION_MODE_* */ 197 __u32 default_compute_preempt_mode; /* NVGPU_COMPUTE_PREEMPTION_MODE_* */
198 198
199 __u64 local_video_memory_size; /* in bytes, non-zero only for dGPUs */
200
199 /* Notes: 201 /* Notes:
200 - This struct can be safely appended with new fields. However, always 202 - This struct can be safely appended with new fields. However, always
201 keep the structure size multiple of 8 and make sure that the binary 203 keep the structure size multiple of 8 and make sure that the binary
@@ -434,6 +436,72 @@ struct nvgpu_gpu_get_engine_info_args {
434 __u64 engine_info_buf_addr; 436 __u64 engine_info_buf_addr;
435}; 437};
436 438
439#define NVGPU_GPU_ALLOC_VIDMEM_FLAG_CONTIGUOUS (1U << 0)
440
441/* CPU access and coherency flags (3 bits). Use CPU access with care,
442 * BAR resources are scarce. */
443#define NVGPU_GPU_ALLOC_VIDMEM_FLAG_CPU_NOT_MAPPABLE (0U << 1)
444#define NVGPU_GPU_ALLOC_VIDMEM_FLAG_CPU_WRITE_COMBINE (1U << 1)
445#define NVGPU_GPU_ALLOC_VIDMEM_FLAG_CPU_CACHED (2U << 1)
446#define NVGPU_GPU_ALLOC_VIDMEM_FLAG_CPU_MASK (7U << 1)
447
448#define NVGPU_GPU_ALLOC_VIDMEM_FLAG_VPR (1U << 4)
449
450/* Allocation of device-specific local video memory. Returns dmabuf fd
451 * on success. */
452struct nvgpu_gpu_alloc_vidmem_args {
453 union {
454 struct {
455 /* Size for allocation. Must be a multiple of
456 * small page size. */
457 __u64 size;
458
459 /* NVGPU_GPU_ALLOC_VIDMEM_FLAG_* */
460 __u32 flags;
461
462 /* Informational mem tag for resource usage
463 * tracking. */
464 __u16 memtag;
465
466 __u16 reserved0;
467
468 /* GPU-visible physical memory alignment in
469 * bytes.
470 *
471 * Alignment must be a power of two. Minimum
472 * alignment is the small page size, which 0
473 * also denotes.
474 *
475 * For contiguous and non-contiguous
476 * allocations, the start address of the
477 * physical memory allocation will be aligned
478 * by this value.
479 *
480 * For non-contiguous allocations, memory is
481 * internally allocated in round_up(size /
482 * alignment) contiguous blocks. The start
483 * address of each block is aligned by the
484 * alignment value. If the size is not a
485 * multiple of alignment (which is ok), the
486 * last allocation block size is (size %
487 * alignment).
488 *
489 * By specifying the big page size here and
490 * allocation size that is a multiple of big
491 * pages, it will be guaranteed that the
492 * allocated buffer is big page size mappable.
493 */
494 __u32 alignment;
495
496 __u32 reserved1[3];
497 } in;
498
499 struct {
500 __s32 dmabuf_fd;
501 } out;
502 };
503};
504
437#define NVGPU_GPU_IOCTL_ZCULL_GET_CTX_SIZE \ 505#define NVGPU_GPU_IOCTL_ZCULL_GET_CTX_SIZE \
438 _IOR(NVGPU_GPU_IOCTL_MAGIC, 1, struct nvgpu_gpu_zcull_get_ctx_size_args) 506 _IOR(NVGPU_GPU_IOCTL_MAGIC, 1, struct nvgpu_gpu_zcull_get_ctx_size_args)
439#define NVGPU_GPU_IOCTL_ZCULL_GET_INFO \ 507#define NVGPU_GPU_IOCTL_ZCULL_GET_INFO \
@@ -489,8 +557,11 @@ struct nvgpu_gpu_get_engine_info_args {
489#define NVGPU_GPU_IOCTL_GET_ENGINE_INFO \ 557#define NVGPU_GPU_IOCTL_GET_ENGINE_INFO \
490 _IOWR(NVGPU_GPU_IOCTL_MAGIC, 26, \ 558 _IOWR(NVGPU_GPU_IOCTL_MAGIC, 26, \
491 struct nvgpu_gpu_get_engine_info_args) 559 struct nvgpu_gpu_get_engine_info_args)
560#define NVGPU_GPU_IOCTL_ALLOC_VIDMEM \
561 _IOWR(NVGPU_GPU_IOCTL_MAGIC, 27, \
562 struct nvgpu_gpu_alloc_vidmem_args)
492#define NVGPU_GPU_IOCTL_LAST \ 563#define NVGPU_GPU_IOCTL_LAST \
493 _IOC_NR(NVGPU_GPU_IOCTL_GET_ENGINE_INFO) 564 _IOC_NR(NVGPU_GPU_IOCTL_ALLOC_VIDMEM)
494#define NVGPU_GPU_IOCTL_MAX_ARG_SIZE \ 565#define NVGPU_GPU_IOCTL_MAX_ARG_SIZE \
495 sizeof(struct nvgpu_gpu_get_cpu_time_correlation_info_args) 566 sizeof(struct nvgpu_gpu_get_cpu_time_correlation_info_args)
496 567