All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] *dma-buf: Add an API for exporting sync files (v13)
@ 2022-05-04 20:34 Jason Ekstrand
  2022-05-04 20:34 ` [PATCH 1/2] dma-buf: " Jason Ekstrand
  2022-05-04 20:34 ` [PATCH 2/2] dma-buf: Add an API for importing sync files (v8) Jason Ekstrand
  0 siblings, 2 replies; 15+ messages in thread
From: Jason Ekstrand @ 2022-05-04 20:34 UTC (permalink / raw)
  To: dri-devel
  Cc: Daniel Stone, Michel Dänzer, wayland-devel, Jason Ekstrand,
	Dave Airlie, mesa-dev, Christian König

Modern userspace APIs like Vulkan are built on an explicit synchronization
model.  This doesn't always play nicely with the implicit synchronization used
in the kernel and assumed by X11 and Wayland.  The client -> compositor half
of the synchronization isn't too bad, at least on intel, because we can
control whether or not i915 synchronizes on the buffer and whether or not it's
considered written.

The harder part is the compositor -> client synchronization when we get the
buffer back from the compositor.  We're required to be able to provide the
client with a VkSemaphore and VkFence representing the point in time where the
window system (compositor and/or display) finished using the buffer.  With
current APIs, it's very hard to do this in such a way that we don't get
confused by the Vulkan driver's access of the buffer.  In particular, once we
tell the kernel that we're rendering to the buffer again, any CPU waits on the
buffer or GPU dependencies will wait on some of the client rendering and not
just the compositor.

This new IOCTL solves this problem by allowing us to get a snapshot of the
implicit synchronization state of a given dma-buf in the form of a sync file.
It's effectively the same as a poll() or I915_GEM_WAIT only, instead of CPU
waiting directly, it encapsulates the wait operation, at the current moment in
time, in a sync_file so we can check/wait on it later.  As long as the Vulkan
driver does the sync_file export from the dma-buf before we re-introduce it
for rendering, it will only contain fences from the compositor or display.
This allows to accurately turn it into a VkFence or VkSemaphore without any
over-synchronization.

This patch series actually contains two new ioctls.  There is the export one
mentioned above as well as an RFC for an import ioctl which provides the other
half.  The intention is to land the export ioctl since it seems like there's
no real disagreement on that one.  The import ioctl, however, has a lot of
debate around it so it's intended to be RFC-only for now.

Mesa MR: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4037
IGT tests: https://patchwork.freedesktop.org/series/90490/

v10 (Jason Ekstrand, Daniel Vetter):
 - Add reviews/acks
 - Add a patch to rename _rcu to _unlocked
 - Split things better so import is clearly RFC status

v11 (Daniel Vetter):
 - Add more CCs to try and get maintainers
 - Add a patch to document DMA_BUF_IOCTL_SYNC
 - Generally better docs
 - Use separate structs for import/export (easier to document)
 - Fix an issue in the import patch

v12 (Daniel Vetter):
 - Better docs for DMA_BUF_IOCTL_SYNC

v12 (Christian König):
 - Drop the rename patch in favor of Christian's series
 - Add a comment to the commit message for the dma-buf sync_file export
   ioctl saying why we made it an ioctl on dma-buf

v13 (Jason Ekstrand):
 - Rebase on Christian König's fence rework

Cc: Christian König <christian.koenig@amd.com>
Cc: Michel Dänzer <michel@daenzer.net>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Cc: Daniel Stone <daniels@collabora.com>
Cc: mesa-dev@lists.freedesktop.org
Cc: wayland-devel@lists.freedesktop.org

Jason Ekstrand (2):
  dma-buf: Add an API for exporting sync files (v13)
  dma-buf: Add an API for importing sync files (v8)

 drivers/dma-buf/dma-buf.c    | 100 +++++++++++++++++++++++++++++++++++
 include/uapi/linux/dma-buf.h |  57 ++++++++++++++++++++
 2 files changed, 157 insertions(+)

-- 
2.36.0


