From 30ebc1a6396f73402587d2d43567e1e8264dbcaf Mon Sep 17 00:00:00 2001 From: Ketan Patil Date: Thu, 4 May 2023 09:49:37 +0000 Subject: [PATCH] video: tegra: nvmap: Add support for querying granule size Add support for querying the granule size using NvRmMemQueryHeapParams. In case of compression carveout it returns granule size in which memory is allocated while in case of IOVMM heap, it returns PAGE_SIZE. Bug 3956637 Change-Id: I3ec4f5388caecbca0a728e1878007f6b3d4320ef Signed-off-by: Ketan Patil Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2899867 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: Pritesh Raithatha Reviewed-by: Krishna Reddy GVS: Gerrit_Virtual_Submit --- drivers/video/tegra/nvmap/nvmap_ioctl.c | 3 +++ include/uapi/linux/nvmap.h | 1 + 2 files changed, 4 insertions(+) diff --git a/drivers/video/tegra/nvmap/nvmap_ioctl.c b/drivers/video/tegra/nvmap/nvmap_ioctl.c index 4519a46a..b8a22681 100644 --- a/drivers/video/tegra/nvmap/nvmap_ioctl.c +++ b/drivers/video/tegra/nvmap/nvmap_ioctl.c @@ -1354,6 +1354,8 @@ int nvmap_ioctl_query_heap_params(struct file *filp, void __user *arg) heap = nvmap_dev->heaps[i].carveout; op.total = nvmap_query_heap_size(heap); op.free = heap->free_size; + if (nvmap_dev->heaps[i].carveout->is_compression_co) + op.granule_size = nvmap_dev->heaps[i].carveout->granule_size; break; } } @@ -1367,6 +1369,7 @@ int nvmap_ioctl_query_heap_params(struct file *filp, void __user *arg) if (ret) goto exit; op.free = free_mem; + op.granule_size = PAGE_SIZE; } if (copy_to_user(arg, &op, sizeof(op))) diff --git a/include/uapi/linux/nvmap.h b/include/uapi/linux/nvmap.h index c35472d7..1a771c22 100644 --- a/include/uapi/linux/nvmap.h +++ b/include/uapi/linux/nvmap.h @@ -239,6 +239,7 @@ struct nvmap_query_heap_params { __u64 total; __u64 free; __u64 largest_free_block; + __u32 granule_size; }; /**