diff options
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 23 |
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); |