All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Previn <alan.previn.teres.alexis@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Alan Previn <alan.previn.teres.alexis@intel.com>
Subject: [igt-dev] [PATCH i-g-t 05/17] Perform a regular 3d copy as a control checkpoint
Date: Sat, 15 May 2021 16:01:30 -0700	[thread overview]
Message-ID: <20210515230142.1816456-6-alan.previn.teres.alexis@intel.com> (raw)
In-Reply-To: <20210515230142.1816456-1-alan.previn.teres.alexis@intel.com>

As a control checkpoint, allocate buffers to be used
as texture and render target in the 3d engine for a
regular src to dest copy blit and verify buffer pixels.

Signed-off-by: Alan Previn <alan.previn.teres.alexis@intel.com>
---
 tests/i915/gem_pxp.c | 168 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 158 insertions(+), 10 deletions(-)

diff --git a/tests/i915/gem_pxp.c b/tests/i915/gem_pxp.c
index be7b2749..339d4347 100644
--- a/tests/i915/gem_pxp.c
+++ b/tests/i915/gem_pxp.c
@@ -250,6 +250,24 @@ static void test_ctx_alloc_recover_on_protect_on(int i915)
 	igt_assert_eq(ret, -EPERM);
 }
 
+static void test_ctx_mod_regular_to_all_valid(int i915)
+{
+	int ret;
+	uint32_t ctx;
+
+	ret = create_ctx_with_params(i915, false, false, false, false, &ctx);
+	igt_assert_eq(ret, 0);
+	igt_assert_eq(get_ctx_protected_param(i915, ctx), 0);
+	igt_assert_eq(get_ctx_recovery_param(i915, ctx), 1);
+	ret = modify_ctx_param(i915, ctx, CHANGE_PARAM_RECOVERY, false);
+	igt_assert_eq(ret, 0);
+	ret = modify_ctx_param(i915, ctx, CHANGE_PARAM_PROTECTED, true);
+	igt_assert_eq(ret, -EPERM);
+	igt_assert_eq(get_ctx_protected_param(i915, ctx), 0);
+	igt_assert_eq(get_ctx_recovery_param(i915, ctx), 0);
+	gem_context_destroy(i915, ctx);
+}
+
 static void test_ctx_mod_recover_off_to_on(int i915)
 {
 	int ret;
@@ -299,28 +317,145 @@ static void test_ctx_mod_protected_to_all_invalid(int i915)
 	gem_context_destroy(i915, ctx);
 }
 
-static void test_ctx_mod_regular_to_all_valid(int i915)
+static void fill_bo_content(int i915, uint32_t bo, uint32_t size, uint32_t initcolor)
+{
+	uint32_t *ptr, *ptrtmp;
+	int loop = 0;
+
+	ptr = gem_mmap__device_coherent(i915, bo, 0, size, PROT_WRITE);
+	ptrtmp = ptr;
+
+	/* read and count all dword matches till size */
+	while (loop++ < (size/4)) {
+		*ptrtmp = initcolor;
+		++ptrtmp;
+	}
+
+	igt_assert(gem_munmap(ptr, size) == 0);
+}
+
+#define COMPARE_COLOR_READIBLE     1
+#define COMPARE_COLOR_UNREADIBLE   2
+#define COMPARE_N_PIXELS_VERBOSELY 0
+
+static void assert_bo_content_check(int i915, uint32_t bo, int compare_op,
+				    uint32_t size, uint32_t color)
+{
+	uint32_t *ptr, *ptrtmp;
+	int loop = 0, num_matches = 0;
+	uint32_t value;
+	bool op_readible = (compare_op == COMPARE_COLOR_READIBLE);
+
+	ptr = gem_mmap__device_coherent(i915, bo, 0, size, PROT_READ);
+	ptrtmp = ptr;
+
+	if (COMPARE_N_PIXELS_VERBOSELY) {
+		igt_info("--------->>>\n");
+		while (loop < COMPARE_N_PIXELS_VERBOSELY && loop < (size/4)) {
+			value = *ptrtmp;
+			igt_info("Color read = 0x%08x ", value);
+			igt_info("expected %c= 0x%08x)\n", op_readible?'=':'!', color);
+			++ptrtmp;
+			++loop;
+		}
+		igt_info("<<<---------\n");
+		ptrtmp = ptr;
+		loop = 0;
+	}
+
+	/* count all pixels for matches */
+	while (loop++ < (size/4)) {
+		value = *ptrtmp;
+		if (value == color)
+			++num_matches;
+		++ptrtmp;
+	}
+
+	if (op_readible)
+		igt_assert_eq(num_matches, (size/4));
+	else
+		igt_assert_eq(num_matches, 0);
+
+	igt_assert(gem_munmap(ptr, size) == 0);
+}
+
+static uint32_t alloc_and_fill_dest_buff(int i915, bool protected, uint32_t size,
+					 uint32_t init_color)
 {
+	uint32_t bo;
 	int ret;
-	uint32_t ctx;
 
-	ret = create_ctx_with_params(i915, false, false, false, false, &ctx);
+	ret = create_bo_ext(i915, size, protected, &bo);
 	igt_assert_eq(ret, 0);
-	igt_assert_eq(get_ctx_protected_param(i915, ctx), 0);
-	igt_assert_eq(get_ctx_recovery_param(i915, ctx), 1);
-	ret = modify_ctx_param(i915, ctx, CHANGE_PARAM_RECOVERY, false);
+	igt_assert(bo);
+	fill_bo_content(i915, bo, size, init_color);
+	assert_bo_content_check(i915, bo, COMPARE_COLOR_READIBLE, size, init_color);
+
+	return bo;
+}
+
+/*
+ * Rendering tests surface attributes, keep it simple:
+ * page aligned width==stride, thus, and size
+ */
+#define TSTSURF_WIDTH       1024
+#define TSTSURF_HEIGHT      128
+#define TSTSURF_BYTESPP     4
+#define TSTSURF_STRIDE      (TSTSURF_WIDTH*TSTSURF_BYTESPP)
+#define TSTSURF_SIZE        (TSTSURF_STRIDE*TSTSURF_HEIGHT)
+#define TSTSURF_FILLCOLOR1  0xfaceface
+#define TSTSURF_INITCOLOR1  0x12341234
+
+static void test_render_baseline(int i915)
+{
+	uint32_t ctx, srcbo, dstbo;
+	struct intel_buf *srcbuf, *dstbuf;
+	struct buf_ops *bops;
+	struct intel_bb *ibb;
+	uint32_t devid;
+	int ret;
+
+	devid = intel_get_drm_devid(i915);
+	igt_assert(devid);
+
+	bops = buf_ops_create(i915);
+	igt_assert(bops);
+
+	/* Perform a regular 3d copy as a control checkpoint */
+	ret = create_ctx_with_params(i915, false, false, false, false, &ctx);
 	igt_assert_eq(ret, 0);
-	ret = modify_ctx_param(i915, ctx, CHANGE_PARAM_PROTECTED, true);
-	igt_assert_eq(ret, -EPERM);
-	igt_assert_eq(get_ctx_protected_param(i915, ctx), 0);
-	igt_assert_eq(get_ctx_recovery_param(i915, ctx), 0);
+	ibb = intel_bb_create_with_context(i915, ctx, 4096);
+	igt_assert(ibb);
+
+	dstbo = alloc_and_fill_dest_buff(i915, false, TSTSURF_SIZE, TSTSURF_INITCOLOR1);
+	dstbuf = intel_buf_create_using_handle(bops, dstbo, TSTSURF_WIDTH, TSTSURF_HEIGHT,
+					       TSTSURF_BYTESPP*8, 0, I915_TILING_NONE, 0);
+
+	srcbo = alloc_and_fill_dest_buff(i915, false, TSTSURF_SIZE, TSTSURF_FILLCOLOR1);
+	srcbuf = intel_buf_create_using_handle(bops, srcbo, TSTSURF_WIDTH, TSTSURF_HEIGHT,
+					       TSTSURF_BYTESPP*8, 0, I915_TILING_NONE, 0);
+
+	gen12_render_copyfunc(ibb, srcbuf, 0, 0, TSTSURF_WIDTH, TSTSURF_HEIGHT, dstbuf, 0, 0);
+	gem_sync(i915, dstbo);
+
+	assert_bo_content_check(i915, dstbo, COMPARE_COLOR_READIBLE,
+				TSTSURF_SIZE, TSTSURF_FILLCOLOR1);
+
+	intel_bb_destroy(ibb);
+	intel_buf_destroy(srcbuf);
+	gem_close(i915, srcbo);
+	intel_buf_destroy(dstbuf);
+	gem_close(i915, dstbo);
 	gem_context_destroy(i915, ctx);
+	buf_ops_destroy(bops);
 }
 
 igt_main
 {
 	int i915 = -1;
 	bool pxp_supported = false;
+	igt_render_copyfunc_t rendercopy = NULL;
+	uint32_t devid = 0;
 
 	igt_fixture
 	{
@@ -374,6 +509,19 @@ igt_main
 		igt_subtest("reject-modify-context-protection-off-3")
 			test_ctx_mod_protected_to_all_invalid(i915);
 	}
+	igt_subtest_group {
+		igt_fixture {
+			igt_require(pxp_supported);
+			devid = intel_get_drm_devid(i915);
+			igt_assert(devid);
+			rendercopy = igt_get_render_copyfunc(devid);
+			igt_require(rendercopy);
+		}
+
+		igt_describe("Verify protected render operations:");
+		igt_subtest("regular-baseline-src-copy-readible")
+			test_render_baseline(i915);
+	}
 
 	igt_fixture {
 		close(i915);
-- 
2.25.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2021-05-15 23:01 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-15 23:01 [igt-dev] [PATCH i-g-t 00/17] Introduce PXP Test Alan Previn
2021-05-15 23:01 ` [igt-dev] [PATCH i-g-t 01/17] Sync i915_drm.h UAPI from kernel Alan Previn
2021-05-15 23:01 ` [igt-dev] [PATCH i-g-t 02/17] Add PXP UAPI support in i915_drm.h Alan Previn
2021-05-15 23:01 ` [igt-dev] [PATCH i-g-t 03/17] Upadte IOCTL wrapper with DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT Alan Previn
2021-05-15 23:01 ` [igt-dev] [PATCH i-g-t 04/17] Add basic PXP testing of buffer and context alloc Alan Previn
2021-05-17  3:10   ` Dixit, Ashutosh
2021-05-17 10:26   ` Petri Latvala
2021-05-17 14:42     ` Dixit, Ashutosh
2021-05-17 14:50       ` Petri Latvala
2021-05-17 16:34         ` Teres Alexis, Alan Previn
2021-05-15 23:01 ` Alan Previn [this message]
2021-05-15 23:01 ` [igt-dev] [PATCH i-g-t 06/17] Add PXP attribute support in batchbuffer and buffer_ops libs Alan Previn
2021-05-15 23:01 ` [igt-dev] [PATCH i-g-t 07/17] Add MI_SET_APPID instruction definition Alan Previn
2021-05-15 23:01 ` [igt-dev] [PATCH i-g-t 08/17] Enable protected session cmd in gen12_render_copyfunc Alan Previn
2021-05-15 23:01 ` [igt-dev] [PATCH i-g-t 09/17] Add subtest to copy raw source to protected dest Alan Previn
2021-05-15 23:01 ` [igt-dev] [PATCH i-g-t 10/17] Add test where both src and dest are protected Alan Previn
2021-05-15 23:01 ` [igt-dev] [PATCH i-g-t 11/17] Verify PXP teardown occured through suspend-resume Alan Previn
2021-05-15 23:01 ` [igt-dev] [PATCH i-g-t 12/17] Verify execbuf fails with stale PXP context after teardown Alan Previn
2021-05-15 23:01 ` [igt-dev] [PATCH i-g-t 13/17] Verify execbuf fails with stale PXP buffer " Alan Previn
2021-05-15 23:01 ` [igt-dev] [PATCH i-g-t 14/17] Verify execbuf ok with stale prot-buff and regular context Alan Previn
2021-05-15 23:01 ` [igt-dev] [PATCH i-g-t 15/17] Ensure RESET_STAT reports invalidated protected context Alan Previn
2021-05-15 23:01 ` [igt-dev] [PATCH i-g-t 16/17] Verify protected surfaces are dma buffer sharable Alan Previn
2021-05-15 23:01 ` [igt-dev] [PATCH i-g-t 17/17] tests/i915_pxp: CRC validation for display tests Alan Previn
2021-05-16  0:07 ` [igt-dev] ✓ Fi.CI.BAT: success for Introduce PXP Test (rev4) Patchwork
2021-05-16  2:13 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2021-05-18 10:33 [igt-dev] [PATCH i-g-t 00/17] Introduce PXP Test Alan Previn
2021-05-18 10:33 ` [igt-dev] [PATCH i-g-t 05/17] Perform a regular 3d copy as a control checkpoint Alan Previn
2021-06-02 21:37   ` Rodrigo Vivi

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=20210515230142.1816456-6-alan.previn.teres.alexis@intel.com \
    --to=alan.previn.teres.alexis@intel.com \
    --cc=igt-dev@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.