public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t v6 1/4] test: Add PSR2 selective update tests
@ 2019-02-08  0:53 José Roberto de Souza
  2019-02-08  0:53 ` [igt-dev] [PATCH i-g-t v6 2/4] tests/intel-ci: Add basic PSR2 tests to fast feedback test list José Roberto de Souza
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: José Roberto de Souza @ 2019-02-08  0:53 UTC (permalink / raw)
  To: igt-dev; +Cc: Dhinakaran Pandiyan, Rodrigo Vivi

This tests checks if hardware is able to do selective update when
screen changes.
PSR2 don't trigger interruptions and the 'PSR2 SU status' register
is not kept loaded all the times, so it is necessary keep polling
PSR status debugfs until those values are loaded.

Also from DEEP_SLEEP state HW will not do a seletive update, as
most of the memory/context is lost in deep sleep state hardware will
need to exit PSR mode then wait a configured number of frames to
activate PSR again to then start doing seletive updates, that is why
just one screen change is not enough to pass this tests.

When a selective update happens and the values are loaded and read
from debugfs it is compared with the expected value of seletive
update blocks, if matches the polling is stopped and the test passed
otherwise it will wait until it reachs a maximum number o screen
changes to fail the test.

v2: Using new SU blocks debugfs output

v3:
- removed the timerfd to fail the test, now failing based in a
maximum number of screen changes
- removing thread to read debugfs, read from main thread is enough
- improved commit message

v4:
- getting cairo context for frontbuffer test in prepare()
- droppoing poll(), using blocking timerfd instead

v5:
- Doing a modeset before trying to enable PSR2

v6:
- doing atomic commits to fix(legacy commit is taking more time in
recent kernels causing us to miss the SU when reading debugfs) and
speedup test
- fixed code to skip test when PSR2 is not possile

Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
---
 lib/igt_psr.c          |  29 ++++
 lib/igt_psr.h          |   1 +
 tests/Makefile.sources |   1 +
 tests/kms_psr2_su.c    | 294 +++++++++++++++++++++++++++++++++++++++++
 tests/meson.build      |   1 +
 5 files changed, 326 insertions(+)
 create mode 100644 tests/kms_psr2_su.c

diff --git a/lib/igt_psr.c b/lib/igt_psr.c
index 6ad2c522..b5847bfd 100644
--- a/lib/igt_psr.c
+++ b/lib/igt_psr.c
@@ -178,3 +178,32 @@ bool psr_sink_support(int debugfs_fd, enum psr_mode mode)
 		 */
 		return strstr(buf, "Sink support: yes [0x03]");
 }
+
+#define PSR2_SU_BLOCK_STR_LOOKUP "PSR2 SU blocks:\n0\t"
+
+static bool
+psr2_read_last_num_su_blocks_val(int debugfs_fd, uint16_t *num_su_blocks)
+{
+	char buf[PSR_STATUS_MAX_LEN];
+	char *str;
+	int ret;
+
+	ret = igt_debugfs_simple_read(debugfs_fd, "i915_edp_psr_status", buf,
+				      sizeof(buf));
+	if (ret < 0)
+		return false;
+
+	str = strstr(buf, PSR2_SU_BLOCK_STR_LOOKUP);
+	if (!str)
+		return false;
+
+	str = &str[strlen(PSR2_SU_BLOCK_STR_LOOKUP)];
+	*num_su_blocks = (uint16_t)strtol(str, NULL, 10);
+
+	return true;
+}
+
+bool psr2_wait_su(int debugfs_fd, uint16_t *num_su_blocks)
+{
+	return igt_wait(psr2_read_last_num_su_blocks_val(debugfs_fd, num_su_blocks), 40, 1);
+}
diff --git a/lib/igt_psr.h b/lib/igt_psr.h
index 7e7017bf..49599cf8 100644
--- a/lib/igt_psr.h
+++ b/lib/igt_psr.h
@@ -40,5 +40,6 @@ bool psr_wait_update(int debugfs_fd, enum psr_mode mode);
 bool psr_enable(int debugfs_fd, enum psr_mode);
 bool psr_disable(int debugfs_fd);
 bool psr_sink_support(int debugfs_fd, enum psr_mode);
+bool psr2_wait_su(int debugfs_fd, uint16_t *num_su_blocks);
 
 #endif
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index a234fa5d..d2c4f9fe 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -62,6 +62,7 @@ TESTS_progs = \
 	kms_plane_scaling \
 	kms_properties \
 	kms_psr \
+	kms_psr2_su \
 	kms_pwrite_crc \
 	kms_rmfb \
 	kms_rotation_crc \
diff --git a/tests/kms_psr2_su.c b/tests/kms_psr2_su.c
new file mode 100644
index 00000000..2c75b85b
--- /dev/null
+++ b/tests/kms_psr2_su.c
@@ -0,0 +1,294 @@
+/*
+ * Copyright © 2019 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#include "igt.h"
+#include "igt_sysfs.h"
+#include "igt_psr.h"
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/timerfd.h>
+#include "intel_bufmgr.h"
+
+IGT_TEST_DESCRIPTION("Test PSR2 selective update");
+
+#define SQUARE_SIZE 100
+/* each selective update block is 4 lines tall */
+#define EXPECTED_NUM_SU_BLOCKS ((SQUARE_SIZE / 4) + (SQUARE_SIZE % 4 ? 1 : 0))
+
+/*
+ * Minimum is 15 as the number of frames to active PSR2 could be configured
+ * to 15 frames plus a few more in case we miss a selective update between
+ * debugfs reads.
+ */
+#define MAX_SCREEN_CHANGES 20
+
+enum operations {
+	PAGE_FLIP,
+	FRONTBUFFER,
+	LAST
+};
+
+static const char *op_str(enum operations op)
+{
+	static const char * const name[] = {
+		[PAGE_FLIP] = "page_flip",
+		[FRONTBUFFER] = "frontbuffer"
+	};
+
+	return name[op];
+}
+
+typedef struct {
+	int drm_fd;
+	int debugfs_fd;
+	igt_display_t display;
+	drm_intel_bufmgr *bufmgr;
+	drmModeModeInfo *mode;
+	igt_output_t *output;
+	struct igt_fb fb[2];
+	enum operations op;
+	cairo_t *cr;
+	int change_screen_timerfd;
+	uint32_t screen_changes;
+} data_t;
+
+static void setup_output(data_t *data)
+{
+	igt_display_t *display = &data->display;
+	igt_output_t *output;
+	enum pipe pipe;
+
+	for_each_pipe_with_valid_output(display, pipe, output) {
+		drmModeConnectorPtr c = output->config.connector;
+
+		if (c->connector_type != DRM_MODE_CONNECTOR_eDP)
+			continue;
+
+		igt_output_set_pipe(output, pipe);
+		data->output = output;
+		data->mode = igt_output_get_mode(output);
+
+		return;
+	}
+}
+
+static void display_init(data_t *data)
+{
+	igt_display_require(&data->display, data->drm_fd);
+	setup_output(data);
+}
+
+static void display_fini(data_t *data)
+{
+	igt_display_fini(&data->display);
+}
+
+static void prepare(data_t *data)
+{
+	igt_plane_t *primary;
+
+	/* all green frame */
+	igt_create_color_fb(data->drm_fd,
+			    data->mode->hdisplay, data->mode->vdisplay,
+			    DRM_FORMAT_XRGB8888,
+			    LOCAL_DRM_FORMAT_MOD_NONE,
+			    0.0, 1.0, 0.0,
+			    &data->fb[0]);
+
+	if (data->op == PAGE_FLIP) {
+		cairo_t *cr;
+
+		igt_create_color_fb(data->drm_fd,
+				    data->mode->hdisplay, data->mode->vdisplay,
+				    DRM_FORMAT_XRGB8888,
+				    LOCAL_DRM_FORMAT_MOD_NONE,
+				    0.0, 1.0, 0.0,
+				    &data->fb[1]);
+
+		cr = igt_get_cairo_ctx(data->drm_fd, &data->fb[1]);
+		/* paint a white square */
+		igt_paint_color_alpha(cr, 0, 0, SQUARE_SIZE, SQUARE_SIZE,
+				      1.0, 1.0, 1.0, 1.0);
+		igt_put_cairo_ctx(data->drm_fd,  &data->fb[1], cr);
+	} else if (data->op == FRONTBUFFER) {
+		data->cr = igt_get_cairo_ctx(data->drm_fd, &data->fb[0]);
+	}
+
+	primary = igt_output_get_plane_type(data->output,
+					    DRM_PLANE_TYPE_PRIMARY);
+
+	igt_plane_set_fb(primary, &data->fb[0]);
+	igt_display_commit2(&data->display, COMMIT_ATOMIC);
+
+	data->screen_changes = 0;
+}
+
+static bool update_screen_and_test(data_t *data)
+{
+	uint16_t su_blocks;
+	bool ret = false;
+
+	data->screen_changes++;
+
+	switch (data->op) {
+	case PAGE_FLIP: {
+		igt_plane_t *primary;
+
+		primary = igt_output_get_plane_type(data->output,
+						    DRM_PLANE_TYPE_PRIMARY);
+
+		igt_plane_set_fb(primary, &data->fb[data->screen_changes & 1]);
+		igt_display_commit2(&data->display, COMMIT_ATOMIC);
+		break;
+	}
+	case FRONTBUFFER: {
+		drmModeClip clip;
+
+		clip.x1 = clip.y1 = 0;
+		clip.x2 = clip.y2 = SQUARE_SIZE;
+
+		if (data->screen_changes & 1) {
+			/* go back to all green frame with a square */
+			igt_paint_color_alpha(data->cr, 0, 0, SQUARE_SIZE,
+					      SQUARE_SIZE, 1.0, 1.0, 1.0, 1.0);
+		} else {
+			/* go back to all green frame */
+			igt_paint_color_alpha(data->cr, 0, 0, SQUARE_SIZE,
+					      SQUARE_SIZE, 0, 1.0, 0, 1.0);
+		}
+
+		drmModeDirtyFB(data->drm_fd, data->fb[0].fb_id, &clip, 1);
+		break;
+	}
+	default:
+		igt_assert_f(data->op, "Operation not handled\n");
+	}
+
+	if (psr2_wait_su(data->debugfs_fd, &su_blocks))
+		ret = su_blocks == EXPECTED_NUM_SU_BLOCKS;
+
+	return ret;
+}
+
+static void run(data_t *data)
+{
+	bool result = false;
+
+	igt_assert(psr_wait_entry(data->debugfs_fd, PSR_MODE_2));
+
+	while (data->screen_changes < MAX_SCREEN_CHANGES && !result) {
+		uint64_t exp;
+		int r;
+
+		r = read(data->change_screen_timerfd, &exp, sizeof(exp));
+		if (r == sizeof(uint64_t) && exp)
+			result = update_screen_and_test(data);
+	}
+
+	igt_debug("Screen changes: %u\n", data->screen_changes);
+	igt_assert_f(result,
+		     "No matching selective update blocks read from debugfs\n");
+}
+
+static void cleanup(data_t *data)
+{
+	igt_plane_t *primary;
+
+	primary = igt_output_get_plane_type(data->output,
+					    DRM_PLANE_TYPE_PRIMARY);
+	igt_plane_set_fb(primary, NULL);
+	igt_display_commit2(&data->display, COMMIT_ATOMIC);
+
+	if (data->op == PAGE_FLIP)
+		igt_remove_fb(data->drm_fd, &data->fb[1]);
+	else if (data->op == FRONTBUFFER)
+		igt_put_cairo_ctx(data->drm_fd, &data->fb[0], data->cr);
+
+	igt_remove_fb(data->drm_fd, &data->fb[0]);
+}
+
+int main(int argc, char *argv[])
+{
+	data_t data = {};
+
+	igt_subtest_init_parse_opts(&argc, argv, "", NULL,
+				    NULL, NULL, NULL);
+	igt_skip_on_simulation();
+
+	igt_fixture {
+		struct itimerspec interval;
+		int r;
+
+		data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+		data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
+		kmstest_set_vt_graphics_mode();
+
+		igt_require_f(psr_sink_support(data.debugfs_fd, PSR_MODE_2),
+			      "Sink does not support PSR2\n");
+
+		data.bufmgr = drm_intel_bufmgr_gem_init(data.drm_fd, 4096);
+		igt_assert(data.bufmgr);
+		drm_intel_bufmgr_gem_enable_reuse(data.bufmgr);
+
+		display_init(&data);
+
+		/* Test if PSR2 can be enabled */
+		igt_require_f(psr_enable(data.debugfs_fd, PSR_MODE_2),
+			      "Error enabling PSR2\n");
+		data.op = FRONTBUFFER;
+		prepare(&data);
+		r = psr_wait_entry(data.debugfs_fd, PSR_MODE_2);
+		cleanup(&data);
+		igt_require_f(r, "PSR2 can not be enabled\n");
+
+		/* blocking timerfd */
+		data.change_screen_timerfd = timerfd_create(CLOCK_MONOTONIC, 0);
+		igt_require(data.change_screen_timerfd != -1);
+		/* Changing screen at 30hz to support 30hz panels */
+		interval.it_value.tv_nsec = NSEC_PER_SEC / 30;
+		interval.it_value.tv_sec = 0;
+		interval.it_interval.tv_nsec = interval.it_value.tv_nsec;
+		interval.it_interval.tv_sec = interval.it_value.tv_sec;
+		r = timerfd_settime(data.change_screen_timerfd, 0, &interval, NULL);
+		igt_require_f(r != -1, "Error setting timerfd\n");
+	}
+
+	for (data.op = PAGE_FLIP; data.op < LAST; data.op++) {
+		igt_subtest_f("%s", op_str(data.op)) {
+			prepare(&data);
+			run(&data);
+			cleanup(&data);
+		}
+	}
+
+	igt_fixture {
+		close(data.debugfs_fd);
+		drm_intel_bufmgr_destroy(data.bufmgr);
+		display_fini(&data);
+	}
+
+	igt_exit();
+}
diff --git a/tests/meson.build b/tests/meson.build
index 0f12df26..ec980651 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -49,6 +49,7 @@ test_progs = [
 	'kms_plane_scaling',
 	'kms_properties',
 	'kms_psr',
+	'kms_psr2_su',
 	'kms_pwrite_crc',
 	'kms_rmfb',
 	'kms_rotation_crc',
-- 
2.20.1

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [igt-dev] [PATCH i-g-t v6 2/4] tests/intel-ci: Add basic PSR2 tests to fast feedback test list
  2019-02-08  0:53 [igt-dev] [PATCH i-g-t v6 1/4] test: Add PSR2 selective update tests José Roberto de Souza
@ 2019-02-08  0:53 ` José Roberto de Souza
  2019-02-14  0:23   ` Pandiyan, Dhinakaran via igt-dev
  2019-02-08  0:53 ` [igt-dev] [PATCH i-g-t v6 3/4] tests/psr: Test the switching between all PSR version from debugfs José Roberto de Souza
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: José Roberto de Souza @ 2019-02-08  0:53 UTC (permalink / raw)
  To: igt-dev; +Cc: Dhinakaran Pandiyan, Rodrigo Vivi

