public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH v9 0/7] User readable error codes on atomic_ioctl failure
@ 2026-02-10  9:03 Arun R Murthy
  2026-02-10  9:03 ` [PATCH v9 1/7] drm: Define user readable error codes for atomic ioctl Arun R Murthy
                   ` (7 more replies)
  0 siblings, 8 replies; 16+ messages in thread
From: Arun R Murthy @ 2026-02-10  9:03 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Jani Nikula, Rodrigo Vivi, Joonas Lahtinen,
	Tvrtko Ursulin, xaver.hugl, harry.wentland, uma.shankar,
	louis.chauvet, naveen1.kumar, ramya.krishna.yella
  Cc: dri-devel, intel-gfx, intel-xe, Arun R Murthy, Suraj Kandpal

The series focuses on providing a user readable error value on a failure
in drm_atomic_ioctl(). Usually -EINVAL is returned in most of the error
cases and it is difficult for the user to decode the error and get to
know the real cause for the error. If user gets to know the reason for
the error then corrective measurements can be taken up.

User will have to check for the capability
DRM_CAP_ATOMIC_ERROR_REPORTING before using this feature so as to ensure
that the driver supports failure reporting.

TODO: driver specific error codes are to be added and will be done in
the follow-up patches.

TODO: Once the series is merged the element 'reserved' used for sending
the failure code in struct drm_mode_atomic is to changed to err_code.

The IGT related changes are pushed for review @
https://patchwork.freedesktop.org/series/153330/

    To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
    To: suraj.kandpal@intel.com>
    To: Maxime Ripard <mripard@kernel.org>
    To: Thomas Zimmermann <tzimmermann@suse.de>
    To: David Airlie <airlied@gmail.com>
    To: Simona Vetter <simona@ffwll.ch>
    To: Jani Nikula <jani.nikula@linux.intel.com>
    To: Rodrigo Vivi <rodrigo.vivi@intel.com>
    To: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
    To: Tvrtko Ursulin <tursulin@ursulin.net>
    To: xaver.hugl@kde.org
    To: harry.wentland@amd.com
    To: uma.shankar@intel.com
    To: louis.chauvet@bootlin.com
    To: naveen1.kumar@intel.com
    To: ramya.krishna.yella@intel.com
    Cc: dri-devel@lists.freedesktop.org
    Cc: intel-gfx@lists.freedesktop.org
    Cc: intel-xe@lists.freedesktop.org
    Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>

Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
Changes in v9:
- EDITME: describe what is new in this series revision.
- EDITME: use bulletpoints and terse descriptions.
- Link to v8: https://lore.kernel.org/r/20260129-atomic-v8-0-4cb7b0faa051@intel.com

---
Arun R Murthy (7):
      drm: Define user readable error codes for atomic ioctl
      drm/atomic: Add error_code element in atomic_state
      drm/atomic: Allocate atomic_state at the beginning of atomic_ioctl
      drm/atomic: Call complete_signaling only if prepare_signaling is done
      drm/atomic: Return user readable error in atomic_ioctl
      drm/i915/display: Error codes for async flip failures
      drm: Introduce DRM_CAP_ATOMIC_ERROR_REPORTING

 drivers/gpu/drm/drm_atomic.c                 | 31 ++++++++++
 drivers/gpu/drm/drm_atomic_uapi.c            | 89 ++++++++++++++++++++--------
 drivers/gpu/drm/drm_ioctl.c                  |  3 +
 drivers/gpu/drm/i915/display/intel_display.c | 25 ++++----
 include/drm/drm_atomic.h                     | 10 ++++
 include/uapi/drm/drm.h                       |  7 +++
 include/uapi/drm/drm_mode.h                  | 37 ++++++++++++
 7 files changed, 165 insertions(+), 37 deletions(-)
---
base-commit: 6a3c9a03d943eb112c916c7419a837bc7de3a296
change-id: 20250728-atomic-c9713fd357e4

Best regards,
-- 
Arun R Murthy <arun.r.murthy@intel.com>


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

* [PATCH v9 1/7] drm: Define user readable error codes for atomic ioctl
  2026-02-10  9:03 [PATCH v9 0/7] User readable error codes on atomic_ioctl failure Arun R Murthy
