diff options
author | Konsta Holtta <kholtta@nvidia.com> | 2016-07-15 08:52:52 -0400 |
---|---|---|
committer | Vijayakumar Subbu <vsubbu@nvidia.com> | 2016-07-21 08:55:26 -0400 |
commit | 13231006671a1da11cfaf7a67e69430199820788 (patch) | |
tree | 6b4053838d672b158fe636b60768240585a21eb0 /drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c | |
parent | 83071083d779b67ad73172675a6dfa34ed19b414 (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 'drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c index 3e34b6b8..6b832670 100644 --- a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c | |||
@@ -704,6 +704,49 @@ clean_up: | |||
704 | return err; | 704 | return err; |
705 | } | 705 | } |
706 | 706 | ||
707 | static int nvgpu_gpu_alloc_vidmem(struct gk20a *g, | ||
708 | struct nvgpu_gpu_alloc_vidmem_args *args) | ||
709 | { | ||
710 | u32 align = args->in.alignment ? args->in.alignment : SZ_4K; | ||
711 | int fd; | ||
712 | |||
713 | gk20a_dbg_fn(""); | ||
714 | |||
715 | /* not yet supported */ | ||
716 | if (WARN_ON(args->in.flags & NVGPU_GPU_ALLOC_VIDMEM_FLAG_CPU_MASK)) | ||
717 | return -EINVAL; | ||
718 | |||
719 | /* not yet supported */ | ||
720 | if (WARN_ON(args->in.flags & NVGPU_GPU_ALLOC_VIDMEM_FLAG_VPR)) | ||
721 | return -EINVAL; | ||
722 | |||
723 | if (args->in.size & (SZ_4K - 1)) | ||
724 | return -EINVAL; | ||
725 | |||
726 | if (!args->in.size) | ||
727 | return -EINVAL; | ||
728 | |||
729 | if (align & (align - 1)) | ||
730 | return -EINVAL; | ||
731 | |||
732 | if (align > roundup_pow_of_two(args->in.size)) { | ||
733 | /* log this special case, buddy allocator detail */ | ||
734 | gk20a_warn(dev_from_gk20a(g), | ||
735 | "alignment larger than buffer size rounded up to power of 2 is not supported"); | ||
736 | return -EINVAL; | ||
737 | } | ||
738 | |||
739 | fd = gk20a_vidmem_buf_alloc(g, args->in.size); | ||
740 | if (fd < 0) | ||
741 | return fd; | ||
742 | |||
743 | args->out.dmabuf_fd = fd; | ||
744 | |||
745 | gk20a_dbg_fn("done, fd=%d", fd); | ||
746 | |||
747 | return 0; | ||
748 | } | ||
749 | |||
707 | long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | 750 | long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
708 | { | 751 | { |
709 | struct device *dev = filp->private_data; | 752 | struct device *dev = filp->private_data; |
@@ -951,6 +994,11 @@ long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg | |||
951 | (struct nvgpu_gpu_get_engine_info_args *)buf); | 994 | (struct nvgpu_gpu_get_engine_info_args *)buf); |
952 | break; | 995 | break; |
953 | 996 | ||
997 | case NVGPU_GPU_IOCTL_ALLOC_VIDMEM: | ||
998 | err = nvgpu_gpu_alloc_vidmem(g, | ||
999 | (struct nvgpu_gpu_alloc_vidmem_args *)buf); | ||
1000 | break; | ||
1001 | |||
954 | default: | 1002 | default: |
955 | dev_dbg(dev_from_gk20a(g), "unrecognized gpu ioctl cmd: 0x%x", cmd); | 1003 | dev_dbg(dev_from_gk20a(g), "unrecognized gpu ioctl cmd: 0x%x", cmd); |
956 | err = -ENOTTY; | 1004 | err = -ENOTTY; |