summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSachit Kadle <skadle@nvidia.com>2016-09-15 04:01:57 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2016-10-20 11:14:32 -0400
commit0a1e7c6b0905a6e3dcdcd483565fb5cb6f6bdd38 (patch)
tree8c45564d277e229ea2bcbc235e887744333e1aa9 /drivers
parent3fde49053323c673641eb24e4b6009afae15c842 (diff)
gpu: nvgpu: correct gpfifo size calculation
This change fixes up the calculation of gpfifo entries, to be allocated depending on the ioctl used: 1) For the legacy ALLOC_GPFIFO ioctl, we preserve the calculation of gpfifo entries within the kernel. 2) For the new ALLOC_GPFIFO_EX ioctl, we assume that userspace has pre-calculated power-of-2 value. We process this value un-modified and only verify that it is a valid power-of-2. Bug 1795076 Change-Id: I8d2ddfdae40b02fe6b81e63dfd8857ad514a3dfd Signed-off-by: Sachit Kadle <skadle@nvidia.com> Reviewed-on: http://git-master/r/1220968 (cherry picked from commit c42396d9836e9b7ec73e0728f0c502b63aff70db) Reviewed-on: http://git-master/r/1223937 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/nvgpu/gk20a/channel_gk20a.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
index b846054d..6d4b4f60 100644
--- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
@@ -1701,9 +1701,7 @@ int gk20a_alloc_channel_gpfifo(struct channel_gk20a *c,
1701 u32 gpfifo_size; 1701 u32 gpfifo_size;
1702 int err = 0; 1702 int err = 0;
1703 1703
1704 /* Kernel can insert one extra gpfifo entry before user submitted gpfifos 1704 gpfifo_size = args->num_entries;
1705 and another one after, for internal usage. Triple the requested size. */
1706 gpfifo_size = roundup_pow_of_two(args->num_entries * 3);
1707 1705
1708 if (args->flags & NVGPU_ALLOC_GPFIFO_FLAGS_VPR_ENABLED) 1706 if (args->flags & NVGPU_ALLOC_GPFIFO_FLAGS_VPR_ENABLED)
1709 c->vpr = true; 1707 c->vpr = true;
@@ -3404,6 +3402,10 @@ long gk20a_channel_ioctl(struct file *filp,
3404 gk20a_idle(dev); 3402 gk20a_idle(dev);
3405 break; 3403 break;
3406 case NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO_EX: 3404 case NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO_EX:
3405 {
3406 struct nvgpu_alloc_gpfifo_ex_args *alloc_gpfifo_ex_args =
3407 (struct nvgpu_alloc_gpfifo_ex_args *)buf;
3408
3407 err = gk20a_busy(dev); 3409 err = gk20a_busy(dev);
3408 if (err) { 3410 if (err) {
3409 dev_err(dev, 3411 dev_err(dev,
@@ -3411,10 +3413,16 @@ long gk20a_channel_ioctl(struct file *filp,
3411 __func__, cmd); 3413 __func__, cmd);
3412 break; 3414 break;
3413 } 3415 }
3416
3417 if (!is_power_of_2(alloc_gpfifo_ex_args->num_entries)) {
3418 err = -EINVAL;
3419 break;
3420 }
3414 err = gk20a_alloc_channel_gpfifo(ch, 3421 err = gk20a_alloc_channel_gpfifo(ch,
3415 (struct nvgpu_alloc_gpfifo_ex_args *)buf); 3422 (struct nvgpu_alloc_gpfifo_ex_args *)buf);
3416 gk20a_idle(dev); 3423 gk20a_idle(dev);
3417 break; 3424 break;
3425 }
3418 case NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO: 3426 case NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO:
3419 { 3427 {
3420 struct nvgpu_alloc_gpfifo_ex_args alloc_gpfifo_ex_args; 3428 struct nvgpu_alloc_gpfifo_ex_args alloc_gpfifo_ex_args;
@@ -3432,8 +3440,13 @@ long gk20a_channel_ioctl(struct file *filp,
3432 /* prepare new args structure */ 3440 /* prepare new args structure */
3433 memset(&alloc_gpfifo_ex_args, 0, 3441 memset(&alloc_gpfifo_ex_args, 0,
3434 sizeof(struct nvgpu_alloc_gpfifo_ex_args)); 3442 sizeof(struct nvgpu_alloc_gpfifo_ex_args));
3435 alloc_gpfifo_ex_args.num_entries = 3443 /*
3436 alloc_gpfifo_args->num_entries; 3444 * Kernel can insert one extra gpfifo entry before user
3445 * submitted gpfifos and another one after, for internal usage.
3446 * Triple the requested size.
3447 */
3448 alloc_gpfifo_ex_args.num_entries = roundup_pow_of_two(
3449 alloc_gpfifo_args->num_entries * 3);
3437 alloc_gpfifo_ex_args.flags = alloc_gpfifo_args->flags; 3450 alloc_gpfifo_ex_args.flags = alloc_gpfifo_args->flags;
3438 3451
3439 err = gk20a_alloc_channel_gpfifo(ch, &alloc_gpfifo_ex_args); 3452 err = gk20a_alloc_channel_gpfifo(ch, &alloc_gpfifo_ex_args);