public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Jeevan B <jeevan.b@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: arun.r.murthy@intel.com, Jeevan B <jeevan.b@intel.com>
Subject: [PATCH i-g-t 3/3] RFC: tests/kms_atomic_error_code: Add tests for atomic failure reporting
Date: Thu,  9 Apr 2026 15:06:39 +0530	[thread overview]
Message-ID: <20260409093639.27449-4-jeevan.b@intel.com> (raw)
In-Reply-To: <20260409093639.27449-1-jeevan.b@intel.com>

This test validates that, when supported by the kernel, atomic commit
failures that occur during state validation return meaningful failure
codes instead of only -EINVAL. The test checks common failure classes
such as invalid API usage, async property changes, full modeset
requirements, and bandwidth-related limitations.

The test requires DRM_CAP_ATOMIC_ERROR_REPORTING and is skipped entirely
when the capability is not exposed by the driver. Subtests that depend
on optional or hardware-specific behavior skip gracefully when the
kernel does not reach the relevant validation stage.

Signed-off-by: Jeevan B <jeevan.b@intel.com>
---
 tests/kms_atomic_error.c | 156 +++++++++++++++++++++++++++++++++++++++
 tests/meson.build        |   1 +
 2 files changed, 157 insertions(+)
 create mode 100644 tests/kms_atomic_error.c

