diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/ioctl_channel.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_channel.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c index b4d7d501..06dfb180 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c | |||
@@ -774,6 +774,7 @@ static int gk20a_ioctl_channel_submit_gpfifo( | |||
774 | struct gk20a_fence *fence_out; | 774 | struct gk20a_fence *fence_out; |
775 | struct fifo_profile_gk20a *profile = NULL; | 775 | struct fifo_profile_gk20a *profile = NULL; |
776 | u32 submit_flags = 0; | 776 | u32 submit_flags = 0; |
777 | int fd = -1; | ||
777 | 778 | ||
778 | int ret = 0; | 779 | int ret = 0; |
779 | gk20a_dbg_fn(""); | 780 | gk20a_dbg_fn(""); |
@@ -794,19 +795,31 @@ static int gk20a_ioctl_channel_submit_gpfifo( | |||
794 | nvgpu_get_fence_args(&args->fence, &fence); | 795 | nvgpu_get_fence_args(&args->fence, &fence); |
795 | submit_flags = | 796 | submit_flags = |
796 | nvgpu_submit_gpfifo_user_flags_to_common_flags(args->flags); | 797 | nvgpu_submit_gpfifo_user_flags_to_common_flags(args->flags); |
798 | |||
799 | /* Try and allocate an fd here*/ | ||
800 | if ((args->flags & NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_GET) | ||
801 | && (args->flags & NVGPU_SUBMIT_GPFIFO_FLAGS_SYNC_FENCE)) { | ||
802 | fd = get_unused_fd_flags(O_RDWR); | ||
803 | if (fd < 0) | ||
804 | return fd; | ||
805 | } | ||
806 | |||
797 | ret = gk20a_submit_channel_gpfifo(ch, NULL, args, args->num_entries, | 807 | ret = gk20a_submit_channel_gpfifo(ch, NULL, args, args->num_entries, |
798 | submit_flags, &fence, | 808 | submit_flags, &fence, |
799 | &fence_out, false, profile); | 809 | &fence_out, false, profile); |
800 | 810 | ||
801 | if (ret) | 811 | if (ret) { |
812 | if (fd != -1) | ||
813 | put_unused_fd(fd); | ||
802 | goto clean_up; | 814 | goto clean_up; |
815 | } | ||
803 | 816 | ||
804 | /* Convert fence_out to something we can pass back to user space. */ | 817 | /* Convert fence_out to something we can pass back to user space. */ |
805 | if (args->flags & NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_GET) { | 818 | if (args->flags & NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_GET) { |
806 | if (args->flags & NVGPU_SUBMIT_GPFIFO_FLAGS_SYNC_FENCE) { | 819 | if (args->flags & NVGPU_SUBMIT_GPFIFO_FLAGS_SYNC_FENCE) { |
807 | int fd = gk20a_fence_install_fd(fence_out); | 820 | ret = gk20a_fence_install_fd(fence_out, fd); |
808 | if (fd < 0) | 821 | if (ret) |
809 | ret = fd; | 822 | put_unused_fd(fd); |
810 | else | 823 | else |
811 | args->fence.id = fd; | 824 | args->fence.id = fd; |
812 | } else { | 825 | } else { |