From d86fc5414beb6758d0b04ec78dd6589411dda66d Mon Sep 17 00:00:00 2001 From: Konsta Holtta Date: Mon, 9 Mar 2015 13:51:20 +0200 Subject: gpu: nvgpu: use vmalloc for temp gpfifo in submit Use vmalloc instead of kzalloc for the temporary gpfifo buffer copied from userspace in the ioctl when submitting gpfifos. The data may be too big for kzalloc, and it doesn't need to be physically contiguous. Bug 1617747 Bug 200081843 Change-Id: I66a43d17eb13a2783bc1f0598a38abbf330b2ba6 Signed-off-by: Konsta Holtta Reviewed-on: http://git-master/r/715207 Reviewed-by: Sami Kiminki Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a/channel_gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index 9a0800d1..feb80adf 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "debug_gk20a.h" @@ -2200,7 +2201,7 @@ static int gk20a_ioctl_channel_submit_gpfifo( struct nvgpu_submit_gpfifo_args *args) { struct gk20a_fence *fence_out; - void *gpfifo; + void *gpfifo = NULL; u32 size; int ret = 0; @@ -2209,16 +2210,20 @@ static int gk20a_ioctl_channel_submit_gpfifo( if (ch->has_timedout) return -ETIMEDOUT; + /* zero-sized submits are allowed, since they can be used for + * synchronization; we might still wait and do an increment */ size = args->num_entries * sizeof(struct nvgpu_gpfifo); + if (size) { + gpfifo = vmalloc(size); + if (!gpfifo) + return -ENOMEM; - gpfifo = kzalloc(size, GFP_KERNEL); - if (!gpfifo) - return -ENOMEM; - - if (copy_from_user(gpfifo, - (void __user *)(uintptr_t)args->gpfifo, size)) { - ret = -EINVAL; - goto clean_up; + if (copy_from_user(gpfifo, + (void __user *)(uintptr_t)args->gpfifo, + size)) { + ret = -EINVAL; + goto clean_up; + } } ret = gk20a_submit_channel_gpfifo(ch, gpfifo, args->num_entries, @@ -2244,7 +2249,7 @@ static int gk20a_ioctl_channel_submit_gpfifo( gk20a_fence_put(fence_out); clean_up: - kfree(gpfifo); + vfree(gpfifo); return ret; } -- cgit v1.2.2