Lets run the same PSR1 basic tests for PSR2 to caught PSR2
regressions faster.

Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
---
 tests/intel-ci/fast-feedback.testlist | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/intel-ci/fast-feedback.testlist b/tests/intel-ci/fast-feedback.testlist
index a95d2e95..38f4811e 100644
--- a/tests/intel-ci/fast-feedback.testlist
+++ b/tests/intel-ci/fast-feedback.testlist
@@ -225,6 +225,10 @@ igt@kms_psr@primary_page_flip
 igt@kms_psr@cursor_plane_move
 igt@kms_psr@sprite_plane_onoff
 igt@kms_psr@primary_mmap_gtt
+igt@kms_psr@psr2_primary_page_flip
+igt@kms_psr@psr2_cursor_plane_move
+igt@kms_psr@psr2_sprite_plane_onoff
+igt@kms_psr@psr2_primary_mmap_gtt
 igt@kms_setmode@basic-clone-single-crtc
 igt@pm_backlight@basic-brightness
 igt@pm_rpm@basic-pci-d3-state
-- 
2.20.1

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [igt-dev] [PATCH i-g-t v6 3/4] tests/psr: Test the switching between all PSR version from debugfs
  2019-02-08  0:53 [igt-dev] [PATCH i-g-t v6 1/4] test: Add PSR2 selective update tests José Roberto de Souza
  2019-02-08  0:53 ` [igt-dev] [PATCH i-g-t v6 2/4] tests/intel-ci: Add basic PSR2 tests to fast feedback test list José Roberto de Souza
@ 2019-02-08  0:53 ` José Roberto de Souza
  2019-02-08  0:53 ` [igt-dev] [PATCH i-g-t v6 4/4] DO NOT MERGE: Check result of kms_psr2_su tests José Roberto de Souza
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: José Roberto de Souza @ 2019-02-08  0:53 UTC (permalink / raw)
  To: igt-dev; +Cc: Dhinakaran Pandiyan

A bug was found in the code that handles the switching of PSR modes
from debugfs, the fix was sent to kernel but lets add this test to
avoid future regrestions.

Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
---
 lib/igt_psr.c   | 28 +++++++++++++++++++++++++
 lib/igt_psr.h   |  1 +
 tests/kms_psr.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 84 insertions(+)

diff --git a/lib/igt_psr.c b/lib/igt_psr.c
index b5847bfd..defef63b 100644
--- a/lib/igt_psr.c
+++ b/lib/igt_psr.c
@@ -207,3 +207,31 @@ bool psr2_wait_su(int debugfs_fd, uint16_t *num_su_blocks)
 {
 	return igt_wait(psr2_read_last_num_su_blocks_val(debugfs_fd, num_su_blocks), 40, 1);
 }
+
+/**
+ * Returns true if PSR is enabled(don't mean active) and set mode parameter
+ * with the PSR version that is enabled if not NULL.
+ */
+bool psr_enabled(int debugfs_fd, enum psr_mode *mode)
+{
+	char buf[PSR_STATUS_MAX_LEN];
+	int ret;
+
+	ret = igt_debugfs_simple_read(debugfs_fd, "i915_edp_psr_status", buf,
+				      sizeof(buf));
+	if (ret < 1)
+		return false;
+
+	if (strstr(buf, "PSR mode: disabled"))
+		return false;
+
+	if (!mode)
+		return true;
+
+	if (strstr(buf, "PSR2 enabled"))
+		*mode = PSR_MODE_2;
+	else
+		*mode = PSR_MODE_1;
+
+	return true;
+}
diff --git a/lib/igt_psr.h b/lib/igt_psr.h
index 49599cf8..2e92265d 100644
--- a/lib/igt_psr.h
+++ b/lib/igt_psr.h
@@ -41,5 +41,6 @@ bool psr_enable(int debugfs_fd, enum psr_mode);
 bool psr_disable(int debugfs_fd);
 bool psr_sink_support(int debugfs_fd, enum psr_mode);
 bool psr2_wait_su(int debugfs_fd, uint16_t *num_su_blocks);
+bool psr_enabled(int debugfs_fd, enum psr_mode *mode);
 
 #endif
diff --git a/tests/kms_psr.c b/tests/kms_psr.c
index 3e16a6bf..c7ecb1c1 100644
--- a/tests/kms_psr.c
+++ b/tests/kms_psr.c
@@ -454,6 +454,61 @@ int main(int argc, char *argv[])
 		display_init(&data);
 	}
 
+	igt_subtest_f("debugfs") {
+		enum psr_mode mode;
+
+		igt_require(!data.with_psr_disabled);
+
+		data.test_plane_id = DRM_PLANE_TYPE_PRIMARY;
+		setup_test_plane(&data, data.test_plane_id);
+
+		/*
+		 * Testing all combinations:
+		 * disabled -> PSR1
+		 * disabled -> PSR2
+		 *
+		 * PSR1 -> disabled
+		 * PSR1 -> PSR2
+		 *
+		 * PSR2 -> disabled
+		 * PSR2 -> PSR1
+		 *
+		 * Not testing the default value in debugfs because the result
+		 * of the default value will vary between kernel versions,
+		 * gen version and enable_psr kernel parameter.
+		 */
+		psr_disable(data.debugfs_fd);
+		igt_assert(!psr_enabled(data.debugfs_fd, NULL));
+
+		psr_enable(data.debugfs_fd, PSR_MODE_1);
+		igt_assert(psr_enabled(data.debugfs_fd, &mode));
+		igt_assert(mode == PSR_MODE_1);
+
+		psr_disable(data.debugfs_fd);
+		igt_assert(!psr_enabled(data.debugfs_fd, NULL));
+
+		if (data.supports_psr2) {
+			psr_enable(data.debugfs_fd, PSR_MODE_2);
+			igt_assert(psr_enabled(data.debugfs_fd, &mode));
+			igt_assert(mode == PSR_MODE_2);
+
+			psr_disable(data.debugfs_fd);
+			igt_assert(!psr_enabled(data.debugfs_fd, NULL));
+
+			psr_enable(data.debugfs_fd, PSR_MODE_2);
+			igt_assert(psr_enabled(data.debugfs_fd, &mode));
+			igt_assert(mode == PSR_MODE_2);
+
+			psr_enable(data.debugfs_fd, PSR_MODE_1);
+			igt_assert(psr_enabled(data.debugfs_fd, &mode));
+			igt_assert(mode == PSR_MODE_1);
+
+			psr_enable(data.debugfs_fd, PSR_MODE_2);
+			igt_assert(psr_enabled(data.debugfs_fd, &mode));
+			igt_assert(mode == PSR_MODE_2);
+		}
+	}
+
 	for (data.op_psr_mode = PSR_MODE_1; data.op_psr_mode <= PSR_MODE_2;
 	     data.op_psr_mode++) {
 
-- 
2.20.1

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [igt-dev] [PATCH i-g-t v6 4/4] DO NOT MERGE: Check result of kms_psr2_su tests
  2019-02-08  0:53 [igt-dev] [PATCH i-g-t v6 1/4] test: Add PSR2 selective update tests José Roberto de Souza
  2019-02-08  0:53 ` [igt-dev] [PATCH i-g-t v6 2/4] tests/intel-ci: Add basic PSR2 tests to fast feedback test list José Roberto de Souza
  2019-02-08  0:53 ` [igt-dev] [PATCH i-g-t v6 3/4] tests/psr: Test the switching between all PSR version from debugfs José Roberto de Souza
@ 2019-02-08  0:53 ` José Roberto de Souza
  2019-02-08  1:30 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,v6,1/4] test: Add PSR2 selective update tests Patchwork
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: José Roberto de Souza @ 2019-02-08  0:53 UTC (permalink / raw)
  To: igt-dev

Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
---
 tests/intel-ci/fast-feedback.testlist | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/intel-ci/fast-feedback.testlist b/tests/intel-ci/fast-feedback.testlist
