Starter task: Querying errors from
Subsystems (3)
cover Starter task: Querying errors from
This patch series adds an ioctl that allows userspace to query a syncobj to get error codes from fences when submitted jobs fail, in response to the starter task in the drm todo documentation.
According to the kernel documentation:
https://docs.kernel.org/gpu/drm-uapi.html#testing-and-validation
I will need to add relevant test-cases into IGT alongside this patch, is that correct?
I am still a beginner, so I am submitting this as a RFC to make sure I'm going in the right direction with this - Would love to get some feedback on this patch series. Should I need to add additional parameters for flag inputs as well?
Yicong Hui (2):
drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error
status
drm/syncobj/doc: Remove starter task from todo list
Documentation/gpu/todo.rst | 16 ---------------- drivers/gpu/drm/drm_internal.h | 2 ++ drivers/gpu/drm/drm_ioctl.c | 2 ++ drivers/gpu/drm/drm_syncobj.c | 22 ++++++++++++++++++++++ include/uapi/drm/drm.h | 13 +++++++++++++ 5 files changed, 39 insertions(+), 16 deletions(-)
Signature · 1 line
2.53.0
RFC PATCH 1/2 drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status
Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to allow userspace to query the error status of a fence held by a timeline/binary syncobj.
--- drivers/gpu/drm/drm_internal.h | 2 ++ drivers/gpu/drm/drm_ioctl.c | 2 ++ drivers/gpu/drm/drm_syncobj.c | 22 ++++++++++++++++++++++ include/uapi/drm/drm.h | 13 +++++++++++++ 4 files changed, 39 insertions(+)
drivers/gpu/drm/drm_internal.h +2 -0
@@ -285,6 +285,8 @@ int drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private);int drm_syncobj_query_ioctl (struct drm_device *dev,void *data,struct drm_file *file_private); +int drm_syncobj_query_error_ioctl (struct drm_device *dev,void *data, +struct drm_file *file_private);/* drm_framebuffer.c */ void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,
drivers/gpu/drm/drm_ioctl.c +2 -0
@@ -732,6 +732,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = {DRM_IOCTL_DEF (DRM_IOCTL_MODE_LIST_LESSEES , drm_mode_list_lessees_ioctl,DRM_MASTER ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_GET_LEASE , drm_mode_get_lease_ioctl,DRM_MASTER ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_REVOKE_LEASE , drm_mode_revoke_lease_ioctl,DRM_MASTER ), +DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_QUERY_ERROR , drm_syncobj_query_error_ioctl, + DRM_RENDER_ALLOW), };#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE(drm_ioctls)
drivers/gpu/drm/drm_syncobj.c +22 -0
@@ -1717,3 +1717,25 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,return ret; } + +int drm_syncobj_query_error_ioctl (struct drm_device *dev,void *data, +struct drm_file *file_private) +{ +struct drm_syncobj_error *args = data; +struct dma_fence *fence; +int ret; + +if (!drm_core_check_feature (dev,DRIVER_SYNCOBJ )) +return -EOPNOTSUPP ; + + ret =drm_syncobj_find_fence (file_private, args->handle, args->point,0 , &fence); + +if (ret) +return ret; + + args->error = fence->error; + +dma_fence_put (fence); + +return 0 ; +}
include/uapi/drm/drm.h +13 -0
@@ -1051,6 +1051,11 @@ struct drm_syncobj_timeline_array {__u32 flags; }; +struct drm_syncobj_error { +__u32 handle; +__s32 error; +__u64 point; +};/* Query current scanout sequence number */ struct drm_crtc_get_sequence {
@@ -1363,6 +1368,14 @@ extern "C" {*/ #define DRM_IOCTL_GEM_CHANGE_HANDLE DRM_IOWR(0xD2, struct drm_gem_change_handle) +/** +* DRM_IOCTL_SYNCOBJ_QUERY_ERROR - Query the error code from a failed drm_syncobj +* +* This ioctl provides userspace a way to query the error code of a binary and +* timeline drm_syncobj in the case that the submission fails. +*/ +#define DRM_IOCTL_SYNCOBJ_QUERY_ERROR DRM_IOWR(0xD3, struct drm_syncobj_error) +/* * Device specific ioctls should only be in their respective headers * The device specific ioctl range is from 0x40 to 0x9f.
Signature · 1 line
2.53.0
RFC PATCH 2/2 drm/syncobj/doc: Remove starter task from todo list
In reply to Yicong HuiRemove the starter task for adding DRM_IOCTL_SYNCOBJ_QUERY_ERROR ioctl.
--- Documentation/gpu/todo.rst | 16 ---------------- 1 file changed, 16 deletions(-)
Documentation/gpu/todo.rst +0 -16
@@ -878,22 +878,6 @@ Contact: Javier Martinez Canillas <[email protected]> Level: Advanced -Querying errors from drm_syncobj -================================ - -The drm_syncobj container can be used by driver independent code to signal -complection of submission. - -One minor feature still missing is a generic DRM IOCTL to query the error -status of binary and timeline drm_syncobj. - -This should probably be improved by implementing the necessary kernel interface -and adding support for that in the userspace stack. - -Contact: Christian König - -Level: Starter - DRM GPU Scheduler =================
Signature · 1 line
2.53.0
Re: [RFC PATCH v1 1/2] drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status
In reply to Yicong HuiQuoted 2 lines · Yicong Hui
Add
DRM_IOCTL_SYNCOBJ_QUERY_ERRORto allow userspace to query the error status of a fence held by a timeline/binary syncobj.
Not bad for a first try, but quite a bunch of general comments.
First of all to get that merged you need to point out a Mesa merge request where this interface is actually used in userspace, so that we can look at the full solution.
Quoted 26 lines
Signed-off-by Yicong Hui <[email protected]>--- drivers/gpu/drm/drm_internal.h | 2 ++ drivers/gpu/drm/drm_ioctl.c | 2 ++ drivers/gpu/drm/drm_syncobj.c | 22 ++++++++++++++++++++++ include/uapi/drm/drm.h | 13 +++++++++++++ 4 files changed, 39 insertions(+)drivers/gpu/drm/drm_internal.h +2
-0@@ -285,6 +285,8 @@ int drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private);int drm_syncobj_query_ioctl (struct drm_device *dev,void *data,struct drm_file *file_private); +int drm_syncobj_query_error_ioctl (struct drm_device *dev,void *data, +struct drm_file *file_private);/* drm_framebuffer.c */ void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,drivers/gpu/drm/drm_ioctl.c +0
-0
drivers/gpu/drm/drm_ioctl.c static const struct drm_ioctl_desc drm_ioctls[] = { · line 736
Quoted 5 lines
drivers/gpu/drm/drm_ioctl.c +2
-0@@ -732,6 +732,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = {DRM_IOCTL_DEF (DRM_IOCTL_MODE_LIST_LESSEES , drm_mode_list_lessees_ioctl,DRM_MASTER ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_GET_LEASE , drm_mode_get_lease_ioctl,DRM_MASTER ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_REVOKE_LEASE , drm_mode_revoke_lease_ioctl,DRM_MASTER ), +DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_QUERY_ERROR , drm_syncobj_query_error_ioctl, + DRM_RENDER_ALLOW),
My educated guess is that userspace doesn't want to call this IOCTL separately because of performance reasons.
Instead add some additional flag to DRM_SYNCOBJ_WAIT_FLAGS_* so that the IOCTL aborts the wait and returns an error as soon as it sees any fence with an error.
Another DRM_SYNCOBJ_QUERY_FLAGS_* is potentially also useful to query the error on a number of drm_syncobjs at the same time.
But in general since this is not a HW feature the userspace developers need to voice their requirements and explain how they want to have that implemented.
So adding Michel on CC, I've briefly discussed that topic with him on XDC last year.
Thanks,
Christian.
Quoted 64 lines
drivers/gpu/drm/drm_ioctl.c +0
-0};#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE(drm_ioctls)drivers/gpu/drm/drm_syncobj.c +22
-0@@ -1717,3 +1717,25 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,return ret; } + +int drm_syncobj_query_error_ioctl (struct drm_device *dev,void *data, +struct drm_file *file_private) +{ +struct drm_syncobj_error *args = data; +struct dma_fence *fence; +int ret; + +if (!drm_core_check_feature (dev,DRIVER_SYNCOBJ )) +return -EOPNOTSUPP ; + + ret =drm_syncobj_find_fence (file_private, args->handle, args->point,0 , &fence); + +if (ret) +return ret; + + args->error = fence->error; + +dma_fence_put (fence); + +return 0 ; +}include/uapi/drm/drm.h +13
-0@@ -1051,6 +1051,11 @@ struct drm_syncobj_timeline_array {__u32 flags; }; +struct drm_syncobj_error { +__u32 handle; +__s32 error; +__u64 point; +};/* Query current scanout sequence number */ struct drm_crtc_get_sequence {@@ -1363,6 +1368,14 @@ extern "C" {*/ #define DRM_IOCTL_GEM_CHANGE_HANDLE DRM_IOWR(0xD2, struct drm_gem_change_handle) +/** +* DRM_IOCTL_SYNCOBJ_QUERY_ERROR - Query the error code from a failed drm_syncobj +* +* This ioctl provides userspace a way to query the error code of a binary and +* timeline drm_syncobj in the case that the submission fails. +*/ +#define DRM_IOCTL_SYNCOBJ_QUERY_ERROR DRM_IOWR(0xD3, struct drm_syncobj_error) +/* * Device specific ioctls should only be in their respective headers * The device specific ioctl range is from 0x40 to 0x9f.
Re: [RFC PATCH v1 1/2] drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status
Quoted 13 lines · Christian König
Quoted 2 lines · Yicong Hui
Add
DRM_IOCTL_SYNCOBJ_QUERY_ERRORto allow userspace to query the error status of a fence held by a timeline/binary syncobj.Not bad for a first try, but quite a bunch of general comments.
First of all to get that merged you need to point out a Mesa merge request where this interface is actually used in userspace, so that we can look at the full solution.
My educated guess is that userspace doesn't want to call this IOCTL separately because of performance reasons.
Instead add some additional flag to DRM_SYNCOBJ_WAIT_FLAGS_* so that the IOCTL aborts the wait and returns an error as soon as it sees any fence with an error.
Quoted 8 lines
Another DRM_SYNCOBJ_QUERY_FLAGS_* is potentially also useful to query the error on a number of
drm_syncobjsat the same time.But in general since this is not a HW feature the userspace developers need to voice their requirements and explain how they want to have that implemented.
So adding Michel on CC, I've briefly discussed that topic with him on XDC last year.
Thanks,
Christian.
Hi, thank you for the feedback! :D
Shall I just wait for Michel's input on what interface would work best for Mesa?
Thank you!
-Yicong
Re: [RFC PATCH v1 1/2] drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status
In reply to Christian KönigAdding the wayland-devel list for Wayland compositor developers.
Also adding the mesa-dev list for Mesa developers, though note that this list isn't really active anymore. You might want to create an MR or Gitlab issue to get feedback from Mesa developers.
Quoted 10 lines · Christian König
drivers/gpu/drm/drm_ioctl.c static const struct drm_ioctl_desc drm_ioctls[] = { · line 736
Quoted 7 lines
drivers/gpu/drm/drm_ioctl.c +2
-0@@ -732,6 +732,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = {DRM_IOCTL_DEF (DRM_IOCTL_MODE_LIST_LESSEES , drm_mode_list_lessees_ioctl,DRM_MASTER ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_GET_LEASE , drm_mode_get_lease_ioctl,DRM_MASTER ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_REVOKE_LEASE , drm_mode_revoke_lease_ioctl,DRM_MASTER ), +DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_QUERY_ERROR , drm_syncobj_query_error_ioctl, + DRM_RENDER_ALLOW),My educated guess is that userspace doesn't want to call this IOCTL separately because of performance reasons.
Quoted 5 lines
Instead add some additional flag to DRM_SYNCOBJ_WAIT_FLAGS_* so that the IOCTL aborts the wait and returns an error as soon as it sees any fence with an error.
Another DRM_SYNCOBJ_QUERY_FLAGS_* is potentially also useful to query the error on a number of
drm_syncobjsat the same time.But in general since this is not a HW feature the userspace developers need to voice their requirements and explain how they want to have that implemented.
mutter currently doesn't use the syncobj-specific ioctls to wait for a syncobj (timeline point) to signal / check if it has. Instead, it uses drmSyncobjEventfd / drmSyncobjExportSyncFile to get an eventfd / sync_file representing the timeline point / fence, then checks the status of the fd and waits for it to signal using generic poll()-style functionality. So unless the error condition can be communicated via the latter (and plumbed through glib APIs), mutter would need to check for fence errors separately.
Xwayland uses drmSyncobjTimelineWait to check if a syncobj timeline point has a fence / has signalled, it also uses drmSyncobjEventfd similarly to mutter though.
Signature · 2 lines
Earthling Michel Dänzer \ GNOME / Xwayland / Mesa developer https://redhat.com \ Libre software enthusiast
Re: [RFC PATCH v1 1/2] drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status
Quoted 17 lines · Michel Dänzer
Adding the wayland-devel list for Wayland compositor developers.
Also adding the mesa-dev list for Mesa developers, though note that this list isn't really active anymore. You might want to create an MR or Gitlab issue to get feedback from Mesa developers.
Quoted 10 lines · Christian König
drivers/gpu/drm/drm_ioctl.c static const struct drm_ioctl_desc drm_ioctls[] = { · line 736
Quoted 7 lines
drivers/gpu/drm/drm_ioctl.c +2
-0@@ -732,6 +732,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = {DRM_IOCTL_DEF (DRM_IOCTL_MODE_LIST_LESSEES , drm_mode_list_lessees_ioctl,DRM_MASTER ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_GET_LEASE , drm_mode_get_lease_ioctl,DRM_MASTER ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_REVOKE_LEASE , drm_mode_revoke_lease_ioctl,DRM_MASTER ), +DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_QUERY_ERROR , drm_syncobj_query_error_ioctl, + DRM_RENDER_ALLOW),My educated guess is that userspace doesn't want to call this IOCTL separately because of performance reasons.
Quoted 7 lines
Quoted 5 lines
Instead add some additional flag to DRM_SYNCOBJ_WAIT_FLAGS_* so that the IOCTL aborts the wait and returns an error as soon as it sees any fence with an error.
Another DRM_SYNCOBJ_QUERY_FLAGS_* is potentially also useful to query the error on a number of
drm_syncobjsat the same time.But in general since this is not a HW feature the userspace developers need to voice their requirements and explain how they want to have that implemented.
mutter currently doesn't use the syncobj-specific ioctls to wait for a syncobj (timeline point) to signal / check if it has. Instead, it uses drmSyncobjEventfd / drmSyncobjExportSyncFile to get an eventfd /
sync_filerepresenting the timeline point / fence, then checks the status of the fd and waits for it to signal using generic poll()-style functionality. So unless the error condition can be communicated via the latter (and plumbed through glib APIs), mutter would need to check for fence errors separately.
Good point, poll() has a POLLERR flag for that but I have no idea if eventfd supports that in any way. So potentially doable as well but a bit more work.
Using a new DRM_SYNCOBJ_QUERY_FLAGS_ERROR on all signaled syncobj as separate way to query if there was an error should work for you in the meantime?
Quoted 1 line
Xwayland uses drmSyncobjTimelineWait to check if a syncobj timeline point has a fence / has signalled, it also uses drmSyncobjEventfd similarly to mutter though.
Yeah that sounds like something Yicong could tackle.
@Yicong any more questions or do you got the idea?
Regards,
Christian.
Re: [RFC PATCH v1 1/2] drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status
Quoted 16 lines · Christian König
Quoted 15 lines · Michel Dänzer
Quoted 14 lines · Christian König
drivers/gpu/drm/drm_ioctl.c static const struct drm_ioctl_desc drm_ioctls[] = { · line 736
Quoted 7 lines
drivers/gpu/drm/drm_ioctl.c +2
-0@@ -732,6 +732,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = {DRM_IOCTL_DEF (DRM_IOCTL_MODE_LIST_LESSEES , drm_mode_list_lessees_ioctl,DRM_MASTER ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_GET_LEASE , drm_mode_get_lease_ioctl,DRM_MASTER ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_REVOKE_LEASE , drm_mode_revoke_lease_ioctl,DRM_MASTER ), +DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_QUERY_ERROR , drm_syncobj_query_error_ioctl, + DRM_RENDER_ALLOW),My educated guess is that userspace doesn't want to call this IOCTL separately because of performance reasons.
Instead add some additional flag to DRM_SYNCOBJ_WAIT_FLAGS_* so that the IOCTL aborts the wait and returns an error as soon as it sees any fence with an error.
Another DRM_SYNCOBJ_QUERY_FLAGS_* is potentially also useful to query the error on a number of
drm_syncobjsat the same time.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
But in general since this is not a HW feature the userspace developers need to voice their requirements and explain how they want to have that implemented.
mutter currently doesn't use the syncobj-specific ioctls to wait for a syncobj (timeline point) to signal / check if it has. Instead, it uses drmSyncobjEventfd / drmSyncobjExportSyncFile to get an eventfd /
sync_filerepresenting the timeline point / fence, then checks the status of the fd and waits for it to signal using generic poll()-style functionality. So unless the error condition can be communicated via the latter (and plumbed through glib APIs), mutter would need to check for fence errors separately.Good point,
poll()has a POLLERR flag for that but I have no idea if eventfd supports that in any way. So potentially doable as well but a bit more work.Using a new
DRM_SYNCOBJ_QUERY_FLAGS_ERRORon all signaled syncobj as separate way to query if there was an error should work for you in the meantime?
Yeah should be fine, though if POLLERR is possible, that might save constantly calling into the kernel to check for an error status that won't happen the vast majority of the time?
The bigger question might be what user space can do with the error status. I wrote down some ideas for mutter in https://gitlab.gnome.org/GNOME/mutter/-/issues/4624 .
Signature · 2 lines
Earthling Michel Dänzer \ GNOME / Xwayland / Mesa developer https://redhat.com \ Libre software enthusiast
Re: [RFC PATCH v1 1/2] drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status
Quoted 7 lines
Instead add some additional flag to DRM_SYNCOBJ_WAIT_FLAGS_* so that the IOCTL aborts the wait and returns an error as soon as it sees any fence with an error.
Another DRM_SYNCOBJ_QUERY_FLAGS_* is potentially also useful to query the error on a number of
drm_syncobjsat the same time.Using a new
DRM_SYNCOBJ_QUERY_FLAGS_ERRORon all signaled syncobj as separate way to query if there was an error should work for you in the meantime?@Yicong any more questions or do you got the idea?
So to confirm, I should implement a flag DRM_SYNCOBJ_WAIT_FLAGS_ERROR which would make the DRM_IOCTL_SYNCOBJ_WAIT ioctl just wait until any fence returns an error, then return the error code of that syncobj/fence's first error, and then return 0 if everything completes without any errors?
and add flag DRM_SYNCOBJ_QUERY_FLAGS_ERROR which would make the DRM_IOCTL_SYNCOBJ_QUERY ioctl fill out the points array with the error codes of each syncobj instead of the latest timeline point? Should it leave the entry as 0 for syncobjs with no error or leave it as it would be without the flag? And if it has multiple fences with errors it should just return the latest error right?
Quoted 1 line
Good point,
poll()has a POLLERR flag for that but I have no idea if eventfd supports that in any way. So potentially doable as well but a bit more work.
Okay, that sounds like somewhere I could potentially implement similar functionality for poll() in a follow-up patch later in the future
Thank you!
- Yicong
Re: [RFC PATCH v1 1/2] drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status
Quoted 9 lines · Yicong Hui
Quoted 7 lines
Instead add some additional flag to DRM_SYNCOBJ_WAIT_FLAGS_* so that the IOCTL aborts the wait and returns an error as soon as it sees any fence with an error.
Another DRM_SYNCOBJ_QUERY_FLAGS_* is potentially also useful to query the error on a number of
drm_syncobjsat the same time.Using a new
DRM_SYNCOBJ_QUERY_FLAGS_ERRORon all signaled syncobj as separate way to query if there was an error should work for you in the meantime?@Yicong any more questions or do you got the idea?
So to confirm, I should implement a flag
DRM_SYNCOBJ_WAIT_FLAGS_ERRORwhich would make theDRM_IOCTL_SYNCOBJ_WAITioctl just wait until any fence returns an error, then return the error code of that syncobj/fence's first error, and then return 0 if everything completes without any errors?
Correct, yes. I mean the name of the flag can probably be improved, my suggestion is DRM_SYNCOBJ_WAIT_FLAGS_ABORT_ON_ERROR, but in general you seem to got the idea.
Quoted 1 line
and add flag
DRM_SYNCOBJ_QUERY_FLAGS_ERRORwhich would make theDRM_IOCTL_SYNCOBJ_QUERYioctl fill out the points array with the error codes of each syncobj instead of the latest timeline point? Should it leave the entry as 0 for syncobjs with no error or leave it as it would be without the flag? And if it has multiple fences with errors it should just return the latest error right?
Well I would fill in the handles array with the error codes, this way you can return both the signaled point as well as the error at the same time. For this you would just need to document very clearly that the handles array now has a double functionality.
I think it is sufficient to return the first error found. We don't need to make it to complicated.
Quoted 2 lines
Quoted 1 line
Good point,
poll()has a POLLERR flag for that but I have no idea if eventfd supports that in any way. So potentially doable as well but a bit more work.Okay, that sounds like somewhere I could potentially implement similar functionality for
poll()in a follow-up patch later in the future
Yeah, agree. That is a nice to have functionality to allow mutter to avoid an extra IOCTL to check for errors in the most common case, but it is certainly a second step and a bit more complicated than the initial task.
Regards,
Christian.
Quoted 4 lines
Thank you!
- Yicong