diff options
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c index ca587d00..6969a3a7 100644 --- a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c | |||
@@ -16,6 +16,8 @@ | |||
16 | 16 | ||
17 | #include <linux/highmem.h> | 17 | #include <linux/highmem.h> |
18 | #include <linux/cdev.h> | 18 | #include <linux/cdev.h> |
19 | #include <linux/file.h> | ||
20 | #include <linux/anon_inodes.h> | ||
19 | #include <uapi/linux/nvgpu.h> | 21 | #include <uapi/linux/nvgpu.h> |
20 | 22 | ||
21 | #include "gk20a.h" | 23 | #include "gk20a.h" |
@@ -148,6 +150,53 @@ static int gk20a_ctrl_mark_compressible_write( | |||
148 | return ret; | 150 | return ret; |
149 | } | 151 | } |
150 | 152 | ||
153 | static int gk20a_ctrl_alloc_as( | ||
154 | struct gk20a *g, | ||
155 | struct nvgpu_alloc_as_args *args) | ||
156 | { | ||
157 | struct platform_device *dev = g->dev; | ||
158 | struct gk20a_as_share *as_share; | ||
159 | int err; | ||
160 | int fd; | ||
161 | struct file *file; | ||
162 | char *name; | ||
163 | |||
164 | err = get_unused_fd_flags(O_RDWR); | ||
165 | if (err < 0) | ||
166 | return err; | ||
167 | fd = err; | ||
168 | |||
169 | name = kasprintf(GFP_KERNEL, "nvhost-%s-fd%d", | ||
170 | dev_name(&dev->dev), fd); | ||
171 | |||
172 | file = anon_inode_getfile(name, g->as.cdev.ops, NULL, O_RDWR); | ||
173 | kfree(name); | ||
174 | if (IS_ERR(file)) { | ||
175 | err = PTR_ERR(file); | ||
176 | goto clean_up; | ||
177 | } | ||
178 | fd_install(fd, file); | ||
179 | |||
180 | err = gk20a_get_client(g); | ||
181 | if (err) | ||
182 | goto clean_up; | ||
183 | |||
184 | err = gk20a_as_alloc_share(&g->as, args->big_page_size, &as_share); | ||
185 | if (err) | ||
186 | goto clean_up_client; | ||
187 | |||
188 | file->private_data = as_share; | ||
189 | |||
190 | args->as_fd = fd; | ||
191 | return 0; | ||
192 | |||
193 | clean_up_client: | ||
194 | gk20a_put_client(g); | ||
195 | clean_up: | ||
196 | put_unused_fd(fd); | ||
197 | return err; | ||
198 | } | ||
199 | |||
151 | long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | 200 | long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
152 | { | 201 | { |
153 | struct platform_device *dev = filp->private_data; | 202 | struct platform_device *dev = filp->private_data; |
@@ -309,6 +358,10 @@ long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg | |||
309 | err = gk20a_ctrl_mark_compressible_write(g, | 358 | err = gk20a_ctrl_mark_compressible_write(g, |
310 | (struct nvgpu_gpu_mark_compressible_write_args *)buf); | 359 | (struct nvgpu_gpu_mark_compressible_write_args *)buf); |
311 | break; | 360 | break; |
361 | case NVGPU_GPU_IOCTL_ALLOC_AS: | ||
362 | err = gk20a_ctrl_alloc_as(g, | ||
363 | (struct nvgpu_alloc_as_args *)buf); | ||
364 | break; | ||
312 | default: | 365 | default: |
313 | dev_dbg(dev_from_gk20a(g), "unrecognized gpu ioctl cmd: 0x%x", cmd); | 366 | dev_dbg(dev_from_gk20a(g), "unrecognized gpu ioctl cmd: 0x%x", cmd); |
314 | err = -ENOTTY; | 367 | err = -ENOTTY; |