[Intel-gfx] [PATCH 1/9] drm: kselftest for drm_mm_init()
Chris Wilson
chris at chris-wilson.co.uk
Fri Dec 9 13:08:17 UTC 2016
Simple first test to just exercise initialisation of struct drm_mm.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
drivers/gpu/drm/drm_mm_selftests.h | 1 +
drivers/gpu/drm/test-drm_mm.c | 41 ++++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+)
diff --git a/drivers/gpu/drm/drm_mm_selftests.h b/drivers/gpu/drm/drm_mm_selftests.h
index 0a2e98a33ba0..8a9166f4626f 100644
--- a/drivers/gpu/drm/drm_mm_selftests.h
+++ b/drivers/gpu/drm/drm_mm_selftests.h
@@ -5,4 +5,5 @@
*
* Tests are executed in reverse order by igt/drm_mm
*/
+selftest(init, igt_init)
selftest(sanitycheck, igt_sanitycheck) /* keep last */
diff --git a/drivers/gpu/drm/test-drm_mm.c b/drivers/gpu/drm/test-drm_mm.c
index 049f36b38868..d89615987303 100644
--- a/drivers/gpu/drm/test-drm_mm.c
+++ b/drivers/gpu/drm/test-drm_mm.c
@@ -20,6 +20,47 @@ static int igt_sanitycheck(void *ignored)
return 0;
}
+static int igt_init(void *ignored)
+{
+ struct drm_mm mm;
+ struct drm_mm_node *hole;
+ struct drm_mm_node tmp;
+ u64 start, end;
+ int ret = -EINVAL;
+
+ memset(&mm, 0xff, sizeof(mm));
+ drm_mm_init(&mm, 0, 4096);
+ if (!drm_mm_clean(&mm)) {
+ pr_err("mm not empty on creation\n");
+ goto out;
+ }
+
+ drm_mm_for_each_hole(hole, &mm, start, end) {
+ if (start != 0 || end != 4096) {
+ pr_err("empty mm has incorrect hole, found (%llx, %llx), expect (%llx, %llx)\n",
+ start, end,
+ 0ull, 4096ull);
+ goto out;
+ }
+ }
+
+ memset(&tmp, 0, sizeof(tmp));
+ tmp.start = 0;
+ tmp.size = 4096;
+ ret = drm_mm_reserve_node(&mm, &tmp);
+ if (ret) {
+ pr_err("failed to reserve whole drm_mm\n");
+ goto out;
+ }
+ drm_mm_remove_node(&tmp);
+
+out:
+ if (ret)
+ drm_mm_debug_table(&mm, __func__);
+ drm_mm_takedown(&mm);
+ return ret;
+}
+
#include "drm_selftest.c"
static int __init test_drm_mm_init(void)
--
2.11.0
More information about the Intel-gfx
mailing list