^ permalink raw reply	[flat|nested] 15+ messages in thread
* [PATCH 0/2] dma-buf: Add an API for exporting sync files (v13)
@ 2022-05-04 22:43 Jason Ekstrand
  2022-05-04 22:43 ` [PATCH 2/2] dma-buf: Add an API for importing sync files (v8) Jason Ekstrand
  0 siblings, 1 reply; 15+ messages in thread
From: Jason Ekstrand @ 2022-05-04 22:43 UTC (permalink / raw)
  To: dri-devel
  Cc: Daniel Stone, Michel Dänzer, wayland-devel, Jason Ekstrand,
	Dave Airlie, mesa-dev, Christian König

Modern userspace APIs like Vulkan are built on an explicit synchronization
model.  This doesn't always play nicely with the implicit synchronization used
in the kernel and assumed by X11 and Wayland.  The client -> compositor half
of the synchronization isn't too bad, at least on intel, because we can
control whether or not i915 synchronizes on the buffer and whether or not it's
considered written.

The harder part is the compositor -> client synchronization when we get the
buffer back from the compositor.  We're required to be able to provide the
client with a VkSemaphore and VkFence representing the point in time where the
window system (compositor and/or display) finished using the buffer.  With
current APIs, it's very hard to do this in such a way that we don't get
confused by the Vulkan driver's access of the buffer.  In particular, once we
tell the kernel that we're rendering to the buffer again, any CPU waits on the
buffer or GPU dependencies will wait on some of the client rendering and not
just the compositor.

This new IOCTL solves this problem by allowing us to get a snapshot of the
implicit synchronization state of a given dma-buf in the form of a sync file.
It's effectively the same as a poll() or I915_GEM_WAIT only, instead of CPU
waiting directly, it encapsulates the wait operation, at the current moment in
time, in a sync_file so we can check/wait on it later.  As long as the Vulkan
driver does the sync_file export from the dma-buf before we re-introduce it
for rendering, it will only contain fences from the compositor or display.
This allows to accurately turn it into a VkFence or VkSemaphore without any
over-synchronization.

This patch series actually contains two new ioctls.  There is the export one
mentioned above as well as an RFC for an import ioctl which provides the other
half.  The intention is to land the export ioctl since it seems like there's
no real disagreement on that one.  The import ioctl, however, has a lot of
debate around it so it's intended to be RFC-only for now.

Mesa MR: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4037
IGT tests: https://patchwork.freedesktop.org/series/90490/

v10 (Jason Ekstrand, Daniel Vetter):
 - Add reviews/acks
 - Add a patch to rename _rcu to _unlocked
 - Split things better so import is clearly RFC status

v11 (Daniel Vetter):
 - Add more CCs to try and get maintainers
 - Add a patch to document DMA_BUF_IOCTL_SYNC
 - Generally better docs
 - Use separate structs for import/export (easier to document)
 - Fix an issue in the import patch

v12 (Daniel Vetter):
 - Better docs for DMA_BUF_IOCTL_SYNC

v12 (Christian König):
 - Drop the rename patch in favor of Christian's series
 - Add a comment to the commit message for the dma-buf sync_file export
   ioctl saying why we made it an ioctl on dma-buf

v13 (Jason Ekstrand):
 - Rebase on Christian König's fence rework

Cc: Christian König <christian.koenig@amd.com>
Cc: Michel Dänzer <michel@daenzer.net>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Cc: Daniel Stone <daniels@collabora.com>
Cc: mesa-dev@lists.freedesktop.org
Cc: wayland-devel@lists.freedesktop.org

Jason Ekstrand (2):
  dma-buf: Add an API for exporting sync files (v13)
  dma-buf: Add an API for importing sync files (v8)

 drivers/dma-buf/dma-buf.c    | 100 +++++++++++++++++++++++++++++++++++
 include/uapi/linux/dma-buf.h |  57 ++++++++++++++++++++
 2 files changed, 157 insertions(+)

-- 
2.36.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2022-05-06 10:19 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-04 20:34 [PATCH 0/2] *dma-buf: Add an API for exporting sync files (v13) Jason Ekstrand
2022-05-04 20:34 ` [PATCH 1/2] dma-buf: " Jason Ekstrand
2022-05-04 22:49   ` Daniel Vetter
2022-05-05  8:05     ` Jason Ekstrand
2022-05-05  8:23       ` Daniel Vetter
2022-05-06  0:11         ` Jason Ekstrand
2022-05-05  6:25   ` Christian König
2022-05-05  8:10     ` Jason Ekstrand
2022-05-05  8:27       ` Christian König
2022-05-05  8:35         ` Daniel Vetter
2022-05-04 20:34 ` [PATCH 2/2] dma-buf: Add an API for importing sync files (v8) Jason Ekstrand
2022-05-04 22:53   ` Daniel Vetter
2022-05-05  8:13     ` Jason Ekstrand
2022-05-05  8:39       ` Daniel Vetter
2022-05-04 22:43 [PATCH 0/2] dma-buf: Add an API for exporting sync files (v13) Jason Ekstrand
2022-05-04 22:43 ` [PATCH 2/2] dma-buf: Add an API for importing sync files (v8) Jason Ekstrand

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.