---
drivers/gpu/drm/tests/drm_exec_test.c | 36 +++++++++++++++++++++------
1 file changed, 29 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/tests/drm_exec_test.c b/drivers/gpu/drm/tests/drm_exec_test.c
index 727ac267682e..df31f89a7945 100644
--- a/drivers/gpu/drm/tests/drm_exec_test.c
+++ b/drivers/gpu/drm/tests/drm_exec_test.c
@@ -12,11 +12,31 @@
#include <drm/drm_exec.h>
#include <drm/drm_device.h>
+#include <drm/drm_drv.h>
#include <drm/drm_gem.h>
+#include <drm/drm_kunit_helpers.h>
#include "../lib/drm_random.h"
-static struct drm_device dev;
+static struct device *dev;
+static struct drm_device *drm;
+
+static int test_init(struct kunit *test)
+{
+ dev = drm_kunit_helper_alloc_device(test);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
+
+ drm = __drm_kunit_helper_alloc_drm_device(test, dev, sizeof(*drm), 0,
+ DRIVER_MODESET);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, drm);
+
+ return 0;
+}
+
+static void test_exit(struct kunit *test)
+{
+ drm_kunit_helper_free_device(test, dev);
+}
static void sanitycheck(struct kunit *test)
{
@@ -33,7 +53,7 @@ static void test_lock(struct kunit *test)
struct drm_exec exec;
int ret;
- drm_gem_private_object_init(&dev, &gobj, PAGE_SIZE);
+ drm_gem_private_object_init(drm, &gobj, PAGE_SIZE);
drm_exec_init(&exec, DRM_EXEC_INTERRUPTIBLE_WAIT);
drm_exec_until_all_locked(&exec) {
@@ -52,7 +72,7 @@ static void test_lock_unlock(struct kunit *test)
struct drm_exec exec;
int ret;
- drm_gem_private_object_init(&dev, &gobj, PAGE_SIZE);
+ drm_gem_private_object_init(drm, &gobj, PAGE_SIZE);
drm_exec_init(&exec, DRM_EXEC_INTERRUPTIBLE_WAIT);
drm_exec_until_all_locked(&exec) {
@@ -78,7 +98,7 @@ static void test_duplicates(struct kunit *test)
struct drm_exec exec;
int ret;
- drm_gem_private_object_init(&dev, &gobj, PAGE_SIZE);
+ drm_gem_private_object_init(drm, &gobj, PAGE_SIZE);
drm_exec_init(&exec, DRM_EXEC_IGNORE_DUPLICATES);
drm_exec_until_all_locked(&exec) {
@@ -106,7 +126,7 @@ static void test_prepare(struct kunit *test)
struct drm_exec exec;
int ret;
- drm_gem_private_object_init(&dev, &gobj, PAGE_SIZE);
+ drm_gem_private_object_init(drm, &gobj, PAGE_SIZE);
drm_exec_init(&exec, DRM_EXEC_INTERRUPTIBLE_WAIT);
drm_exec_until_all_locked(&exec) {
@@ -127,8 +147,8 @@ static void test_prepare_array(struct kunit *test)
struct drm_exec exec;
int ret;
- drm_gem_private_object_init(&dev, &gobj1, PAGE_SIZE);
- drm_gem_private_object_init(&dev, &gobj2, PAGE_SIZE);
+ drm_gem_private_object_init(drm, &gobj1, PAGE_SIZE);
+ drm_gem_private_object_init(drm, &gobj2, PAGE_SIZE);
drm_exec_init(&exec, DRM_EXEC_INTERRUPTIBLE_WAIT);
drm_exec_until_all_locked(&exec)
@@ -150,6 +170,8 @@ static struct kunit_case drm_exec_tests[] = {
static struct kunit_suite drm_exec_test_suite = {
.name = "drm_exec",
+ .init = test_init,
+ .exit = test_exit,
.test_cases = drm_exec_tests,
};