index 38f4811e..0f8cf381 100644
--- a/tests/intel-ci/fast-feedback.testlist
+++ b/tests/intel-ci/fast-feedback.testlist
@@ -229,6 +229,8 @@ igt@kms_psr@psr2_primary_page_flip
 igt@kms_psr@psr2_cursor_plane_move
 igt@kms_psr@psr2_sprite_plane_onoff
 igt@kms_psr@psr2_primary_mmap_gtt
+igt@kms_psr2_su@page_flip
+igt@kms_psr2_su@frontbuffer
 igt@kms_setmode@basic-clone-single-crtc
 igt@pm_backlight@basic-brightness
 igt@pm_rpm@basic-pci-d3-state
-- 
2.20.1

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,v6,1/4] test: Add PSR2 selective update tests
  2019-02-08  0:53 [igt-dev] [PATCH i-g-t v6 1/4] test: Add PSR2 selective update tests José Roberto de Souza
                   ` (2 preceding siblings ...)
  2019-02-08  0:53 ` [igt-dev] [PATCH i-g-t v6 4/4] DO NOT MERGE: Check result of kms_psr2_su tests José Roberto de Souza
@ 2019-02-08  1:30 ` Patchwork
  2019-02-08  5:23 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
  2019-02-14  0:21 ` [igt-dev] [PATCH i-g-t v6 1/4] " Dhinakaran Pandiyan via igt-dev
  5 siblings, 0 replies; 9+ messages in thread
From: Patchwork @ 2019-02-08  1:30 UTC (permalink / raw)
  To: José Roberto de Souza; +Cc: igt-dev

== Series Details ==

Series: series starting with [i-g-t,v6,1/4] test: Add PSR2 selective update tests
URL   : https://patchwork.freedesktop.org/series/56374/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5565 -> IGTPW_2359
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/56374/revisions/1/mbox/

New tests
---------

  New tests have been introduced between CI_DRM_5565 and IGTPW_2359:
