diff mbox

[44/46] drm/i915: Add mock tests for GTT/VMA handling

Message ID 20170202090905.29028-45-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson Feb. 2, 2017, 9:09 a.m. UTC
Use the live tests against the mock ppgtt for quick testing on all
platforms of the VMA layer.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 43 +++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

Comments

Matthew Auld Feb. 8, 2017, 12:12 p.m. UTC | #1
On 2 February 2017 at 09:09, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> Use the live tests against the mock ppgtt for quick testing on all
> platforms of the VMA layer.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Joonas Lahtinen Feb. 9, 2017, 10:53 a.m. UTC | #2
On to, 2017-02-02 at 09:09 +0000, Chris Wilson wrote:
> Use the live tests against the mock ppgtt for quick testing on all
> platforms of the VMA layer.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

> +static int exercise_mock(struct drm_i915_private *i915,
> +			 int (*func)(struct drm_i915_private *i915,
> +				     struct i915_address_space *vm,
> +				     u64 hole_start, u64 hole_end,
> +				     unsigned long end_time))

typedef might not hurt.

Regards, Joonas
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
index c1c7a8837ffd..7ec6fb2208a6 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
@@ -28,6 +28,7 @@ 
 #include "../i915_selftest.h"
 #include "i915_random.h"
 
+#include "mock_context.h"
 #include "mock_drm.h"
 #include "mock_gem_device.h"
 
@@ -694,6 +695,45 @@  static void track_vma_bind(struct i915_vma *vma)
 	list_move_tail(&vma->vm_link, &vma->vm->inactive_list);
 }
 
+static int exercise_mock(struct drm_i915_private *i915,
+			 int (*func)(struct drm_i915_private *i915,
+				     struct i915_address_space *vm,
+				     u64 hole_start, u64 hole_end,
+				     unsigned long end_time))
+{
+	struct i915_gem_context *ctx;
+	struct i915_hw_ppgtt *ppgtt;
+	IGT_TIMEOUT(end_time);
+	int err;
+
+	ctx = mock_context(i915, "mock");
+	if (!ctx)
+		return -ENOMEM;
+
+	ppgtt = ctx->ppgtt;
+	GEM_BUG_ON(!ppgtt);
+
+	err = func(i915, &ppgtt->base, 0, ppgtt->base.total, end_time);
+
+	mock_context_close(ctx);
+	return err;
+}
+
+static int igt_mock_fill(void *arg)
+{
+	return exercise_mock(arg, fill_hole);
+}
+
+static int igt_mock_walk(void *arg)
+{
+	return exercise_mock(arg, walk_hole);
+}
+
+static int igt_mock_drunk(void *arg)
+{
+	return exercise_mock(arg, drunk_hole);
+}
+
 static int igt_gtt_reserve(void *arg)
 {
 	struct drm_i915_private *i915 = arg;
@@ -1067,6 +1107,9 @@  static int igt_gtt_insert(void *arg)
 int i915_gem_gtt_mock_selftests(void)
 {
 	static const struct i915_subtest tests[] = {
+		SUBTEST(igt_mock_drunk),
+		SUBTEST(igt_mock_walk),
+		SUBTEST(igt_mock_fill),
 		SUBTEST(igt_gtt_reserve),
 		SUBTEST(igt_gtt_insert),
 	};