summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
diff options
context:
space:
mode:
authorKonsta Holtta <kholtta@nvidia.com>2015-01-30 08:22:11 -0500
committerDan Willemsen <dwillemsen@nvidia.com>2015-04-04 21:05:59 -0400
commitadb33505b21a8e75267bb74d602becf8db51946b (patch)
tree6b8d674e5c098ec0b85b692c5d50c59c749bc177 /drivers/gpu/nvgpu/gk20a/channel_gk20a.c
parent24ddf71b9009291b829e6c30eb1b22e8838f7367 (diff)
gpu: nvgpu: add open channel ioctl to ctrl node
Add the ioctl to open a new gpu channel to also the control node for improved process startup performance, in addition to the current open ioctl in the channel node. The new channel fd creation is refactored to a separate function which is called from both ctrl and channel ioctls. Bug 1604952 Change-Id: I3357ceec694c0e6d7a85807183884324cb725d3a Signed-off-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-on: http://git-master/r/679516 Reviewed-by: Sami Kiminki <skiminki@nvidia.com> Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/channel_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/channel_gk20a.c80
1 files changed, 44 insertions, 36 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
index 80cddb32..d61656fc 100644
--- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
@@ -811,6 +811,48 @@ int gk20a_channel_open(struct inode *inode, struct file *filp)
811 return ret; 811 return ret;
812} 812}
813 813
814int gk20a_channel_open_ioctl(struct gk20a *g,
815 struct nvgpu_channel_open_args *args)
816{
817 int err;
818 int fd;
819 struct file *file;
820 char *name;
821
822 err = get_unused_fd_flags(O_RDWR);
823 if (err < 0)
824 return err;
825 fd = err;
826
827 name = kasprintf(GFP_KERNEL, "nvhost-%s-fd%d",
828 dev_name(&g->dev->dev), fd);
829 if (!name) {
830 err = -ENOMEM;
831 goto clean_up;
832 }
833
834 file = anon_inode_getfile(name, g->channel.cdev.ops, NULL, O_RDWR);
835 kfree(name);
836 if (IS_ERR(file)) {
837 err = PTR_ERR(file);
838 goto clean_up;
839 }
840 fd_install(fd, file);
841
842 err = __gk20a_channel_open(g, file);
843 if (err)
844 goto clean_up_file;
845
846 args->channel_fd = fd;
847 return 0;
848
849clean_up_file:
850 fput(file);
851clean_up:
852 put_unused_fd(fd);
853 return err;
854}
855
814/* allocate private cmd buffer. 856/* allocate private cmd buffer.
815 used for inserting commands before/after user submitted buffers. */ 857 used for inserting commands before/after user submitted buffers. */
816static int channel_gk20a_alloc_priv_cmdbuf(struct channel_gk20a *c) 858static int channel_gk20a_alloc_priv_cmdbuf(struct channel_gk20a *c)
@@ -2237,43 +2279,9 @@ long gk20a_channel_ioctl(struct file *filp,
2237 2279
2238 switch (cmd) { 2280 switch (cmd) {
2239 case NVGPU_IOCTL_CHANNEL_OPEN: 2281 case NVGPU_IOCTL_CHANNEL_OPEN:
2240 { 2282 err = gk20a_channel_open_ioctl(ch->g,
2241 int fd; 2283 (struct nvgpu_channel_open_args *)buf);
2242 struct file *file;
2243 char *name;
2244
2245 err = get_unused_fd_flags(O_RDWR);
2246 if (err < 0)
2247 break;
2248 fd = err;
2249
2250 name = kasprintf(GFP_KERNEL, "nvhost-%s-fd%d",
2251 dev_name(&dev->dev), fd);
2252 if (!name) {
2253 err = -ENOMEM;
2254 put_unused_fd(fd);
2255 break;
2256 }
2257
2258 file = anon_inode_getfile(name, filp->f_op, NULL, O_RDWR);
2259 kfree(name);
2260 if (IS_ERR(file)) {
2261 err = PTR_ERR(file);
2262 put_unused_fd(fd);
2263 break;
2264 }
2265 fd_install(fd, file);
2266
2267 err = __gk20a_channel_open(ch->g, file);
2268 if (err) {
2269 put_unused_fd(fd);
2270 fput(file);
2271 break;
2272 }
2273
2274 ((struct nvgpu_channel_open_args *)buf)->channel_fd = fd;
2275 break; 2284 break;
2276 }
2277 case NVGPU_IOCTL_CHANNEL_SET_NVMAP_FD: 2285 case NVGPU_IOCTL_CHANNEL_SET_NVMAP_FD:
2278 break; 2286 break;
2279 case NVGPU_IOCTL_CHANNEL_ALLOC_OBJ_CTX: 2287 case NVGPU_IOCTL_CHANNEL_ALLOC_OBJ_CTX: