mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH v1 0/2] Starter task: Querying errors from
@ 2026-02-13 12:08 Yicong Hui
  2026-02-13 12:08 ` [RFC PATCH v1 1/2] drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status Yicong Hui
  2026-02-13 12:08 ` [RFC PATCH v1 2/2] drm/syncobj/doc: Remove starter task from todo list Yicong Hui
  0 siblings, 2 replies; 10+ messages in thread
From: Yicong Hui @ 2026-02-13 12:08 UTC (permalink / raw)
  To: christian.koenig
  Cc: dri-devel, linux-kernel, skhan, david.hunter.linux, Yicong Hui

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(-)

-- 
2.53.0


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

* [RFC PATCH v1 1/2] drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status
  2026-02-13 12:08 [RFC PATCH v1 0/2] Starter task: Querying errors from Yicong Hui
@ 2026-02-13 12:08 ` Yicong Hui
  2026-02-17 10:29   ` Christian König
  2026-02-13 12:08 ` [RFC PATCH v1 2/2] drm/syncobj/doc: Remove starter task from todo list Yicong Hui
  1 sibling, 1 reply; 10+ messages in thread
From: Yicong Hui @ 2026-02-13 12:08 UTC (permalink / raw)
  To: christian.koenig
  Cc: dri-devel, linux-kernel, skhan, david.hunter.linux, Yicong Hui

Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to allow userspace to query the error
status of a fence held by a timeline/binary syncobj.

Signed-off-by: Yicong Hui <yiconghui@gmail.com>
---
 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(+)

diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index f893b1e3a596..d4d722983544 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -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,
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index ff193155129e..61b114a6a65f 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -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)
diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index 2d4ab745fdad..2152cd029070 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -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;
+}
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index 27cc159c1d27..087c0f2120ec 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -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.
-- 
2.53.0


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

* [RFC PATCH v1 2/2] drm/syncobj/doc: Remove starter task from todo list
  2026-02-13 12:08 [RFC PATCH v1 0/2] Starter task: Querying errors from Yicong Hui
  2026-02-13 12:08 ` [RFC PATCH v1 1/2] drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status Yicong Hui
@ 2026-02-13 12:08 ` Yicong Hui
  1 sibling, 0 replies; 10+ messages in thread
From: Yicong Hui @ 2026-02-13 12:08 UTC (permalink / raw)
  To: christian.koenig
  Cc: dri-devel, linux-kernel, skhan, david.hunter.linux, Yicong Hui

Remove the starter task for adding DRM_IOCTL_SYNCOBJ_QUERY_ERROR
ioctl.

Signed-off-by: Yicong Hui <yiconghui@gmail.com>
---
 Documentation/gpu/todo.rst | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index 520da44a04a6..8dcb1901142e 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -878,22 +878,6 @@ Contact: Javier Martinez Canillas <javierm@redhat.com>
 
 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
 =================
 
-- 
2.53.0


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

* Re: [RFC PATCH v1 1/2] drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status
  2026-02-13 12:08 ` [RFC PATCH v1 1/2] drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status Yicong Hui
@ 2026-02-17 10:29   ` Christian König
  2026-02-17 11:35     ` Yicong Hui
  2026-02-17 14:35     ` Michel Dänzer
  0 siblings, 2 replies; 10+ messages in thread
From: Christian König @ 2026-02-17 10:29 UTC (permalink / raw)
  To: Yicong Hui
  Cc: dri-devel, linux-kernel, skhan, david.hunter.linux, Michel Dänzer

On 2/13/26 13:08, Yicong Hui wrote:
> Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to 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.

> Signed-off-by: Yicong Hui <yiconghui@gmail.com>
> ---
>  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(+)
> 
> diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
> index f893b1e3a596..d4d722983544 100644
> --- a/drivers/gpu/drm/drm_internal.h
> +++ b/drivers/gpu/drm/drm_internal.h
> @@ -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,
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index ff193155129e..61b114a6a65f 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -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.

>  };
>  
>  #define DRM_CORE_IOCTL_COUNT	ARRAY_SIZE(drm_ioctls)
> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
> index 2d4ab745fdad..2152cd029070 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -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;
> +}
> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
> index 27cc159c1d27..087c0f2120ec 100644
> --- a/include/uapi/drm/drm.h
> +++ b/include/uapi/drm/drm.h
> @@ -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.


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

* Re: [RFC PATCH v1 1/2] drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status
  2026-02-17 10:29   ` Christian König
@ 2026-02-17 11:35     ` Yicong Hui
  2026-02-17 14:35     ` Michel Dänzer
  1 sibling, 0 replies; 10+ messages in thread
From: Yicong Hui @ 2026-02-17 11:35 UTC (permalink / raw)
  To: Christian König
  Cc: dri-devel, linux-kernel, skhan, david.hunter.linux, Michel Dänzer

On 2/17/26 10:29 AM, Christian König wrote:
> On 2/13/26 13:08, Yicong Hui wrote:
>> Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to 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.
> 
> 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.


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

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

* Re: [RFC PATCH v1 1/2] drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status
  2026-02-17 10:29   ` Christian König
  2026-02-17 11:35     ` Yicong Hui
@ 2026-02-17 14:35     ` Michel Dänzer
  2026-02-17 14:45       ` Christian König
  1 sibling, 1 reply; 10+ messages in thread
From: Michel Dänzer @ 2026-02-17 14:35 UTC (permalink / raw)
  To: Christian König, Yicong Hui
  Cc: dri-devel, linux-kernel, skhan, david.hunter.linux,
	wayland-devel, mesa-dev


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.


On 2/17/26 11:29, Christian König wrote:
>>
>> @@ -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.

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.


-- 
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast

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

* Re: [RFC PATCH v1 1/2] drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status
  2026-02-17 14:35     ` Michel Dänzer
@ 2026-02-17 14:45       ` Christian König
  2026-02-18 14:49         ` Michel Dänzer
  0 siblings, 1 reply; 10+ messages in thread
From: Christian König @ 2026-02-17 14:45 UTC (permalink / raw)
  To: Michel Dänzer, Yicong Hui
  Cc: dri-devel, linux-kernel, skhan, david.hunter.linux,
	wayland-devel, mesa-dev

On 2/17/26 15:35, Michel Dänzer wrote:
> 
> 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.
> 
> 
> On 2/17/26 11:29, Christian König wrote:
>>>
>>> @@ -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.
> 
> 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.

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?

> 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.


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

* Re: [RFC PATCH v1 1/2] drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status
  2026-02-17 14:45       ` Christian König
@ 2026-02-18 14:49         ` Michel Dänzer
  2026-02-19  0:15           ` Yicong Hui
  0 siblings, 1 reply; 10+ messages in thread
From: Michel Dänzer @ 2026-02-18 14:49 UTC (permalink / raw)
  To: Christian König, Yicong Hui
  Cc: dri-devel, linux-kernel, skhan, david.hunter.linux,
	wayland-devel, mesa-dev

On 2/17/26 15:45, Christian König wrote:
> On 2/17/26 15:35, Michel Dänzer wrote:
>> On 2/17/26 11:29, Christian König wrote:
>>>>
>>>> @@ -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.
>>
>> 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.
> 
> 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?

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 .


-- 
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast

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

* Re: [RFC PATCH v1 1/2] drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status
  2026-02-18 14:49         ` Michel Dänzer
@ 2026-02-19  0:15           ` Yicong Hui
  2026-02-19  7:31             ` Christian König
  0 siblings, 1 reply; 10+ messages in thread
From: Yicong Hui @ 2026-02-19  0:15 UTC (permalink / raw)
  To: Michel Dänzer, Christian König
  Cc: dri-devel, linux-kernel, skhan, david.hunter.linux,
	wayland-devel, mesa-dev

> 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.

> 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?

> @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?

> 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
  

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

* Re: [RFC PATCH v1 1/2] drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status
  2026-02-19  0:15           ` Yicong Hui
@ 2026-02-19  7:31             ` Christian König
  0 siblings, 0 replies; 10+ messages in thread
From: Christian König @ 2026-02-19  7:31 UTC (permalink / raw)
  To: Yicong Hui, Michel Dänzer
  Cc: dri-devel, linux-kernel, skhan, david.hunter.linux,
	wayland-devel, mesa-dev

On 2/19/26 01:15, Yicong Hui wrote:
>> 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.
> 
>> 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?
> 
>> @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?

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.

> 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?

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.

>> 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.

> 
> Thank you!
> - Yicong
>  


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

end of thread, other threads:[~2026-02-19  7:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-13 12:08 [RFC PATCH v1 0/2] Starter task: Querying errors from Yicong Hui
2026-02-13 12:08 ` [RFC PATCH v1 1/2] drm/syncobj: Add DRM_IOCTL_SYNCOBJ_QUERY_ERROR to query fence error status Yicong Hui
2026-02-17 10:29   ` Christian König
2026-02-17 11:35     ` Yicong Hui
2026-02-17 14:35     ` Michel Dänzer
2026-02-17 14:45       ` Christian König
2026-02-18 14:49         ` Michel Dänzer
2026-02-19  0:15           ` Yicong Hui
2026-02-19  7:31             ` Christian König
2026-02-13 12:08 ` [RFC PATCH v1 2/2] drm/syncobj/doc: Remove starter task from todo list Yicong Hui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®