From fa6ab1943e2977c64f62ba5b9c05b6d7fba234f3 Mon Sep 17 00:00:00 2001 From: Konsta Holtta Date: Tue, 20 Sep 2016 13:34:52 +0300 Subject: 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 Reviewed-on: http://git-master/r/1223762 (cherry picked from commit 96221d96c7972c6387944603e974f7639d6dbe70) Reviewed-on: http://git-master/r/1235980 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/mm_gk20a.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'drivers/gpu/nvgpu/gk20a/mm_gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c index f46f7a81..ff9bb5e2 100644 --- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c @@ -2276,6 +2276,26 @@ err_kfree: #endif } +int gk20a_vidmem_get_space(struct gk20a *g, u64 *space) +{ +#if defined(CONFIG_GK20A_VIDMEM) + struct gk20a_allocator *allocator = &g->mm.vidmem.allocator; + + gk20a_dbg_fn(""); + + if (!gk20a_alloc_initialized(allocator)) + return -ENOSYS; + + mutex_lock(&g->mm.vidmem.clear_list_mutex); + *space = gk20a_alloc_space(allocator) + + atomic64_read(&g->mm.vidmem.bytes_pending); + mutex_unlock(&g->mm.vidmem.clear_list_mutex); + return 0; +#else + return -ENOSYS; +#endif +} + static u64 gk20a_mm_get_align(struct gk20a *g, struct scatterlist *sgl, enum gk20a_aperture aperture) { -- cgit v1.2.2