···364364 struct msm_gem_submit *submit;365365 struct msm_gpu *gpu = priv->gpu;366366 struct fence *in_fence = NULL;367367+ struct sync_file *sync_file = NULL;368368+ int out_fence_fd = -1;367369 unsigned i;368370 int ret;369371···384382 ret = mutex_lock_interruptible(&dev->struct_mutex);385383 if (ret)386384 return ret;385385+386386+ if (args->flags & MSM_SUBMIT_FENCE_FD_OUT) {387387+ out_fence_fd = get_unused_fd_flags(O_CLOEXEC);388388+ if (out_fence_fd < 0) {389389+ ret = out_fence_fd;390390+ goto out_unlock;391391+ }392392+ }387393388394 submit = submit_create(dev, gpu, args->nr_bos, args->nr_cmds);389395 if (!submit) {···505495 goto out;506496 }507497498498+ if (args->flags & MSM_SUBMIT_FENCE_FD_OUT) {499499+ sync_file = sync_file_create(submit->fence);500500+ if (!sync_file) {501501+ ret = -ENOMEM;502502+ goto out;503503+ }504504+ }505505+508506 msm_gpu_submit(gpu, submit, ctx);509507510508 args->fence = submit->fence->seqno;509509+510510+ if (args->flags & MSM_SUBMIT_FENCE_FD_OUT) {511511+ fd_install(out_fence_fd, sync_file->file);512512+ args->fence_fd = out_fence_fd;513513+ }511514512515out:513516 if (in_fence)···529506 if (ret)530507 msm_gem_submit_free(submit);531508out_unlock:509509+ if (ret && (out_fence_fd >= 0))510510+ put_unused_fd(out_fence_fd);532511 mutex_unlock(&dev->struct_mutex);533512 return ret;534513}
+3-1
include/uapi/drm/msm_drm.h
···187187/* Valid submit ioctl flags: */188188#define MSM_SUBMIT_NO_IMPLICIT 0x80000000 /* disable implicit sync */189189#define MSM_SUBMIT_FENCE_FD_IN 0x40000000 /* enable input fence_fd */190190+#define MSM_SUBMIT_FENCE_FD_OUT 0x20000000 /* enable output fence_fd */190191#define MSM_SUBMIT_FLAGS ( \191192 MSM_SUBMIT_NO_IMPLICIT | \192193 MSM_SUBMIT_FENCE_FD_IN | \194194+ MSM_SUBMIT_FENCE_FD_OUT | \193195 0)194196195197/* Each cmdstream submit consists of a table of buffers involved, and···205203 __u32 nr_cmds; /* in, number of submit_cmd's */206204 __u64 __user bos; /* in, ptr to array of submit_bo's */207205 __u64 __user cmds; /* in, ptr to array of submit_cmd's */208208- __s32 fence_fd; /* in/out fence fd (see MSM_SUBMIT_FENCE_FD_IN) */206206+ __s32 fence_fd; /* in/out fence fd (see MSM_SUBMIT_FENCE_FD_IN/OUT) */209207};210208211209/* The normal way to synchronize with the GPU is just to CPU_PREP on