summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
diff options
context:
space:
mode:
authorDebarshi Dutta <ddutta@nvidia.com>2018-03-23 06:02:27 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-04-23 00:04:48 -0400
commitd0e4dfd6efd651abc431aba9cfae5907638f8172 (patch)
tree1a412eaa4636ff2e2862c1623bad3a5ea6883d4e /drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
parentc918c42a4a3651f757c6966aead4b07eb4b56697 (diff)
gpu: nvgpu: sync_framework cleanups
This patch deals with cleanups meant to make things simpler for the upcoming os abstraction patches for the sync framework. This patch causes some substantial changes which are listed out as follows. 1) sync_timeline is moved out of gk20a_fence into struct nvgpu_channel_linux. New function pointers are created to facilitate os independent methods for enabling/disabling timeline and are now named as os_fence_framework. These function pointers are located in the struct os_channel under struct gk20a. 2) construction of the channel_sync require nvgpu_finalize_poweron_linux() to be invoked before invocations to nvgpu_init_mm_ce_context(). Hence, these methods are now moved away from gk20a_finalize_poweron() and invoked after nvgpu_finalize_poweron_linux(). 3) sync_fence creation is now delinked from fence construction and move to the channel_sync_gk20a's channel_incr methods. These sync_fences are mainly associated with post_fences. 4) In case userspace requires the sync_fences to be constructed, we try to obtain an fd before the gk20a_channel_submit_gpfifo() instead of trying to do that later. This is used to avoid potential after effects of duplicate work submission due to failure to obtain an unused fd. JIRA NVGPU-66 Change-Id: I42a3e4e2e692a113b1b36d2b48ab107ae4444dfa Signed-off-by: Debarshi Dutta <ddutta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1678400 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c')
-rw-r--r--drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
index e4b66460..70707a5c 100644
--- a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
+++ b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
@@ -344,10 +344,19 @@ static int gk20a_ctrl_prepare_compressible_read(
344 struct gk20a_fence *fence_out = NULL; 344 struct gk20a_fence *fence_out = NULL;
345 int submit_flags = nvgpu_submit_gpfifo_user_flags_to_common_flags( 345 int submit_flags = nvgpu_submit_gpfifo_user_flags_to_common_flags(
346 args->submit_flags); 346 args->submit_flags);
347 int fd = -1;
347 348
348 fence.id = args->fence.syncpt_id; 349 fence.id = args->fence.syncpt_id;
349 fence.value = args->fence.syncpt_value; 350 fence.value = args->fence.syncpt_value;
350 351
352 /* Try and allocate an fd here*/
353 if ((submit_flags & NVGPU_SUBMIT_FLAGS_FENCE_GET)
354 && (submit_flags & NVGPU_SUBMIT_FLAGS_SYNC_FENCE)) {
355 fd = get_unused_fd_flags(O_RDWR);
356 if (fd < 0)
357 return fd;
358 }
359
351 ret = gk20a_prepare_compressible_read(l, args->handle, 360 ret = gk20a_prepare_compressible_read(l, args->handle,
352 args->request_compbits, args->offset, 361 args->request_compbits, args->offset,
353 args->compbits_hoffset, args->compbits_voffset, 362 args->compbits_hoffset, args->compbits_voffset,
@@ -356,20 +365,24 @@ static int gk20a_ctrl_prepare_compressible_read(
356 submit_flags, &fence, &args->valid_compbits, 365 submit_flags, &fence, &args->valid_compbits,
357 &args->zbc_color, &fence_out); 366 &args->zbc_color, &fence_out);
358 367
359 if (ret) 368 if (ret) {
369 if (fd != -1)
370 put_unused_fd(fd);
360 return ret; 371 return ret;
372 }
361 373
362 /* Convert fence_out to something we can pass back to user space. */ 374 /* Convert fence_out to something we can pass back to user space. */
363 if (submit_flags & NVGPU_SUBMIT_FLAGS_FENCE_GET) { 375 if (submit_flags & NVGPU_SUBMIT_FLAGS_FENCE_GET) {
364 if (submit_flags & NVGPU_SUBMIT_FLAGS_SYNC_FENCE) { 376 if (submit_flags & NVGPU_SUBMIT_FLAGS_SYNC_FENCE) {
365 if (fence_out) { 377 if (fence_out) {
366 int fd = gk20a_fence_install_fd(fence_out); 378 ret = gk20a_fence_install_fd(fence_out, fd);
367 if (fd < 0) 379 if (ret)
368 ret = fd; 380 put_unused_fd(fd);
369 else 381 else
370 args->fence.fd = fd; 382 args->fence.fd = fd;
371 } else { 383 } else {
372 args->fence.fd = -1; 384 args->fence.fd = -1;
385 put_unused_fd(fd);
373 } 386 }
374 } else { 387 } else {
375 if (fence_out) { 388 if (fence_out) {