@ 2026-02-10  9:03 ` Arun R Murthy
  2026-02-11  6:31   ` Claude review: " Claude Code Review Bot
  2026-02-10  9:03 ` [PATCH v9 2/7] drm/atomic: Add error_code element in atomic_state Arun R Murthy
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Arun R Murthy @ 2026-02-10  9:03 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Jani Nikula, Rodrigo Vivi, Joonas Lahtinen,
	Tvrtko Ursulin, xaver.hugl, harry.wentland, uma.shankar,
	louis.chauvet, naveen1.kumar, ramya.krishna.yella
  Cc: dri-devel, intel-gfx, intel-xe, Arun R Murthy, Suraj Kandpal

There can be multiple reasons for a failure in atomic_ioctl. Most often
in these error conditions -EINVAL is returned. User/Compositor would
have to blindly take a call on failure of this ioctl so as to use
ALLOW_MODESET or retry. It would be good if user/compositor gets a
readable error code on failure so they can take proper corrections in
the next commit.
The struct drm_mode_atomic is being passed by the user/compositor which
holds the properties for modeset/flip. Reusing the same struct for
returning the error code in case of failure, thereby creation of new
uapi/interface for returning the error code is not required.
The element 'reserved' in the struct drm_mode_atomic is used for
returning the user readable error code. This points to the struct
drm_mode_atomic_err_code. Failure reasons as a string can also be added
on need basis by the variable failure_string in the same struct
drm_mode_atomic_err_code.

v3: Remove fixed error (Jani/Xaver)
v5: Fix kernel-doc (Jani)
v7: Rephrase the kernel doc description (Suraj)
v8: Removed the below enum and suggest to use INVALID_API_USAGE (Xaver)
	DRM_MODE_ATOMIC_ASYNC_NOT_SUPP_PLANE
	DRM_MODE_ATOMIC_ASYNC_MODIFIER_NOT_SUPP

Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com>
---
 include/uapi/drm/drm_mode.h | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 3693d82b5279f1cf14fc2adb538ea830591cc598..71e91d4f05ee8d556e8e7137a6cdcc7f3b261a75 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -45,6 +45,7 @@ extern "C" {
 #define DRM_CONNECTOR_NAME_LEN	32
 #define DRM_DISPLAY_MODE_LEN	32
 #define DRM_PROP_NAME_LEN	32
+#define DRM_MODE_ATOMIC_FAILURE_STRING_LEN	128
 
 #define DRM_MODE_TYPE_BUILTIN	(1<<0) /* deprecated */
 #define DRM_MODE_TYPE_CLOCK_C	((1<<1) | DRM_MODE_TYPE_BUILTIN) /* deprecated */
@@ -1343,6 +1344,42 @@ struct drm_mode_destroy_dumb {
 		DRM_MODE_ATOMIC_NONBLOCK |\
 		DRM_MODE_ATOMIC_ALLOW_MODESET)
 
+/**
+ * enum drm_mode_atomic_failure_codes -  error codes for failures in atomic_ioctl
+ * @DRM_MODE_ATOMIC_INVALID_API_USAGE: invallid API usage(DRM_ATOMIC not
+ *				       enabled, invalid falg, page_flip event
+ *				       with test-only, etc)
+ * @DRM_MODE_ATOMIC_CRTC_NEED_FULL_MODESET: Need full modeset on this crtc
+ * @DRM_MODE_ATOMIC_NEED_FULL_MODESET: Need full modeset on all connected crtc's
+ * @DRM_MODE_ATOMIC_ASYNC_PROP_CHANGED: Property changed in async flip
+ */
+enum drm_mode_atomic_failure_codes {
+	DRM_MODE_ATOMIC_INVALID_API_USAGE,
+	DRM_MODE_ATOMIC_CRTC_NEED_FULL_MODESET,
+	DRM_MODE_ATOMIC_NEED_FULL_MODESET,
+	DRM_MODE_ATOMIC_ASYNC_PROP_CHANGED,
+};
+
+/**
+ * struct drm_mode_atomic_err_code - struct to store the error code
+ *
+ * pointer to this struct will be stored in reserved variable of
+ * struct drm_mode_atomic to report the failure cause to the user.
+ *
+ * @failure_code: error codes defined in enum drm_moide_atomic_failure_code
+ * @failure_objs_ptr: pointer to the drm_object that caused error
+ * @reserved: reserved for future use
+ * @count_objs: count of drm_objects if multiple drm_objects caused error
+ * @failure_string: user readable error message string
+ */
+struct drm_mode_atomic_err_code {
+	__u64 failure_code;
+	__u64 failure_objs_ptr;
+	__u64 reserved;
+	__u32 count_objs;
+	char failure_string[DRM_MODE_ATOMIC_FAILURE_STRING_LEN];
+};
+
 struct drm_mode_atomic {
 	__u32 flags;
 	__u32 count_objs;

-- 
2.25.1


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

* [PATCH v9 2/7] drm/atomic: Add error_code element in atomic_state
  2026-02-10  9:03 [PATCH v9 0/7] User readable error codes on atomic_ioctl failure Arun R Murthy
  2026-02-10  9:03 ` [PATCH v9 1/7] drm: Define user readable error codes for atomic ioctl Arun R Murthy
@ 2026-02-10  9:03 ` Arun R Murthy
  2026-02-11  6:31   ` Claude review: " Claude Code Review Bot
  2026-02-10  9:03 ` [PATCH v9 3/7] drm/atomic: Allocate atomic_state at the beginning of atomic_ioctl Arun R Murthy
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Arun R Murthy @ 2026-02-10  9:03 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Jani Nikula, Rodrigo Vivi, Joonas Lahtinen,
	Tvrtko Ursulin, xaver.hugl, harry.wentland, uma.shankar,
	louis.chauvet, naveen1.kumar, ramya.krishna.yella
  Cc: dri-devel, intel-gfx, intel-xe, Arun R Murthy, Suraj Kandpal

Now that a proper error code will be returned to the user on any failure
in atomic_ioctl() via struct drm_mode_atomic, add a new element
error_code in the struct drm_atomic_state so as to hold the error code
during the atomic_check() and atomic_commit() phases.
New function added to print the error message and fill the struct
err_code with proper error message and error code.

v5: Add a function for printing the error message and filling err_code
    struct
v6: Replace drm_err with drm_dbg_atomic print
v6: Add keyword "commit failed" in dbg msg (Suraj)

Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com>
---
 drivers/gpu/drm/drm_atomic.c | 31 +++++++++++++++++++++++++++++++
 include/drm/drm_atomic.h     | 10 ++++++++++
 2 files changed, 41 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 52738b80ddbeb124896f6124df5628e2ac27faa4..0f4f6071cc305a114654c6973272bbc4b1ff36c8 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -2105,6 +2105,37 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p)
 }
 EXPORT_SYMBOL(drm_state_dump);
 
+/**
+ * drm_mode_atomic_add_error_msg - function to add error code and error string
+ *
+ * @err_code: pointer to struct drm_mode_atomic_err_code that stores the failure
+ *	      reason
+ * @failure_code: failure code in enum drm_mode_atomic_failure_codes
+ * @failure_string: failure reason string message
+ *
+ * Returns: void
+ */
+void drm_mode_atomic_add_error_msg(struct drm_mode_atomic_err_code *err_code,
+				   __u64 failure_code, const char *format, ...)
+{
+	struct drm_atomic_state *state = container_of(err_code,
+						      struct drm_atomic_state,
+						      error_code);
+	va_list varg;
+	char *failure_string;
+
+	err_code->failure_code = failure_code;
+
+	va_start(varg, format);
+	failure_string = kvasprintf(GFP_ATOMIC, format, varg);
+
+	drm_dbg_atomic(state->dev, "Commit failed: %s\n", failure_string);
+	strscpy_pad(err_code->failure_string, failure_string,
+		    sizeof(err_code->failure_string));
+	va_end(varg);
+}
+EXPORT_SYMBOL(drm_mode_atomic_add_error_msg);
+
 #ifdef CONFIG_DEBUG_FS
 static int drm_state_info(struct seq_file *m, void *data)
 {
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 178f8f62c80fc58fe42e8564a716da1a99ddb7da..b080f981ec1afd4b2569aba703c93fc1ea582cbf 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -633,6 +633,13 @@ struct drm_atomic_state {
 	 * commit without blocking.
 	 */
 	struct work_struct commit_work;
+
+	/* @error_code: pointer to struct holding failure reason and string
+	 *
+	 * struct to convey user readable error to the user.
+	 * Error codes defined in enum drm_mode_atomic_failure_flags
+	 */
+	struct drm_mode_atomic_err_code error_code;
 };
 
 void __drm_crtc_commit_free(struct kref *kref);
@@ -1360,5 +1367,8 @@ drm_atomic_get_old_bridge_state(const struct drm_atomic_state *state,
 struct drm_bridge_state *
 drm_atomic_get_new_bridge_state(const struct drm_atomic_state *state,
 				struct drm_bridge *bridge);
+__printf(3, 4)
+void drm_mode_atomic_add_error_msg(struct drm_mode_atomic_err_code *err_code,
+				   __u64 failure_code, const char *format, ...);
 
 #endif /* DRM_ATOMIC_H_ */

-- 
2.25.1


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

* [PATCH v9 3/7] drm/atomic: Allocate atomic_state at the beginning of atomic_ioctl
  2026-02-10  9:03 [PATCH v9 0/7] User readable error codes on atomic_ioctl failure Arun R Murthy
  2026-02-10  9:03 ` [PATCH v9 1/7] drm: Define user readable error codes for atomic ioctl Arun R Murthy
  2026-02-10  9:03 ` [PATCH v9 2/7] drm/atomic: Add error_code element in atomic_state Arun R Murthy
@ 2026-02-10  9:03 ` Arun R Murthy
  2026-02-11  6:31   ` Claude review: " Claude Code Review Bot
  2026-02-10  9:03 ` [PATCH v9 4/7] drm/atomic: Call complete_signaling only if prepare_signaling is done Arun R Murthy
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Arun R Murthy @ 2026-02-10  9:03 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Jani Nikula, Rodrigo Vivi, Joonas Lahtinen,
	Tvrtko Ursulin, xaver.hugl, harry.wentland, uma.shankar,
	louis.chauvet, naveen1.kumar, ramya.krishna.yella
  Cc: dri-devel, intel-gfx, intel-xe, Arun R Murthy