diff --git a/tests/kms_atomic_error.c b/tests/kms_atomic_error.c
new file mode 100644
index 000000000..fe62d2ce0
--- /dev/null
+++ b/tests/kms_atomic_error.c
@@ -0,0 +1,156 @@
+/**
+ * TEST: kms_atomic_error_code
+ * Category: KMS
+ * Functionality: Atomic
+ * Mega-feature: Atomic error reporting
+ *
+ * SUBTEST: invalid-api-usage
+ * Description: Verify that invalid atomic API usage is reported with
+ * 		DRM_MODE_ATOMIC_INVALID_API_USAGE.
+ *
+ * SUBTEST: need-full-modeset
+ * Description: Verify that atomic commits which require a full modeset
+ * 		are reported with DRM_MODE_ATOMIC_NEED_FULL_MODESET.
+ *
+ * SUBTEST: async-prop-changed
+ * Description: Verify that modifying non async-safe properties in an
+ * 		async atomic commit is reported with
+ * 		DRM_MODE_ATOMIC_ASYNC_PROP_CHANGED.
+ *
+ * SUBTEST: bandwidth-errors
+ * Description: Verify that atomic commit failures caused by bandwidth or
+ * 		resource limitations are reported using one of the
+ * 		bandwidth-related atomic failure codes.
+ */
+
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "igt.h"
+#include "drm.h"
+#include "drmtest.h"
+#include "ioctl_wrappers.h"
+
+IGT_TEST_DESCRIPTION("Validate DRM atomic failure error codes");
+
+typedef struct {
+	int drm_fd;
+} data_t;
+
+static void init_atomic_ioc(struct drm_mode_atomic *ioc,
+			    struct drm_mode_atomic_err_code *err)
+{
+	memset(ioc, 0, sizeof(*ioc));
+	memset(err, 0, sizeof(*err));
+
+	ioc->reserved = to_user_pointer(err);
+}
+
+static void test_invalid_api_usage(data_t *data)
+{
+	struct drm_mode_atomic ioc;
+	struct drm_mode_atomic_err_code err;
+
+	init_atomic_ioc(&ioc, &err);
+
+	ioc.flags = 0xdeadbeef;
+
+	do_ioctl_err(data->drm_fd, DRM_IOCTL_MODE_ATOMIC, &ioc, EINVAL);
+
+	igt_assert_eq(err.failure_code,
+		      DRM_MODE_ATOMIC_INVALID_API_USAGE);
+}
+
+static void test_need_full_modeset(data_t *data)
+{
+	struct drm_mode_atomic ioc;
+	struct drm_mode_atomic_err_code err;
+	int ret;
+
+	init_atomic_ioc(&ioc, &err);
+
+	ret = drmIoctl(data->drm_fd, DRM_IOCTL_MODE_ATOMIC, &ioc);
+
+	if (ret == 0)
+		igt_skip("Atomic commit succeeded; full modeset not required\n");
+
+	igt_assert_eq(err.failure_code,
+		      DRM_MODE_ATOMIC_NEED_FULL_MODESET);
+}
+
+static void test_async_prop_changed(data_t *data)
+{
+	struct drm_mode_atomic ioc;
+	struct drm_mode_atomic_err_code err;
+
+	igt_require(igt_has_drm_cap(data->drm_fd,
+		    DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP));
+
+	init_atomic_ioc(&ioc, &err);
+
+	ioc.flags = DRM_MODE_ATOMIC_NONBLOCK;
+
+	do_ioctl_err(data->drm_fd, DRM_IOCTL_MODE_ATOMIC, &ioc, EINVAL);
+
+	igt_assert_eq(err.failure_code,
+		      DRM_MODE_ATOMIC_ASYNC_PROP_CHANGED);
+}
+
+static void test_bandwidth_errors(data_t *data)
+{
+	struct drm_mode_atomic ioc;
+	struct drm_mode_atomic_err_code err;
+	int ret;
+
+	init_atomic_ioc(&ioc, &err);
+
+	ret = drmIoctl(data->drm_fd, DRM_IOCTL_MODE_ATOMIC, &ioc);
+
+	if (ret == 0)
+		igt_skip("Platform satisfies bandwidth constraints\n");
+
+	switch (err.failure_code) {
+		case DRM_MODE_ATOMIC_SCANOUT_BW:
+		case DRM_MODE_ATTOMIC_CONNECTOR_BW:
+		case DRM_MODE_ATTOMIC_PIPE_BW:
+		case DRM_MODE_ATOMIC_MEMORY_DOMAIN:
+			break;
+		default:
+			igt_assert_f(false,
+				     "Unexpected atomic failure code: %llu\n",
+				     err.failure_code);
+	}
+}
+
+int igt_main()
+{
+	data_t data = {};
+
+	igt_fixture() {
+		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
+
+		igt_require_f(
+				igt_has_drm_cap(data.drm_fd,
+						DRM_CAP_ATOMIC_ERROR_REPORTING),
+						"DRM atomic error code reporting not supported\n");
+	}
+
+	igt_subtest("invalid-api-usage")
+		test_invalid_api_usage(&data);
+
+	igt_subtest("need-full-modeset")
+		test_need_full_modeset(&data);
+
+	igt_subtest("async-prop-changed")
+		test_async_prop_changed(&data);
+
+	igt_subtest("bandwidth-errors")
+		test_bandwidth_errors(&data);
+
+	igt_fixture() {
+		close(data.drm_fd);
+	}
+
+	igt_exit();
+}
diff --git a/tests/meson.build b/tests/meson.build
index 26d9345ec..1bb50ef96 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -21,6 +21,7 @@ test_progs = [
 	'kms_addfb_basic',
 	'kms_async_flips',
 	'kms_atomic',
+        'kms_atomic_error',
 	'kms_atomic_interruptible',
 	'kms_atomic_transition',
 	'kms_bw',
-- 
2.43.0


  parent reply	other threads:[~2026-04-09  9:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-09  9:36 [PATCH i-g-t 0/3] RFC: Add tests for atomic failure error reporting Jeevan B
2026-04-09  9:36 ` [PATCH i-g-t 1/3] DONT_MERGE: include/drm-uapi: Add atomic_ioctl error codes Jeevan B
2026-04-09  9:36 ` [PATCH i-g-t 2/3] DONT_MERGE: include/drm-uapi: Add ERROR_REPORTING capability Jeevan B
2026-04-09  9:36 ` Jeevan B [this message]
2026-04-10  2:49 ` ✓ i915.CI.BAT: success for RFC: Add tests for atomic failure error reporting Patchwork
2026-04-10  2:50 ` ✓ Xe.CI.BAT: " Patchwork
2026-04-10  6:48 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-04-10 21:50 ` ✗ i915.CI.Full: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260409093639.27449-4-jeevan.b@intel.com \
    --to=jeevan.b@intel.com \
    --cc=arun.r.murthy@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox