gpu: nvgpu: implement VEID alloc/free

Implement the ioctls NVGPU_TSG_IOCTL_CREATE_SUBCONTEXT and
NVGPU_TSG_IOCTL_DELETE_SUBCONTEXT. These will allocate and
free the VEID numbers.

Address space association with the VEIDs is verified to
ensure that channels association with VEIDs and address
space remains consistent.

Bug 3677982
JIRA NVGPU-8681

Change-Id: I2d913baf61a6bdeec412c58270c0024b80ca15c6
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2766765
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Sagar Kamble
2022-08-23 07:30:40 +00:00
committed by mobile promotions
parent 9233886943
commit d1b28712b6
8 changed files with 492 additions and 2 deletions

View File

@@ -16,6 +16,7 @@
#include <linux/cdev.h>
#include <linux/uaccess.h>
#include <linux/fs.h>
#include <linux/file.h>
#include <nvgpu/trace.h>
#include <uapi/linux/nvgpu.h>
@@ -453,6 +454,31 @@ int gk20a_as_dev_release(struct inode *inode, struct file *filp)
return gk20a_as_release_share(as_share);
}
/*
* This returns the AS with a reference. The caller must
* nvgpu_vm_put() the ref back after use.
*
* NULL is returned if the AS was not found.
*/
struct vm_gk20a *nvgpu_vm_get_from_file(int fd)
{
struct gk20a_as_share *as_share;
struct file *f = fget(fd);
if (!f)
return NULL;
if (f->f_op != &gk20a_as_ops) {
fput(f);
return NULL;
}
as_share = (struct gk20a_as_share *)f->private_data;
nvgpu_vm_get(as_share->vm);
fput(f);
return as_share->vm;
}
long gk20a_as_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
int err = 0;