diff options
author | Konsta Holtta <kholtta@nvidia.com> | 2016-09-20 06:34:52 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2016-10-14 11:12:34 -0400 |
commit | fa6ab1943e2977c64f62ba5b9c05b6d7fba234f3 (patch) | |
tree | 6fd04ad08ee38c0cc66ed34e12e21a9ac07e41c9 /drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c | |
parent | 4d07572c8279f199c220e7c606cc9ffb73216d83 (diff) |
gpu: nvgpu: add ioctl for querying memory state
Add NVGPU_GPU_IOCTL_GET_MEMORY_STATE to read the amount of free
device-local video memory, if applicable.
Some reserved fields are added to support different types of queries in
the future (e.g. context-local free amount).
Bug 1787771
Bug 200233138
Change-Id: Id5ffd02ad4d6ed3a6dc196541938573c27b340ac
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: http://git-master/r/1223762
(cherry picked from commit 96221d96c7972c6387944603e974f7639d6dbe70)
Reviewed-on: http://git-master/r/1235980
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c index 6b832670..2fdf719a 100644 --- a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c | |||
@@ -747,6 +747,24 @@ static int nvgpu_gpu_alloc_vidmem(struct gk20a *g, | |||
747 | return 0; | 747 | return 0; |
748 | } | 748 | } |
749 | 749 | ||
750 | static int nvgpu_gpu_get_memory_state(struct gk20a *g, | ||
751 | struct nvgpu_gpu_get_memory_state_args *args) | ||
752 | { | ||
753 | int err; | ||
754 | |||
755 | gk20a_dbg_fn(""); | ||
756 | |||
757 | if (args->reserved[0] || args->reserved[1] || | ||
758 | args->reserved[2] || args->reserved[3]) | ||
759 | return -EINVAL; | ||
760 | |||
761 | err = gk20a_vidmem_get_space(g, &args->total_free_bytes); | ||
762 | |||
763 | gk20a_dbg_fn("done, err=%d, bytes=%lld", err, args->total_free_bytes); | ||
764 | |||
765 | return err; | ||
766 | } | ||
767 | |||
750 | long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | 768 | long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
751 | { | 769 | { |
752 | struct device *dev = filp->private_data; | 770 | struct device *dev = filp->private_data; |
@@ -999,6 +1017,11 @@ long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg | |||
999 | (struct nvgpu_gpu_alloc_vidmem_args *)buf); | 1017 | (struct nvgpu_gpu_alloc_vidmem_args *)buf); |
1000 | break; | 1018 | break; |
1001 | 1019 | ||
1020 | case NVGPU_GPU_IOCTL_GET_MEMORY_STATE: | ||
1021 | err = nvgpu_gpu_get_memory_state(g, | ||
1022 | (struct nvgpu_gpu_get_memory_state_args *)buf); | ||
1023 | break; | ||
1024 | |||
1002 | default: | 1025 | default: |
1003 | dev_dbg(dev_from_gk20a(g), "unrecognized gpu ioctl cmd: 0x%x", cmd); | 1026 | dev_dbg(dev_from_gk20a(g), "unrecognized gpu ioctl cmd: 0x%x", cmd); |
1004 | err = -ENOTTY; | 1027 | err = -ENOTTY; |