drm/syncobj: Add better overview documentation for syncobj
Subsystems (2)
PATCH 1/1 drm/syncobj: Add better overview documentation for syncobj
This patch only brings the syncobj documentation up-to-date for the original form of syncobj. It does not contain any information about the design of timeline syncobjs.
--- drivers/gpu/drm/drm_syncobj.c | 81 +++++++++++++++++++++++++++++++---- 1 file changed, 73 insertions(+), 8 deletions(-)
drivers/gpu/drm/drm_syncobj.c +73 -8
@@ -29,17 +29,82 @@/** * DOC: Overview * -* DRM synchronisation objects (syncobj, see struct &drm_syncobj) are -* persistent objects that contain an optional fence. The fence can be updated -* with a new fence, or be NULL. +* DRM synchronisation objects (syncobj, see struct &drm_syncobj) provide a +* synchronization primitive which can be used by userspace to explicitly +* synchronize GPU commands, can be shared between userspace processes, and +* can be shared between different DRM drivers. +* Their primary use-case is to implement Vulkan fences and semaphores. +* The syncobj userspace API provides ioctls for several operations: * -* syncobj's can be waited upon, where it will wait for the underlying -* fence. +* - Creation and destruction of syncobjs +* - Import and export of syncobjs to/from a syncobj file descriptor +* - Import and export a syncobj's underlying fence to/from a sync file +* - Reset a syncobj (set its fence to NULL) +* - Signal a syncobj (set a trivially signaled fence) +* - Wait a syncobj's fence to be signaled * -* syncobj's can be export to fd's and back, these fd's are opaque and -* have no other use case, except passing the syncobj between processes. +* At it's core, a syncobj simply a wrapper around a pointer to a struct +* &dma_fence which may be NULL. +* When GPU work which signals a syncobj is enqueued in a DRM driver, +* the syncobj fence is replaced with a fence which will be signaled by the +* completion of that work. +* When GPU work which waits on a syncobj is enqueued in a DRM driver, the +* driver retrieves syncobj's current fence at the time the work is enqueued +* waits on that fence before submitting the work to hardware. +* If the syncobj's fence is NULL, the enqueue operation is expected to fail. +* All manipulation of the syncobjs's fence happens in terms of the current +* fence at the time the ioctl is called by userspace regardless of whether +* that operation is an immediate host-side operation (signal or reset) or +* or an operation which is enqueued in some driver queue. * -* Their primary use-case is to implement Vulkan fences and semaphores. +* +* Host-side wait on syncobjs +* -------------------------- +* +* The userspace syncobj API provides an ioctl for waiting on a set of +* syncobjs. +* The wait ioctl takes an array of syncobj handles and a flag indicating +* whether it should return immediately once one syncobj has been signaled +* or if it should wait for all the syncobjs to be signaled. +* Unlike the enqueued GPU work dependencies, the host-side wait ioctl +* will also optionally wait for the syncobj to first receive a fence and +* then wait on that fence. +* Assuming the syncobj starts off with a NULL fence, this allows a client +* to do a host wait in one thread (or process) which waits on GPU work +* submitted in another thread (or process) without having to manually +* synchronize between the two. +* This requirement is inherited from the Vulkan fence API. +* +* +* Import/export of syncobjs +* ------------------------- +* +* The userspace syncobj API provides two mechanisms for import/export of +* syncobjs. +* +* The first lets the client import or export an entire syncobj to a file +* descriptor. +* These fd's are opaque and have no other use case, except passing the +* syncobj between processes. +* All syncobj handles which are created as the result of such an import +* operation refer to the same underlying syncobj as was used for the +* export and the syncobj can be used persistently across all the processes +* with which it is shared. +* Unlike dma-buf, importing a syncobj creates a new handle for every +* import instead of de-duplicating. +* The primary use-case of this persistent import/export is for shared +* Vulkan fences and semaphores. +* +* The second import/export mechanism lets the client export the syncobj's +* current fence to/from a &sync_file. +* When a syncobj is exported to a sync file, that sync file wraps the +* sycnobj's fence at the time of export and any later signal or reset +* operations on the syncobj will not affect the exported sync file. +* When a sync file is imported into a syncobj, the syncobj's fence is set +* to the fence wrapped by that sync file. +* Because sync files are immutable, resetting or signaling the syncobj +* will not affect any sync files whose fences have been imported into the +* syncobj. * * syncobj have a kref reference count, but also have an optional file. * The file is only created once the syncobj is exported.
Signature · 6 lines
2.21.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thanks a lot for writing this :)
I now have a canvas to add stuff on!
Just a couple of questions below.
-Lionel
Quoted 12 lines · Jason Ekstrand
This patch only brings the syncobj documentation up-to-date for the original form of syncobj. It does not contain any information about the design of timeline syncobjs.
--- drivers/gpu/drm/drm_syncobj.c | 81 +++++++++++++++++++++++++++++++---- 1 file changed, 73 insertions(+), 8 deletions(-)drivers/gpu/drm/drm_syncobj.c +0
-0
drivers/gpu/drm/drm_syncobj.c line 35
Quoted 10 lines
drivers/gpu/drm/drm_syncobj.c +4
-3@@ -29,17 +29,82 @@/** * DOC: Overview * -* DRM synchronisation objects (syncobj, see struct &drm_syncobj) are -* persistent objects that contain an optional fence. The fence can be updated -* with a new fence, or be NULL. +* DRM synchronisation objects (syncobj, see struct &drm_syncobj) provide a +* synchronization primitive which can be used by userspace to explicitly +* synchronize GPU commands, can be shared between userspace processes, and +* can be shared between different DRM drivers.
I've been wondering whether we should call it a container for a synchronization primitive rather than a primitive itself.
Sync files are also a container, just we fewer features (no host operations).
It's not really important :)
Quoted 19 lines
drivers/gpu/drm/drm_syncobj.c +13
-4+* Their primary use-case is to implement Vulkan fences and semaphores. +* The syncobj userspace API provides ioctls for several operations: * -* syncobj's can be waited upon, where it will wait for the underlying -* fence. +* - Creation and destruction of syncobjs +* - Import and export of syncobjs to/from a syncobj file descriptor +* - Import and export a syncobj's underlying fence to/from a sync file +* - Reset a syncobj (set its fence to NULL) +* - Signal a syncobj (set a trivially signaled fence) +* - Wait a syncobj's fence to be signaled * -* syncobj's can be export to fd's and back, these fd's are opaque and -* have no other use case, except passing the syncobj between processes. +* At it's core, a syncobj simply a wrapper around a pointer to a struct +* &dma_fence which may be NULL. +* When GPU work which signals a syncobj is enqueued in a DRM driver, +* the syncobj fence is replaced with a fence which will be signaled by the +* completion of that work.
drivers/gpu/drm/drm_syncobj.c line 42
Quoted 10 lines
drivers/gpu/drm/drm_syncobj.c +8
-1+* When GPU work which waits on a syncobj is enqueued in a DRM driver, the +* driver retrieves syncobj's current fence at the time the work is enqueued +* waits on that fence before submitting the work to hardware. +* If the syncobj's fence is NULL, the enqueue operation is expected to fail. +* All manipulation of the syncobjs's fence happens in terms of the current +* fence at the time the ioctl is called by userspace regardless of whether +* that operation is an immediate host-side operation (signal or reset) or +* or an operation which is enqueued in some driver queue. * -* Their primary use-case is to implement Vulkan fences and semaphores.
Maybe add a line about creation (and its signaled flag)?
Quoted 7 lines
drivers/gpu/drm/drm_syncobj.c +7
-0+* +* Host-side wait on syncobjs +* -------------------------- +* +* The userspace syncobj API provides an ioctl for waiting on a set of +* syncobjs. +* The wait ioctl takes an array of syncobj handles and a flag indicating
drivers/gpu/drm/drm_syncobj.c line 76
Quoted 10 lines
drivers/gpu/drm/drm_syncobj.c +10
-0+* whether it should return immediately once one syncobj has been signaled +* or if it should wait for all the syncobjs to be signaled. +* Unlike the enqueued GPU work dependencies, the host-side wait ioctl +* will also optionally wait for the syncobj to first receive a fence and +* then wait on that fence. +* Assuming the syncobj starts off with a NULL fence, this allows a client +* to do a host wait in one thread (or process) which waits on GPU work +* submitted in another thread (or process) without having to manually +* synchronize between the two. +* This requirement is inherited from the Vulkan fence API.
Should we list the flags & ioctl names?
Quoted 22 lines
drivers/gpu/drm/drm_syncobj.c +22
-0+* +* +* Import/export of syncobjs +* ------------------------- +* +* The userspace syncobj API provides two mechanisms for import/export of +* syncobjs. +* +* The first lets the client import or export an entire syncobj to a file +* descriptor. +* These fd's are opaque and have no other use case, except passing the +* syncobj between processes. +* All syncobj handles which are created as the result of such an import +* operation refer to the same underlying syncobj as was used for the +* export and the syncobj can be used persistently across all the processes +* with which it is shared. +* Unlike dma-buf, importing a syncobj creates a new handle for every +* import instead of de-duplicating. +* The primary use-case of this persistent import/export is for shared +* Vulkan fences and semaphores. +* +* The second import/export mechanism lets the client export the syncobj's
drivers/gpu/drm/drm_syncobj.c line 108
Quoted 10 lines
drivers/gpu/drm/drm_syncobj.c +9
-0+* current fence to/from a &sync_file. +* When a syncobj is exported to a sync file, that sync file wraps the +* sycnobj's fence at the time of export and any later signal or reset +* operations on the syncobj will not affect the exported sync file. +* When a sync file is imported into a syncobj, the syncobj's fence is set +* to the fence wrapped by that sync file. +* Because sync files are immutable, resetting or signaling the syncobj +* will not affect any sync files whose fences have been imported into the +* syncobj. *
This 3 lines below seem to be redundant now?
Maybe rephrase with something like :
"Sharing a syncobj increases its refcount. The syncobj is destroyed when a client release the last reference."
drivers/gpu/drm/drm_syncobj.c line 110
Quoted 2 lines
drivers/gpu/drm/drm_syncobj.c +0
-0* syncobj have a kref reference count, but also have an optional file. * The file is only created once the syncobj is exported.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 37 lines · Lionel Landwerlin
Thanks a lot for writing this :)
I now have a canvas to add stuff on!Just a couple of questions below.
-Lionel
Review
Quoted 8 lines · Jason Ekstrand
This patch only brings the syncobj documentation up-to-date for the original form of syncobj. It does not contain any information about the design of timeline syncobjs.
--- drivers/gpu/drm/drm_syncobj.c | 81 +++++++++++++++++++++++++++++++---- 1 file changed, 73 insertions(+), 8 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/drm_syncobj.cdrivers/gpu/drm/drm_syncobj.c line 33
Quoted 9 lines
index
1438dcb3ebb1..03cc888744fb100644drivers/gpu/drm/drm_syncobj.c +0
-2@@ -29,17 +29,82 @@/** * DOC: Overview * -* DRM synchronisation objects (syncobj, see struct &drm_syncobj) are -* persistent objects that contain an optional fence. The fence can be updated
drivers/gpu/drm/drm_syncobj.c line 32
Quoted 2 lines
drivers/gpu/drm/drm_syncobj.c +1
-1-* with a new fence, or be NULL. +* DRM synchronisation objects (syncobj, see struct &drm_syncobj) provide a
drivers/gpu/drm/drm_syncobj.c line 33
Quoted 1 line
drivers/gpu/drm/drm_syncobj.c +1
-0+* synchronization primitive which can be used by userspace to explicitly
drivers/gpu/drm/drm_syncobj.c line 34
Quoted 1 line
drivers/gpu/drm/drm_syncobj.c +1
-0+* synchronize GPU commands, can be shared between userspace processes, and
drivers/gpu/drm/drm_syncobj.c line 35
Quoted 1 line
drivers/gpu/drm/drm_syncobj.c +1
-0+* can be shared between different DRM drivers.
Quoted 8 lines
I've been wondering whether we should call it a container for a synchronization primitive rather than a primitive itself.
Sync files are also a container, just we fewer features (no host operations).
It's not really important :)
That's a fun philosophical question and I think the answer entirely depends on which side of the ioctl you're on. :-)
Quoted 31 lines
Quoted 8 lines
drivers/gpu/drm/drm_syncobj.c +5
-2+* Their primary use-case is to implement Vulkan fences and semaphores. +* The syncobj userspace API provides ioctls for several operations: * -* syncobj's can be waited upon, where it will wait for the underlying -* fence. +* - Creation and destruction of syncobjs +* - Import and export of syncobjs to/from a syncobj file descriptor +* - Import and export a syncobj's underlying fence to/from a sync file drivers/gpu/drm/drm_syncobj.c
Quoted 10 lines
drivers/gpu/drm/drm_syncobj.c +7
-2+* - Reset a syncobj (set its fence to NULL) +* - Signal a syncobj (set a trivially signaled fence) +* - Wait a syncobj's fence to be signaled * -* syncobj's can be export to fd's and back, these fd's are opaque and -* have no other use case, except passing the syncobj between processes. +* At it's core, a syncobj simply a wrapper around a pointer to a struct +* &dma_fence which may be NULL. +* When GPU work which signals a syncobj is enqueued in a DRM driver, +* the syncobj fence is replaced with a fence which will be signaled by the
drivers/gpu/drm/drm_syncobj.c line 51
Quoted 2 lines
drivers/gpu/drm/drm_syncobj.c +2
-0+* completion of that work. +* When GPU work which waits on a syncobj is enqueued in a DRM driver, the
drivers/gpu/drm/drm_syncobj.c line 52
Quoted 1 line
drivers/gpu/drm/drm_syncobj.c +1
-0+* driver retrieves syncobj's current fence at the time the work is enqueued
drivers/gpu/drm/drm_syncobj.c line 54
Quoted 2 lines
drivers/gpu/drm/drm_syncobj.c +2
-0+* waits on that fence before submitting the work to hardware. +* If the syncobj's fence is NULL, the enqueue operation is expected to fail.
drivers/gpu/drm/drm_syncobj.c line 55
Quoted 1 line
drivers/gpu/drm/drm_syncobj.c +1
-0+* All manipulation of the syncobjs's fence happens in terms of the current
drivers/gpu/drm/drm_syncobj.c line 56
Quoted 1 line
drivers/gpu/drm/drm_syncobj.c +1
-0+* fence at the time the ioctl is called by userspace regardless of whether
Quoted 9 lines
drivers/gpu/drm/drm_syncobj.c line 57
Quoted 1 line
drivers/gpu/drm/drm_syncobj.c +1
-0+* that operation is an immediate host-side operation (signal or reset) or
drivers/gpu/drm/drm_syncobj.c line 42
Quoted 3 lines
drivers/gpu/drm/drm_syncobj.c +1
-1+* or an operation which is enqueued in some driver queue. * -* Their primary use-case is to implement Vulkan fences and semaphores. Maybe add a line about creation (and its signaled flag)?
Sure, I'll also make a comment about reset and signal.
Quoted 16 lines
drivers/gpu/drm/drm_syncobj.c
Quoted 7 lines
drivers/gpu/drm/drm_syncobj.c +7
-0+* +* Host-side wait on syncobjs +* -------------------------- +* +* The userspace syncobj API provides an ioctl for waiting on a set of +* syncobjs. +* The wait ioctl takes an array of syncobj handles and a flag indicating
drivers/gpu/drm/drm_syncobj.c line 67
Quoted 1 line
drivers/gpu/drm/drm_syncobj.c +1
-0+* whether it should return immediately once one syncobj has been signaled
drivers/gpu/drm/drm_syncobj.c
Quoted 3 lines
drivers/gpu/drm/drm_syncobj.c +3
-0+* or if it should wait for all the syncobjs to be signaled. +* Unlike the enqueued GPU work dependencies, the host-side wait ioctl +* will also optionally wait for the syncobj to first receive a fence and
drivers/gpu/drm/drm_syncobj.c line 72
Quoted 2 lines
drivers/gpu/drm/drm_syncobj.c +2
-0+* then wait on that fence. +* Assuming the syncobj starts off with a NULL fence, this allows a
Quoted 9 lines
client
drivers/gpu/drm/drm_syncobj.c line 76
Quoted 4 lines
drivers/gpu/drm/drm_syncobj.c +4
-0+* to do a host wait in one thread (or process) which waits on GPU work +* submitted in another thread (or process) without having to manually +* synchronize between the two. +* This requirement is inherited from the Vulkan fence API. Should we list the flags & ioctl names?
I don't know. Maybe Dave or Daniel can tell me how these things are usually done?
Quoted 35 lines
drivers/gpu/drm/drm_syncobj.c
Quoted 6 lines
drivers/gpu/drm/drm_syncobj.c +6
-0+* +* +* Import/export of syncobjs +* ------------------------- +* +* The userspace syncobj API provides two mechanisms for import/export of
drivers/gpu/drm/drm_syncobj.c
Quoted 3 lines
drivers/gpu/drm/drm_syncobj.c +3
-0+* syncobjs. +* +* The first lets the client import or export an entire syncobj to a file
drivers/gpu/drm/drm_syncobj.c
Quoted 6 lines
drivers/gpu/drm/drm_syncobj.c +6
-0+* descriptor. +* These fd's are opaque and have no other use case, except passing the +* syncobj between processes. +* All syncobj handles which are created as the result of such an import +* operation refer to the same underlying syncobj as was used for the +* export and the syncobj can be used persistently across all the processes
drivers/gpu/drm/drm_syncobj.c
Quoted 7 lines
drivers/gpu/drm/drm_syncobj.c +7
-0+* with which it is shared. +* Unlike dma-buf, importing a syncobj creates a new handle for every +* import instead of de-duplicating. +* The primary use-case of this persistent import/export is for shared +* Vulkan fences and semaphores. +* +* The second import/export mechanism lets the client export the syncobj's
drivers/gpu/drm/drm_syncobj.c
Quoted 5 lines
drivers/gpu/drm/drm_syncobj.c +5
-0+* current fence to/from a &sync_file. +* When a syncobj is exported to a sync file, that sync file wraps the +* sycnobj's fence at the time of export and any later signal or reset +* operations on the syncobj will not affect the exported sync file. +* When a sync file is imported into a syncobj, the syncobj's fence is set
drivers/gpu/drm/drm_syncobj.c
Quoted 3 lines
drivers/gpu/drm/drm_syncobj.c +3
-0+* to the fence wrapped by that sync file. +* Because sync files are immutable, resetting or signaling the syncobj +* will not affect any sync files whose fences have been imported into
Quoted 7 lines
the
drivers/gpu/drm/drm_syncobj.c line 108
Quoted 2 lines
drivers/gpu/drm/drm_syncobj.c +1
-0+* syncobj. * This 3 lines below seem to be redundant now?
Which three lines are you referring to? The thing about krefs? I agree that it feels a bit odd with the rest of the documentation because it's a very internal detail and the rest of what I've written is an overview. Maybe the bit about krefs should go in the top section and the bit about the file should stay here?
Quoted 6 lines
Maybe rephrase with something like :
"Sharing a syncobj increases its refcount. The syncobj is destroyed when a client release the last reference."
I don't think we need to describe how reference counting works.
Quoted 5 lines
drivers/gpu/drm/drm_syncobj.c line 110
Quoted 2 lines
drivers/gpu/drm/drm_syncobj.c +0
-0* syncobj have a kref reference count, but also have an optional file. * The file is only created once the syncobj is exported.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
I somehow totally missed that patch, looks like it maybe ended up in the spam folder.
Am 05.08.19 um 19:01 schrieb Jason Ekstrand:
On Sat, Aug 3, 2019 at 3:19 AM Lionel Landwerlin <[email protected]<mailto:[email protected]>> wrote:
Thanks a lot for writing this :)
I now have a canvas to add stuff on!
Just a couple of questions below.
-Lionel
Quoted 12 lines · Jason Ekstrand
This patch only brings the syncobj documentation up-to-date for the original form of syncobj. It does not contain any information about the design of timeline syncobjs.
--- drivers/gpu/drm/drm_syncobj.c | 81 +++++++++++++++++++++++++++++++---- 1 file changed, 73 insertions(+), 8 deletions(-)drivers/gpu/drm/drm_syncobj.c +0
-0
drivers/gpu/drm/drm_syncobj.c line 35
Quoted 10 lines
drivers/gpu/drm/drm_syncobj.c +4
-3@@ -29,17 +29,82 @@/** * DOC: Overview * -* DRM synchronisation objects (syncobj, see struct &drm_syncobj) are -* persistent objects that contain an optional fence. The fence can be updated -* with a new fence, or be NULL. +* DRM synchronisation objects (syncobj, see struct &drm_syncobj) provide a +* synchronization primitive which can be used by userspace to explicitly +* synchronize GPU commands, can be shared between userspace processes, and +* can be shared between different DRM drivers.
I've been wondering whether we should call it a container for a synchronization primitive rather than a primitive itself.
Sync files are also a container, just we fewer features (no host operations).
It's not really important :)
That's a fun philosophical question and I think the answer entirely depends on which side of the ioctl you're on. :-)
Yeah, but this is kernel documentation, not userspace documentation. So I agree that syncobjs are just a container inside the kernel.
drivers/gpu/drm/drm_syncobj.c line 44
Quoted 11 lines
drivers/gpu/drm/drm_syncobj.c +8
-2+* Their primary use-case is to implement Vulkan fences and semaphores. +* The syncobj userspace API provides ioctls for several operations: * -* syncobj's can be waited upon, where it will wait for the underlying -* fence. +* - Creation and destruction of syncobjs +* - Import and export of syncobjs to/from a syncobj file descriptor +* - Import and export a syncobj's underlying fence to/from a sync file +* - Reset a syncobj (set its fence to NULL) +* - Signal a syncobj (set a trivially signaled fence) +* - Wait a syncobj's fence to be signaled
Wait for a fence to appear.
Quoted 8 lines
drivers/gpu/drm/drm_syncobj.c +5
-2* -* syncobj's can be export to fd's and back, these fd's are opaque and -* have no other use case, except passing the syncobj between processes. +* At it's core, a syncobj simply a wrapper around a pointer to a struct +* &dma_fence which may be NULL. +* When GPU work which signals a syncobj is enqueued in a DRM driver, +* the syncobj fence is replaced with a fence which will be signaled by the +* completion of that work.
drivers/gpu/drm/drm_syncobj.c line 42
Quoted 10 lines
drivers/gpu/drm/drm_syncobj.c +8
-1+* When GPU work which waits on a syncobj is enqueued in a DRM driver, the +* driver retrieves syncobj's current fence at the time the work is enqueued +* waits on that fence before submitting the work to hardware. +* If the syncobj's fence is NULL, the enqueue operation is expected to fail. +* All manipulation of the syncobjs's fence happens in terms of the current +* fence at the time the ioctl is called by userspace regardless of whether +* that operation is an immediate host-side operation (signal or reset) or +* or an operation which is enqueued in some driver queue. * -* Their primary use-case is to implement Vulkan fences and semaphores.
Maybe add a line about creation (and its signaled flag)?
Sure, I'll also make a comment about reset and signal.
Quoted 7 lines
drivers/gpu/drm/drm_syncobj.c +7
-0+* +* Host-side wait on syncobjs +* -------------------------- +* +* The userspace syncobj API provides an ioctl for waiting on a set of +* syncobjs. +* The wait ioctl takes an array of syncobj handles and a flag indicating
drivers/gpu/drm/drm_syncobj.c line 76
Quoted 10 lines
drivers/gpu/drm/drm_syncobj.c +10
-0+* whether it should return immediately once one syncobj has been signaled +* or if it should wait for all the syncobjs to be signaled. +* Unlike the enqueued GPU work dependencies, the host-side wait ioctl +* will also optionally wait for the syncobj to first receive a fence and +* then wait on that fence. +* Assuming the syncobj starts off with a NULL fence, this allows a client +* to do a host wait in one thread (or process) which waits on GPU work +* submitted in another thread (or process) without having to manually +* synchronize between the two. +* This requirement is inherited from the Vulkan fence API.
Should we list the flags & ioctl names?
I don't know. Maybe Dave or Daniel can tell me how these things are usually done?
You could & reference the enum/defines of the IOCTL numbers in the first sentence or something like this.
Quoted 22 lines
drivers/gpu/drm/drm_syncobj.c +22
-0+* +* +* Import/export of syncobjs +* ------------------------- +* +* The userspace syncobj API provides two mechanisms for import/export of +* syncobjs. +* +* The first lets the client import or export an entire syncobj to a file +* descriptor. +* These fd's are opaque and have no other use case, except passing the +* syncobj between processes. +* All syncobj handles which are created as the result of such an import +* operation refer to the same underlying syncobj as was used for the +* export and the syncobj can be used persistently across all the processes +* with which it is shared. +* Unlike dma-buf, importing a syncobj creates a new handle for every +* import instead of de-duplicating. +* The primary use-case of this persistent import/export is for shared +* Vulkan fences and semaphores. +* +* The second import/export mechanism lets the client export the syncobj's
drivers/gpu/drm/drm_syncobj.c line 108
Quoted 10 lines
drivers/gpu/drm/drm_syncobj.c +9
-0+* current fence to/from a &sync_file. +* When a syncobj is exported to a sync file, that sync file wraps the +* sycnobj's fence at the time of export and any later signal or reset +* operations on the syncobj will not affect the exported sync file. +* When a sync file is imported into a syncobj, the syncobj's fence is set +* to the fence wrapped by that sync file. +* Because sync files are immutable, resetting or signaling the syncobj +* will not affect any sync files whose fences have been imported into the +* syncobj. *
This 3 lines below seem to be redundant now?
Which three lines are you referring to? The thing about krefs? I agree that it feels a bit odd with the rest of the documentation because it's a very internal detail and the rest of what I've written is an overview. Maybe the bit about krefs should go in the top section and the bit about the file should stay here?
Maybe rephrase with something like :
"Sharing a syncobj increases its refcount. The syncobj is destroyed when a client release the last reference."
I don't think we need to describe how reference counting works.
Agreed, we should just mention that things are referenced instead of copied. How this referencing works is out of scope here.
drivers/gpu/drm/drm_syncobj.c line 110
Quoted 2 lines
drivers/gpu/drm/drm_syncobj.c +0
-0* syncobj have a kref reference count, but also have an optional file. * The file is only created once the syncobj is exported.
To much detail.
Regards,
Christian.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 drm/syncobj: Add better overview documentation for syncobj (v2)
In reply to Jason EkstrandThis patch only brings the syncobj documentation up-to-date for the original form of syncobj. It does not contain any information about the design of timeline syncobjs.
v2: Incorporate feedback from Lionel and Christian:
- Mention actual ioctl and flag names
- Better language around reference counting
- Misc. language cleanups
--- drivers/gpu/drm/drm_syncobj.c | 98 +++++++++++++++++++++++++++++++---- 1 file changed, 87 insertions(+), 11 deletions(-)
drivers/gpu/drm/drm_syncobj.c +87 -11
@@ -29,21 +29,97 @@/** * DOC: Overview * -* DRM synchronisation objects (syncobj, see struct &drm_syncobj) are -* persistent objects that contain an optional fence. The fence can be updated -* with a new fence, or be NULL. +* DRM synchronisation objects (syncobj, see struct &drm_syncobj) provide a +* container for a synchronization primitive which can be used by userspace +* to explicitly synchronize GPU commands, can be shared between userspace +* processes, and can be shared between different DRM drivers. +* Their primary use-case is to implement Vulkan fences and semaphores. +* The syncobj userspace API provides ioctls for several operations: * -* syncobj's can be waited upon, where it will wait for the underlying -* fence. +* - Creation and destruction of syncobjs +* - Import and export of syncobjs to/from a syncobj file descriptor +* - Import and export a syncobj's underlying fence to/from a sync file +* - Reset a syncobj (set its fence to NULL) +* - Signal a syncobj (set a trivially signaled fence) +* - Wait for a syncobj's fence to appear and be signaled * -* syncobj's can be export to fd's and back, these fd's are opaque and -* have no other use case, except passing the syncobj between processes. +* At it's core, a syncobj is simply a wrapper around a pointer to a struct +* &dma_fence which may be NULL. +* When a syncobj is first created, its pointer is either NULL or a pointer +* to an already signaled fence depending on whether the +* &DRM_SYNCOBJ_CREATE_SIGNALED flag is passed to +* &DRM_IOCTL_SYNCOBJ_CREATE. +* When GPU work which signals a syncobj is enqueued in a DRM driver, +* the syncobj fence is replaced with a fence which will be signaled by the +* completion of that work. +* When GPU work which waits on a syncobj is enqueued in a DRM driver, the +* driver retrieves syncobj's current fence at the time the work is enqueued +* waits on that fence before submitting the work to hardware. +* If the syncobj's fence is NULL, the enqueue operation is expected to fail. +* All manipulation of the syncobjs's fence happens in terms of the current +* fence at the time the ioctl is called by userspace regardless of whether +* that operation is an immediate host-side operation (signal or reset) or +* or an operation which is enqueued in some driver queue. +* &DRM_IOCTL_SYNCOBJ_RESET and &DRM_IOCTL_SYNCOBJ_SIGNAL can be used to +* manipulate a syncobj from the host by resetting its pointer to NULL or +* setting its pointer to a fence which is already signaled. * -* Their primary use-case is to implement Vulkan fences and semaphores. * -* syncobj have a kref reference count, but also have an optional file. -* The file is only created once the syncobj is exported. -* The file takes a reference on the kref. +* Host-side wait on syncobjs +* -------------------------- +* +* &DRM_IOCTL_SYNCOBJ_WAIT takes an array of syncobj handles and does a +* host-side wait on all of the syncobj fences simultaneously. +* If &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL is set, the wait ioctl will wait on +* all of the syncobj fences to be signaled before it returns. +* Otherwise, it returns once at least one syncobj fence has been signaled +* and the index of a signaled fence is written back to the client. +* +* Unlike the enqueued GPU work dependencies which fail if they see a NULL +* fence in a syncobj, if &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT is set, +* the host-side wait will first wait for the syncobj to receive a non-NULL +* fence and then wait on that fence. +* If &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT is not set and any one of the +* syncobjs in the array has a NULL fence, -EINVAL will be returned. +* Assuming the syncobj starts off with a NULL fence, this allows a client +* to do a host wait in one thread (or process) which waits on GPU work +* submitted in another thread (or process) without having to manually +* synchronize between the two. +* This requirement is inherited from the Vulkan fence API. +* +* +* Import/export of syncobjs +* ------------------------- +* +* &DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE and &DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD +* provide two mechanisms for import/export of syncobjs. +* +* The first lets the client import or export an entire syncobj to a file +* descriptor. +* These fd's are opaque and have no other use case, except passing the +* syncobj between processes. +* All exported file descriptors and any syncobj handles created as a +* result of importing those file descriptors own a reference to the +* same underlying struct &drm_syncobj and the syncobj can be used +* persistently across all the processes with which it is shared. +* The syncobj is freed only once the last reference is dropped. +* Unlike dma-buf, importing a syncobj creates a new handle (with its own +* reference) for every import instead of de-duplicating. +* The primary use-case of this persistent import/export is for shared +* Vulkan fences and semaphores. +* +* The second import/export mechanism, which is indicated by +* &DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE or +* &DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE lets the client +* import/export the syncobj's current fence from/to a &sync_file. +* When a syncobj is exported to a sync file, that sync file wraps the +* sycnobj's fence at the time of export and any later signal or reset +* operations on the syncobj will not affect the exported sync file. +* When a sync file is imported into a syncobj, the syncobj's fence is set +* to the fence wrapped by that sync file. +* Because sync files are immutable, resetting or signaling the syncobj +* will not affect any sync files whose fences have been imported into the +* syncobj. */ #include <linux/anon_inodes.h>
Signature · 6 lines
2.21.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm/syncobj: Add better overview documentation for syncobj (v2)
Quoted 10 lines · Jason Ekstrand
This patch only brings the syncobj documentation up-to-date for the original form of syncobj. It does not contain any information about the design of timeline syncobjs.
v2: Incorporate feedback from Lionel and Christian:
- Mention actual ioctl and flag names
- Better language around reference counting
- Misc. language cleanupsSigned-off-by Jason Ekstrand <[email protected]>
Quoted 107 lines
--- drivers/gpu/drm/drm_syncobj.c | 98 +++++++++++++++++++++++++++++++---- 1 file changed, 87 insertions(+), 11 deletions(-)drivers/gpu/drm/drm_syncobj.c +80
-11@@ -29,21 +29,97 @@/** * DOC: Overview * -* DRM synchronisation objects (syncobj, see struct &drm_syncobj) are -* persistent objects that contain an optional fence. The fence can be updated -* with a new fence, or be NULL. +* DRM synchronisation objects (syncobj, see struct &drm_syncobj) provide a +* container for a synchronization primitive which can be used by userspace +* to explicitly synchronize GPU commands, can be shared between userspace +* processes, and can be shared between different DRM drivers. +* Their primary use-case is to implement Vulkan fences and semaphores. +* The syncobj userspace API provides ioctls for several operations: * -* syncobj's can be waited upon, where it will wait for the underlying -* fence. +* - Creation and destruction of syncobjs +* - Import and export of syncobjs to/from a syncobj file descriptor +* - Import and export a syncobj's underlying fence to/from a sync file +* - Reset a syncobj (set its fence to NULL) +* - Signal a syncobj (set a trivially signaled fence) +* - Wait for a syncobj's fence to appear and be signaled * -* syncobj's can be export to fd's and back, these fd's are opaque and -* have no other use case, except passing the syncobj between processes. +* At it's core, a syncobj is simply a wrapper around a pointer to a struct +* &dma_fence which may be NULL. +* When a syncobj is first created, its pointer is either NULL or a pointer +* to an already signaled fence depending on whether the +* &DRM_SYNCOBJ_CREATE_SIGNALED flag is passed to +* &DRM_IOCTL_SYNCOBJ_CREATE. +* When GPU work which signals a syncobj is enqueued in a DRM driver, +* the syncobj fence is replaced with a fence which will be signaled by the +* completion of that work. +* When GPU work which waits on a syncobj is enqueued in a DRM driver, the +* driver retrieves syncobj's current fence at the time the work is enqueued +* waits on that fence before submitting the work to hardware. +* If the syncobj's fence is NULL, the enqueue operation is expected to fail. +* All manipulation of the syncobjs's fence happens in terms of the current +* fence at the time the ioctl is called by userspace regardless of whether +* that operation is an immediate host-side operation (signal or reset) or +* or an operation which is enqueued in some driver queue. +* &DRM_IOCTL_SYNCOBJ_RESET and &DRM_IOCTL_SYNCOBJ_SIGNAL can be used to +* manipulate a syncobj from the host by resetting its pointer to NULL or +* setting its pointer to a fence which is already signaled. * -* Their primary use-case is to implement Vulkan fences and semaphores. * -* syncobj have a kref reference count, but also have an optional file. -* The file is only created once the syncobj is exported. -* The file takes a reference on the kref. +* Host-side wait on syncobjs +* -------------------------- +* +* &DRM_IOCTL_SYNCOBJ_WAIT takes an array of syncobj handles and does a +* host-side wait on all of the syncobj fences simultaneously. +* If &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL is set, the wait ioctl will wait on +* all of the syncobj fences to be signaled before it returns. +* Otherwise, it returns once at least one syncobj fence has been signaled +* and the index of a signaled fence is written back to the client. +* +* Unlike the enqueued GPU work dependencies which fail if they see a NULL +* fence in a syncobj, if &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT is set, +* the host-side wait will first wait for the syncobj to receive a non-NULL +* fence and then wait on that fence. +* If &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT is not set and any one of the +* syncobjs in the array has a NULL fence, -EINVAL will be returned. +* Assuming the syncobj starts off with a NULL fence, this allows a client +* to do a host wait in one thread (or process) which waits on GPU work +* submitted in another thread (or process) without having to manually +* synchronize between the two. +* This requirement is inherited from the Vulkan fence API. +* +* +* Import/export of syncobjs +* ------------------------- +* +* &DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE and &DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD +* provide two mechanisms for import/export of syncobjs. +* +* The first lets the client import or export an entire syncobj to a file +* descriptor. +* These fd's are opaque and have no other use case, except passing the +* syncobj between processes. +* All exported file descriptors and any syncobj handles created as a +* result of importing those file descriptors own a reference to the +* same underlying struct &drm_syncobj and the syncobj can be used +* persistently across all the processes with which it is shared. +* The syncobj is freed only once the last reference is dropped. +* Unlike dma-buf, importing a syncobj creates a new handle (with its own +* reference) for every import instead of de-duplicating. +* The primary use-case of this persistent import/export is for shared +* Vulkan fences and semaphores. +* +* The second import/export mechanism, which is indicated by +* &DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE or +* &DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE lets the client +* import/export the syncobj's current fence from/to a &sync_file. +* When a syncobj is exported to a sync file, that sync file wraps the
drivers/gpu/drm/drm_syncobj.c line 125
Quoted 10 lines
drivers/gpu/drm/drm_syncobj.c +7
-0+* sycnobj's fence at the time of export and any later signal or reset +* operations on the syncobj will not affect the exported sync file. +* When a sync file is imported into a syncobj, the syncobj's fence is set +* to the fence wrapped by that sync file. +* Because sync files are immutable, resetting or signaling the syncobj +* will not affect any sync files whose fences have been imported into the +* syncobj. */ #include <linux/anon_inodes.h>
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm/syncobj: Add better overview documentation for syncobj (v2)
Christan, any thoughts on v2?
--Jason
Quoted 130 lines · On August 7, 2019 09:06:47 Lionel Landwerlin <[email protected]>…
Quoted 10 lines · Jason Ekstrand
This patch only brings the syncobj documentation up-to-date for the original form of syncobj. It does not contain any information about the design of timeline syncobjs.
v2: Incorporate feedback from Lionel and Christian:
- Mention actual ioctl and flag names
- Better language around reference counting
- Misc. language cleanupsSigned-off-by Jason Ekstrand <[email protected]>Reviewed-by Lionel Landwerlin <[email protected]>Quoted 116 lines
--- drivers/gpu/drm/drm_syncobj.c | 98 +++++++++++++++++++++++++++++++---- 1 file changed, 87 insertions(+), 11 deletions(-)drivers/gpu/drm/drm_syncobj.c +87
-11@@ -29,21 +29,97 @@/** * DOC: Overview * -* DRM synchronisation objects (syncobj, see struct &drm_syncobj) are -* persistent objects that contain an optional fence. The fence can be updated -* with a new fence, or be NULL. +* DRM synchronisation objects (syncobj, see struct &drm_syncobj) provide a +* container for a synchronization primitive which can be used by userspace +* to explicitly synchronize GPU commands, can be shared between userspace +* processes, and can be shared between different DRM drivers. +* Their primary use-case is to implement Vulkan fences and semaphores. +* The syncobj userspace API provides ioctls for several operations: * -* syncobj's can be waited upon, where it will wait for the underlying -* fence. +* - Creation and destruction of syncobjs +* - Import and export of syncobjs to/from a syncobj file descriptor +* - Import and export a syncobj's underlying fence to/from a sync file +* - Reset a syncobj (set its fence to NULL) +* - Signal a syncobj (set a trivially signaled fence) +* - Wait for a syncobj's fence to appear and be signaled * -* syncobj's can be export to fd's and back, these fd's are opaque and -* have no other use case, except passing the syncobj between processes. +* At it's core, a syncobj is simply a wrapper around a pointer to a struct +* &dma_fence which may be NULL. +* When a syncobj is first created, its pointer is either NULL or a pointer +* to an already signaled fence depending on whether the +* &DRM_SYNCOBJ_CREATE_SIGNALED flag is passed to +* &DRM_IOCTL_SYNCOBJ_CREATE. +* When GPU work which signals a syncobj is enqueued in a DRM driver, +* the syncobj fence is replaced with a fence which will be signaled by the +* completion of that work. +* When GPU work which waits on a syncobj is enqueued in a DRM driver, the +* driver retrieves syncobj's current fence at the time the work is enqueued +* waits on that fence before submitting the work to hardware. +* If the syncobj's fence is NULL, the enqueue operation is expected to fail. +* All manipulation of the syncobjs's fence happens in terms of the current +* fence at the time the ioctl is called by userspace regardless of whether +* that operation is an immediate host-side operation (signal or reset) or +* or an operation which is enqueued in some driver queue. +* &DRM_IOCTL_SYNCOBJ_RESET and &DRM_IOCTL_SYNCOBJ_SIGNAL can be used to +* manipulate a syncobj from the host by resetting its pointer to NULL or +* setting its pointer to a fence which is already signaled. * -* Their primary use-case is to implement Vulkan fences and semaphores. * -* syncobj have a kref reference count, but also have an optional file. -* The file is only created once the syncobj is exported. -* The file takes a reference on the kref. +* Host-side wait on syncobjs +* -------------------------- +* +* &DRM_IOCTL_SYNCOBJ_WAIT takes an array of syncobj handles and does a +* host-side wait on all of the syncobj fences simultaneously. +* If &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL is set, the wait ioctl will wait on +* all of the syncobj fences to be signaled before it returns. +* Otherwise, it returns once at least one syncobj fence has been signaled +* and the index of a signaled fence is written back to the client. +* +* Unlike the enqueued GPU work dependencies which fail if they see a NULL +* fence in a syncobj, if &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT is set, +* the host-side wait will first wait for the syncobj to receive a non-NULL +* fence and then wait on that fence. +* If &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT is not set and any one of the +* syncobjs in the array has a NULL fence, -EINVAL will be returned. +* Assuming the syncobj starts off with a NULL fence, this allows a client +* to do a host wait in one thread (or process) which waits on GPU work +* submitted in another thread (or process) without having to manually +* synchronize between the two. +* This requirement is inherited from the Vulkan fence API. +* +* +* Import/export of syncobjs +* ------------------------- +* +* &DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE and &DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD +* provide two mechanisms for import/export of syncobjs. +* +* The first lets the client import or export an entire syncobj to a file +* descriptor. +* These fd's are opaque and have no other use case, except passing the +* syncobj between processes. +* All exported file descriptors and any syncobj handles created as a +* result of importing those file descriptors own a reference to the +* same underlying struct &drm_syncobj and the syncobj can be used +* persistently across all the processes with which it is shared. +* The syncobj is freed only once the last reference is dropped. +* Unlike dma-buf, importing a syncobj creates a new handle (with its own +* reference) for every import instead of de-duplicating. +* The primary use-case of this persistent import/export is for shared +* Vulkan fences and semaphores. +* +* The second import/export mechanism, which is indicated by +* &DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE or +* &DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE lets the client +* import/export the syncobj's current fence from/to a &sync_file. +* When a syncobj is exported to a sync file, that sync file wraps the +* sycnobj's fence at the time of export and any later signal or reset +* operations on the syncobj will not affect the exported sync file. +* When a sync file is imported into a syncobj, the syncobj's fence is set +* to the fence wrapped by that sync file. +* Because sync files are immutable, resetting or signaling the syncobj +* will not affect any sync files whose fences have been imported into the +* syncobj. */
Quoted 1 line
drivers/gpu/drm/drm_syncobj.c line 125
Quoted 1 line
drivers/gpu/drm/drm_syncobj.c +0
-0#include <linux/anon_inodes.h>
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm/syncobj: Add better overview documentation for syncobj (v2)
Hi Jason,
this mail also somehow ended up to be rejected by our spam filter and I'm not sure why :(
Anyway, feel free to add my Acked-by. From the technical point I would give an r-b as well, but I'm not a native speaker of English.
Cheers,
Christian.
Am 08.08.19 um 06:47 schrieb Jason Ekstrand:
Quoted 176 lines
Christan, any thoughts on v2?
--Jason
Quoted 168 lines · On August 7, 2019 09:06:47 Lionel Landwerlin <[email protected]>…
Quoted 11 lines · Jason Ekstrand
This patch only brings the syncobj documentation up-to-date for the original form of syncobj. It does not contain any information about the
design of timeline syncobjs.v2: Incorporate feedback from Lionel and Christian:
- Mention actual ioctl and flag names
- Better language around reference counting
- Misc. language cleanupsSigned-off-by Jason Ekstrand <[email protected]>Reviewed-by Lionel Landwerlin <[email protected]>Quoted 153 lines
---
drivers/gpu/drm/drm_syncobj.c| 98
+++++++++++++++++++++++++++++++----1 file changed, 87 insertions(+), 11 deletions(-)drivers/gpu/drm/drm_syncobj.c +0
-2@@ -29,21 +29,97 @@ /*** DOC: Overview * -* DRM synchronisation objects (syncobj, see struct &drm_syncobj) are -* persistent objects that contain an optional fence. The Ok,fence can be updated
- * with a new fence, or be NULL.
+ * DRM synchronisation objects (syncobj, see struct&drm_syncobj) provide a
+ * container for a synchronization primitive which can be used by userspace
+ * to explicitly synchronize GPU commands, can be shared between userspace
+ * processes, and can be shared between different DRM drivers.
+ * Their primary use-case is to implement Vulkan fences and semaphores.
+ * The syncobj userspace API provides ioctls for several operations:
*
- * syncobj's can be waited upon, where it will wait for the underlying
- * fence.
+ * - Creation and destruction of syncobjs
+ * - Import and export of syncobjs to/from a syncobj file descriptor
+ * - Import and export a syncobj's underlying fence to/from a sync file
+ * - Reset a syncobj (set its fence to NULL)
+ * - Signal a syncobj (set a trivially signaled fence)
+ * - Wait for a syncobj's fence to appear and be signaled *
- * syncobj's can be export to fd's and back, these fd's are opaque and
- * have no other use case, except passing the syncobj between processes.
+ * At it's core, a syncobj is simply a wrapper around a pointer to a struct
+ *&dma_fencewhich may be NULL.
+ * When a syncobj is first created, its pointer is either NULL or a pointer
+ * to an already signaled fence depending on whether the
+ *&DRM_SYNCOBJ_CREATE_SIGNALEDflag is passed to
+ *&DRM_IOCTL_SYNCOBJ_CREATE.
+ * When GPU work which signals a syncobj is enqueued in a DRM driver,
+ * the syncobj fence is replaced with a fence which will be signaled by the
+ * completion of that work.
+ * When GPU work which waits on a syncobj is enqueued in a DRM driver, the
+ * driver retrieves syncobj's current fence at the time the work is enqueued
+ * waits on that fence before submitting the work to hardware.
+ * If the syncobj's fence is NULL, the enqueue operation is expected to fail.
+ * All manipulation of the syncobjs's fence happens in terms of the current
+ * fence at the time the ioctl is called by userspace regardless of whether
+ * that operation is an immediate host-side operation (signal or reset) or
+ * or an operation which is enqueued in some driver queue.
+ *&DRM_IOCTL_SYNCOBJ_RESETand&DRM_IOCTL_SYNCOBJ_SIGNALcan be used to
+ * manipulate a syncobj from the host by resetting its pointer to NULL or
+ * setting its pointer to a fence which is already signaled. *
- * Their primary use-case is to implement Vulkan fences and semaphores.
*
- * syncobj have a kref reference count, but also have an optional file.
- * The file is only created once the syncobj is exported.
- * The file takes a reference on the kref.
+ * Host-side wait on syncobjs
+ * --------------------------
+ *
+ *&DRM_IOCTL_SYNCOBJ_WAITtakes an array of syncobj handles and does a
+ * host-side wait on all of the syncobj fences simultaneously.
+ * If&DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALLis set, the wait ioctl will wait on
+ * all of the syncobj fences to be signaled before it returns.
+ * Otherwise, it returns once at least one syncobj fence has been signaled
+ * and the index of a signaled fence is written back to the client.
+ *
+ * Unlike the enqueued GPU work dependencies which fail if they see a NULL
+ * fence in a syncobj, if&DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMITis set,
+ * the host-side wait will first wait for the syncobj to receive a non-NULL
+ * fence and then wait on that fence.
+ * If&DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMITis not set and any one of the
+ * syncobjs in the array has a NULL fence,-EINVALwill be returned.
+ * Assuming the syncobj starts off with a NULL fence, this allows a client
+ * to do a host wait in one thread (or process) which waits on GPU work
+ * submitted in another thread (or process) without having to manually
+ * synchronize between the two.
+ * This requirement is inherited from the Vulkan fence API.
+ *
+ *
+ * Import/export of syncobjs
+ * -------------------------
+ *
+ *&DRM_IOCTL_SYNCOBJ_FD_TO_HANDLEand&DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD
+ * provide two mechanisms for import/export of syncobjs.
+ *
+ * The first lets the client import or export an entire syncobj to a file
+ * descriptor.
+ * These fd's are opaque and have no other use case, except passing the
+ * syncobj between processes.
+ * All exported file descriptors and any syncobj handles created as a
+ * result of importing those file descriptors own a reference to the
+ * same underlying struct&drm_syncobjand the syncobj can be used
+ * persistently across all the processes with which it is shared.
+ * The syncobj is freed only once the last reference is dropped.
+ * Unlike dma-buf, importing a syncobj creates a new handle (with its own
+ * reference) for every import instead of de-duplicating.
+ * The primary use-case of this persistent import/export is for shared
+ * Vulkan fences and semaphores.
+ *
+ * The second import/export mechanism, which is indicated by
+ *&DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILEor
+ *&DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILElets the client
+ * import/export the syncobj's current fence from/to a&sync_file.
+ * When a syncobj is exported to a sync file, that sync file wraps the
+ * sycnobj's fence at the time of export and any later signal or reset
+ * operations on the syncobj will not affect the exported sync file.
+ * When a sync file is imported into a syncobj, the syncobj's fence is set
+ * to the fence wrapped by that sync file.
+ * Because sync files are immutable, resetting or signaling the syncobj
+ * will not affect any sync files whose fences have been imported into the
+ * syncobj.
*/
Quoted 4 lines
Quoted 1 line
Quoted 1 line
#include <
linux/anon_inodes.h>
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 drm/syncobj: Add better overview documentation for syncobj (v2)
In reply to Jason EkstrandThis patch only brings the syncobj documentation up-to-date for the original form of syncobj. It does not contain any information about the design of timeline syncobjs.
v2: Incorporate feedback from Lionel and Christian:
- Mention actual ioctl and flag names
- Better language around reference counting
- Misc. language cleanups
--- drivers/gpu/drm/drm_syncobj.c | 98 +++++++++++++++++++++++++++++++---- 1 file changed, 87 insertions(+), 11 deletions(-)
drivers/gpu/drm/drm_syncobj.c +87 -11
@@ -29,21 +29,97 @@/** * DOC: Overview * -* DRM synchronisation objects (syncobj, see struct &drm_syncobj) are -* persistent objects that contain an optional fence. The fence can be updated -* with a new fence, or be NULL. +* DRM synchronisation objects (syncobj, see struct &drm_syncobj) provide a +* container for a synchronization primitive which can be used by userspace +* to explicitly synchronize GPU commands, can be shared between userspace +* processes, and can be shared between different DRM drivers. +* Their primary use-case is to implement Vulkan fences and semaphores. +* The syncobj userspace API provides ioctls for several operations: * -* syncobj's can be waited upon, where it will wait for the underlying -* fence. +* - Creation and destruction of syncobjs +* - Import and export of syncobjs to/from a syncobj file descriptor +* - Import and export a syncobj's underlying fence to/from a sync file +* - Reset a syncobj (set its fence to NULL) +* - Signal a syncobj (set a trivially signaled fence) +* - Wait for a syncobj's fence to appear and be signaled * -* syncobj's can be export to fd's and back, these fd's are opaque and -* have no other use case, except passing the syncobj between processes. +* At it's core, a syncobj is simply a wrapper around a pointer to a struct +* &dma_fence which may be NULL. +* When a syncobj is first created, its pointer is either NULL or a pointer +* to an already signaled fence depending on whether the +* &DRM_SYNCOBJ_CREATE_SIGNALED flag is passed to +* &DRM_IOCTL_SYNCOBJ_CREATE. +* When GPU work which signals a syncobj is enqueued in a DRM driver, +* the syncobj fence is replaced with a fence which will be signaled by the +* completion of that work. +* When GPU work which waits on a syncobj is enqueued in a DRM driver, the +* driver retrieves syncobj's current fence at the time the work is enqueued +* waits on that fence before submitting the work to hardware. +* If the syncobj's fence is NULL, the enqueue operation is expected to fail. +* All manipulation of the syncobjs's fence happens in terms of the current +* fence at the time the ioctl is called by userspace regardless of whether +* that operation is an immediate host-side operation (signal or reset) or +* or an operation which is enqueued in some driver queue. +* &DRM_IOCTL_SYNCOBJ_RESET and &DRM_IOCTL_SYNCOBJ_SIGNAL can be used to +* manipulate a syncobj from the host by resetting its pointer to NULL or +* setting its pointer to a fence which is already signaled. * -* Their primary use-case is to implement Vulkan fences and semaphores. * -* syncobj have a kref reference count, but also have an optional file. -* The file is only created once the syncobj is exported. -* The file takes a reference on the kref. +* Host-side wait on syncobjs +* -------------------------- +* +* &DRM_IOCTL_SYNCOBJ_WAIT takes an array of syncobj handles and does a +* host-side wait on all of the syncobj fences simultaneously. +* If &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL is set, the wait ioctl will wait on +* all of the syncobj fences to be signaled before it returns. +* Otherwise, it returns once at least one syncobj fence has been signaled +* and the index of a signaled fence is written back to the client. +* +* Unlike the enqueued GPU work dependencies which fail if they see a NULL +* fence in a syncobj, if &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT is set, +* the host-side wait will first wait for the syncobj to receive a non-NULL +* fence and then wait on that fence. +* If &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT is not set and any one of the +* syncobjs in the array has a NULL fence, -EINVAL will be returned. +* Assuming the syncobj starts off with a NULL fence, this allows a client +* to do a host wait in one thread (or process) which waits on GPU work +* submitted in another thread (or process) without having to manually +* synchronize between the two. +* This requirement is inherited from the Vulkan fence API. +* +* +* Import/export of syncobjs +* ------------------------- +* +* &DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE and &DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD +* provide two mechanisms for import/export of syncobjs. +* +* The first lets the client import or export an entire syncobj to a file +* descriptor. +* These fd's are opaque and have no other use case, except passing the +* syncobj between processes. +* All exported file descriptors and any syncobj handles created as a +* result of importing those file descriptors own a reference to the +* same underlying struct &drm_syncobj and the syncobj can be used +* persistently across all the processes with which it is shared. +* The syncobj is freed only once the last reference is dropped. +* Unlike dma-buf, importing a syncobj creates a new handle (with its own +* reference) for every import instead of de-duplicating. +* The primary use-case of this persistent import/export is for shared +* Vulkan fences and semaphores. +* +* The second import/export mechanism, which is indicated by +* &DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE or +* &DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE lets the client +* import/export the syncobj's current fence from/to a &sync_file. +* When a syncobj is exported to a sync file, that sync file wraps the +* sycnobj's fence at the time of export and any later signal or reset +* operations on the syncobj will not affect the exported sync file. +* When a sync file is imported into a syncobj, the syncobj's fence is set +* to the fence wrapped by that sync file. +* Because sync files are immutable, resetting or signaling the syncobj +* will not affect any sync files whose fences have been imported into the +* syncobj. */ #include <linux/anon_inodes.h>
Signature · 6 lines
2.21.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm/syncobj: Add better overview documentation for syncobj (v2)
Would one of you mind pushing? I don't have drm-misc commit bits.
Quoted 140 lines · Jason Ekstrand
This patch only brings the syncobj documentation up-to-date for the original form of syncobj. It does not contain any information about the design of timeline syncobjs.
v2: Incorporate feedback from Lionel and Christian:
- Mention actual ioctl and flag names
- Better language around reference counting
- Misc. language cleanupsSigned-off-by Jason Ekstrand <[email protected]>Reviewed-by Lionel Landwerlin <[email protected]>Acked-by Christian König <[email protected]>--- drivers/gpu/drm/drm_syncobj.c | 98 +++++++++++++++++++++++++++++++---- 1 file changed, 87 insertions(+), 11 deletions(-)drivers/gpu/drm/drm_syncobj.c +0
-2@@ -29,21 +29,97 @@/** * DOC: Overview * -* DRM synchronisation objects (syncobj, see struct &drm_syncobj) are -* persistent objects that contain an optional fence. The fence can be updated
- * with a new fence, or be NULL.
+ * DRM synchronisation objects (syncobj, see struct&drm_syncobj) provide a
+ * container for a synchronization primitive which can be used by userspace
+ * to explicitly synchronize GPU commands, can be shared between userspace
+ * processes, and can be shared between different DRM drivers.
+ * Their primary use-case is to implement Vulkan fences and semaphores.
+ * The syncobj userspace API provides ioctls for several operations:
*
- * syncobj's can be waited upon, where it will wait for the underlying
- * fence.+ * - Creation and destruction of syncobjs + * - Import and export of syncobjs to/from a syncobj file descriptor + * - Import and export a syncobj's underlying fence to/from a sync file + * - Reset a syncobj (set its fence to NULL) + * - Signal a syncobj (set a trivially signaled fence) + * - Wait for a syncobj's fence to appear and be signaled*
- * syncobj's can be export to fd's and back, these fd's are opaque and
- * have no other use case, except passing the syncobj between processes.
+ * At it's core, a syncobj is simply a wrapper around a pointer to a struct
+ *&dma_fencewhich may be NULL.
+ * When a syncobj is first created, its pointer is either NULL or a pointer
+ * to an already signaled fence depending on whether the
+ *&DRM_SYNCOBJ_CREATE_SIGNALEDflag is passed to
+ *&DRM_IOCTL_SYNCOBJ_CREATE.
+ * When GPU work which signals a syncobj is enqueued in a DRM driver,
+ * the syncobj fence is replaced with a fence which will be signaled by the
+ * completion of that work.
+ * When GPU work which waits on a syncobj is enqueued in a DRM driver, the
+ * driver retrieves syncobj's current fence at the time the work is enqueued
+ * waits on that fence before submitting the work to hardware.
+ * If the syncobj's fence is NULL, the enqueue operation is expected to fail.
+ * All manipulation of the syncobjs's fence happens in terms of the current
+ * fence at the time the ioctl is called by userspace regardless of whether
+ * that operation is an immediate host-side operation (signal or reset) or
+ * or an operation which is enqueued in some driver queue.
+ *&DRM_IOCTL_SYNCOBJ_RESETand&DRM_IOCTL_SYNCOBJ_SIGNALcan be used to
+ * manipulate a syncobj from the host by resetting its pointer to NULL or
+ * setting its pointer to a fence which is already signaled.
*
- * Their primary use-case is to implement Vulkan fences and semaphores. *
- * syncobj have a kref reference count, but also have an optional file.
- * The file is only created once the syncobj is exported.
- * The file takes a reference on the kref.
+ * Host-side wait on syncobjs
+ * --------------------------
+ *
+ *&DRM_IOCTL_SYNCOBJ_WAITtakes an array of syncobj handles and does a
+ * host-side wait on all of the syncobj fences simultaneously.
+ * If&DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALLis set, the wait ioctl will wait on
+ * all of the syncobj fences to be signaled before it returns.
+ * Otherwise, it returns once at least one syncobj fence has been signaled
+ * and the index of a signaled fence is written back to the client.
+ *
+ * Unlike the enqueued GPU work dependencies which fail if they see a NULL
+ * fence in a syncobj, if&DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMITis set,
+ * the host-side wait will first wait for the syncobj to receive a non-NULL
+ * fence and then wait on that fence.
+ * If&DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMITis not set and any one of the
+ * syncobjs in the array has a NULL fence,-EINVALwill be returned.
+ * Assuming the syncobj starts off with a NULL fence, this allows a client
+ * to do a host wait in one thread (or process) which waits on GPU work
+ * submitted in another thread (or process) without having to manually
+ * synchronize between the two.
+ * This requirement is inherited from the Vulkan fence API.
+ *
+ *
+ * Import/export of syncobjs
+ * -------------------------
+ *
+ *&DRM_IOCTL_SYNCOBJ_FD_TO_HANDLEand&DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD
+ * provide two mechanisms for import/export of syncobjs.
+ *
+ * The first lets the client import or export an entire syncobj to a file
+ * descriptor.
+ * These fd's are opaque and have no other use case, except passing the
+ * syncobj between processes.
+ * All exported file descriptors and any syncobj handles created as a
+ * result of importing those file descriptors own a reference to the
+ * same underlying struct&drm_syncobjand the syncobj can be used
+ * persistently across all the processes with which it is shared.
+ * The syncobj is freed only once the last reference is dropped.
+ * Unlike dma-buf, importing a syncobj creates a new handle (with its own
+ * reference) for every import instead of de-duplicating.
+ * The primary use-case of this persistent import/export is for shared
+ * Vulkan fences and semaphores.
+ *
+ * The second import/export mechanism, which is indicated by
+ *&DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILEor
+ *&DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILElets the client
+ * import/export the syncobj's current fence from/to a&sync_file.
+ * When a syncobj is exported to a sync file, that sync file wraps the
+ * sycnobj's fence at the time of export and any later signal or reset
+ * operations on the syncobj will not affect the exported sync file.
+ * When a sync file is imported into a syncobj, the syncobj's fence is set
+ * to the fence wrapped by that sync file.
+ * Because sync files are immutable, resetting or signaling the syncobj
+ * will not affect any sync files whose fences have been imported into the
+ * syncobj.
*/
Quoted 5 lines
#include <
linux/anon_inodes.h>
--
2.21.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel