1. 29 Aug, 2017 35 commits
  2. 28 Aug, 2017 5 commits
    • Jason Ekstrand's avatar
      drm/syncobj: Add a syncobj_array_find helper · 3e6fb72d
      Jason Ekstrand authored
      The wait ioctl has a bunch of code to read an syncobj handle array from
      userspace and turn it into an array of syncobj pointers.  We're about to
      add two new IOCTLs which will need to work with arrays of syncobj
      handles so let's make some helpers.
      Signed-off-by: default avatarJason Ekstrand <jason@jlekstrand.net>
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      3e6fb72d
    • Jason Ekstrand's avatar
      drm/syncobj: Allow wait for submit and signal behavior (v5) · e7aca503
      Jason Ekstrand authored
      Vulkan VkFence semantics require that the application be able to perform
      a CPU wait on work which may not yet have been submitted.  This is
      perfectly safe because the CPU wait has a timeout which will get
      triggered eventually if no work is ever submitted.  This behavior is
      advantageous for multi-threaded workloads because, so long as all of the
      threads agree on what fences to use up-front, you don't have the extra
      cross-thread synchronization cost of thread A telling thread B that it
      has submitted its dependent work and thread B is now free to wait.
      
      Within a single process, this can be implemented in the userspace driver
      by doing exactly the same kind of tracking the app would have to do
      using posix condition variables or similar.  However, in order for this
      to work cross-process (as is required by VK_KHR_external_fence), we need
      to handle this in the kernel.
      
      This commit adds a WAIT_FOR_SUBMIT flag to DRM_IOCTL_SYNCOBJ_WAIT which
      instructs the IOCTL to wait for the syncobj to have a non-null fence and
      then wait on the fence.  Combined with DRM_IOCTL_SYNCOBJ_RESET, you can
      easily get the Vulkan behavior.
      
      v2:
       - Fix a bug in the invalid syncobj error path
       - Unify the wait-all and wait-any cases
      v3:
       - Unify the timeout == 0 case a bit with the timeout > 0 case
       - Use wait_event_interruptible_timeout
      v4:
       - Use proxy fence
      v5:
       - Revert to a combination of v2 and v3
       - Don't use proxy fences
       - Don't use wait_event_interruptible_timeout because it just adds an
         extra layer of callbacks
      Signed-off-by: default avatarJason Ekstrand <jason@jlekstrand.net>
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Christian König <christian.koenig@amd.com>
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      e7aca503
    • Jason Ekstrand's avatar
      drm/syncobj: Add a CREATE_SIGNALED flag · 1fc08218
      Jason Ekstrand authored
      This requests that the driver create the sync object such that it
      already has a signaled dma_fence attached.  Because we don't need
      anything in particular (just something signaled), we use a dummy null
      fence.  This is useful for Vulkan which has a similar flag that can be
      passed to vkCreateFence.
      Signed-off-by: default avatarJason Ekstrand <jason@jlekstrand.net>
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      1fc08218
    • Jason Ekstrand's avatar
      drm/syncobj: Add a callback mechanism for replace_fence (v3) · 9c19fb10
      Jason Ekstrand authored
      It is useful in certain circumstances to know when the fence is replaced
      in a syncobj.  Specifically, it may be useful to know when the fence
      goes from NULL to something valid.  This does make syncobj_replace_fence
      a little more expensive because it has to take a lock but, in the common
      case where there is no callback list, it spends a very short amount of
      time inside the lock.
      
      v2:
       - Don't lock in drm_syncobj_fence_get.  We only really need to lock
         around fence_replace to make the callback work.
      v3:
       - Fix the cb_list comment to make kbuild happy
      Signed-off-by: default avatarJason Ekstrand <jason@jlekstrand.net>
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      9c19fb10
    • Dave Airlie's avatar
      drm/syncobj: add sync obj wait interface. (v8) · 5e60a10e
      Dave Airlie authored
      This interface will allow sync object to be used to back
      Vulkan fences. This API is pretty much the vulkan fence waiting
      API, and I've ported the code from amdgpu.
      
      v2: accept relative timeout, pass remaining time back
      to userspace.
      v3: return to absolute timeouts.
      v4: absolute zero = poll,
          rewrite any/all code to have same operation for arrays
          return -EINVAL for 0 fences.
      v4.1: fixup fences allocation check, use u64_to_user_ptr
      v5: move to sec/nsec, and use timespec64 for calcs.
      v6: use -ETIME and drop the out status flag. (-ETIME
      is suggested by ickle, I can feel a shed painting)
      v7: talked to Daniel/Arnd, use ktime and ns everywhere.
      v8: be more careful in the timeout calculations
          use uint32_t for counter variables so we don't overflow
          graciously handle -ENOINT being returned from dma_fence_wait_timeout
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      Reviewed-by: default avatarJason Ekstrand <jason@jlekstrand.net>
      Acked-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      5e60a10e