Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/msm: submit support for out-fences

Signed-off-by: Rob Clark <robdclark@gmail.com>

+28 -1
+25
drivers/gpu/drm/msm/msm_gem_submit.c
··· 364 364 struct msm_gem_submit *submit; 365 365 struct msm_gpu *gpu = priv->gpu; 366 366 struct fence *in_fence = NULL; 367 + struct sync_file *sync_file = NULL; 368 + int out_fence_fd = -1; 367 369 unsigned i; 368 370 int ret; 369 371 ··· 384 382 ret = mutex_lock_interruptible(&dev->struct_mutex); 385 383 if (ret) 386 384 return ret; 385 + 386 + if (args->flags & MSM_SUBMIT_FENCE_FD_OUT) { 387 + out_fence_fd = get_unused_fd_flags(O_CLOEXEC); 388 + if (out_fence_fd < 0) { 389 + ret = out_fence_fd; 390 + goto out_unlock; 391 + } 392 + } 387 393 388 394 submit = submit_create(dev, gpu, args->nr_bos, args->nr_cmds); 389 395 if (!submit) { ··· 505 495 goto out; 506 496 } 507 497 498 + if (args->flags & MSM_SUBMIT_FENCE_FD_OUT) { 499 + sync_file = sync_file_create(submit->fence); 500 + if (!sync_file) { 501 + ret = -ENOMEM; 502 + goto out; 503 + } 504 + } 505 + 508 506 msm_gpu_submit(gpu, submit, ctx); 509 507 510 508 args->fence = submit->fence->seqno; 509 + 510 + if (args->flags & MSM_SUBMIT_FENCE_FD_OUT) { 511 + fd_install(out_fence_fd, sync_file->file); 512 + args->fence_fd = out_fence_fd; 513 + } 511 514 512 515 out: 513 516 if (in_fence) ··· 529 506 if (ret) 530 507 msm_gem_submit_free(submit); 531 508 out_unlock: 509 + if (ret && (out_fence_fd >= 0)) 510 + put_unused_fd(out_fence_fd); 532 511 mutex_unlock(&dev->struct_mutex); 533 512 return ret; 534 513 }
+3 -1
include/uapi/drm/msm_drm.h
··· 187 187 /* Valid submit ioctl flags: */ 188 188 #define MSM_SUBMIT_NO_IMPLICIT 0x80000000 /* disable implicit sync */ 189 189 #define MSM_SUBMIT_FENCE_FD_IN 0x40000000 /* enable input fence_fd */ 190 + #define MSM_SUBMIT_FENCE_FD_OUT 0x20000000 /* enable output fence_fd */ 190 191 #define MSM_SUBMIT_FLAGS ( \ 191 192 MSM_SUBMIT_NO_IMPLICIT | \ 192 193 MSM_SUBMIT_FENCE_FD_IN | \ 194 + MSM_SUBMIT_FENCE_FD_OUT | \ 193 195 0) 194 196 195 197 /* Each cmdstream submit consists of a table of buffers involved, and ··· 205 203 __u32 nr_cmds; /* in, number of submit_cmd's */ 206 204 __u64 __user bos; /* in, ptr to array of submit_bo's */ 207 205 __u64 __user cmds; /* in, ptr to array of submit_cmd's */ 208 - __s32 fence_fd; /* in/out fence fd (see MSM_SUBMIT_FENCE_FD_IN) */ 206 + __s32 fence_fd; /* in/out fence fd (see MSM_SUBMIT_FENCE_FD_IN/OUT) */ 209 207 }; 210 208 211 209 /* The normal way to synchronize with the GPU is just to CPU_PREP on