[igt-dev] [PATCH i-g-t] tests/kms_psr2_sf: Add option to run test with PSR disabled
José Roberto de Souza
jose.souza at intel.com
Fri May 7 23:19:01 UTC 2021
That is helpful to check if glitches found with this test also
reproduces with PSR2 disabled.
Cc: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya at intel.com>
Cc: Karthik B S <karthik.b.s at intel.com>
Cc: Gwan-gyeong Mun <gwan-gyeong.mun at intel.com>
Signed-off-by: José Roberto de Souza <jose.souza at intel.com>
---
lib/igt_psr.h | 1 +
tests/kms_psr2_sf.c | 100 +++++++++++++++++++++++++++++++++-----------
2 files changed, 76 insertions(+), 25 deletions(-)
diff --git a/lib/igt_psr.h b/lib/igt_psr.h
index c47b197b1..8ef48d1d0 100644
--- a/lib/igt_psr.h
+++ b/lib/igt_psr.h
@@ -31,6 +31,7 @@
#define PSR_STATUS_MAX_LEN 512
enum psr_mode {
+ PSR_MODE_DISABLED = -1,
PSR_MODE_1,
PSR_MODE_2,
PSR_MODE_2_SEL_FETCH,
diff --git a/tests/kms_psr2_sf.c b/tests/kms_psr2_sf.c
index d4c19ca98..939154bdc 100644
--- a/tests/kms_psr2_sf.c
+++ b/tests/kms_psr2_sf.c
@@ -68,6 +68,7 @@ typedef struct {
int test_plane_id;
igt_plane_t *test_plane;
cairo_t *cr;
+ bool with_psr_disabled;
} data_t;
static const char *op_str(enum operations op)
@@ -457,7 +458,8 @@ static void damaged_plane_move(data_t *data)
igt_display_commit2(&data->display, COMMIT_ATOMIC);
- igt_assert(psr_wait_entry(data->debugfs_fd, PSR_MODE_2));
+ if (!data->with_psr_disabled)
+ igt_assert(psr_wait_entry(data->debugfs_fd, PSR_MODE_2));
expected_output(data);
}
@@ -490,14 +492,16 @@ static void damaged_plane_update(data_t *data)
igt_plane_set_position(data->test_plane, 0, 0);
igt_display_commit2(&data->display, COMMIT_ATOMIC);
- igt_assert(psr_wait_entry(data->debugfs_fd, PSR_MODE_2));
+ if (!data->with_psr_disabled)
+ igt_assert(psr_wait_entry(data->debugfs_fd, PSR_MODE_2));
expected_output(data);
}
static void run(data_t *data)
{
- igt_assert(psr_wait_entry(data->debugfs_fd, PSR_MODE_2));
+ if (!data->with_psr_disabled)
+ igt_assert(psr_wait_entry(data->debugfs_fd, PSR_MODE_2));
switch (data->op) {
case PLANE_UPDATE:
@@ -542,43 +546,89 @@ static void cleanup(data_t *data)
igt_remove_fb(data->drm_fd, &data->fb_test);
}
-igt_main
+static int opt_handler(int opt, int opt_index, void *_data)
{
- data_t data = {};
+ data_t *data = _data;
+
+ switch (opt) {
+ case 'n':
+ data->with_psr_disabled = true;
+ break;
+ default:
+ return IGT_OPT_HANDLER_ERROR;
+ }
+
+ return IGT_OPT_HANDLER_SUCCESS;
+}
+
+const char *help_str =
+ " --no-psr\tRun test with PSR disabled";
+static struct option long_options[] = {
+ {"no-psr", 0, 0, 'n'},
+ { 0, 0, 0, 0 }
+};
+
+data_t g_data = {};
+
+static void sink_support_check(data_t *data)
+{
+ if (data->with_psr_disabled)
+ return;
+
+ igt_require_f(psr_sink_support(data->drm_fd, data->debugfs_fd, PSR_MODE_2),
+ "Sink does not support PSR2\n");
+}
+
+static void psr_enable_and_check(data_t *data)
+{
+ enum psr_mode mode = PSR_MODE_2_SEL_FETCH;
+
+ if (data->with_psr_disabled)
+ mode = PSR_MODE_DISABLED;
+
+ igt_require_f(psr_enable(data->drm_fd, data->debugfs_fd, mode),
+ "Error enabling PSR2\n");
+}
+
+static void psr_state_check(data_t *data)
+{
+ bool r;
+
+ if (data->with_psr_disabled)
+ r = psr_disabled_check(data->debugfs_fd);
+ else
+ r = psr_wait_entry(data->debugfs_fd, PSR_MODE_2);
+
+ if (!r)
+ psr_print_debugfs(data->debugfs_fd);
+ igt_require_f(r, "PSR2 can not be enabled\n");
+
+ if (!data->with_psr_disabled)
+ igt_require_f(psr2_selective_fetch_check(data->debugfs_fd),
+ "PSR2 selective fetch not enabled\n");
+
+}
+
+igt_main_args("", long_options, help_str, opt_handler, &g_data)
+{
+ data_t data = g_data;
int i;
igt_fixture {
- 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.drm_fd,
- data.debugfs_fd, PSR_MODE_2),
- "Sink does not support PSR2\n");
-
+ sink_support_check(&data);
display_init(&data);
-
- /* Test if PSR2 can be enabled */
- igt_require_f(psr_enable(data.drm_fd,
- data.debugfs_fd, PSR_MODE_2_SEL_FETCH),
- "Error enabling PSR2\n");
+ psr_enable_and_check(&data);
data.damage_area_count = MAX_DAMAGE_AREAS;
data.op = PLANE_UPDATE;
data.test_plane_id = DRM_PLANE_TYPE_PRIMARY;
prepare(&data);
- r = psr_wait_entry(data.debugfs_fd, PSR_MODE_2);
- if (!r)
- psr_print_debugfs(data.debugfs_fd);
-
- igt_require_f(psr2_selective_fetch_check(data.debugfs_fd),
- "PSR2 selective fetch not enabled\n");
+ psr_state_check(&data);
cleanup(&data);
- if (!r)
- psr_print_debugfs(data.debugfs_fd);
- igt_require_f(r, "PSR2 can not be enabled\n");
}
/* Verify primary plane selective fetch */
--
2.31.1
More information about the igt-dev
mailing list