Known issues
------------

  Here are the changes found in IGTPW_2359 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_exec_suspend@basic-s4-devices:
    - fi-blb-e6850:       PASS -> INCOMPLETE [fdo#107718]

  
#### Possible fixes ####

  * igt@kms_busy@basic-flip-a:
    - fi-gdg-551:         FAIL [fdo#103182] -> PASS +1

  * igt@kms_frontbuffer_tracking@basic:
    - fi-byt-clapper:     FAIL [fdo#103167] -> PASS

  * igt@pm_rpm@basic-pci-d3-state:
    - fi-bsw-kefka:       {SKIP} [fdo#109271] -> PASS

  * igt@pm_rpm@basic-rte:
    - fi-bsw-kefka:       FAIL [fdo#108800] -> PASS

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
  [fdo#103182]: https://bugs.freedesktop.org/show_bug.cgi?id=103182
  [fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
  [fdo#108800]: https://bugs.freedesktop.org/show_bug.cgi?id=108800
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271


Participating hosts (48 -> 44)
------------------------------

  Missing    (4): fi-icl-y fi-ilk-m540 fi-byt-squawks fi-bsw-cyan 


Build changes
-------------

    * IGT: IGT_4813 -> IGTPW_2359

  CI_DRM_5565: f49184d5453e20258aaacf1d600868c16ee8c744 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_2359: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2359/
  IGT_4813: 09f506726d0e115ee7f4a1604ae71adcf9f12690 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools



== Testlist changes ==

+igt@kms_psr2_su@frontbuffer
+igt@kms_psr2_su@page_flip
+igt@kms_psr@debugfs

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2359/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,v6,1/4] test: Add PSR2 selective update tests
  2019-02-08  0:53 [igt-dev] [PATCH i-g-t v6 1/4] test: Add PSR2 selective update tests José Roberto de Souza
                   ` (3 preceding siblings ...)
  2019-02-08  1:30 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,v6,1/4] test: Add PSR2 selective update tests Patchwork
@ 2019-02-08  5:23 ` Patchwork
  2019-02-14  0:21 ` [igt-dev] [PATCH i-g-t v6 1/4] " Dhinakaran Pandiyan via igt-dev
  5 siblings, 0 replies; 9+ messages in thread
From: Patchwork @ 2019-02-08  5:23 UTC (permalink / raw)
  To: José Roberto de Souza; +Cc: igt-dev

== Series Details ==

Series: series starting with [i-g-t,v6,1/4] test: Add PSR2 selective update tests
URL   : https://patchwork.freedesktop.org/series/56374/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5565_full -> IGTPW_2359_full
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/56374/revisions/1/mbox/

New tests
---------

  New tests have been introduced between CI_DRM_5565_full and IGTPW_2359_full:
Known issues
------------

  Here are the changes found in IGTPW_2359_full that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_exec_big:
    - shard-hsw:          PASS -> TIMEOUT [fdo#107937]

  * igt@kms_available_modes_crc@available_mode_test_crc:
    - shard-apl:          PASS -> FAIL [fdo#106641]
    - shard-glk:          PASS -> FAIL [fdo#106641]
    - shard-kbl:          PASS -> FAIL [fdo#106641]

  * igt@kms_busy@extended-modeset-hang-newfb-render-b:
    - shard-apl:          NOTRUN -> DMESG-WARN [fdo#107956]

  * igt@kms_color@pipe-a-legacy-gamma:
    - shard-kbl:          PASS -> FAIL [fdo#104782] / [fdo#108145]
    - shard-apl:          PASS -> FAIL [fdo#104782] / [fdo#108145]

  * igt@kms_color@pipe-b-degamma:
    - shard-kbl:          PASS -> FAIL [fdo#104782]

  * igt@kms_cursor_crc@cursor-128x128-onscreen:
    - shard-kbl:          PASS -> FAIL [fdo#103232]

  * igt@kms_cursor_crc@cursor-256x256-sliding:
    - shard-glk:          PASS -> FAIL [fdo#103232] +3

  * igt@kms_cursor_crc@cursor-64x21-random:
    - shard-apl:          PASS -> FAIL [fdo#103232] +3

  * igt@kms_cursor_crc@cursor-64x64-suspend:
    - shard-apl:          PASS -> FAIL [fdo#103191] / [fdo#103232]
    - shard-kbl:          PASS -> FAIL [fdo#103191] / [fdo#103232]

  * igt@kms_cursor_crc@cursor-alpha-opaque:
    - shard-glk:          PASS -> FAIL [fdo#109350]

  * igt@kms_flip@2x-flip-vs-modeset-interruptible:
    - shard-hsw:          PASS -> DMESG-WARN [fdo#102614]

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-mmap-cpu:
    - shard-glk:          PASS -> FAIL [fdo#103167] +7

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-pwrite:
    - shard-apl:          PASS -> FAIL [fdo#103167] +3

  * igt@kms_frontbuffer_tracking@fbc-1p-rte:
    - shard-glk:          PASS -> FAIL [fdo#103167] / [fdo#105682]

  * igt@kms_plane_alpha_blend@pipe-a-alpha-transparant-fb:
    - shard-glk:          NOTRUN -> FAIL [fdo#108145]

  * igt@kms_plane_alpha_blend@pipe-b-alpha-opaque-fb:
    - shard-glk:          PASS -> FAIL [fdo#108145] +1

  * igt@kms_universal_plane@universal-plane-pipe-b-functional:
    - shard-apl:          PASS -> FAIL [fdo#103166] +1
    - shard-kbl:          PASS -> FAIL [fdo#103166]

  * igt@kms_universal_plane@universal-plane-pipe-c-functional:
    - shard-glk:          PASS -> FAIL [fdo#103166] +5

  
#### Possible fixes ####

  * igt@gem_ctx_isolation@vcs0-s3:
    - shard-kbl:          INCOMPLETE [fdo#103665] -> PASS

  * igt@gem_eio@reset-stress:
    - shard-hsw:          INCOMPLETE [fdo#103540] / [fdo#109482] -> PASS

  * igt@gem_exec_reuse@contexts:
    - shard-apl:          INCOMPLETE [fdo#103927] -> PASS

  * igt@kms_busy@extended-pageflip-hang-newfb-render-b:
    - shard-kbl:          DMESG-WARN [fdo#103313] / [fdo#105345] -> PASS

  * igt@kms_cursor_crc@cursor-64x64-sliding:
    - shard-glk:          FAIL [fdo#103232] -> PASS +1
    - shard-apl:          FAIL [fdo#103232] -> PASS +1
    - shard-kbl:          FAIL [fdo#103232] -> PASS

  * igt@kms_cursor_crc@cursor-alpha-opaque:
    - shard-apl:          FAIL [fdo#109350] -> PASS

  * igt@kms_frontbuffer_tracking@fbc-2p-primscrn-cur-indfb-move:
    - shard-glk:          FAIL [fdo#103167] -> PASS +3

  * igt@kms_plane_alpha_blend@pipe-c-constant-alpha-max:
    - shard-glk:          FAIL [fdo#108145] -> PASS +2
    - shard-kbl:          FAIL [fdo#108145] -> PASS
    - shard-apl:          FAIL [fdo#108145] -> PASS

  * igt@kms_plane_multiple@atomic-pipe-c-tiling-yf:
    - shard-apl:          FAIL [fdo#103166] -> PASS +2

  * igt@kms_rotation_crc@multiplane-rotation:
    - shard-glk:          DMESG-FAIL [fdo#105763] / [fdo#106538] -> PASS

  * igt@kms_universal_plane@universal-plane-pipe-a-functional:
    - shard-kbl:          FAIL [fdo#103166] -> PASS

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
  [fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
  [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
  [fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
  [fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
  [fdo#103313]: https://bugs.freedesktop.org/show_bug.cgi?id=103313
  [fdo#103540]: https://bugs.freedesktop.org/show_bug.cgi?id=103540
  [fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
  [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
  [fdo#104782]: https://bugs.freedesktop.org/show_bug.cgi?id=104782
  [fdo#105345]: https://bugs.freedesktop.org/show_bug.cgi?id=105345
  [fdo#105682]: https://bugs.freedesktop.org/show_bug.cgi?id=105682
  [fdo#105763]: https://bugs.freedesktop.org/show_bug.cgi?id=105763
  [fdo#106538]: https://bugs.freedesktop.org/show_bug.cgi?id=106538
  [fdo#106641]: https://bugs.freedesktop.org/show_bug.cgi?id=106641
  [fdo#107937]: https://bugs.freedesktop.org/show_bug.cgi?id=107937
  [fdo#107956]: https://bugs.freedesktop.org/show_bug.cgi?id=107956
  [fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
  [fdo#109350]: https://bugs.freedesktop.org/show_bug.cgi?id=109350
  [fdo#109482]: https://bugs.freedesktop.org/show_bug.cgi?id=109482


Participating hosts (6 -> 4)
------------------------------

  Missing    (2): shard-skl shard-iclb 


Build changes
-------------

    * IGT: IGT_4813 -> IGTPW_2359
    * Piglit: piglit_4509 -> None

  CI_DRM_5565: f49184d5453e20258aaacf1d600868c16ee8c744 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_2359: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2359/
  IGT_4813: 09f506726d0e115ee7f4a1604ae71adcf9f12690 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2359/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v6 1/4] test: Add PSR2 selective update tests
  2019-02-08  0:53 [igt-dev] [PATCH i-g-t v6 1/4] test: Add PSR2 selective update tests José Roberto de Souza
                   ` (4 preceding siblings ...)
  2019-02-08  5:23 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
@ 2019-02-14  0:21 ` Dhinakaran Pandiyan via igt-dev
  2019-02-14  0:46   ` Souza, Jose via igt-dev
  5 siblings, 1 reply; 9+ messages in thread
From: Dhinakaran Pandiyan via igt-dev @ 2019-02-14  0:21 UTC (permalink / raw)
  To: José Roberto de Souza, igt-dev; +Cc: Rodrigo Vivi

On Thu, 2019-02-07 at 16:53 -0800, José Roberto de Souza wrote:
> This tests checks if hardware is able to do selective update when
> screen changes.
> PSR2 don't trigger interruptions and the 'PSR2 SU status' register
> is not kept loaded all the times, so it is necessary keep polling
> PSR status debugfs until those values are loaded.
> 
> Also from DEEP_SLEEP state HW will not do a seletive update, as
> most of the memory/context is lost in deep sleep state hardware will
> need to exit PSR mode then wait a configured number of frames to
> activate PSR again to then start doing seletive updates, that is why
> just one screen change is not enough to pass this tests.
> 
> When a selective update happens and the values are loaded and read
> from debugfs it is compared with the expected value of seletive
> update blocks, if matches the polling is stopped and the test passed
> otherwise it will wait until it reachs a maximum number o screen
> changes to fail the test.
> 
> v2: Using new SU blocks debugfs output
> 
> v3:
> - removed the timerfd to fail the test, now failing based in a
> maximum number of screen changes
> - removing thread to read debugfs, read from main thread is enough
> - improved commit message
> 
> v4:
> - getting cairo context for frontbuffer test in prepare()
> - droppoing poll(), using blocking timerfd instead
> 
> v5:
> - Doing a modeset before trying to enable PSR2
> 
> v6:
> - doing atomic commits to fix(legacy commit is taking more time in
> recent kernels causing us to miss the SU when reading debugfs) and
> speedup test
> - fixed code to skip test when PSR2 is not possile

Thanks for making these changes.

> 
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
> Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
> ---
>  lib/igt_psr.c          |  29 ++++
>  lib/igt_psr.h          |   1 +
>  tests/Makefile.sources |   1 +
>  tests/kms_psr2_su.c    | 294
> +++++++++++++++++++++++++++++++++++++++++
>  tests/meson.build      |   1 +
>  5 files changed, 326 insertions(+)
>  create mode 100644 tests/kms_psr2_su.c
> 
> diff --git a/lib/igt_psr.c b/lib/igt_psr.c
> index 6ad2c522..b5847bfd 100644
> --- a/lib/igt_psr.c
> +++ b/lib/igt_psr.c
> @@ -178,3 +178,32 @@ bool psr_sink_support(int debugfs_fd, enum
> psr_mode mode)
>  		 */
>  		return strstr(buf, "Sink support: yes [0x03]");
>  }
> +
> +#define PSR2_SU_BLOCK_STR_LOOKUP "PSR2 SU blocks:\n0\t"
> +
> +static bool
> +psr2_read_last_num_su_blocks_val(int debugfs_fd, uint16_t
> *num_su_blocks)
> +{
> +	char buf[PSR_STATUS_MAX_LEN];
> +	char *str;
> +	int ret;
> +
> +	ret = igt_debugfs_simple_read(debugfs_fd,
> "i915_edp_psr_status", buf,
> +				      sizeof(buf));
> +	if (ret < 0)
> +		return false;
> +
> +	str = strstr(buf, PSR2_SU_BLOCK_STR_LOOKUP);
> +	if (!str)
> +		return false;
> +
> +	str = &str[strlen(PSR2_SU_BLOCK_STR_LOOKUP)];
> +	*num_su_blocks = (uint16_t)strtol(str, NULL, 10);
> +
> +	return true;
> +}
> +
> +bool psr2_wait_su(int debugfs_fd, uint16_t *num_su_blocks)
> +{
> +	return igt_wait(psr2_read_last_num_su_blocks_val(debugfs_fd,
> num_su_blocks), 40, 1);
> +}
> diff --git a/lib/igt_psr.h b/lib/igt_psr.h
> index 7e7017bf..49599cf8 100644
> --- a/lib/igt_psr.h
> +++ b/lib/igt_psr.h
> @@ -40,5 +40,6 @@ bool psr_wait_update(int debugfs_fd, enum psr_mode
> mode);
>  bool psr_enable(int debugfs_fd, enum psr_mode);
>  bool psr_disable(int debugfs_fd);
>  bool psr_sink_support(int debugfs_fd, enum psr_mode);
> +bool psr2_wait_su(int debugfs_fd, uint16_t *num_su_blocks);
>  
>  #endif
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index a234fa5d..d2c4f9fe 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -62,6 +62,7 @@ TESTS_progs = \
>  	kms_plane_scaling \
>  	kms_properties \
>  	kms_psr \
> +	kms_psr2_su \
>  	kms_pwrite_crc \
>  	kms_rmfb \
>  	kms_rotation_crc \
> diff --git a/tests/kms_psr2_su.c b/tests/kms_psr2_su.c
> new file mode 100644
> index 00000000..2c75b85b
> --- /dev/null
> +++ b/tests/kms_psr2_su.c
> @@ -0,0 +1,294 @@
> +/*
> + * Copyright © 2019 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person
> obtaining a
> + * copy of this software and associated documentation files (the
> "Software"),
> + * to deal in the Software without restriction, including without
> limitation
> + * the rights to use, copy, modify, merge, publish, distribute,
> sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom
> the
> + * Software is furnished to do so, subject to the following
> conditions:
> + *
> + * The above copyright notice and this permission notice (including
> the next
> + * paragraph) shall be included in all copies or substantial
> portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO
> EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
> OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> OTHER DEALINGS
> + * IN THE SOFTWARE.
> + *
> + */
> +
> +#include "igt.h"
> +#include "igt_sysfs.h"
> +#include "igt_psr.h"
> +#include <errno.h>
> +#include <stdbool.h>
> +#include <stdio.h>
> +#include <string.h>
> +#include <sys/timerfd.h>
> +#include "intel_bufmgr.h"
> +
> +IGT_TEST_DESCRIPTION("Test PSR2 selective update");
> +
> +#define SQUARE_SIZE 100
> +/* each selective update block is 4 lines tall */
> +#define EXPECTED_NUM_SU_BLOCKS ((SQUARE_SIZE / 4) + (SQUARE_SIZE % 4
> ? 1 : 0))
> +
> +/*
> + * Minimum is 15 as the number of frames to active PSR2 could be
> configured
> + * to 15 frames plus a few more in case we miss a selective update
> between
> + * debugfs reads.
> + */
> +#define MAX_SCREEN_CHANGES 20
> +
> +enum operations {
> +	PAGE_FLIP,
> +	FRONTBUFFER,
> +	LAST
Something like "INVALID" would have made it more obvious?


> +};
> +
> +static const char *op_str(enum operations op)
> +{
> +	static const char * const name[] = {
> +		[PAGE_FLIP] = "page_flip",
> +		[FRONTBUFFER] = "frontbuffer"
> +	};
> +
> +	return name[op];
> +}
> +
> +typedef struct {
> +	int drm_fd;
> +	int debugfs_fd;
> +	igt_display_t display;
> +	drm_intel_bufmgr *bufmgr;
> +	drmModeModeInfo *mode;
> +	igt_output_t *output;
> +	struct igt_fb fb[2];
> +	enum operations op;
> +	cairo_t *cr;
> +	int change_screen_timerfd;
> +	uint32_t screen_changes;
> +} data_t;
> +
> +static void setup_output(data_t *data)
> +{
> +	igt_display_t *display = &data->display;
> +	igt_output_t *output;
> +	enum pipe pipe;
> +
> +	for_each_pipe_with_valid_output(display, pipe, output) {
> +		drmModeConnectorPtr c = output->config.connector;
> +
> +		if (c->connector_type != DRM_MODE_CONNECTOR_eDP)
> +			continue;
> +
> +		igt_output_set_pipe(output, pipe);
> +		data->output = output;
> +		data->mode = igt_output_get_mode(output);
> +
> +		return;
> +	}
> +}
> +
> +static void display_init(data_t *data)
> +{
> +	igt_display_require(&data->display, data->drm_fd);
> +	setup_output(data);
> +}
> +
> +static void display_fini(data_t *data)
> +{
> +	igt_display_fini(&data->display);
> +}
> +
> +static void prepare(data_t *data)
> +{
> +	igt_plane_t *primary;
> +
> +	/* all green frame */
> +	igt_create_color_fb(data->drm_fd,
> +			    data->mode->hdisplay, data->mode->vdisplay,
> +			    DRM_FORMAT_XRGB8888,
> +			    LOCAL_DRM_FORMAT_MOD_NONE,
> +			    0.0, 1.0, 0.0,
> +			    &data->fb[0]);
> +
> +	if (data->op == PAGE_FLIP) {
> +		cairo_t *cr;
> +
> +		igt_create_color_fb(data->drm_fd,
> +				    data->mode->hdisplay, data->mode-
> >vdisplay,
> +				    DRM_FORMAT_XRGB8888,
> +				    LOCAL_DRM_FORMAT_MOD_NONE,
> +				    0.0, 1.0, 0.0,
> +				    &data->fb[1]);
> +
> +		cr = igt_get_cairo_ctx(data->drm_fd, &data->fb[1]);
> +		/* paint a white square */
> +		igt_paint_color_alpha(cr, 0, 0, SQUARE_SIZE,
> SQUARE_SIZE,
> +				      1.0, 1.0, 1.0, 1.0);
> +		igt_put_cairo_ctx(data->drm_fd,  &data->fb[1], cr);
> +	} else if (data->op == FRONTBUFFER) {
> +		data->cr = igt_get_cairo_ctx(data->drm_fd, &data-
> >fb[0]);
> +	}
> +
> +	primary = igt_output_get_plane_type(data->output,
> +					    DRM_PLANE_TYPE_PRIMARY);
> +
> +	igt_plane_set_fb(primary, &data->fb[0]);
> +	igt_display_commit2(&data->display, COMMIT_ATOMIC);
> +
> +	data->screen_changes = 0;
> +}
> +
> +static bool update_screen_and_test(data_t *data)
> +{
> +	uint16_t su_blocks;
> +	bool ret = false;
> +
> +	data->screen_changes++;
> +
> +	switch (data->op) {
> +	case PAGE_FLIP: {
> +		igt_plane_t *primary;
> +
> +		primary = igt_output_get_plane_type(data->output,
> +						    DRM_PLANE_TYPE_PRIM
> ARY);
> +
> +		igt_plane_set_fb(primary, &data->fb[data-
> >screen_changes & 1]);
> +		igt_display_commit2(&data->display, COMMIT_ATOMIC);
> +		break;
> +	}
> +	case FRONTBUFFER: {
> +		drmModeClip clip;
> +
> +		clip.x1 = clip.y1 = 0;
> +		clip.x2 = clip.y2 = SQUARE_SIZE;
> +
> +		if (data->screen_changes & 1) {
> +			/* go back to all green frame with a square */
> +			igt_paint_color_alpha(data->cr, 0, 0,
> SQUARE_SIZE,
> +					      SQUARE_SIZE, 1.0, 1.0,
> 1.0, 1.0);
> +		} else {
> +			/* go back to all green frame */
> +			igt_paint_color_alpha(data->cr, 0, 0,
> SQUARE_SIZE,
> +					      SQUARE_SIZE, 0, 1.0, 0,
> 1.0);
> +		}
> +
> +		drmModeDirtyFB(data->drm_fd, data->fb[0].fb_id, &clip,
> 1);
> +		break;
> +	}
> +	default:
> +		igt_assert_f(data->op, "Operation not handled\n");
> +	}
> +
> +	if (psr2_wait_su(data->debugfs_fd, &su_blocks))
> +		ret = su_blocks == EXPECTED_NUM_SU_BLOCKS;
> +
> +	return ret;
> +}
> +
> +static void run(data_t *data)
> +{
> +	bool result = false;
> +
> +	igt_assert(psr_wait_entry(data->debugfs_fd, PSR_MODE_2));
> +
> +	while (data->screen_changes < MAX_SCREEN_CHANGES && !result) {

nitpick: Updating data->screen_changes here would have made it clear
that we increment it every iteration.

With or without above changes, 
Reviewed-by: Dhinakaran Pandiyan <
dhinakaran.pandiyan@intel.com>
On ICL, 
Tested-by: Dhinakaran Pandiyan <
dhinakaran.pandiyan@intel.com>

> +		uint64_t exp;
> +		int r;
> +
> +		r = read(data->change_screen_timerfd, &exp,
> sizeof(exp));
> +		if (r == sizeof(uint64_t) && exp)
> +			result = update_screen_and_test(data);
> +	}
> +
> +	igt_debug("Screen changes: %u\n", data->screen_changes);
> +	igt_assert_f(result,
> +		     "No matching selective update blocks read from
> debugfs\n");
> +}
> +
> +static void cleanup(data_t *data)
> +{
> +	igt_plane_t *primary;
> +
> +	primary = igt_output_get_plane_type(data->output,
> +					    DRM_PLANE_TYPE_PRIMARY);
> +	igt_plane_set_fb(primary, NULL);
> +	igt_display_commit2(&data->display, COMMIT_ATOMIC);
> +
> +	if (data->op == PAGE_FLIP)
> +		igt_remove_fb(data->drm_fd, &data->fb[1]);
> +	else if (data->op == FRONTBUFFER)
> +		igt_put_cairo_ctx(data->drm_fd, &data->fb[0], data-
> >cr);
> +
> +	igt_remove_fb(data->drm_fd, &data->fb[0]);
> +}
> +
> +int main(int argc, char *argv[])
> +{
> +	data_t data = {};
> +
> +	igt_subtest_init_parse_opts(&argc, argv, "", NULL,
> +				    NULL, NULL, NULL);
> +	igt_skip_on_simulation();
> +
> +	igt_fixture {
> +		struct itimerspec interval;
> +		int r;
> +
> +		data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
> +		data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
> +		kmstest_set_vt_graphics_mode();
> +
> +		igt_require_f(psr_sink_support(data.debugfs_fd,
> PSR_MODE_2),
> +			      "Sink does not support PSR2\n");
> +
> +		data.bufmgr = drm_intel_bufmgr_gem_init(data.drm_fd,
> 4096);
> +		igt_assert(data.bufmgr);
> +		drm_intel_bufmgr_gem_enable_reuse(data.bufmgr);
> +
> +		display_init(&data);
> +
> +		/* Test if PSR2 can be enabled */
> +		igt_require_f(psr_enable(data.debugfs_fd, PSR_MODE_2),
> +			      "Error enabling PSR2\n");
> +		data.op = FRONTBUFFER;
> +		prepare(&data);
> +		r = psr_wait_entry(data.debugfs_fd, PSR_MODE_2);
I would rename this "r" to something more intuitive as assertions get
debug logged.



> +		cleanup(&data);
> +		igt_require_f(r, "PSR2 can not be enabled\n");
> +
> +		/* blocking timerfd */
> +		data.change_screen_timerfd =
> timerfd_create(CLOCK_MONOTONIC, 0);
> +		igt_require(data.change_screen_timerfd != -1);
> +		/* Changing screen at 30hz to support 30hz panels */
> +		interval.it_value.tv_nsec = NSEC_PER_SEC / 30;
> +		interval.it_value.tv_sec = 0;
> +		interval.it_interval.tv_nsec =
> interval.it_value.tv_nsec;
> +		interval.it_interval.tv_sec = interval.it_value.tv_sec;
> +		r = timerfd_settime(data.change_screen_timerfd, 0,
> &interval, NULL);
> +		igt_require_f(r != -1, "Error setting timerfd\n");
> +	}
> +
> +	for (data.op = PAGE_FLIP; data.op < LAST; data.op++) {
> +		igt_subtest_f("%s", op_str(data.op)) {
> +			prepare(&data);
> +			run(&data);
> +			cleanup(&data);
> +		}
> +	}
> +
> +	igt_fixture {
> +		close(data.debugfs_fd);
> +		drm_intel_bufmgr_destroy(data.bufmgr);
> +		display_fini(&data);
> +	}
> +
> +	igt_exit();
> +}
> diff --git a/tests/meson.build b/tests/meson.build
> index 0f12df26..ec980651 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -49,6 +49,7 @@ test_progs = [
>  	'kms_plane_scaling',
>  	'kms_properties',
>  	'kms_psr',
> +	'kms_psr2_su',
>  	'kms_pwrite_crc',
>  	'kms_rmfb',
>  	'kms_rotation_crc',

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v6 2/4] tests/intel-ci: Add basic PSR2 tests to fast feedback test list
  2019-02-08  0:53 ` [igt-dev] [PATCH i-g-t v6 2/4] tests/intel-ci: Add basic PSR2 tests to fast feedback test list José Roberto de Souza
@ 2019-02-14  0:23   ` Pandiyan, Dhinakaran via igt-dev
  0 siblings, 0 replies; 9+ messages in thread
From: Pandiyan, Dhinakaran via igt-dev @ 2019-02-14  0:23 UTC (permalink / raw)
  To: igt-dev@lists.freedesktop.org, Souza, Jose; +Cc: Vivi, Rodrigo

On Thu, 2019-02-07 at 16:53 -0800, José Roberto de Souza wrote:
> Lets run the same PSR1 basic tests for PSR2 to caught PSR2
> regressions faster.
> 
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>

Assuming the tests pass,
Acked-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>

Please get an ack from CI folks too.

-DK

> Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
> ---
>  tests/intel-ci/fast-feedback.testlist | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tests/intel-ci/fast-feedback.testlist b/tests/intel-
> ci/fast-feedback.testlist
> index a95d2e95..38f4811e 100644
> --- a/tests/intel-ci/fast-feedback.testlist
> +++ b/tests/intel-ci/fast-feedback.testlist
> @@ -225,6 +225,10 @@ igt@kms_psr@primary_page_flip
>  igt@kms_psr@cursor_plane_move
>  igt@kms_psr@sprite_plane_onoff
>  igt@kms_psr@primary_mmap_gtt
> +igt@kms_psr@psr2_primary_page_flip
> +igt@kms_psr@psr2_cursor_plane_move
> +igt@kms_psr@psr2_sprite_plane_onoff
> +igt@kms_psr@psr2_primary_mmap_gtt
>  igt@kms_setmode@basic-clone-single-crtc
>  igt@pm_backlight@basic-brightness
>  igt@pm_rpm@basic-pci-d3-state
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v6 1/4] test: Add PSR2 selective update tests
  2019-02-14  0:21 ` [igt-dev] [PATCH i-g-t v6 1/4] " Dhinakaran Pandiyan via igt-dev
@ 2019-02-14  0:46   ` Souza, Jose via igt-dev
  0 siblings, 0 replies; 9+ messages in thread
From: Souza, Jose via igt-dev @ 2019-02-14  0:46 UTC (permalink / raw)
  To: igt-dev@lists.freedesktop.org, Pandiyan, Dhinakaran; +Cc: Vivi, Rodrigo


[-- Attachment #1.1: Type: text/plain, Size: 15136 bytes --]

On Wed, 2019-02-13 at 16:21 -0800, Dhinakaran Pandiyan wrote:
> On Thu, 2019-02-07 at 16:53 -0800, José Roberto de Souza wrote:
> > This tests checks if hardware is able to do selective update when
> > screen changes.
> > PSR2 don't trigger interruptions and the 'PSR2 SU status' register
> > is not kept loaded all the times, so it is necessary keep polling
> > PSR status debugfs until those values are loaded.
> > 
> > Also from DEEP_SLEEP state HW will not do a seletive update, as
> > most of the memory/context is lost in deep sleep state hardware
> > will
> > need to exit PSR mode then wait a configured number of frames to
> > activate PSR again to then start doing seletive updates, that is
> > why
> > just one screen change is not enough to pass this tests.
> > 
> > When a selective update happens and the values are loaded and read
> > from debugfs it is compared with the expected value of seletive
> > update blocks, if matches the polling is stopped and the test
> > passed
> > otherwise it will wait until it reachs a maximum number o screen
> > changes to fail the test.
> > 
> > v2: Using new SU blocks debugfs output
> > 
> > v3:
> > - removed the timerfd to fail the test, now failing based in a
> > maximum number of screen changes
> > - removing thread to read debugfs, read from main thread is enough
> > - improved commit message
> > 
> > v4:
> > - getting cairo context for frontbuffer test in prepare()
> > - droppoing poll(), using blocking timerfd instead
> > 
> > v5:
> > - Doing a modeset before trying to enable PSR2
> > 
> > v6:
> > - doing atomic commits to fix(legacy commit is taking more time in
> > recent kernels causing us to miss the SU when reading debugfs) and
> > speedup test
> > - fixed code to skip test when PSR2 is not possile
> 
> Thanks for making these changes.
> 
> > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
> > Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
> > ---
> >  lib/igt_psr.c          |  29 ++++
> >  lib/igt_psr.h          |   1 +
> >  tests/Makefile.sources |   1 +
> >  tests/kms_psr2_su.c    | 294
> > +++++++++++++++++++++++++++++++++++++++++
> >  tests/meson.build      |   1 +
> >  5 files changed, 326 insertions(+)
> >  create mode 100644 tests/kms_psr2_su.c
> > 
> > diff --git a/lib/igt_psr.c b/lib/igt_psr.c
> > index 6ad2c522..b5847bfd 100644
> > --- a/lib/igt_psr.c
> > +++ b/lib/igt_psr.c
> > @@ -178,3 +178,32 @@ bool psr_sink_support(int debugfs_fd, enum
> > psr_mode mode)
> >  		 */
> >  		return strstr(buf, "Sink support: yes [0x03]");
> >  }
> > +
> > +#define PSR2_SU_BLOCK_STR_LOOKUP "PSR2 SU blocks:\n0\t"
> > +
> > +static bool
> > +psr2_read_last_num_su_blocks_val(int debugfs_fd, uint16_t
> > *num_su_blocks)
> > +{
> > +	char buf[PSR_STATUS_MAX_LEN];
> > +	char *str;
> > +	int ret;
> > +
> > +	ret = igt_debugfs_simple_read(debugfs_fd,
> > "i915_edp_psr_status", buf,
> > +				      sizeof(buf));
> > +	if (ret < 0)
> > +		return false;
> > +
> > +	str = strstr(buf, PSR2_SU_BLOCK_STR_LOOKUP);
> > +	if (!str)
> > +		return false;
> > +
> > +	str = &str[strlen(PSR2_SU_BLOCK_STR_LOOKUP)];
> > +	*num_su_blocks = (uint16_t)strtol(str, NULL, 10);
> > +
> > +	return true;
> > +}
> > +
> > +bool psr2_wait_su(int debugfs_fd, uint16_t *num_su_blocks)
> > +{
> > +	return igt_wait(psr2_read_last_num_su_blocks_val(debugfs_fd,
> > num_su_blocks), 40, 1);
> > +}
> > diff --git a/lib/igt_psr.h b/lib/igt_psr.h
> > index 7e7017bf..49599cf8 100644
> > --- a/lib/igt_psr.h
> > +++ b/lib/igt_psr.h
> > @@ -40,5 +40,6 @@ bool psr_wait_update(int debugfs_fd, enum
> > psr_mode
> > mode);
> >  bool psr_enable(int debugfs_fd, enum psr_mode);
> >  bool psr_disable(int debugfs_fd);
> >  bool psr_sink_support(int debugfs_fd, enum psr_mode);
> > +bool psr2_wait_su(int debugfs_fd, uint16_t *num_su_blocks);
> >  
> >  #endif
> > diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> > index a234fa5d..d2c4f9fe 100644
> > --- a/tests/Makefile.sources
> > +++ b/tests/Makefile.sources
> > @@ -62,6 +62,7 @@ TESTS_progs = \
> >  	kms_plane_scaling \
> >  	kms_properties \
> >  	kms_psr \
> > +	kms_psr2_su \
> >  	kms_pwrite_crc \
> >  	kms_rmfb \
> >  	kms_rotation_crc \
> > diff --git a/tests/kms_psr2_su.c b/tests/kms_psr2_su.c
> > new file mode 100644
> > index 00000000..2c75b85b
> > --- /dev/null
> > +++ b/tests/kms_psr2_su.c
> > @@ -0,0 +1,294 @@
> > +/*
> > + * Copyright © 2019 Intel Corporation
> > + *
> > + * Permission is hereby granted, free of charge, to any person
> > obtaining a
> > + * copy of this software and associated documentation files (the
> > "Software"),
> > + * to deal in the Software without restriction, including without
> > limitation
> > + * the rights to use, copy, modify, merge, publish, distribute,
> > sublicense,
> > + * and/or sell copies of the Software, and to permit persons to
> > whom
> > the
> > + * Software is furnished to do so, subject to the following
> > conditions:
> > + *
> > + * The above copyright notice and this permission notice
> > (including
> > the next
> > + * paragraph) shall be included in all copies or substantial
> > portions of the
> > + * Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> > EXPRESS OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> > MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO
> > EVENT SHALL
> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
> > DAMAGES
> > OR OTHER
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> > ARISING
> > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> > OTHER DEALINGS
> > + * IN THE SOFTWARE.
> > + *
> > + */
> > +
> > +#include "igt.h"
> > +#include "igt_sysfs.h"
> > +#include "igt_psr.h"
> > +#include <errno.h>
> > +#include <stdbool.h>
> > +#include <stdio.h>
> > +#include <string.h>
> > +#include <sys/timerfd.h>
> > +#include "intel_bufmgr.h"
> > +
> > +IGT_TEST_DESCRIPTION("Test PSR2 selective update");
> > +
> > +#define SQUARE_SIZE 100
> > +/* each selective update block is 4 lines tall */
> > +#define EXPECTED_NUM_SU_BLOCKS ((SQUARE_SIZE / 4) + (SQUARE_SIZE %
> > 4
> > ? 1 : 0))
> > +
> > +/*
> > + * Minimum is 15 as the number of frames to active PSR2 could be
> > configured
> > + * to 15 frames plus a few more in case we miss a selective update
> > between
> > + * debugfs reads.
> > + */
> > +#define MAX_SCREEN_CHANGES 20
> > +
> > +enum operations {
> > +	PAGE_FLIP,
> > +	FRONTBUFFER,
> > +	LAST
> Something like "INVALID" would have made it more obvious?
> 
> 
> > +};
> > +
> > +static const char *op_str(enum operations op)
> > +{
> > +	static const char * const name[] = {
> > +		[PAGE_FLIP] = "page_flip",
> > +		[FRONTBUFFER] = "frontbuffer"
> > +	};
> > +
> > +	return name[op];
> > +}
> > +
> > +typedef struct {
> > +	int drm_fd;
> > +	int debugfs_fd;
> > +	igt_display_t display;
> > +	drm_intel_bufmgr *bufmgr;
> > +	drmModeModeInfo *mode;
> > +	igt_output_t *output;
> > +	struct igt_fb fb[2];
> > +	enum operations op;
> > +	cairo_t *cr;
> > +	int change_screen_timerfd;
> > +	uint32_t screen_changes;
> > +} data_t;
> > +
> > +static void setup_output(data_t *data)
> > +{
> > +	igt_display_t *display = &data->display;
> > +	igt_output_t *output;
> > +	enum pipe pipe;
> > +
> > +	for_each_pipe_with_valid_output(display, pipe, output) {
> > +		drmModeConnectorPtr c = output->config.connector;
> > +
> > +		if (c->connector_type != DRM_MODE_CONNECTOR_eDP)
> > +			continue;
> > +
> > +		igt_output_set_pipe(output, pipe);
> > +		data->output = output;
> > +		data->mode = igt_output_get_mode(output);
> > +
> > +		return;
> > +	}
> > +}
> > +
> > +static void display_init(data_t *data)
> > +{
> > +	igt_display_require(&data->display, data->drm_fd);
> > +	setup_output(data);
> > +}
> > +
> > +static void display_fini(data_t *data)
> > +{
> > +	igt_display_fini(&data->display);
> > +}
> > +
> > +static void prepare(data_t *data)
> > +{
> > +	igt_plane_t *primary;
> > +
> > +	/* all green frame */
> > +	igt_create_color_fb(data->drm_fd,
> > +			    data->mode->hdisplay, data->mode->vdisplay,
> > +			    DRM_FORMAT_XRGB8888,
> > +			    LOCAL_DRM_FORMAT_MOD_NONE,
> > +			    0.0, 1.0, 0.0,
> > +			    &data->fb[0]);
> > +
> > +	if (data->op == PAGE_FLIP) {
> > +		cairo_t *cr;
> > +
> > +		igt_create_color_fb(data->drm_fd,
> > +				    data->mode->hdisplay, data->mode-
> > > vdisplay,
> > +				    DRM_FORMAT_XRGB8888,
> > +				    LOCAL_DRM_FORMAT_MOD_NONE,
> > +				    0.0, 1.0, 0.0,
> > +				    &data->fb[1]);
> > +
> > +		cr = igt_get_cairo_ctx(data->drm_fd, &data->fb[1]);
> > +		/* paint a white square */
> > +		igt_paint_color_alpha(cr, 0, 0, SQUARE_SIZE,
> > SQUARE_SIZE,
> > +				      1.0, 1.0, 1.0, 1.0);
> > +		igt_put_cairo_ctx(data->drm_fd,  &data->fb[1], cr);
> > +	} else if (data->op == FRONTBUFFER) {
> > +		data->cr = igt_get_cairo_ctx(data->drm_fd, &data-
> > > fb[0]);
> > +	}
> > +
> > +	primary = igt_output_get_plane_type(data->output,
> > +					    DRM_PLANE_TYPE_PRIMARY);
> > +
> > +	igt_plane_set_fb(primary, &data->fb[0]);
> > +	igt_display_commit2(&data->display, COMMIT_ATOMIC);
> > +
> > +	data->screen_changes = 0;
> > +}
> > +
> > +static bool update_screen_and_test(data_t *data)
> > +{
> > +	uint16_t su_blocks;
> > +	bool ret = false;
> > +
> > +	data->screen_changes++;
> > +
> > +	switch (data->op) {
> > +	case PAGE_FLIP: {
> > +		igt_plane_t *primary;
> > +
> > +		primary = igt_output_get_plane_type(data->output,
> > +						    DRM_PLANE_TYPE_PRIM
> > ARY);
> > +
> > +		igt_plane_set_fb(primary, &data->fb[data-
> > > screen_changes & 1]);
> > +		igt_display_commit2(&data->display, COMMIT_ATOMIC);
> > +		break;
> > +	}
> > +	case FRONTBUFFER: {
> > +		drmModeClip clip;
> > +
> > +		clip.x1 = clip.y1 = 0;
> > +		clip.x2 = clip.y2 = SQUARE_SIZE;
> > +
> > +		if (data->screen_changes & 1) {
> > +			/* go back to all green frame with a square */
> > +			igt_paint_color_alpha(data->cr, 0, 0,
> > SQUARE_SIZE,
> > +					      SQUARE_SIZE, 1.0, 1.0,
> > 1.0, 1.0);
> > +		} else {
> > +			/* go back to all green frame */
> > +			igt_paint_color_alpha(data->cr, 0, 0,
> > SQUARE_SIZE,
> > +					      SQUARE_SIZE, 0, 1.0, 0,
> > 1.0);
> > +		}
> > +
> > +		drmModeDirtyFB(data->drm_fd, data->fb[0].fb_id, &clip,
> > 1);
> > +		break;
> > +	}
> > +	default:
> > +		igt_assert_f(data->op, "Operation not handled\n");
> > +	}
> > +
> > +	if (psr2_wait_su(data->debugfs_fd, &su_blocks))
> > +		ret = su_blocks == EXPECTED_NUM_SU_BLOCKS;
> > +
> > +	return ret;
> > +}
> > +
> > +static void run(data_t *data)
> > +{
> > +	bool result = false;
> > +
> > +	igt_assert(psr_wait_entry(data->debugfs_fd, PSR_MODE_2));
> > +
> > +	while (data->screen_changes < MAX_SCREEN_CHANGES && !result) {
> 
> nitpick: Updating data->screen_changes here would have made it clear
> that we increment it every iteration.
> 
> With or without above changes, 
> Reviewed-by: Dhinakaran Pandiyan <
> dhinakaran.pandiyan@intel.com>
> On ICL, 
> Tested-by: Dhinakaran Pandiyan <
> dhinakaran.pandiyan@intel.com>
> 

Thanks, I just pushed this, we can improve on top when adding more
operations.

> > +		uint64_t exp;
> > +		int r;
> > +
> > +		r = read(data->change_screen_timerfd, &exp,
> > sizeof(exp));
> > +		if (r == sizeof(uint64_t) && exp)
> > +			result = update_screen_and_test(data);
> > +	}
> > +
> > +	igt_debug("Screen changes: %u\n", data->screen_changes);
> > +	igt_assert_f(result,
> > +		     "No matching selective update blocks read from
> > debugfs\n");
> > +}
> > +
> > +static void cleanup(data_t *data)
> > +{
> > +	igt_plane_t *primary;
> > +
> > +	primary = igt_output_get_plane_type(data->output,
> > +					    DRM_PLANE_TYPE_PRIMARY);
> > +	igt_plane_set_fb(primary, NULL);
> > +	igt_display_commit2(&data->display, COMMIT_ATOMIC);
> > +
> > +	if (data->op == PAGE_FLIP)
> > +		igt_remove_fb(data->drm_fd, &data->fb[1]);
> > +	else if (data->op == FRONTBUFFER)
> > +		igt_put_cairo_ctx(data->drm_fd, &data->fb[0], data-
> > > cr);
> > +
> > +	igt_remove_fb(data->drm_fd, &data->fb[0]);
> > +}
> > +
> > +int main(int argc, char *argv[])
> > +{
> > +	data_t data = {};
> > +
> > +	igt_subtest_init_parse_opts(&argc, argv, "", NULL,
> > +				    NULL, NULL, NULL);
> > +	igt_skip_on_simulation();
> > +
> > +	igt_fixture {
> > +		struct itimerspec interval;
> > +		int r;
> > +
> > +		data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
> > +		data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
> > +		kmstest_set_vt_graphics_mode();
> > +
> > +		igt_require_f(psr_sink_support(data.debugfs_fd,
> > PSR_MODE_2),
> > +			      "Sink does not support PSR2\n");
> > +
> > +		data.bufmgr = drm_intel_bufmgr_gem_init(data.drm_fd,
> > 4096);
> > +		igt_assert(data.bufmgr);
> > +		drm_intel_bufmgr_gem_enable_reuse(data.bufmgr);
> > +
> > +		display_init(&data);
> > +
> > +		/* Test if PSR2 can be enabled */
> > +		igt_require_f(psr_enable(data.debugfs_fd, PSR_MODE_2),
> > +			      "Error enabling PSR2\n");
> > +		data.op = FRONTBUFFER;
> > +		prepare(&data);
> > +		r = psr_wait_entry(data.debugfs_fd, PSR_MODE_2);
> I would rename this "r" to something more intuitive as assertions get
> debug logged.
> 
> 
> 
> > +		cleanup(&data);
> > +		igt_require_f(r, "PSR2 can not be enabled\n");
> > +
> > +		/* blocking timerfd */
> > +		data.change_screen_timerfd =
> > timerfd_create(CLOCK_MONOTONIC, 0);
> > +		igt_require(data.change_screen_timerfd != -1);
> > +		/* Changing screen at 30hz to support 30hz panels */
> > +		interval.it_value.tv_nsec = NSEC_PER_SEC / 30;
> > +		interval.it_value.tv_sec = 0;
> > +		interval.it_interval.tv_nsec =
> > interval.it_value.tv_nsec;
> > +		interval.it_interval.tv_sec = interval.it_value.tv_sec;
> > +		r = timerfd_settime(data.change_screen_timerfd, 0,
> > &interval, NULL);
> > +		igt_require_f(r != -1, "Error setting timerfd\n");
> > +	}
> > +
> > +	for (data.op = PAGE_FLIP; data.op < LAST; data.op++) {
> > +		igt_subtest_f("%s", op_str(data.op)) {
> > +			prepare(&data);
> > +			run(&data);
> > +			cleanup(&data);
> > +		}
> > +	}
> > +
> > +	igt_fixture {
> > +		close(data.debugfs_fd);
> > +		drm_intel_bufmgr_destroy(data.bufmgr);
> > +		display_fini(&data);
> > +	}
> > +
> > +	igt_exit();
> > +}
> > diff --git a/tests/meson.build b/tests/meson.build
> > index 0f12df26..ec980651 100644
> > --- a/tests/meson.build
> > +++ b/tests/meson.build
> > @@ -49,6 +49,7 @@ test_progs = [
> >  	'kms_plane_scaling',
> >  	'kms_properties',
> >  	'kms_psr',
> > +	'kms_psr2_su',
> >  	'kms_pwrite_crc',
> >  	'kms_rmfb',
> >  	'kms_rotation_crc',

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-02-14  0:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-08  0:53 [igt-dev] [PATCH i-g-t v6 1/4] test: Add PSR2 selective update tests José Roberto de Souza
2019-02-08  0:53 ` [igt-dev] [PATCH i-g-t v6 2/4] tests/intel-ci: Add basic PSR2 tests to fast feedback test list José Roberto de Souza
2019-02-14  0:23   ` Pandiyan, Dhinakaran via igt-dev
2019-02-08  0:53 ` [igt-dev] [PATCH i-g-t v6 3/4] tests/psr: Test the switching between all PSR version from debugfs José Roberto de Souza
2019-02-08  0:53 ` [igt-dev] [PATCH i-g-t v6 4/4] DO NOT MERGE: Check result of kms_psr2_su tests José Roberto de Souza
2019-02-08  1:30 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,v6,1/4] test: Add PSR2 selective update tests Patchwork
2019-02-08  5:23 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-02-14  0:21 ` [igt-dev] [PATCH i-g-t v6 1/4] " Dhinakaran Pandiyan via igt-dev
2019-02-14  0:46   ` Souza, Jose via igt-dev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox