All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 16/25] drm/i915/selftests: Mock the engine sorting for easy validation
Date: Sun, 10 Nov 2019 18:57:57 +0000	[thread overview]
Message-ID: <20191110185806.17413-16-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20191110185806.17413-1-chris@chris-wilson.co.uk>

To make exploration of different sorting orders and presentation of the
engines via the uabi easier, wrap the basic engine registration into a
mock (aka standalone) selftest.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/gt/intel_engine_user.c   |  4 +
 .../gpu/drm/i915/gt/selftest_engine_user.c    | 86 +++++++++++++++++++
 .../drm/i915/selftests/i915_mock_selftests.h  |  3 +-
 3 files changed, 92 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/i915/gt/selftest_engine_user.c

diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.c b/drivers/gpu/drm/i915/gt/intel_engine_user.c
index 7f7150a733f4..15bb05aa1986 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_user.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_user.c
@@ -293,3 +293,7 @@ unsigned int intel_engines_has_context_isolation(struct drm_i915_private *i915)
 
 	return which;
 }
+
+#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
+#include "selftest_engine_user.c"
+#endif
diff --git a/drivers/gpu/drm/i915/gt/selftest_engine_user.c b/drivers/gpu/drm/i915/gt/selftest_engine_user.c
new file mode 100644
index 000000000000..d11cc6a4af09
--- /dev/null
+++ b/drivers/gpu/drm/i915/gt/selftest_engine_user.c
@@ -0,0 +1,86 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright © 2019 Intel Corporation
+ */
+
+#include "i915_drv.h"
+
+static void destroy_engines(struct drm_i915_private *i915)
+{
+	struct intel_engine_cs *engine, *next;
+
+	rbtree_postorder_for_each_entry_safe(engine, next,
+					     &i915->uabi_engines, uabi_node)
+		kfree(engine);
+}
+
+static int mock_uabi_engines(void *arg)
+{
+	static const u8 limits[] = {
+		[RENDER_CLASS] = 1,
+		[COPY_ENGINE_CLASS] = 1,
+		[VIDEO_DECODE_CLASS] = I915_MAX_VCS,
+		[VIDEO_ENHANCEMENT_CLASS] = I915_MAX_VECS,
+	};
+	struct intel_engine_cs *engine;
+	struct drm_i915_private *i915;
+	unsigned long num_engines;
+	unsigned long found;
+	int c, i;
+	int err = 0;
+
+	i915 = kzalloc(sizeof(*i915), GFP_KERNEL);
+	if (!i915)
+		return -ENOMEM;
+
+	num_engines = 0;
+	for (c = 0; c < ARRAY_SIZE(limits); c++) {
+		for (i = 0; i < limits[c]; i++) {
+			engine = kzalloc(sizeof(*engine), GFP_KERNEL);
+			if (!engine)
+				goto err;
+
+			engine->i915 = i915;
+
+			engine->class = c;
+			engine->instance = i;
+
+			intel_engine_add_user(engine);
+			num_engines++;
+		}
+	}
+
+err:
+	/* Check as far as we got up to -- will explode if not quite right */
+	intel_engines_driver_register(i915);
+
+	found = 0;
+	for_each_uabi_engine(engine, i915) {
+		pr_info("%s (%d, %d) -> [%d, %d]\n",
+			engine->name,
+			engine->uabi_class,
+			engine->uabi_instance,
+			engine->class,
+			engine->instance);
+		found++;
+	}
+	if (found != num_engines) {
+		pr_err("Registered %lu engines; only found %lu uABI engines\n",
+		       num_engines, found);
+		err = -EINVAL;
+	}
+
+	destroy_engines(i915);
+	kfree(i915);
+	return err;
+}
+
+int intel_engine_user_mock_selftests(void)
+{
+	static const struct i915_subtest tests[] = {
+		SUBTEST(mock_uabi_engines),
+	};
+
+	return i915_subtests(tests, NULL);
+}
diff --git a/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h b/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h
index aa5a0e7f5d9e..9a2dd8350650 100644
--- a/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h
+++ b/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h
@@ -14,7 +14,8 @@ selftest(fence, i915_sw_fence_mock_selftests)
 selftest(scatterlist, scatterlist_mock_selftests)
 selftest(syncmap, i915_syncmap_mock_selftests)
 selftest(uncore, intel_uncore_mock_selftests)
-selftest(engine, intel_engine_cs_mock_selftests)
+selftest(engine_cs, intel_engine_cs_mock_selftests)
+selftest(engine_user, intel_engine_user_mock_selftests)
 selftest(timelines, intel_timeline_mock_selftests)
 selftest(requests, i915_request_mock_selftests)
 selftest(objects, i915_gem_object_mock_selftests)
-- 
2.24.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

WARNING: multiple messages have this Message-ID (diff)
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH 16/25] drm/i915/selftests: Mock the engine sorting for easy validation
Date: Sun, 10 Nov 2019 18:57:57 +0000	[thread overview]
Message-ID: <20191110185806.17413-16-chris@chris-wilson.co.uk> (raw)
Message-ID: <20191110185757.1X_osMQd5OxjUoEBPmIN9g0OyLTiee96QxT10tPHFSI@z> (raw)
In-Reply-To: <20191110185806.17413-1-chris@chris-wilson.co.uk>

To make exploration of different sorting orders and presentation of the
engines via the uabi easier, wrap the basic engine registration into a
mock (aka standalone) selftest.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/gt/intel_engine_user.c   |  4 +
 .../gpu/drm/i915/gt/selftest_engine_user.c    | 86 +++++++++++++++++++
 .../drm/i915/selftests/i915_mock_selftests.h  |  3 +-
 3 files changed, 92 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/i915/gt/selftest_engine_user.c

diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.c b/drivers/gpu/drm/i915/gt/intel_engine_user.c
index 7f7150a733f4..15bb05aa1986 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_user.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_user.c
@@ -293,3 +293,7 @@ unsigned int intel_engines_has_context_isolation(struct drm_i915_private *i915)
 
 	return which;
 }
+
+#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
+#include "selftest_engine_user.c"
+#endif
diff --git a/drivers/gpu/drm/i915/gt/selftest_engine_user.c b/drivers/gpu/drm/i915/gt/selftest_engine_user.c
new file mode 100644
index 000000000000..d11cc6a4af09
--- /dev/null
+++ b/drivers/gpu/drm/i915/gt/selftest_engine_user.c
@@ -0,0 +1,86 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright © 2019 Intel Corporation
+ */
+
+#include "i915_drv.h"
+
+static void destroy_engines(struct drm_i915_private *i915)
+{
+	struct intel_engine_cs *engine, *next;
+
+	rbtree_postorder_for_each_entry_safe(engine, next,
+					     &i915->uabi_engines, uabi_node)
+		kfree(engine);
+}
+
+static int mock_uabi_engines(void *arg)
+{
+	static const u8 limits[] = {
+		[RENDER_CLASS] = 1,
+		[COPY_ENGINE_CLASS] = 1,
+		[VIDEO_DECODE_CLASS] = I915_MAX_VCS,
+		[VIDEO_ENHANCEMENT_CLASS] = I915_MAX_VECS,
+	};
+	struct intel_engine_cs *engine;
+	struct drm_i915_private *i915;
+	unsigned long num_engines;
+	unsigned long found;
+	int c, i;
+	int err = 0;
+
+	i915 = kzalloc(sizeof(*i915), GFP_KERNEL);
+	if (!i915)
+		return -ENOMEM;
+
+	num_engines = 0;
+	for (c = 0; c < ARRAY_SIZE(limits); c++) {
+		for (i = 0; i < limits[c]; i++) {
+			engine = kzalloc(sizeof(*engine), GFP_KERNEL);
+			if (!engine)
+				goto err;
+
+			engine->i915 = i915;
+
+			engine->class = c;
+			engine->instance = i;
+
+			intel_engine_add_user(engine);
+			num_engines++;
+		}
+	}
+
+err:
+	/* Check as far as we got up to -- will explode if not quite right */
+	intel_engines_driver_register(i915);
+
+	found = 0;
+	for_each_uabi_engine(engine, i915) {
+		pr_info("%s (%d, %d) -> [%d, %d]\n",
+			engine->name,
+			engine->uabi_class,
+			engine->uabi_instance,
+			engine->class,
+			engine->instance);
+		found++;
+	}
+	if (found != num_engines) {
+		pr_err("Registered %lu engines; only found %lu uABI engines\n",
+		       num_engines, found);
+		err = -EINVAL;
+	}
+
+	destroy_engines(i915);
+	kfree(i915);
+	return err;
+}
+
+int intel_engine_user_mock_selftests(void)
+{
+	static const struct i915_subtest tests[] = {
+		SUBTEST(mock_uabi_engines),
+	};
+
+	return i915_subtests(tests, NULL);
+}
diff --git a/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h b/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h
index aa5a0e7f5d9e..9a2dd8350650 100644
--- a/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h
+++ b/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h
@@ -14,7 +14,8 @@ selftest(fence, i915_sw_fence_mock_selftests)
 selftest(scatterlist, scatterlist_mock_selftests)
 selftest(syncmap, i915_syncmap_mock_selftests)
 selftest(uncore, intel_uncore_mock_selftests)
-selftest(engine, intel_engine_cs_mock_selftests)
+selftest(engine_cs, intel_engine_cs_mock_selftests)
+selftest(engine_user, intel_engine_user_mock_selftests)
 selftest(timelines, intel_timeline_mock_selftests)
 selftest(requests, i915_request_mock_selftests)
 selftest(objects, i915_gem_object_mock_selftests)
-- 
2.24.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2019-11-10 18:58 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-10 18:57 [PATCH 01/25] drm/i915: Protect context while grabbing its name for the request Chris Wilson
2019-11-10 18:57 ` [Intel-gfx] " Chris Wilson
2019-11-10 18:57 ` [PATCH 02/25] drm/i915/gem: Embed context/timeline name inside the GEM context Chris Wilson
2019-11-10 18:57   ` [Intel-gfx] " Chris Wilson
2019-11-11 11:20   ` Mika Kuoppala
2019-11-11 11:20     ` [Intel-gfx] " Mika Kuoppala
2019-11-10 18:57 ` [PATCH 03/25] drm/i915/gem: Update context name on closing Chris Wilson
2019-11-10 18:57   ` [Intel-gfx] " Chris Wilson
2019-11-11 10:47   ` Mika Kuoppala
2019-11-11 10:47     ` [Intel-gfx] " Mika Kuoppala
2019-11-11 10:58     ` Chris Wilson
2019-11-11 10:58       ` [Intel-gfx] " Chris Wilson
2019-11-10 18:57 ` [PATCH 04/25] drm/i915/execlists: Move reset_active() from schedule-out to schedule-in Chris Wilson
2019-11-10 18:57   ` [Intel-gfx] " Chris Wilson
2019-11-10 18:57 ` [PATCH 05/25] drm/i915/pmu: "Frequency" is reported as accumulated cycles Chris Wilson
2019-11-10 18:57   ` [Intel-gfx] " Chris Wilson
2019-11-10 18:57 ` [PATCH 06/25] drm/i915/userptr: Handle unlocked gup retries Chris Wilson
2019-11-10 18:57   ` [Intel-gfx] " Chris Wilson
2019-11-10 18:57 ` [PATCH 07/25] drm/i915: Cancel context if it hangs after it is closed Chris Wilson
2019-11-10 18:57   ` [Intel-gfx] " Chris Wilson
2019-11-11 10:54   ` Mika Kuoppala
2019-11-11 10:54     ` [Intel-gfx] " Mika Kuoppala
2019-11-11 11:04     ` Chris Wilson
2019-11-11 11:04       ` [Intel-gfx] " Chris Wilson
2019-11-11 11:25       ` Mika Kuoppala
2019-11-11 11:25         ` [Intel-gfx] " Mika Kuoppala
2019-11-10 18:57 ` [PATCH 08/25] drm/i915: Show guilty context name on GPU reset Chris Wilson
2019-11-10 18:57   ` [Intel-gfx] " Chris Wilson
2019-11-11 11:26   ` Mika Kuoppala
2019-11-11 11:26     ` [Intel-gfx] " Mika Kuoppala
2019-11-10 18:57 ` [PATCH 09/25] drm/i915/icl: Refine PG_HYSTERESIS Chris Wilson
2019-11-10 18:57   ` [Intel-gfx] " Chris Wilson
2019-11-11 10:59   ` Mika Kuoppala
2019-11-11 10:59     ` [Intel-gfx] " Mika Kuoppala
2019-11-10 18:57 ` [PATCH 10/25] drm/i915/execlists: Reduce barrier on context switch to a wmb() Chris Wilson
2019-11-10 18:57   ` [Intel-gfx] " Chris Wilson
2019-11-11 13:19   ` Joonas Lahtinen
2019-11-11 13:19     ` [Intel-gfx] " Joonas Lahtinen
2019-11-10 18:57 ` [PATCH 11/25] drm/i915/gem: Silence sparse for RCU protection inside the constructor Chris Wilson
2019-11-10 18:57   ` [Intel-gfx] " Chris Wilson
2019-11-10 18:57 ` [PATCH 12/25] drm/i915/userptr: Try to acquire the page lock around set_page_dirty() Chris Wilson
2019-11-10 18:57   ` [Intel-gfx] " Chris Wilson
2019-11-10 18:57 ` [PATCH 13/25] drm/i915: Taint the kernel on dumping the GEM ftrace buffer Chris Wilson
2019-11-10 18:57   ` [Intel-gfx] " Chris Wilson
2019-11-11 12:44   ` Joonas Lahtinen
2019-11-11 12:44     ` [Intel-gfx] " Joonas Lahtinen
2019-11-10 18:57 ` [PATCH 14/25] drm/i915/selftests: Exercise parallel blit operations on a single ctx Chris Wilson
2019-11-10 18:57   ` [Intel-gfx] " Chris Wilson
2019-11-11 12:10   ` Matthew Auld
2019-11-11 12:10     ` [Intel-gfx] " Matthew Auld
2019-11-10 18:57 ` [PATCH 15/25] drm/i915/selftests: Perform some basic cycle counting of MI ops Chris Wilson
2019-11-10 18:57   ` [Intel-gfx] " Chris Wilson
2019-11-11 17:10   ` Matthew Auld
2019-11-11 17:10     ` [Intel-gfx] " Matthew Auld
2019-11-11 17:16     ` Chris Wilson
2019-11-11 17:16       ` [Intel-gfx] " Chris Wilson
2019-11-11 17:20       ` Matthew Auld
2019-11-11 17:20         ` [Intel-gfx] " Matthew Auld
2019-11-10 18:57 ` Chris Wilson [this message]
2019-11-10 18:57   ` [Intel-gfx] [PATCH 16/25] drm/i915/selftests: Mock the engine sorting for easy validation Chris Wilson
2019-11-10 18:57 ` [PATCH 17/25] drm/i915/selftests: Fill all the drm_vma_manager holes Chris Wilson
2019-11-10 18:57   ` [Intel-gfx] " Chris Wilson
2019-11-11 12:01   ` Matthew Auld
2019-11-11 12:01     ` [Intel-gfx] " Matthew Auld
2019-11-11 12:09     ` Chris Wilson
2019-11-11 12:09       ` [Intel-gfx] " Chris Wilson
2019-11-10 18:57 ` [PATCH 18/25] Revert "drm/i915: use a separate context for gpu relocs" Chris Wilson
2019-11-10 18:57   ` [Intel-gfx] " Chris Wilson
2019-11-10 18:58 ` [PATCH 19/25] drm/i915: Use a ctor for TYPESAFE_BY_RCU i915_request Chris Wilson
2019-11-10 18:58   ` [Intel-gfx] " Chris Wilson
2019-11-10 18:58 ` [PATCH 20/25] drm/i915: Drop GEM context as a direct link from i915_request Chris Wilson
2019-11-10 18:58   ` [Intel-gfx] " Chris Wilson
2019-11-10 18:58 ` [PATCH 21/25] drm/i915: Push the use-semaphore marker onto the intel_context Chris Wilson
2019-11-10 18:58   ` [Intel-gfx] " Chris Wilson
2019-11-10 18:58 ` [PATCH 22/25] drm/i915: Remove i915->kernel_context Chris Wilson
2019-11-10 18:58   ` [Intel-gfx] " Chris Wilson
2019-11-10 18:58 ` [PATCH 23/25] drm/i915: Move i915_gem_init_contexts() earlier Chris Wilson
2019-11-10 18:58   ` [Intel-gfx] " Chris Wilson
2019-11-10 18:58 ` [PATCH 24/25] drm/i915/uc: Use an internal buffer for firmware images Chris Wilson
2019-11-10 18:58   ` [Intel-gfx] " Chris Wilson
2019-11-10 18:58 ` [PATCH 25/25] drm/i915/gt: Pull GT initialisation under intel_gt_init() Chris Wilson
2019-11-10 18:58   ` [Intel-gfx] " Chris Wilson
2019-11-10 19:20 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/25] drm/i915: Protect context while grabbing its name for the request Patchwork
2019-11-10 19:20   ` [Intel-gfx] " Patchwork
2019-11-10 19:40 ` ✓ Fi.CI.BAT: success " Patchwork
2019-11-10 19:40   ` [Intel-gfx] " Patchwork
2019-11-11 15:34 ` ✗ Fi.CI.IGT: failure " Patchwork
2019-11-11 15:34   ` [Intel-gfx] " 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=20191110185806.17413-16-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.