@@ -5,4 +5,4 @@ test-drm_modeset-y := test-drm_modeset_common.o test-drm_plane_helper.o \
test-drm_rect.o
obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o test-drm_cmdline_parser.o \
- test-drm_buddy.o
+ test-drm_buddy.o test-drm_exec.o
new file mode 100644
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* List each unit test as selftest(name, function)
+ *
+ * The name is used as both an enum and expanded as igt__name to create
+ * a module parameter. It must be unique and legal for a C identifier.
+ *
+ * Tests are executed in order by igt/drm_exec
+ */
+selftest(sanitycheck, igt_sanitycheck) /* keep first (selfcheck for igt) */
+selftest(exec_lock1, igt_exec_lock1)
new file mode 100644
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2019 Intel Corporation
+ */
+
+#define pr_fmt(fmt) "drm_exec: " fmt
+
+#include <linux/module.h>
+#include <linux/prime_numbers.h>
+
+#include <drm/drm_exec.h>
+#include <drm/drm_device.h>
+#include <drm/drm_gem.h>
+
+#include "../lib/drm_random.h"
+
+#define TESTS "drm_exec_selftests.h"
+#include "drm_selftest.h"
+
+static struct drm_device dev;
+
+static int igt_sanitycheck(void *ignored)
+{
+ struct drm_exec exec;
+
+ drm_exec_init(&exec, true);
+ drm_exec_fini(&exec);
+ pr_info("%s - ok!\n", __func__);
+ return 0;
+}
+
+static int igt_exec_lock1(void *ignored)
+{
+ struct drm_gem_object gobj = { };
+ struct drm_exec exec;
+ int ret;
+
+ drm_gem_private_object_init(&dev, &gobj, PAGE_SIZE);
+
+ drm_exec_init(&exec, true);
+ drm_exec_while_not_all_locked(&exec) {
+ ret = drm_exec_prepare_obj(&exec, &gobj, 1);
+ drm_exec_continue_on_contention(&exec);
+ if (ret) {
+ drm_exec_fini(&exec);
+ pr_err("%s - err %d!\n", __func__, ret);
+ return ret;
+ }
+ }
+ drm_exec_fini(&exec);
+ pr_info("%s - ok!\n", __func__);
+ return 0;
+}
+
+#include "drm_selftest.c"
+
+static int __init test_drm_exec_init(void)
+{
+ int err;
+
+ err = run_selftests(selftests, ARRAY_SIZE(selftests), NULL);
+
+ return err > 0 ? 0 : err;
+}
+
+static void __exit test_drm_exec_exit(void)
+{
+}
+
+module_init(test_drm_exec_init);
+module_exit(test_drm_exec_exit);
+
+MODULE_AUTHOR("AMD");
+MODULE_LICENSE("GPL and additional rights");
Largely just the initial skeleton. Signed-off-by: Christian König <christian.koenig@amd.com> --- drivers/gpu/drm/selftests/Makefile | 2 +- .../gpu/drm/selftests/drm_exec_selftests.h | 10 +++ drivers/gpu/drm/selftests/test-drm_exec.c | 74 +++++++++++++++++++ 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/selftests/drm_exec_selftests.h create mode 100644 drivers/gpu/drm/selftests/test-drm_exec.c