Move atomic_state allocation to the beginning of the atomic_ioctl
to accommodate drm_mode_atomic_err_code usage for returning error
code on failures.
As atomic state is required for drm_mode_atomic_err_code to store the
error codes.

v7: Reframe commit message (Suraj)
v8: Moved the clearing fence change to a different patch (Suraj/Louis)
v9: Free allocated atomic_state before return on error, move this change
from patch 5 (Suraj)

Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
 drivers/gpu/drm/drm_atomic_uapi.c | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index dc013a22bf265512a4fa1edf0ae90931ff0d35e6..c228c9aed75acdb09a80df5dad54440a5c182254 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -1576,6 +1576,14 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
 	if (!drm_core_check_feature(dev, DRIVER_ATOMIC))
 		return -EOPNOTSUPP;
 
+	state = drm_atomic_state_alloc(dev);
+	if (!state)
+		return -ENOMEM;
+
+	drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
+	state->acquire_ctx = &ctx;
+	state->allow_modeset = !!(arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET);
+
 	/* disallow for userspace that has not enabled atomic cap (even
 	 * though this may be a bit overkill, since legacy userspace
 	 * wouldn't know how to call this ioctl)
@@ -1583,24 +1591,28 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
 	if (!file_priv->atomic) {
 		drm_dbg_atomic(dev,
 			       "commit failed: atomic cap not enabled\n");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out;
 	}
 
 	if (arg->flags & ~DRM_MODE_ATOMIC_FLAGS) {
 		drm_dbg_atomic(dev, "commit failed: invalid flag\n");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out;
 	}
 
 	if (arg->reserved) {
 		drm_dbg_atomic(dev, "commit failed: reserved field set\n");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out;
 	}
 
 	if (arg->flags & DRM_MODE_PAGE_FLIP_ASYNC) {
 		if (!dev->mode_config.async_page_flip) {
 			drm_dbg_atomic(dev,
 				       "commit failed: DRM_MODE_PAGE_FLIP_ASYNC not supported\n");
-			return -EINVAL;
+			ret = -EINVAL;
+			goto out;
 		}
 
 		async_flip = true;
@@ -1611,16 +1623,10 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
 			(arg->flags & DRM_MODE_PAGE_FLIP_EVENT)) {
 		drm_dbg_atomic(dev,
 			       "commit failed: page-flip event requested with test-only commit\n");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out;
 	}
 
-	state = drm_atomic_state_alloc(dev);
-	if (!state)
-		return -ENOMEM;
-
-	drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
-	state->acquire_ctx = &ctx;
-	state->allow_modeset = !!(arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET);
 	state->plane_color_pipeline = file_priv->plane_color_pipeline;
 
 retry:

-- 
2.25.1


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

* [PATCH v9 4/7] drm/atomic: Call complete_signaling only if prepare_signaling is done
  2026-02-10  9:03 [PATCH v9 0/7] User readable error codes on atomic_ioctl failure Arun R Murthy
                   ` (2 preceding siblings ...)
  2026-02-10  9:03 ` [PATCH v9 3/7] drm/atomic: Allocate atomic_state at the beginning of atomic_ioctl Arun R Murthy
@ 2026-02-10  9:03 ` Arun R Murthy
  2026-02-11  6:31   ` Claude review: " Claude Code Review Bot
  2026-02-10  9:03 ` [PATCH v9 5/7] drm/atomic: Return user readable error in atomic_ioctl Arun R Murthy
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Arun R Murthy @ 2026-02-10  9:03 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Jani Nikula, Rodrigo Vivi, Joonas Lahtinen,
	Tvrtko Ursulin, xaver.hugl, harry.wentland, uma.shankar,
	louis.chauvet, naveen1.kumar, ramya.krishna.yella
  Cc: dri-devel, intel-gfx, intel-xe, Arun R Murthy, Suraj Kandpal

Upon returning valid error code on atomic_ioctl failure, changes have
been done to goto error/out in cases of error instead of returining to
accommodate returning the failure codes. As part of this change
complete_signaling() will be called as part of cleanup. Check if the
fences are initialized/prepared before completing.

Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com>
---
 drivers/gpu/drm/drm_atomic_uapi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index c228c9aed75acdb09a80df5dad54440a5c182254..bcd12b6eac4f497d2edb8581d9fb0fd54cbef827 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -1569,7 +1569,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
 	struct drm_modeset_acquire_ctx ctx;
 	struct drm_out_fence_state *fence_state;
 	int ret = 0;
-	unsigned int i, j, num_fences;
+	unsigned int i, j, num_fences = 0;
 	bool async_flip = false;
 
 	/* disallow for drivers not supporting atomic: */
@@ -1725,7 +1725,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
 	}
 
 out:
-	complete_signaling(dev, state, fence_state, num_fences, !ret);
+	if (num_fences)
+		complete_signaling(dev, state, fence_state, num_fences, !ret);
 
 	if (ret == -EDEADLK) {
 		drm_atomic_state_clear(state);

-- 
2.25.1


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

* [PATCH v9 5/7] drm/atomic: Return user readable error in atomic_ioctl
  2026-02-10  9:03 [PATCH v9 0/7] User readable error codes on atomic_ioctl failure Arun R Murthy
                   ` (3 preceding siblings ...)
  2026-02-10  9:03 ` [PATCH v9 4/7] drm/atomic: Call complete_signaling only if prepare_signaling is done Arun R Murthy
@ 2026-02-10  9:03 ` Arun R Murthy
  2026-02-11  6:31   ` Claude review: " Claude Code Review Bot
  2026-02-10  9:04 ` [PATCH v9 6/7] drm/i915/display: Error codes for async flip failures Arun R Murthy
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Arun R Murthy @ 2026-02-10  9:03 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Jani Nikula, Rodrigo Vivi, Joonas Lahtinen,
	Tvrtko Ursulin, xaver.hugl, harry.wentland, uma.shankar,
	louis.chauvet, naveen1.kumar, ramya.krishna.yella
  Cc: dri-devel, intel-gfx, intel-xe, Arun R Murthy

Add user readable error codes for failure cases in drm_atomic_ioctl() so
that user can decode the error code and take corrective measurements.

v8: Replaced DRM_MODE_ATOMIC_ASYNC_NOT_SUPP_PLANE,
    DRM_MODE_ATOMIC_ASYNC_MODIFIER_NOT_SUPP with INVALID_API_USAGE
    (Xaver)
v9: Move free atomic_state on error to patch 3 (Suraj)

Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
 drivers/gpu/drm/drm_atomic_uapi.c | 58 +++++++++++++++++++++++++++++----------
 1 file changed, 44 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index bcd12b6eac4f497d2edb8581d9fb0fd54cbef827..f0c3f080f5d66c733dfbfa23f38a22132193adec 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -1196,6 +1196,11 @@ int drm_atomic_set_property(struct drm_atomic_state *state,
 			ret = drm_atomic_connector_get_property(connector, connector_state,
 								prop, &old_val);
 			ret = drm_atomic_check_prop_changes(ret, old_val, prop_value, prop);
+			if (ret) {
+				drm_mode_atomic_add_error_msg(&state->error_code,
+							      DRM_MODE_ATOMIC_ASYNC_PROP_CHANGED,
+							      "property change not allowed in async flip");
+			}
 			break;
 		}
 
@@ -1218,6 +1223,11 @@ int drm_atomic_set_property(struct drm_atomic_state *state,
 			ret = drm_atomic_crtc_get_property(crtc, crtc_state,
 							   prop, &old_val);
 			ret = drm_atomic_check_prop_changes(ret, old_val, prop_value, prop);
+			if (ret) {
+				drm_mode_atomic_add_error_msg(&state->error_code,
+							      DRM_MODE_ATOMIC_ASYNC_PROP_CHANGED,
+							      "property change not allowed in async flip");
+			}
 			break;
 		}
 
@@ -1256,9 +1266,10 @@ int drm_atomic_set_property(struct drm_atomic_state *state,
 					ret = plane_funcs->atomic_async_check(plane, state, true);
 
 				if (ret) {
-					drm_dbg_atomic(prop->dev,
-						       "[PLANE:%d:%s] does not support async flips\n",
-						       obj->id, plane->name);
+					drm_mode_atomic_add_error_msg(&state->error_code,
+								      DRM_MODE_ATOMIC_INVALID_API_USAGE,
+								      "[PLANE:%d:%s] does not support async flip",
+								      obj->id, plane->name);
 					break;
 				}
 			}
@@ -1568,6 +1579,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
 	struct drm_atomic_state *state;
 	struct drm_modeset_acquire_ctx ctx;
 	struct drm_out_fence_state *fence_state;
+	struct drm_mode_atomic_err_code __user *error_code_ptr;
 	int ret = 0;
 	unsigned int i, j, num_fences = 0;
 	bool async_flip = false;
@@ -1576,6 +1588,14 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
 	if (!drm_core_check_feature(dev, DRIVER_ATOMIC))
 		return -EOPNOTSUPP;
 
+	if (!arg->reserved)
+		drm_dbg_atomic(dev,
+			       "memory not allocated for drm_atomic error reporting\n");
+	else
+		/* Update the error code if any error to allow user handling it */
+		error_code_ptr = (struct drm_mode_atomic_err_code __user *)
+				 (unsigned long)arg->reserved;
+
 	state = drm_atomic_state_alloc(dev);
 	if (!state)
 		return -ENOMEM;
@@ -1584,11 +1604,16 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
 	state->acquire_ctx = &ctx;
 	state->allow_modeset = !!(arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET);
 
+	memset(&state->error_code, 0, sizeof(*error_code_ptr));
+
 	/* disallow for userspace that has not enabled atomic cap (even
 	 * though this may be a bit overkill, since legacy userspace
 	 * wouldn't know how to call this ioctl)
 	 */
 	if (!file_priv->atomic) {
+		drm_mode_atomic_add_error_msg(&state->error_code,
+					      DRM_MODE_ATOMIC_INVALID_API_USAGE,
+					      "drm atomic capability not enabled");
 		drm_dbg_atomic(dev,
 			       "commit failed: atomic cap not enabled\n");
 		ret = -EINVAL;
@@ -1596,21 +1621,18 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
 	}
 
 	if (arg->flags & ~DRM_MODE_ATOMIC_FLAGS) {
-		drm_dbg_atomic(dev, "commit failed: invalid flag\n");
-		ret = -EINVAL;
-		goto out;
-	}
-
-	if (arg->reserved) {
-		drm_dbg_atomic(dev, "commit failed: reserved field set\n");
+		drm_mode_atomic_add_error_msg(&state->error_code,
+					      DRM_MODE_ATOMIC_INVALID_API_USAGE,
+					      "invalid flag");
 		ret = -EINVAL;
 		goto out;
 	}
 
 	if (arg->flags & DRM_MODE_PAGE_FLIP_ASYNC) {
 		if (!dev->mode_config.async_page_flip) {
-			drm_dbg_atomic(dev,
-				       "commit failed: DRM_MODE_PAGE_FLIP_ASYNC not supported\n");
+			drm_mode_atomic_add_error_msg(&state->error_code,
+						      DRM_MODE_ATOMIC_INVALID_API_USAGE,
+						      "DRM_MODE_PAGE_FLIP_ASYNC not supported with ATOMIC ioctl");
 			ret = -EINVAL;
 			goto out;
 		}
@@ -1621,8 +1643,9 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
 	/* can't test and expect an event at the same time. */
 	if ((arg->flags & DRM_MODE_ATOMIC_TEST_ONLY) &&
 			(arg->flags & DRM_MODE_PAGE_FLIP_EVENT)) {
-		drm_dbg_atomic(dev,
-			       "commit failed: page-flip event requested with test-only commit\n");
+		drm_mode_atomic_add_error_msg(&state->error_code,
+					      DRM_MODE_ATOMIC_INVALID_API_USAGE,
+					      "page-flip event requested with test-only commit");
 		ret = -EINVAL;
 		goto out;
 	}
@@ -1725,6 +1748,13 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
 	}
 
 out:
+	/* Update the error code if any error to allow user handling it */
+	if (ret < 0 && arg->reserved) {
+		if (copy_to_user(error_code_ptr, &state->error_code,
+				 sizeof(state->error_code)))
+			return -EFAULT;
+	}
+
 	if (num_fences)
 		complete_signaling(dev, state, fence_state, num_fences, !ret);
 

-- 
2.25.1


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

* [PATCH v9 6/7] drm/i915/display: Error codes for async flip failures
  2026-02-10  9:03 [PATCH v9 0/7] User readable error codes on atomic_ioctl failure Arun R Murthy
                   ` (4 preceding siblings ...)
  2026-02-10  9:03 ` [PATCH v9 5/7] drm/atomic: Return user readable error in atomic_ioctl Arun R Murthy
@ 2026-02-10  9:04 ` Arun R Murthy
  2026-02-11  6:31   ` Claude review: " Claude Code Review Bot
  2026-02-10  9:04 ` [PATCH v9 7/7] drm: Introduce DRM_CAP_ATOMIC_ERROR_REPORTING Arun R Murthy
  2026-02-11  6:31 ` Claude review: User readable error codes on atomic_ioctl failure Claude Code Review Bot
  7 siblings, 1 reply; 16+ messages in thread
From: Arun R Murthy @ 2026-02-10  9:04 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Jani Nikula, Rodrigo Vivi, Joonas Lahtinen,
	Tvrtko Ursulin, xaver.hugl, harry.wentland, uma.shankar,
	louis.chauvet, naveen1.kumar, ramya.krishna.yella
  Cc: dri-devel, intel-gfx, intel-xe, Arun R Murthy, Suraj Kandpal

For failures in async flip atomic check/commit path return user readable
error codes in struct drm_atomic_state.

v8: Replaced DRM_MODE_ATOMIC_ASYNC_NOT_SUPP_PLANE,
    DRM_MODE_ATOMIC_ASYNC_MODIFIER_NOT_SUPP with INVALUD_API_USAGE
    (Xaver)

Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com>
---
 drivers/gpu/drm/i915/display/intel_display.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 7491e00e385854bde3eb176282e05259cf95b7a3..02ddd7133378ac3c1e3b7ed808beb6e12182e279 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -6016,9 +6016,10 @@ static int intel_async_flip_check_uapi(struct intel_atomic_state *state,
 	}
 
 	if (intel_crtc_needs_modeset(new_crtc_state)) {
-		drm_dbg_kms(display->drm,
-			    "[CRTC:%d:%s] modeset required\n",
-			    crtc->base.base.id, crtc->base.name);
+		drm_mode_atomic_add_error_msg(&state->base.error_code,
+					      DRM_MODE_ATOMIC_CRTC_NEED_FULL_MODESET,
+					      "[CRTC:%d:%s] requires full modeset",
+					      crtc->base.base.id, crtc->base.name);
 		return -EINVAL;
 	}
 
@@ -6085,9 +6086,10 @@ static int intel_async_flip_check_hw(struct intel_atomic_state *state, struct in
 	}
 
 	if (intel_crtc_needs_modeset(new_crtc_state)) {
-		drm_dbg_kms(display->drm,
-			    "[CRTC:%d:%s] modeset required\n",
-			    crtc->base.base.id, crtc->base.name);
+		drm_mode_atomic_add_error_msg(&state->base.error_code,
+					      DRM_MODE_ATOMIC_CRTC_NEED_FULL_MODESET,
+					      "[CRTC:%d:%s] requires full modeset",
+					      crtc->base.base.id, crtc->base.name);
 		return -EINVAL;
 	}
 
@@ -6125,11 +6127,12 @@ static int intel_async_flip_check_hw(struct intel_atomic_state *state, struct in
 
 		if (!intel_plane_can_async_flip(plane, new_plane_state->hw.fb->format,
 						new_plane_state->hw.fb->modifier)) {
-			drm_dbg_kms(display->drm,
-				    "[PLANE:%d:%s] pixel format %p4cc / modifier 0x%llx does not support async flip\n",
-				    plane->base.base.id, plane->base.name,
-				    &new_plane_state->hw.fb->format->format,
-				    new_plane_state->hw.fb->modifier);
+			drm_mode_atomic_add_error_msg(&state->base.error_code,
+						      DRM_MODE_ATOMIC_INVALID_API_USAGE,
+						      "[PLANE:%d:%s] pixel format %p4cc / 0x%llx modifier does not support async flip",
+						      plane->base.base.id, plane->base.name,
+						      &new_plane_state->hw.fb->format->format,
+						      new_plane_state->hw.fb->modifier);
 			return -EINVAL;
 		}
 

-- 
2.25.1


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

* [PATCH v9 7/7] drm: Introduce DRM_CAP_ATOMIC_ERROR_REPORTING
  2026-02-10  9:03 [PATCH v9 0/7] User readable error codes on atomic_ioctl failure Arun R Murthy
                   ` (5 preceding siblings ...)
  2026-02-10  9:04 ` [PATCH v9 6/7] drm/i915/display: Error codes for async flip failures Arun R Murthy
@ 2026-02-10  9:04 ` Arun R Murthy
  2026-02-11  6:31   ` Claude review: " Claude Code Review Bot
  2026-02-11  6:31 ` Claude review: User readable error codes on atomic_ioctl failure Claude Code Review Bot
  7 siblings, 1 reply; 16+ messages in thread
From: Arun R Murthy @ 2026-02-10  9:04 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Jani Nikula, Rodrigo Vivi, Joonas Lahtinen,
	Tvrtko Ursulin, xaver.hugl, harry.wentland, uma.shankar,
	louis.chauvet, naveen1.kumar, ramya.krishna.yella
  Cc: dri-devel, intel-gfx, intel-xe, Arun R Murthy, Suraj Kandpal

The new capability informs users that atomic_ioctl() supports
failure reporting when an error occurs.

Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com>
---
 drivers/gpu/drm/drm_ioctl.c | 3 +++
 include/uapi/drm/drm.h      | 7 +++++++
 2 files changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index ff193155129e7e863888d8958458978566b144f8..59f2b5b53830fd3aadc6e18cf49f0660a99e9c96 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -304,6 +304,9 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 		req->value = drm_core_check_feature(dev, DRIVER_ATOMIC) &&
 			     dev->mode_config.async_page_flip;
 		break;
+	case DRM_CAP_ATOMIC_ERROR_REPORTING:
+		req->value = drm_core_check_feature(dev, DRIVER_ATOMIC) && 1;
+		break;
 	default:
 		return -EINVAL;
 	}
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index 27cc159c1d275c7a7fe057840ef792f30a582bb7..6082410bcabfb4aa37b85e5f03d3611e5aed4aa5 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -812,6 +812,13 @@ struct drm_gem_change_handle {
  * commits.
  */
 #define DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP	0x15
+/**
+ * DRM_CAP_ATOMIC_ERROR_REPORTING
+ *
+ * If set to 1, the driver supports reporting of failure codes on error in
+ * atomic ioctl().
+ */
+#define DRM_CAP_ATOMIC_ERROR_REPORTING	0x16
 
 /* DRM_IOCTL_GET_CAP ioctl argument type */
 struct drm_get_cap {

-- 
2.25.1



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

* Claude review: User readable error codes on atomic_ioctl failure
  2026-02-10  9:03 [PATCH v9 0/7] User readable error codes on atomic_ioctl failure Arun R Murthy
                   ` (6 preceding siblings ...)
  2026-02-10  9:04 ` [PATCH v9 7/7] drm: Introduce DRM_CAP_ATOMIC_ERROR_REPORTING Arun R Murthy
@ 2026-02-11  6:31 ` Claude Code Review Bot
  7 siblings, 0 replies; 16+ messages in thread
From: Claude Code Review Bot @ 2026-02-11  6:31 UTC (permalink / raw)
  To: dri-devel-reviews

Overall Series Review

Subject: User readable error codes on atomic_ioctl failure
Author: Arun R Murthy <arun.r.murthy@intel.com>
Patches: 8
Reviewed: 2026-02-11T16:31:46.766206

---

This v9 patch series introduces user-readable error reporting for DRM atomic ioctl failures. The goal is to provide compositors with detailed error codes instead of generic -EINVAL, enabling better error handling and recovery.

**Series-level Concerns:**

1. **UAPI Misuse of Reserved Field**: The series reuses the `reserved` field in `struct drm_mode_atomic` to pass error information back to userspace. This is problematic:
   - The field is checked to be zero on entry (patch 3 removes this check)
   - Repurposing `reserved` breaks the original design intent and may cause issues with existing userspace
   - Cover letter says "Once the series is merged the element 'reserved' used for sending the failure code in struct drm_mode_atomic is to changed to err_code" - this suggests the naming is wrong but the ABI is being established incorrectly

2. **Memory Allocation Ordering Change**: Patch 3 moves `drm_atomic_state_alloc()` to the beginning of the ioctl, which means state allocation happens before validation checks. This could impact performance in error cases and changes error paths significantly.

3. **Incomplete Coverage**: Only Intel i915 driver errors are implemented (patch 6). The TODO in the cover letter admits driver-specific errors will come later, making this series incomplete for general use.

4. **Error Code Granularity**: The error codes defined are quite coarse-grained and may not provide enough detail for compositors to make intelligent decisions.

5. **v9 Changelog Missing**: Cover letter says "EDITME: describe what is new in this series revision" - the v9 changes are not documented.

---
Generated by Claude Code Patch Reviewer

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

* Claude review: drm: Define user readable error codes for atomic ioctl
  2026-02-10  9:03 ` [PATCH v9 1/7] drm: Define user readable error codes for atomic ioctl Arun R Murthy
@ 2026-02-11  6:31   ` Claude Code Review Bot
  0 siblings, 0 replies; 16+ messages in thread
From: Claude Code Review Bot @ 2026-02-11  6:31 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Issues:**

```c
+/**
+ * enum drm_mode_atomic_failure_codes -  error codes for failures in atomic_ioctl
+ * @DRM_MODE_ATOMIC_INVALID_API_USAGE: invallid API usage(DRM_ATOMIC not
+ *				       enabled, invalid falg, page_flip event
+ *				       with test-only, etc)
```
- **Typo**: "invallid" should be "invalid"
- **Typo**: "falg" should be "flag"
- **Style**: Missing space after "usage" and before the opening parenthesis

```c
+ * @DRM_MODE_ATOMIC_CRTC_NEED_FULL_MODESET: Need full modeset on this crtc
```
- **Consistency**: "Need" should be lowercase to match kernel-doc style

```c
+/**
+ * struct drm_mode_atomic_err_code - struct to store the error code
+ *
+ * pointer to this struct will be stored in reserved variable of
+ * struct drm_mode_atomic to report the failure cause to the user.
```
- **Missing @**: First line should mention "struct to store" in the brief, the detailed description should be below the field descriptions
- Unconventional structure for kernel-doc

```c
+ * @failure_code: error codes defined in enum drm_moide_atomic_failure_code
```
- **Typo**: "drm_moide_atomic_failure_code" should be "drm_mode_atomic_failure_codes"

```c
+struct drm_mode_atomic_err_code {
+	__u64 failure_code;
+	__u64 failure_objs_ptr;
+	__u64 reserved;
+	__u32 count_objs;
+	char failure_string[DRM_MODE_ATOMIC_FAILURE_STRING_LEN];
+};
```
- **ABI Concern**: `failure_objs_ptr` is documented as a pointer but using it from kernel to userspace is complex. How is memory management handled? Who allocates? This needs clarification.
- **Padding**: Structure has implicit padding after `count_objs` before `failure_string`. Should be explicit or reordered.
- **String Safety**: Fixed-size string without explicit null-termination guarantee is risky.

---
Generated by Claude Code Patch Reviewer

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

* Claude review: drm/atomic: Add error_code element in atomic_state
  2026-02-10  9:03 ` [PATCH v9 2/7] drm/atomic: Add error_code element in atomic_state Arun R Murthy
@ 2026-02-11  6:31   ` Claude Code Review Bot
  0 siblings, 0 replies; 16+ messages in thread
From: Claude Code Review Bot @ 2026-02-11  6:31 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Issues:**

```c
+void drm_mode_atomic_add_error_msg(struct drm_mode_atomic_err_code *err_code,
+				   __u64 failure_code, const char *format, ...)
+{
+	struct drm_atomic_state *state = container_of(err_code,
+						      struct drm_atomic_state,
+						      error_code);
```
- **Questionable Design**: Using `container_of` to get back to `drm_atomic_state` is fragile. Why not pass `state` directly?

```c
+	va_list varg;
+	char *failure_string;
+
+	err_code->failure_code = failure_code;
+
+	va_start(varg, format);
+	failure_string = kvasprintf(GFP_ATOMIC, format, varg);
```
- **Memory Leak**: `failure_string` is allocated with `kvasprintf` but never freed
- **NULL Check Missing**: `kvasprintf` can return NULL, not checked before use
- **GFP_ATOMIC**: Why GFP_ATOMIC? The ioctl path should allow GFP_KERNEL

```c
+	drm_dbg_atomic(state->dev, "Commit failed: %s\n", failure_string);
+	strscpy_pad(err_code->failure_string, failure_string,
+		    sizeof(err_code->failure_string));
+	va_end(varg);
+}
```
- **Use After Free Potential**: If `failure_string` is NULL (allocation failed), this crashes
- **Missing kfree**: Memory leak confirmed

---
Generated by Claude Code Patch Reviewer

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

* Claude review: drm/atomic: Allocate atomic_state at the beginning of atomic_ioctl
  2026-02-10  9:03 ` [PATCH v9 3/7] drm/atomic: Allocate atomic_state at the beginning of atomic_ioctl Arun R Murthy
@ 2026-02-11  6:31   ` Claude Code Review Bot
  0 siblings, 0 replies; 16+ messages in thread
From: Claude Code Review Bot @ 2026-02-11  6:31 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Issues:**

```c
+	state = drm_atomic_state_alloc(dev);
+	if (!state)
+		return -ENOMEM;
+
+	drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
+	state->acquire_ctx = &ctx;
+	state->allow_modeset = !!(arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET);
+
 	/* disallow for userspace that has not enabled atomic cap (even
 	 * though this may be a bit overkill, since legacy userspace
 	 * wouldn't know how to call this ioctl)
 	 */
 	if (!file_priv->atomic) {
```
- **Performance Regression**: Now allocating state for requests that will immediately fail validation. This wastes memory and CPU cycles for invalid requests.

```c
-	if (arg->reserved) {
-		drm_dbg_atomic(dev, "commit failed: reserved field set\n");
-		ret = -EINVAL;
-		goto out;
-	}
```
- **ABI Change**: Removing the `reserved` field check fundamentally changes the userspace contract. Old userspace that accidentally sets this field will now have different behavior.
- **Backward Compatibility**: This breaks the principle that reserved fields must be zero.

---
Generated by Claude Code Patch Reviewer

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

* Claude review: drm/atomic: Call complete_signaling only if prepare_signaling is done
  2026-02-10  9:03 ` [PATCH v9 4/7] drm/atomic: Call complete_signaling only if prepare_signaling is done Arun R Murthy
@ 2026-02-11  6:31   ` Claude Code Review Bot
  0 siblings, 0 replies; 16+ messages in thread
From: Claude Code Review Bot @ 2026-02-11  6:31 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Issues:**

```c
-	unsigned int i, j, num_fences;
+	unsigned int i, j, num_fences = 0;
```
- **Correct Fix**: This initializes `num_fences` to handle the new early error paths

```c
 out:
-	complete_signaling(dev, state, fence_state, num_fences, !ret);
+	if (num_fences)
+		complete_signaling(dev, state, fence_state, num_fences, !ret);
```
- **Logic Issue**: `fence_state` may be uninitialized if we goto `out` before `prepare_signaling`. This check doesn't protect against using uninitialized `fence_state` pointer.
- **Should Check**: `if (fence_state)` might be more robust, though checking `num_fences` is probably equivalent if prepare_signaling is the only place it's set.

---
Generated by Claude Code Patch Reviewer

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

* Claude review: drm/atomic: Return user readable error in atomic_ioctl
  2026-02-10  9:03 ` [PATCH v9 5/7] drm/atomic: Return user readable error in atomic_ioctl Arun R Murthy
@ 2026-02-11  6:31   ` Claude Code Review Bot
  0 siblings, 0 replies; 16+ messages in thread
From: Claude Code Review Bot @ 2026-02-11  6:31 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Issues:**

```c
+	if (!arg->reserved)
+		drm_dbg_atomic(dev,
+			       "memory not allocated for drm_atomic error reporting\n");
+	else
+		/* Update the error code if any error to allow user handling it */
+		error_code_ptr = (struct drm_mode_atomic_err_code __user *)
+				 (unsigned long)arg->reserved;
```
- **No Validation**: Userspace pointer is blindly trusted. No `access_ok()` check.
- **Comment After else**: Comment should explain what happens, not repeat what code does
- **Double Cast**: The `(unsigned long)` cast is unnecessary noise

```c
+	memset(&state->error_code, 0, sizeof(*error_code_ptr));
```
- **Size Mismatch**: Using `sizeof(*error_code_ptr)` (userspace size) to clear kernel's `state->error_code`. Should be `sizeof(state->error_code)`. These happen to be the same type, but the pattern is wrong.

```c
	if (!file_priv->atomic) {
+		drm_mode_atomic_add_error_msg(&state->error_code,
+					      DRM_MODE_ATOMIC_INVALID_API_USAGE,
+					      "drm atomic capability not enabled");
		drm_dbg_atomic(dev,
			       "commit failed: atomic cap not enabled\n");
```
- **Duplication**: Error message is duplicated between `add_error_msg` and `drm_dbg_atomic`. The `drm_dbg_atomic` call inside `add_error_msg` already logs.

```c
	if (arg->flags & ~DRM_MODE_ATOMIC_FLAGS) {
-		drm_dbg_atomic(dev, "commit failed: invalid flag\n");
-		ret = -EINVAL;
-		goto out;
-	}
-
-	if (arg->reserved) {
-		drm_dbg_atomic(dev, "commit failed: reserved field set\n");
```
- **Logic Error**: The removal of `arg->reserved` check means old code that validated reserved==0 is gone. This is an ABI break.

```c
+out:
+	/* Update the error code if any error to allow user handling it */
+	if (ret < 0 && arg->reserved) {
+		if (copy_to_user(error_code_ptr, &state->error_code,
+				 sizeof(state->error_code)))
+			return -EFAULT;
+	}
```
- **Cleanup Leak**: Returning -EFAULT directly bypasses remaining cleanup code (modeset locks, state free). Should set `ret = -EFAULT;` and fall through.
- **Error Path**: If `copy_to_user` fails, we're already in an error path and now leaking more resources.

---
Generated by Claude Code Patch Reviewer

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

* Claude review: drm/i915/display: Error codes for async flip failures
  2026-02-10  9:04 ` [PATCH v9 6/7] drm/i915/display: Error codes for async flip failures Arun R Murthy
@ 2026-02-11  6:31   ` Claude Code Review Bot
  0 siblings, 0 replies; 16+ messages in thread
From: Claude Code Review Bot @ 2026-02-11  6:31 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Issues:**

```c
	if (intel_crtc_needs_modeset(new_crtc_state)) {
-		drm_dbg_kms(display->drm,
-			    "[CRTC:%d:%s] modeset required\n",
-			    crtc->base.base.id, crtc->base.name);
+		drm_mode_atomic_add_error_msg(&state->base.error_code,
+					      DRM_MODE_ATOMIC_CRTC_NEED_FULL_MODESET,
+					      "[CRTC:%d:%s] requires full modeset",
+					      crtc->base.base.id, crtc->base.name);
```
- **Inconsistent Logging**: Original used `drm_dbg_kms`, now uses `drm_dbg_atomic` (inside add_error_msg). This changes which debug category the message appears in.
- **Message Change**: "modeset required" vs "requires full modeset" - why change?

```c
+			drm_mode_atomic_add_error_msg(&state->base.error_code,
+						      DRM_MODE_ATOMIC_INVALID_API_USAGE,
+						      "[PLANE:%d:%s] pixel format %p4cc / 0x%llx modifier does not support async flip",
```
- **Format String**: Reordering format string from `%p4cc / modifier 0x%llx` to `%p4cc / 0x%llx modifier` is unnecessary and makes it harder to review.
- **Message Truncation Risk**: This is a long message that may be truncated to 128 chars.

---
Generated by Claude Code Patch Reviewer

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

* Claude review: drm: Introduce DRM_CAP_ATOMIC_ERROR_REPORTING
  2026-02-10  9:04 ` [PATCH v9 7/7] drm: Introduce DRM_CAP_ATOMIC_ERROR_REPORTING Arun R Murthy
@ 2026-02-11  6:31   ` Claude Code Review Bot
  0 siblings, 0 replies; 16+ messages in thread
From: Claude Code Review Bot @ 2026-02-11  6:31 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Issues:**

```c
+	case DRM_CAP_ATOMIC_ERROR_REPORTING:
+		req->value = drm_core_check_feature(dev, DRIVER_ATOMIC) && 1;
+		break;
```
- **Redundant && 1**: `drm_core_check_feature` already returns bool/int. The `&& 1` is unnecessary.
- **Incomplete**: This cap says "I support error reporting" but doesn't tell userspace:
  - What error codes are supported
  - What fields in the error struct are valid
  - Which drivers actually implement it (only i915 in this series)

```c
+/**
+ * DRM_CAP_ATOMIC_ERROR_REPORTING
+ *
+ * If set to 1, the driver supports reporting of failure codes on error in
+ * atomic ioctl().
+ */
+#define DRM_CAP_ATOMIC_ERROR_REPORTING	0x16
```
- **Vague Documentation**: Doesn't explain:
  - How to use the feature (set `reserved` field)
  - What the error struct contains
  - Version/compatibility information

**Summary of Major Issues:**

1. Memory leak in patch 2 (kvasprintf never freed)
2. Resource leak in patch 5 (early return bypasses cleanup)
3. ABI breakage by repurposing `reserved` field
4. Missing input validation (userspace pointer not checked)
5. Inconsistent error handling patterns
6. Typos in documentation
7. Incomplete implementation (Intel only)
8. Performance regression (allocate state for invalid requests)

---
Generated by Claude Code Patch Reviewer

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

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

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-10  9:03 [PATCH v9 0/7] User readable error codes on atomic_ioctl failure Arun R Murthy
2026-02-10  9:03 ` [PATCH v9 1/7] drm: Define user readable error codes for atomic ioctl Arun R Murthy
2026-02-11  6:31   ` Claude review: " Claude Code Review Bot
2026-02-10  9:03 ` [PATCH v9 2/7] drm/atomic: Add error_code element in atomic_state Arun R Murthy
2026-02-11  6:31   ` Claude review: " Claude Code Review Bot
2026-02-10  9:03 ` [PATCH v9 3/7] drm/atomic: Allocate atomic_state at the beginning of atomic_ioctl Arun R Murthy
2026-02-11  6:31   ` Claude review: " Claude Code Review Bot
2026-02-10  9:03 ` [PATCH v9 4/7] drm/atomic: Call complete_signaling only if prepare_signaling is done Arun R Murthy
2026-02-11  6:31   ` Claude review: " Claude Code Review Bot
2026-02-10  9:03 ` [PATCH v9 5/7] drm/atomic: Return user readable error in atomic_ioctl Arun R Murthy
2026-02-11  6:31   ` Claude review: " Claude Code Review Bot
2026-02-10  9:04 ` [PATCH v9 6/7] drm/i915/display: Error codes for async flip failures Arun R Murthy
2026-02-11  6:31   ` Claude review: " Claude Code Review Bot
2026-02-10  9:04 ` [PATCH v9 7/7] drm: Introduce DRM_CAP_ATOMIC_ERROR_REPORTING Arun R Murthy
2026-02-11  6:31   ` Claude review: " Claude Code Review Bot
2026-02-11  6:31 ` Claude review: User readable error codes on atomic_ioctl failure Claude Code Review Bot

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