video: tegra: nvmap: Add NUMA aware query heap API

Add a new API to query the heap params for an input heap present on the
given input numa node. e.g. User may specify to query heap information
of GPU carveout on numa node 0 or numa node 1 etc.

Bug 4231517

Change-Id: I9622828b6a28984564b4c7f17b88b4d38bbd4684
Signed-off-by: Ketan Patil <ketanp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3010795
Reviewed-by: Pritesh Raithatha <praithatha@nvidia.com>
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Ketan Patil
2023-11-06 07:21:17 +00:00
committed by mobile promotions
parent 3d11a320cc
commit 343f9e764f
4 changed files with 34 additions and 5 deletions

View File

@@ -488,6 +488,11 @@ static long nvmap_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
case NVMAP_IOC_QUERY_HEAP_PARAMS: case NVMAP_IOC_QUERY_HEAP_PARAMS:
err = nvmap_ioctl_query_heap_params(filp, uarg); err = nvmap_ioctl_query_heap_params(filp, uarg);
break; break;
case NVMAP_IOC_QUERY_HEAP_PARAMS_NUMA:
err = nvmap_ioctl_query_heap_params_numa(filp, uarg);
break;
case NVMAP_IOC_GET_FD_FOR_RANGE_FROM_LIST: case NVMAP_IOC_GET_FD_FOR_RANGE_FROM_LIST:
err = nvmap_ioctl_get_fd_from_list(filp, uarg); err = nvmap_ioctl_get_fd_from_list(filp, uarg);
break; break;

View File

@@ -1365,7 +1365,7 @@ static unsigned long system_heap_total_mem(void)
return sys_heap.totalram << PAGE_SHIFT; return sys_heap.totalram << PAGE_SHIFT;
} }
int nvmap_ioctl_query_heap_params(struct file *filp, void __user *arg) static int nvmap_query_heap_params(void __user *arg, bool is_numa_aware)
{ {
unsigned int carveout_mask = NVMAP_HEAP_CARVEOUT_MASK; unsigned int carveout_mask = NVMAP_HEAP_CARVEOUT_MASK;
unsigned int iovmm_mask = NVMAP_HEAP_IOVMM; unsigned int iovmm_mask = NVMAP_HEAP_IOVMM;
@@ -1374,6 +1374,7 @@ int nvmap_ioctl_query_heap_params(struct file *filp, void __user *arg)
unsigned int type; unsigned int type;
int ret = 0; int ret = 0;
int i; int i;
int numa_id;
unsigned long free_mem = 0; unsigned long free_mem = 0;
memset(&op, 0, sizeof(op)); memset(&op, 0, sizeof(op));
@@ -1384,6 +1385,8 @@ int nvmap_ioctl_query_heap_params(struct file *filp, void __user *arg)
type = op.heap_mask; type = op.heap_mask;
WARN_ON(type & (type - 1)); WARN_ON(type & (type - 1));
if (is_numa_aware)
numa_id = op.numa_id;
if (nvmap_convert_carveout_to_iovmm) { if (nvmap_convert_carveout_to_iovmm) {
carveout_mask &= ~NVMAP_HEAP_CARVEOUT_GENERIC; carveout_mask &= ~NVMAP_HEAP_CARVEOUT_GENERIC;
@@ -1400,12 +1403,16 @@ int nvmap_ioctl_query_heap_params(struct file *filp, void __user *arg)
if (type & NVMAP_HEAP_CARVEOUT_MASK) { if (type & NVMAP_HEAP_CARVEOUT_MASK) {
for (i = 0; i < nvmap_dev->nr_carveouts; i++) { for (i = 0; i < nvmap_dev->nr_carveouts; i++) {
if (type & nvmap_dev->heaps[i].heap_bit) { if ((type & nvmap_dev->heaps[i].heap_bit) &&
(is_numa_aware ?
(numa_id == nvmap_dev->heaps[i].carveout->numa_node_id) : true)) {
heap = nvmap_dev->heaps[i].carveout; heap = nvmap_dev->heaps[i].carveout;
op.total = nvmap_query_heap_size(heap); op.total = nvmap_query_heap_size(heap);
op.free = heap->free_size; op.free = heap->free_size;
if (nvmap_dev->heaps[i].carveout->is_gpu_co) if (nvmap_dev->heaps[i].carveout->is_gpu_co) {
op.granule_size = nvmap_dev->heaps[i].carveout->granule_size; op.granule_size =
nvmap_dev->heaps[i].carveout->granule_size;
}
break; break;
} }
} }
@@ -1428,6 +1435,16 @@ exit:
return ret; return ret;
} }
int nvmap_ioctl_query_heap_params(struct file *filp, void __user *arg)
{
return nvmap_query_heap_params(arg, false);
}
int nvmap_ioctl_query_heap_params_numa(struct file *filp, void __user *arg)
{
return nvmap_query_heap_params(arg, true);
}
int nvmap_ioctl_dup_handle(struct file *filp, void __user *arg) int nvmap_ioctl_dup_handle(struct file *filp, void __user *arg)
{ {
struct nvmap_client *client = filp->private_data; struct nvmap_client *client = filp->private_data;

View File

@@ -64,6 +64,8 @@ int nvmap_ioctl_handle_from_sci_ipc_id(struct file *filp, void __user *arg);
int nvmap_ioctl_query_heap_params(struct file *filp, void __user *arg); int nvmap_ioctl_query_heap_params(struct file *filp, void __user *arg);
int nvmap_ioctl_query_heap_params_numa(struct file *filp, void __user *arg);
int nvmap_ioctl_dup_handle(struct file *filp, void __user *arg); int nvmap_ioctl_dup_handle(struct file *filp, void __user *arg);
int nvmap_ioctl_get_fd_from_list(struct file *filp, void __user *arg); int nvmap_ioctl_get_fd_from_list(struct file *filp, void __user *arg);

View File

@@ -241,6 +241,7 @@ struct nvmap_query_heap_params {
__u64 free; __u64 free;
__u64 largest_free_block; __u64 largest_free_block;
__u32 granule_size; __u32 granule_size;
__s32 numa_id;
}; };
/** /**
@@ -369,6 +370,10 @@ struct nvmap_fd_for_range_from_list {
#define NVMAP_IOC_GET_FD_FOR_RANGE_FROM_LIST _IOR(NVMAP_IOC_MAGIC, 107, \ #define NVMAP_IOC_GET_FD_FOR_RANGE_FROM_LIST _IOR(NVMAP_IOC_MAGIC, 107, \
struct nvmap_fd_for_range_from_list) struct nvmap_fd_for_range_from_list)
#define NVMAP_IOC_MAXNR (_IOC_NR(NVMAP_IOC_GET_FD_FOR_RANGE_FROM_LIST)) /* NUMA aware query heap params */
#define NVMAP_IOC_QUERY_HEAP_PARAMS_NUMA _IOR(NVMAP_IOC_MAGIC, 108, \
struct nvmap_query_heap_params)
#define NVMAP_IOC_MAXNR (_IOC_NR(NVMAP_IOC_QUERY_HEAP_PARAMS_NUMA))
#endif /* __UAPI_LINUX_NVMAP_H */ #endif /* __UAPI_LINUX_NVMAP_H */