All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t v2] tests/kms_dp_dsc: Force a full modeset when we force dsc enable
@ 2019-04-05 22:55 Manasi Navare
  2019-04-05 23:30 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/kms_dp_dsc: Force a full modeset when we force dsc enable (rev2) Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Manasi Navare @ 2019-04-05 22:55 UTC (permalink / raw)
  To: igt-dev; +Cc: Manasi Navare, Anusha Srivatsa, Petri Latvala

DSC enable gets configured during compute_config and needs
a full modeset to force DSC.
Sometimes in between the tests, if the initial output is same as the
mode being set for DSC then it will not do a full modeset.
So we disable the output before forcing a mode with DSC enable.

You need the kernel patch:
https://patchwork.freedesktop.org/series/59084/

v2:
* Restore the value of force dsc enable after the test and in igt_exit_handler
* Add igt_install_exit_handler to restore values on fail/exit

Fixes: db19bccc1c22 ("test/kms_dp_dsc: Basic KMS test to validate VESA DSC on DP/eDP")
Cc: Petri Latvala <petri.latvala@intel.com>
Cc: Anusha Srivatsa <anusha.srivatsa@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
---
 tests/kms_dp_dsc.c | 133 +++++++++++++++++++++++++++------------------
 1 file changed, 81 insertions(+), 52 deletions(-)

diff --git a/tests/kms_dp_dsc.c b/tests/kms_dp_dsc.c
index da93cd74..acaee890 100644
--- a/tests/kms_dp_dsc.c
+++ b/tests/kms_dp_dsc.c
@@ -63,119 +63,147 @@ typedef struct {
 	int crtc;
 	enum pipe pipe;
 	char conn_name[128];
+	bool force_dsc_en;
 } data_t;
 
+data_t data = {};
+
 static inline void manual(const char *expected)
 {
 	igt_debug_manual_check("all", expected);
 }
 
-static bool is_dp_dsc_supported(data_t *data)
+static bool is_dp_dsc_supported(void)
 {
 	char file_name[128] = {0};
 	char buf[512];
 
-	strcpy(file_name, data->conn_name);
+	strcpy(file_name, data.conn_name);
 	strcat(file_name, "/i915_dsc_fec_support");
-	igt_require(igt_debugfs_simple_read(data->debugfs_fd, file_name, buf,
+	igt_require(igt_debugfs_simple_read(data.debugfs_fd, file_name, buf,
 					    sizeof(buf)) > 0);
-	igt_debugfs_read(data->drm_fd, file_name, buf);
+	igt_debugfs_read(data.drm_fd, file_name, buf);
 
 	return strstr(buf, "DSC_Sink_Support: yes");
 }
 
-static bool is_dp_fec_supported(data_t *data)
+static bool is_dp_fec_supported(void)
 {
 	char file_name[128] = {0};
 	char buf[512];
 
-	strcpy(file_name, data->conn_name);
+	strcpy(file_name, data.conn_name);
 	strcat(file_name, "/i915_dsc_fec_support");
-	igt_debugfs_read(data->drm_fd, file_name, buf);
+	igt_debugfs_read(data.drm_fd, file_name, buf);
 
 	return strstr(buf, "FEC_Sink_Support: yes");
 }
 
-static bool is_dp_dsc_enabled(data_t *data)
+static bool is_dp_dsc_enabled(void)
 {
 	char file_name[128] = {0};
 	char buf[512];
 
-	strcpy(file_name, data->conn_name);
+	strcpy(file_name, data.conn_name);
 	strcat(file_name, "/i915_dsc_fec_support");
-	igt_debugfs_read(data->drm_fd, file_name, buf);
+	igt_debugfs_read(data.drm_fd, file_name, buf);
 
 	return strstr(buf, "DSC_Enabled: yes");
 }
 
-static void force_dp_dsc_enable(data_t *data)
+static bool is_force_dsc_enabled(void)
+{
+	char file_name[128] = {0};
+	char buf[512];
+
+	strcpy(file_name, data.conn_name);
+	strcat(file_name, "/i915_dsc_fec_support");
+	igt_debugfs_read(data.drm_fd, file_name, buf);
+
+	return strstr(buf, "Force_DSC_Enable: yes");
+}
+
+static void force_dp_dsc_enable(void)
 {
 	char file_name[128] = {0};
 	int ret;
 
-	strcpy(file_name, data->conn_name);
+	strcpy(file_name, data.conn_name);
 	strcat(file_name, "/i915_dsc_fec_support");
-	igt_debug ("Forcing DSC enable on %s\n", data->conn_name);
-	ret = igt_sysfs_write(data->debugfs_fd, file_name, "1", 1);
+	igt_debug ("Forcing DSC enable on %s\n", data.conn_name);
+	ret = igt_sysfs_write(data.debugfs_fd, file_name, "1", 1);
 	igt_assert_f(ret > 0, "debugfs_write failed");
 }
 
-static void clear_dp_dsc_enable(data_t *data)
+static void restore_dp_dsc_enable(void)
 {
 	char file_name[128] = {0};
 	int ret;
 
-	strcpy(file_name, data->conn_name);
+	strcpy(file_name, data.conn_name);
 	strcat(file_name, "/i915_dsc_fec_support");
-	igt_debug ("Clearing DSC enable on %s\n", data->conn_name);
-	ret = igt_sysfs_write(data->debugfs_fd, file_name, "0", 1);
+	igt_debug ("Restoring DSC enable on %s\n", data.conn_name);
+	ret = igt_sysfs_write(data.debugfs_fd, file_name,
+			      data.force_dsc_en ? "1" : "0", 1);
 	igt_assert_f(ret > 0, "debugfs_write failed");
 }
 
-static void test_cleanup(data_t *data) {
+static void test_cleanup(void) {
 	igt_plane_t *primary;
 
-	if (data->output) {
-		primary = igt_output_get_plane_type(data->output,
+	if (data.output) {
+		primary = igt_output_get_plane_type(data.output,
 						    DRM_PLANE_TYPE_PRIMARY);
 		igt_plane_set_fb(primary, NULL);
-		igt_display_commit(&data->display);
-		igt_remove_fb(data->drm_fd, &data->fb_test_pattern);
+		igt_display_commit(&data.display);
+		igt_remove_fb(data.drm_fd, &data.fb_test_pattern);
 	}
 }
 
+static void kms_dp_dsc_exit_handler(int sig) {
+
+	restore_dp_dsc_enable();
+}
+
 
 /*
  * Re-probe connectors and do a modeset with DSC
  *
  */
-static void update_display(data_t *data, enum dsc_test_type test_type)
+static void update_display(enum dsc_test_type test_type)
 {
 	igt_plane_t *primary;
-	data->mode = igt_output_get_mode(data->output);
-	data->connector = data->output->config.connector;
+	data.mode = igt_output_get_mode(data.output);
+	data.connector = data.output->config.connector;
 
-	if (data->connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
-	    data->pipe == PIPE_A) {
+	if (data.connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
+	    data.pipe == PIPE_A) {
 		igt_debug("DSC not supported on Pipe A on external DP\n");
 		return;
 	}
 
+	/* Disable the output first */
+	igt_output_set_pipe(data.output, PIPE_NONE);
+	igt_display_commit(&data.display);
+
 	if (test_type == test_basic_dsc_enable) {
 		bool enabled;
 
-		igt_debug("DSC is supported on %s\n", data->conn_name);
-		force_dp_dsc_enable(data);
+		igt_debug("DSC is supported on %s\n", data.conn_name);
+		force_dp_dsc_enable();
 
-		igt_create_pattern_fb(data->drm_fd, data->mode->hdisplay,
-				      data->mode->vdisplay,
+		igt_output_set_pipe(data.output, data.pipe);
+		igt_create_pattern_fb(data.drm_fd, data.mode->hdisplay,
+				      data.mode->vdisplay,
 				      DRM_FORMAT_XRGB8888,
 				      LOCAL_DRM_FORMAT_MOD_NONE,
-				      &data->fb_test_pattern);
-		primary = igt_output_get_plane_type(data->output,
+				      &data.fb_test_pattern);
+		primary = igt_output_get_plane_type(data.output,
 						    DRM_PLANE_TYPE_PRIMARY);
-		igt_plane_set_fb(primary, &data->fb_test_pattern);
-		igt_display_commit(&data->display);
+
+		/* Now set the output to the desired mode */
+		igt_plane_set_fb(primary, &data.fb_test_pattern);
+		igt_display_commit(&data.display);
 
 		/*
 		 * Until we have CRC check support, manually check if RGB test
@@ -183,38 +211,37 @@ static void update_display(data_t *data, enum dsc_test_type test_type)
 		 */
 		manual("RGB test pattern without corruption");
 
-		enabled = is_dp_dsc_enabled(data);
-		clear_dp_dsc_enable(data);
+		enabled = is_dp_dsc_enabled();
+		restore_dp_dsc_enable();
 
 		igt_assert_f(enabled,
-			     "Default DSC enable failed on Connector: %s Pipe: %s",
-			     data->conn_name,
-			     kmstest_pipe_name(data->pipe));
+			     "Default DSC enable failed on Connector: %s Pipe: %s\n",
+			     data.conn_name,
+			     kmstest_pipe_name(data.pipe));
 	} else {
 		igt_assert(!"Unknown test type\n");
 	}
 }
 
-static void run_test(data_t *data, igt_output_t *output,
+static void run_test(igt_output_t *output,
 		     enum dsc_test_type test_type)
 {
 	enum pipe pipe;
 
-	for_each_pipe(&data->display, pipe) {
+	for_each_pipe(&data.display, pipe) {
 
 		if (igt_pipe_connector_valid(pipe, output)) {
-			igt_output_set_pipe(output, pipe);
-			data->pipe = pipe;
-			data->output = output;
-			update_display(data, test_type);
-			test_cleanup(data);
+			data.pipe = pipe;
+			data.output = output;
+			update_display(test_type);
+			test_cleanup();
 		}
 	}
 }
 
 igt_main
 {
-	data_t data = {};
+	//data_t data = {};
 	igt_output_t *output;
 	drmModeRes *res;
 	drmModeConnector *connector;
@@ -225,6 +252,7 @@ igt_main
 		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
 		data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
 		kmstest_set_vt_graphics_mode();
+		igt_install_exit_handler(kms_dp_dsc_exit_handler);
 		igt_display_require(&data.display, data.drm_fd);
 		igt_require(res = drmModeGetResources(data.drm_fd));
 	}
@@ -245,19 +273,20 @@ igt_main
 				sprintf(data.conn_name, "%s-%d",
 					kmstest_connector_type_str(connector->connector_type),
 					connector->connector_type_id);
-				if(!is_dp_dsc_supported(&data)) {
+				if(!is_dp_dsc_supported()) {
 					igt_debug("DSC not supported on connector %s \n",
 						  data.conn_name);
 					continue;
 				}
 				if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
-				    !is_dp_fec_supported(&data)) {
+				    !is_dp_fec_supported()) {
 					igt_debug("DSC cannot be enabled without FEC on %s\n",
 						  data.conn_name);
 					continue;
 				}
 				test_conn_cnt++;
-				run_test(&data, output, test_basic_dsc_enable);
+				data.force_dsc_en = is_force_dsc_enabled();
+				run_test(output, test_basic_dsc_enable);
 			}
 			igt_skip_on(test_conn_cnt == 0);
 		}
-- 
2.19.1

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

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

* [igt-dev] ✓ Fi.CI.BAT: success for tests/kms_dp_dsc: Force a full modeset when we force dsc enable (rev2)
  2019-04-05 22:55 [igt-dev] [PATCH i-g-t v2] tests/kms_dp_dsc: Force a full modeset when we force dsc enable Manasi Navare
@ 2019-04-05 23:30 ` Patchwork
  2019-04-06 23:22 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
  2019-04-08 12:08 ` [igt-dev] [PATCH i-g-t v2] tests/kms_dp_dsc: Force a full modeset when we force dsc enable Imre Deak
  2 siblings, 0 replies; 8+ messages in thread
From: Patchwork @ 2019-04-05 23:30 UTC (permalink / raw)
  To: Manasi Navare; +Cc: igt-dev

== Series Details ==

Series: tests/kms_dp_dsc: Force a full modeset when we force dsc enable (rev2)
URL   : https://patchwork.freedesktop.org/series/58887/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5882 -> IGTPW_2804
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/58887/revisions/2/mbox/

Known issues
------------

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

### IGT changes ###

#### Issues hit ####

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

  * igt@i915_selftest@live_contexts:
    - fi-bdw-gvtdvm:      PASS -> DMESG-FAIL [fdo#110235 ]

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

  
#### Possible fixes ####

  * igt@i915_pm_rpm@module-reload:
    - fi-skl-6770hq:      DMESG-WARN [fdo#105541] -> PASS
    - {fi-icl-u3}:        DMESG-WARN [fdo#107724] -> PASS

  * igt@kms_pipe_crc_basic@hang-read-crc-pipe-a:
    - fi-byt-clapper:     FAIL [fdo#103191] / [fdo#107362] -> PASS +1

  * igt@kms_pipe_crc_basic@read-crc-pipe-b:
    - fi-byt-clapper:     FAIL [fdo#107362] -> 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#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
  [fdo#105541]: https://bugs.freedesktop.org/show_bug.cgi?id=105541
  [fdo#107362]: https://bugs.freedesktop.org/show_bug.cgi?id=107362
  [fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
  [fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
  [fdo#110235 ]: https://bugs.freedesktop.org/show_bug.cgi?id=110235 


Participating hosts (50 -> 42)
------------------------------

  Missing    (8): fi-kbl-soraka fi-ilk-m540 fi-byt-j1900 fi-byt-squawks fi-bsw-cyan fi-gdg-551 fi-bdw-samus fi-skl-6600u 


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

    * IGT: IGT_4932 -> IGTPW_2804

  CI_DRM_5882: 012535789c9c890854cd1e0fb926f44931a82a63 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_2804: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2804/
  IGT_4932: 08cf63a8fac11e3594b57580331fb319241a0d69 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

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

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

* [igt-dev] ✓ Fi.CI.IGT: success for tests/kms_dp_dsc: Force a full modeset when we force dsc enable (rev2)
  2019-04-05 22:55 [igt-dev] [PATCH i-g-t v2] tests/kms_dp_dsc: Force a full modeset when we force dsc enable Manasi Navare
  2019-04-05 23:30 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/kms_dp_dsc: Force a full modeset when we force dsc enable (rev2) Patchwork
@ 2019-04-06 23:22 ` Patchwork
  2019-04-08 12:08 ` [igt-dev] [PATCH i-g-t v2] tests/kms_dp_dsc: Force a full modeset when we force dsc enable Imre Deak
  2 siblings, 0 replies; 8+ messages in thread
From: Patchwork @ 2019-04-06 23:22 UTC (permalink / raw)
  To: Manasi Navare; +Cc: igt-dev

== Series Details ==

Series: tests/kms_dp_dsc: Force a full modeset when we force dsc enable (rev2)
URL   : https://patchwork.freedesktop.org/series/58887/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5882_full -> IGTPW_2804_full
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/58887/revisions/2/mbox/

Known issues
------------

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

### IGT changes ###

#### Issues hit ####

  * igt@gem_eio@reset-stress:
    - shard-snb:          PASS -> FAIL [fdo#109661]

  * igt@gem_exec_suspend@basic-s3:
    - shard-apl:          PASS -> DMESG-WARN [fdo#108566]

  * igt@i915_pm_rps@min-max-config-loaded:
    - shard-apl:          PASS -> FAIL [fdo#102250]

  * igt@kms_atomic_transition@3x-modeset-transitions:
    - shard-snb:          NOTRUN -> SKIP [fdo#109271] / [fdo#109278] +12

  * igt@kms_atomic_transition@3x-modeset-transitions-fencing:
    - shard-kbl:          NOTRUN -> SKIP [fdo#109271] / [fdo#109278]

  * igt@kms_atomic_transition@plane-all-modeset-transition-internal-panels:
    - shard-kbl:          NOTRUN -> SKIP [fdo#109271] +23

  * igt@kms_busy@extended-modeset-hang-newfb-render-a:
    - shard-hsw:          PASS -> DMESG-WARN [fdo#110222] +1

  * igt@kms_busy@extended-modeset-hang-newfb-render-b:
    - shard-kbl:          PASS -> DMESG-WARN [fdo#110222]

  * igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-b:
    - shard-snb:          PASS -> DMESG-WARN [fdo#110222] +2

  * igt@kms_content_protection@legacy:
    - shard-snb:          NOTRUN -> SKIP [fdo#109271] +72

  * igt@kms_cursor_legacy@2x-long-flip-vs-cursor-atomic:
    - shard-glk:          PASS -> FAIL [fdo#104873]

  * igt@kms_flip@2x-flip-vs-expired-vblank:
    - shard-glk:          PASS -> FAIL [fdo#105363]

  * igt@kms_frontbuffer_tracking@fbcpsr-shrfb-scaledprimary:
    - shard-apl:          NOTRUN -> SKIP [fdo#109271] +12

  * igt@kms_plane_alpha_blend@pipe-b-alpha-basic:
    - shard-kbl:          NOTRUN -> FAIL [fdo#108145] / [fdo#108590]

  * igt@kms_plane_scaling@pipe-c-scaler-with-pixel-format:
    - shard-glk:          PASS -> SKIP [fdo#109271] / [fdo#109278]

  * igt@kms_rotation_crc@multiplane-rotation-cropping-top:
    - shard-kbl:          PASS -> FAIL [fdo#109016]

  * igt@kms_vblank@pipe-a-accuracy-idle:
    - shard-glk:          PASS -> FAIL [fdo#102583]

  * igt@kms_vblank@pipe-c-ts-continuation-modeset-rpm:
    - shard-apl:          PASS -> FAIL [fdo#104894]

  * igt@prime_nv_api@i915_self_import:
    - shard-glk:          NOTRUN -> SKIP [fdo#109271] +7

  
#### Possible fixes ####

  * igt@i915_pm_rc6_residency@rc6-accuracy:
    - shard-snb:          SKIP [fdo#109271] -> PASS

  * igt@i915_suspend@sysfs-reader:
    - shard-kbl:          INCOMPLETE [fdo#103665] -> PASS

  * igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-c:
    - shard-hsw:          DMESG-WARN [fdo#110222] -> PASS
    - shard-kbl:          DMESG-WARN [fdo#110222] -> PASS

  * igt@kms_color@pipe-a-ctm-max:
    - shard-kbl:          FAIL [fdo#108147] -> PASS
    - shard-apl:          FAIL [fdo#108147] -> PASS

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

  * igt@kms_cursor_legacy@2x-long-nonblocking-modeset-vs-cursor-atomic:
    - shard-glk:          FAIL [fdo#106509] / [fdo#107409] -> PASS

  * igt@kms_flip@2x-flip-vs-expired-vblank-interruptible:
    - shard-glk:          FAIL [fdo#105363] -> PASS

  * igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-shrfb-plflip-blt:
    - shard-glk:          FAIL [fdo#103167] -> PASS

  * igt@kms_vblank@pipe-b-ts-continuation-modeset-rpm:
    - shard-apl:          FAIL [fdo#104894] -> PASS +1
    - shard-kbl:          FAIL [fdo#104894] -> PASS +1

  
  [fdo#102250]: https://bugs.freedesktop.org/show_bug.cgi?id=102250
  [fdo#102583]: https://bugs.freedesktop.org/show_bug.cgi?id=102583
  [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
  [fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
  [fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
  [fdo#104873]: https://bugs.freedesktop.org/show_bug.cgi?id=104873
  [fdo#104894]: https://bugs.freedesktop.org/show_bug.cgi?id=104894
  [fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
  [fdo#106509]: https://bugs.freedesktop.org/show_bug.cgi?id=106509
  [fdo#107409]: https://bugs.freedesktop.org/show_bug.cgi?id=107409
  [fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
  [fdo#108147]: https://bugs.freedesktop.org/show_bug.cgi?id=108147
  [fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
  [fdo#108590]: https://bugs.freedesktop.org/show_bug.cgi?id=108590
  [fdo#109016]: https://bugs.freedesktop.org/show_bug.cgi?id=109016
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
  [fdo#109661]: https://bugs.freedesktop.org/show_bug.cgi?id=109661
  [fdo#110222]: https://bugs.freedesktop.org/show_bug.cgi?id=110222


Participating hosts (10 -> 5)
------------------------------

  Missing    (5): shard-skl pig-hsw-4770r pig-glk-j5005 shard-iclb pig-skl-6260u 


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

    * IGT: IGT_4932 -> IGTPW_2804
    * Piglit: piglit_4509 -> None

  CI_DRM_5882: 012535789c9c890854cd1e0fb926f44931a82a63 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_2804: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2804/
  IGT_4932: 08cf63a8fac11e3594b57580331fb319241a0d69 @ 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_2804/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t v2] tests/kms_dp_dsc: Force a full modeset when we force dsc enable
  2019-04-05 22:55 [igt-dev] [PATCH i-g-t v2] tests/kms_dp_dsc: Force a full modeset when we force dsc enable Manasi Navare
  2019-04-05 23:30 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/kms_dp_dsc: Force a full modeset when we force dsc enable (rev2) Patchwork
  2019-04-06 23:22 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
@ 2019-04-08 12:08 ` Imre Deak
  2019-04-08 19:06   ` Manasi Navare
  2 siblings, 1 reply; 8+ messages in thread
From: Imre Deak @ 2019-04-08 12:08 UTC (permalink / raw)
  To: Manasi Navare; +Cc: igt-dev, Anusha Srivatsa, Petri Latvala

On Fri, Apr 05, 2019 at 03:55:49PM -0700, Manasi Navare wrote:
> DSC enable gets configured during compute_config and needs
> a full modeset to force DSC.
> Sometimes in between the tests, if the initial output is same as the
> mode being set for DSC then it will not do a full modeset.
> So we disable the output before forcing a mode with DSC enable.
> 
> You need the kernel patch:
> https://patchwork.freedesktop.org/series/59084/
> 
> v2:
> * Restore the value of force dsc enable after the test and in igt_exit_handler
> * Add igt_install_exit_handler to restore values on fail/exit
> 
> Fixes: db19bccc1c22 ("test/kms_dp_dsc: Basic KMS test to validate VESA DSC on DP/eDP")
> Cc: Petri Latvala <petri.latvala@intel.com>
> Cc: Anusha Srivatsa <anusha.srivatsa@intel.com>
> Cc: Imre Deak <imre.deak@intel.com>
> Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> ---
>  tests/kms_dp_dsc.c | 133 +++++++++++++++++++++++++++------------------
>  1 file changed, 81 insertions(+), 52 deletions(-)
> 
> diff --git a/tests/kms_dp_dsc.c b/tests/kms_dp_dsc.c
> index da93cd74..acaee890 100644
> --- a/tests/kms_dp_dsc.c
> +++ b/tests/kms_dp_dsc.c
> @@ -63,119 +63,147 @@ typedef struct {
>  	int crtc;
>  	enum pipe pipe;
>  	char conn_name[128];
> +	bool force_dsc_en;

force_dsc_en_orig?

>  } data_t;
>  
> +data_t data = {};
> +

Maybe make only debugfs_fd and force_dsc_en_orig global to reduce the
churn? Also init debugfs_fd to -1, so the exit handler knows if it's
been closed already.

>  static inline void manual(const char *expected)
>  {
>  	igt_debug_manual_check("all", expected);
>  }
>  
> -static bool is_dp_dsc_supported(data_t *data)
> +static bool is_dp_dsc_supported(void)
>  {
>  	char file_name[128] = {0};
>  	char buf[512];
>  
> -	strcpy(file_name, data->conn_name);
> +	strcpy(file_name, data.conn_name);
>  	strcat(file_name, "/i915_dsc_fec_support");
> -	igt_require(igt_debugfs_simple_read(data->debugfs_fd, file_name, buf,
> +	igt_require(igt_debugfs_simple_read(data.debugfs_fd, file_name, buf,
>  					    sizeof(buf)) > 0);
> -	igt_debugfs_read(data->drm_fd, file_name, buf);
> +	igt_debugfs_read(data.drm_fd, file_name, buf);
>  
>  	return strstr(buf, "DSC_Sink_Support: yes");
>  }
>  
> -static bool is_dp_fec_supported(data_t *data)
> +static bool is_dp_fec_supported(void)
>  {
>  	char file_name[128] = {0};
>  	char buf[512];
>  
> -	strcpy(file_name, data->conn_name);
> +	strcpy(file_name, data.conn_name);
>  	strcat(file_name, "/i915_dsc_fec_support");
> -	igt_debugfs_read(data->drm_fd, file_name, buf);
> +	igt_debugfs_read(data.drm_fd, file_name, buf);
>  
>  	return strstr(buf, "FEC_Sink_Support: yes");
>  }
>  
> -static bool is_dp_dsc_enabled(data_t *data)
> +static bool is_dp_dsc_enabled(void)
>  {
>  	char file_name[128] = {0};
>  	char buf[512];
>  
> -	strcpy(file_name, data->conn_name);
> +	strcpy(file_name, data.conn_name);
>  	strcat(file_name, "/i915_dsc_fec_support");
> -	igt_debugfs_read(data->drm_fd, file_name, buf);
> +	igt_debugfs_read(data.drm_fd, file_name, buf);
>  
>  	return strstr(buf, "DSC_Enabled: yes");
>  }
>  
> -static void force_dp_dsc_enable(data_t *data)
> +static bool is_force_dsc_enabled(void)
> +{
> +	char file_name[128] = {0};
> +	char buf[512];
> +
> +	strcpy(file_name, data.conn_name);
> +	strcat(file_name, "/i915_dsc_fec_support");
> +	igt_debugfs_read(data.drm_fd, file_name, buf);
> +
> +	return strstr(buf, "Force_DSC_Enable: yes");
> +}
> +
> +static void force_dp_dsc_enable(void)
>  {
>  	char file_name[128] = {0};
>  	int ret;
>  
> -	strcpy(file_name, data->conn_name);
> +	strcpy(file_name, data.conn_name);
>  	strcat(file_name, "/i915_dsc_fec_support");
> -	igt_debug ("Forcing DSC enable on %s\n", data->conn_name);
> -	ret = igt_sysfs_write(data->debugfs_fd, file_name, "1", 1);
> +	igt_debug ("Forcing DSC enable on %s\n", data.conn_name);
> +	ret = igt_sysfs_write(data.debugfs_fd, file_name, "1", 1);
>  	igt_assert_f(ret > 0, "debugfs_write failed");
>  }
>  
> -static void clear_dp_dsc_enable(data_t *data)
> +static void restore_dp_dsc_enable(void)

Better named as restore_force_dsc_en()?

>  {
>  	char file_name[128] = {0};
>  	int ret;
>  

You need to check if the sig handler was called multiple times for some
reason:

	if (debugfs_fd < 0)
		return;

> -	strcpy(file_name, data->conn_name);
> +	strcpy(file_name, data.conn_name);
>  	strcat(file_name, "/i915_dsc_fec_support");
> -	igt_debug ("Clearing DSC enable on %s\n", data->conn_name);
> -	ret = igt_sysfs_write(data->debugfs_fd, file_name, "0", 1);
> +	igt_debug ("Restoring DSC enable on %s\n", data.conn_name);
> +	ret = igt_sysfs_write(data.debugfs_fd, file_name,
> +			      data.force_dsc_en ? "1" : "0", 1);

	close(debugfs_fd);
	debugfs_fd = -1;
	
>  	igt_assert_f(ret > 0, "debugfs_write failed");
>  }
>  
> -static void test_cleanup(data_t *data) {
> +static void test_cleanup(void) {
>  	igt_plane_t *primary;
>  
> -	if (data->output) {
> -		primary = igt_output_get_plane_type(data->output,
> +	if (data.output) {
> +		primary = igt_output_get_plane_type(data.output,
>  						    DRM_PLANE_TYPE_PRIMARY);
>  		igt_plane_set_fb(primary, NULL);
> -		igt_display_commit(&data->display);
> -		igt_remove_fb(data->drm_fd, &data->fb_test_pattern);
> +		igt_display_commit(&data.display);
> +		igt_remove_fb(data.drm_fd, &data.fb_test_pattern);
>  	}
>  }
>  
> +static void kms_dp_dsc_exit_handler(int sig) {
> +
> +	restore_dp_dsc_enable();
> +}
> +
>  
>  /*
>   * Re-probe connectors and do a modeset with DSC
>   *
>   */
> -static void update_display(data_t *data, enum dsc_test_type test_type)
> +static void update_display(enum dsc_test_type test_type)
>  {
>  	igt_plane_t *primary;
> -	data->mode = igt_output_get_mode(data->output);
> -	data->connector = data->output->config.connector;
> +	data.mode = igt_output_get_mode(data.output);
> +	data.connector = data.output->config.connector;
>  
> -	if (data->connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
> -	    data->pipe == PIPE_A) {
> +	if (data.connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
> +	    data.pipe == PIPE_A) {
>  		igt_debug("DSC not supported on Pipe A on external DP\n");
>  		return;
>  	}
>  
> +	/* Disable the output first */
> +	igt_output_set_pipe(data.output, PIPE_NONE);
> +	igt_display_commit(&data.display);
> +
>  	if (test_type == test_basic_dsc_enable) {
>  		bool enabled;
>  
> -		igt_debug("DSC is supported on %s\n", data->conn_name);
> -		force_dp_dsc_enable(data);
> +		igt_debug("DSC is supported on %s\n", data.conn_name);
> +		force_dp_dsc_enable();
>  
> -		igt_create_pattern_fb(data->drm_fd, data->mode->hdisplay,
> -				      data->mode->vdisplay,
> +		igt_output_set_pipe(data.output, data.pipe);
> +		igt_create_pattern_fb(data.drm_fd, data.mode->hdisplay,
> +				      data.mode->vdisplay,
>  				      DRM_FORMAT_XRGB8888,
>  				      LOCAL_DRM_FORMAT_MOD_NONE,
> -				      &data->fb_test_pattern);
> -		primary = igt_output_get_plane_type(data->output,
> +				      &data.fb_test_pattern);
> +		primary = igt_output_get_plane_type(data.output,
>  						    DRM_PLANE_TYPE_PRIMARY);
> -		igt_plane_set_fb(primary, &data->fb_test_pattern);
> -		igt_display_commit(&data->display);
> +
> +		/* Now set the output to the desired mode */
> +		igt_plane_set_fb(primary, &data.fb_test_pattern);
> +		igt_display_commit(&data.display);
>  
>  		/*
>  		 * Until we have CRC check support, manually check if RGB test
> @@ -183,38 +211,37 @@ static void update_display(data_t *data, enum dsc_test_type test_type)
>  		 */
>  		manual("RGB test pattern without corruption");
>  
> -		enabled = is_dp_dsc_enabled(data);
> -		clear_dp_dsc_enable(data);
> +		enabled = is_dp_dsc_enabled();
> +		restore_dp_dsc_enable();
>  
>  		igt_assert_f(enabled,
> -			     "Default DSC enable failed on Connector: %s Pipe: %s",
> -			     data->conn_name,
> -			     kmstest_pipe_name(data->pipe));
> +			     "Default DSC enable failed on Connector: %s Pipe: %s\n",
> +			     data.conn_name,
> +			     kmstest_pipe_name(data.pipe));
>  	} else {
>  		igt_assert(!"Unknown test type\n");
>  	}
>  }
>  
> -static void run_test(data_t *data, igt_output_t *output,
> +static void run_test(igt_output_t *output,
>  		     enum dsc_test_type test_type)
>  {
>  	enum pipe pipe;
>  
> -	for_each_pipe(&data->display, pipe) {
> +	for_each_pipe(&data.display, pipe) {
>  
>  		if (igt_pipe_connector_valid(pipe, output)) {
> -			igt_output_set_pipe(output, pipe);
> -			data->pipe = pipe;
> -			data->output = output;
> -			update_display(data, test_type);
> -			test_cleanup(data);
> +			data.pipe = pipe;
> +			data.output = output;
> +			update_display(test_type);
> +			test_cleanup();
>  		}
>  	}
>  }
>  
>  igt_main
>  {
> -	data_t data = {};
> +	//data_t data = {};

Leftover line.

>  	igt_output_t *output;
>  	drmModeRes *res;
>  	drmModeConnector *connector;
> @@ -225,6 +252,7 @@ igt_main
>  		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
>  		data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
>  		kmstest_set_vt_graphics_mode();
> +		igt_install_exit_handler(kms_dp_dsc_exit_handler);

Before this you need to actually save the original value, otherwise the
exit handler may restore an uninitialized value in case it's called
before you save it.

>  		igt_display_require(&data.display, data.drm_fd);
>  		igt_require(res = drmModeGetResources(data.drm_fd));
>  	}
> @@ -245,19 +273,20 @@ igt_main
>  				sprintf(data.conn_name, "%s-%d",
>  					kmstest_connector_type_str(connector->connector_type),
>  					connector->connector_type_id);
> -				if(!is_dp_dsc_supported(&data)) {
> +				if(!is_dp_dsc_supported()) {
>  					igt_debug("DSC not supported on connector %s \n",
>  						  data.conn_name);
>  					continue;
>  				}
>  				if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
> -				    !is_dp_fec_supported(&data)) {
> +				    !is_dp_fec_supported()) {
>  					igt_debug("DSC cannot be enabled without FEC on %s\n",
>  						  data.conn_name);
>  					continue;
>  				}
>  				test_conn_cnt++;
> -				run_test(&data, output, test_basic_dsc_enable);
> +				data.force_dsc_en = is_force_dsc_enabled();
> +				run_test(output, test_basic_dsc_enable);
>  			}
>  			igt_skip_on(test_conn_cnt == 0);
>  		}

Under igt_fixture you close debugfs_fd, but that's not good, since the
exit handler will be called even during normal process exit, and so the
exit handler will find unexpectedly that the fd it needs is closed.

Just leave the closing up to the exit handler as I commented above,
leaving a comment about this fact under igt_fixture.

--Imre

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

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

* Re: [igt-dev] [PATCH i-g-t v2] tests/kms_dp_dsc: Force a full modeset when we force dsc enable
  2019-04-08 12:08 ` [igt-dev] [PATCH i-g-t v2] tests/kms_dp_dsc: Force a full modeset when we force dsc enable Imre Deak
@ 2019-04-08 19:06   ` Manasi Navare
  2019-04-08 20:39     ` Imre Deak
  0 siblings, 1 reply; 8+ messages in thread
From: Manasi Navare @ 2019-04-08 19:06 UTC (permalink / raw)
  To: Imre Deak; +Cc: igt-dev, Anusha Srivatsa, Petri Latvala

On Mon, Apr 08, 2019 at 03:08:05PM +0300, Imre Deak wrote:
> On Fri, Apr 05, 2019 at 03:55:49PM -0700, Manasi Navare wrote:
> > DSC enable gets configured during compute_config and needs
> > a full modeset to force DSC.
> > Sometimes in between the tests, if the initial output is same as the
> > mode being set for DSC then it will not do a full modeset.
> > So we disable the output before forcing a mode with DSC enable.
> > 
> > You need the kernel patch:
> > https://patchwork.freedesktop.org/series/59084/
> > 
> > v2:
> > * Restore the value of force dsc enable after the test and in igt_exit_handler
> > * Add igt_install_exit_handler to restore values on fail/exit
> > 
> > Fixes: db19bccc1c22 ("test/kms_dp_dsc: Basic KMS test to validate VESA DSC on DP/eDP")
> > Cc: Petri Latvala <petri.latvala@intel.com>
> > Cc: Anusha Srivatsa <anusha.srivatsa@intel.com>
> > Cc: Imre Deak <imre.deak@intel.com>
> > Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> > ---
> >  tests/kms_dp_dsc.c | 133 +++++++++++++++++++++++++++------------------
> >  1 file changed, 81 insertions(+), 52 deletions(-)
> > 
> > diff --git a/tests/kms_dp_dsc.c b/tests/kms_dp_dsc.c
> > index da93cd74..acaee890 100644
> > --- a/tests/kms_dp_dsc.c
> > +++ b/tests/kms_dp_dsc.c
> > @@ -63,119 +63,147 @@ typedef struct {
> >  	int crtc;
> >  	enum pipe pipe;
> >  	char conn_name[128];
> > +	bool force_dsc_en;
> 
> force_dsc_en_orig?

Sure, I will rename this

> 
> >  } data_t;
> >  
> > +data_t data = {};
> > +
> 
> Maybe make only debugfs_fd and force_dsc_en_orig global to reduce the
> churn? Also init debugfs_fd to -1, so the exit handler knows if it's
> been closed already.

But then for restore I also need data.conn_name. So i thought I would make
the whole thing global.

> 
> >  static inline void manual(const char *expected)
> >  {
> >  	igt_debug_manual_check("all", expected);
> >  }
> >  
> > -static bool is_dp_dsc_supported(data_t *data)
> > +static bool is_dp_dsc_supported(void)
> >  {
> >  	char file_name[128] = {0};
> >  	char buf[512];
> >  
> > -	strcpy(file_name, data->conn_name);
> > +	strcpy(file_name, data.conn_name);
> >  	strcat(file_name, "/i915_dsc_fec_support");
> > -	igt_require(igt_debugfs_simple_read(data->debugfs_fd, file_name, buf,
> > +	igt_require(igt_debugfs_simple_read(data.debugfs_fd, file_name, buf,
> >  					    sizeof(buf)) > 0);
> > -	igt_debugfs_read(data->drm_fd, file_name, buf);
> > +	igt_debugfs_read(data.drm_fd, file_name, buf);
> >  
> >  	return strstr(buf, "DSC_Sink_Support: yes");
> >  }
> >  
> > -static bool is_dp_fec_supported(data_t *data)
> > +static bool is_dp_fec_supported(void)
> >  {
> >  	char file_name[128] = {0};
> >  	char buf[512];
> >  
> > -	strcpy(file_name, data->conn_name);
> > +	strcpy(file_name, data.conn_name);
> >  	strcat(file_name, "/i915_dsc_fec_support");
> > -	igt_debugfs_read(data->drm_fd, file_name, buf);
> > +	igt_debugfs_read(data.drm_fd, file_name, buf);
> >  
> >  	return strstr(buf, "FEC_Sink_Support: yes");
> >  }
> >  
> > -static bool is_dp_dsc_enabled(data_t *data)
> > +static bool is_dp_dsc_enabled(void)
> >  {
> >  	char file_name[128] = {0};
> >  	char buf[512];
> >  
> > -	strcpy(file_name, data->conn_name);
> > +	strcpy(file_name, data.conn_name);
> >  	strcat(file_name, "/i915_dsc_fec_support");
> > -	igt_debugfs_read(data->drm_fd, file_name, buf);
> > +	igt_debugfs_read(data.drm_fd, file_name, buf);
> >  
> >  	return strstr(buf, "DSC_Enabled: yes");
> >  }
> >  
> > -static void force_dp_dsc_enable(data_t *data)
> > +static bool is_force_dsc_enabled(void)
> > +{
> > +	char file_name[128] = {0};
> > +	char buf[512];
> > +
> > +	strcpy(file_name, data.conn_name);
> > +	strcat(file_name, "/i915_dsc_fec_support");
> > +	igt_debugfs_read(data.drm_fd, file_name, buf);
> > +
> > +	return strstr(buf, "Force_DSC_Enable: yes");
> > +}
> > +
> > +static void force_dp_dsc_enable(void)
> >  {
> >  	char file_name[128] = {0};
> >  	int ret;
> >  
> > -	strcpy(file_name, data->conn_name);
> > +	strcpy(file_name, data.conn_name);
> >  	strcat(file_name, "/i915_dsc_fec_support");
> > -	igt_debug ("Forcing DSC enable on %s\n", data->conn_name);
> > -	ret = igt_sysfs_write(data->debugfs_fd, file_name, "1", 1);
> > +	igt_debug ("Forcing DSC enable on %s\n", data.conn_name);
> > +	ret = igt_sysfs_write(data.debugfs_fd, file_name, "1", 1);
> >  	igt_assert_f(ret > 0, "debugfs_write failed");
> >  }
> >  
> > -static void clear_dp_dsc_enable(data_t *data)
> > +static void restore_dp_dsc_enable(void)
> 
> Better named as restore_force_dsc_en()?

Ok

> 
> >  {
> >  	char file_name[128] = {0};
> >  	int ret;
> >  
> 
> You need to check if the sig handler was called multiple times for some
> reason:
> 
> 	if (debugfs_fd < 0)
> 		return;

Ok will add this check here

> 
> > -	strcpy(file_name, data->conn_name);
> > +	strcpy(file_name, data.conn_name);
> >  	strcat(file_name, "/i915_dsc_fec_support");
> > -	igt_debug ("Clearing DSC enable on %s\n", data->conn_name);
> > -	ret = igt_sysfs_write(data->debugfs_fd, file_name, "0", 1);
> > +	igt_debug ("Restoring DSC enable on %s\n", data.conn_name);
> > +	ret = igt_sysfs_write(data.debugfs_fd, file_name,
> > +			      data.force_dsc_en ? "1" : "0", 1);
> 
> 	close(debugfs_fd);
> 	debugfs_fd = -1;

But if I close it here, I cant call restore function in update_display() after the test is completed.
Probably i dont need it there?

> 	
> >  	igt_assert_f(ret > 0, "debugfs_write failed");
> >  }
> >  
> > -static void test_cleanup(data_t *data) {
> > +static void test_cleanup(void) {
> >  	igt_plane_t *primary;
> >  
> > -	if (data->output) {
> > -		primary = igt_output_get_plane_type(data->output,
> > +	if (data.output) {
> > +		primary = igt_output_get_plane_type(data.output,
> >  						    DRM_PLANE_TYPE_PRIMARY);
> >  		igt_plane_set_fb(primary, NULL);
> > -		igt_display_commit(&data->display);
> > -		igt_remove_fb(data->drm_fd, &data->fb_test_pattern);
> > +		igt_display_commit(&data.display);
> > +		igt_remove_fb(data.drm_fd, &data.fb_test_pattern);
> >  	}
> >  }
> >  
> > +static void kms_dp_dsc_exit_handler(int sig) {
> > +
> > +	restore_dp_dsc_enable();
> > +}
> > +
> >  
> >  /*
> >   * Re-probe connectors and do a modeset with DSC
> >   *
> >   */
> > -static void update_display(data_t *data, enum dsc_test_type test_type)
> > +static void update_display(enum dsc_test_type test_type)
> >  {
> >  	igt_plane_t *primary;
> > -	data->mode = igt_output_get_mode(data->output);
> > -	data->connector = data->output->config.connector;
> > +	data.mode = igt_output_get_mode(data.output);
> > +	data.connector = data.output->config.connector;
> >  
> > -	if (data->connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
> > -	    data->pipe == PIPE_A) {
> > +	if (data.connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
> > +	    data.pipe == PIPE_A) {
> >  		igt_debug("DSC not supported on Pipe A on external DP\n");
> >  		return;
> >  	}
> >  
> > +	/* Disable the output first */
> > +	igt_output_set_pipe(data.output, PIPE_NONE);
> > +	igt_display_commit(&data.display);
> > +
> >  	if (test_type == test_basic_dsc_enable) {
> >  		bool enabled;
> >  
> > -		igt_debug("DSC is supported on %s\n", data->conn_name);
> > -		force_dp_dsc_enable(data);
> > +		igt_debug("DSC is supported on %s\n", data.conn_name);
> > +		force_dp_dsc_enable();
> >  
> > -		igt_create_pattern_fb(data->drm_fd, data->mode->hdisplay,
> > -				      data->mode->vdisplay,
> > +		igt_output_set_pipe(data.output, data.pipe);
> > +		igt_create_pattern_fb(data.drm_fd, data.mode->hdisplay,
> > +				      data.mode->vdisplay,
> >  				      DRM_FORMAT_XRGB8888,
> >  				      LOCAL_DRM_FORMAT_MOD_NONE,
> > -				      &data->fb_test_pattern);
> > -		primary = igt_output_get_plane_type(data->output,
> > +				      &data.fb_test_pattern);
> > +		primary = igt_output_get_plane_type(data.output,
> >  						    DRM_PLANE_TYPE_PRIMARY);
> > -		igt_plane_set_fb(primary, &data->fb_test_pattern);
> > -		igt_display_commit(&data->display);
> > +
> > +		/* Now set the output to the desired mode */
> > +		igt_plane_set_fb(primary, &data.fb_test_pattern);
> > +		igt_display_commit(&data.display);
> >  
> >  		/*
> >  		 * Until we have CRC check support, manually check if RGB test
> > @@ -183,38 +211,37 @@ static void update_display(data_t *data, enum dsc_test_type test_type)
> >  		 */
> >  		manual("RGB test pattern without corruption");
> >  
> > -		enabled = is_dp_dsc_enabled(data);
> > -		clear_dp_dsc_enable(data);
> > +		enabled = is_dp_dsc_enabled();
> > +		restore_dp_dsc_enable();
> >  
> >  		igt_assert_f(enabled,
> > -			     "Default DSC enable failed on Connector: %s Pipe: %s",
> > -			     data->conn_name,
> > -			     kmstest_pipe_name(data->pipe));
> > +			     "Default DSC enable failed on Connector: %s Pipe: %s\n",
> > +			     data.conn_name,
> > +			     kmstest_pipe_name(data.pipe));
> >  	} else {
> >  		igt_assert(!"Unknown test type\n");
> >  	}
> >  }
> >  
> > -static void run_test(data_t *data, igt_output_t *output,
> > +static void run_test(igt_output_t *output,
> >  		     enum dsc_test_type test_type)
> >  {
> >  	enum pipe pipe;
> >  
> > -	for_each_pipe(&data->display, pipe) {
> > +	for_each_pipe(&data.display, pipe) {
> >  
> >  		if (igt_pipe_connector_valid(pipe, output)) {
> > -			igt_output_set_pipe(output, pipe);
> > -			data->pipe = pipe;
> > -			data->output = output;
> > -			update_display(data, test_type);
> > -			test_cleanup(data);
> > +			data.pipe = pipe;
> > +			data.output = output;
> > +			update_display(test_type);
> > +			test_cleanup();
> >  		}
> >  	}
> >  }
> >  
> >  igt_main
> >  {
> > -	data_t data = {};
> > +	//data_t data = {};
> 
> Leftover line.

Yes, sorry about that, will clean it up

> 
> >  	igt_output_t *output;
> >  	drmModeRes *res;
> >  	drmModeConnector *connector;
> > @@ -225,6 +252,7 @@ igt_main
> >  		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
> >  		data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
> >  		kmstest_set_vt_graphics_mode();
> > +		igt_install_exit_handler(kms_dp_dsc_exit_handler);
> 
> Before this you need to actually save the original value, otherwise the
> exit handler may restore an uninitialized value in case it's called
> before you save it.

Since the value is per connector, I cant save it until I have gone through the whole connector type checks.
I will move the igt_install_exit_handler(kms_dp_dsc_exit_handler); to before run_test call then?


> 
> >  		igt_display_require(&data.display, data.drm_fd);
> >  		igt_require(res = drmModeGetResources(data.drm_fd));
> >  	}
> > @@ -245,19 +273,20 @@ igt_main
> >  				sprintf(data.conn_name, "%s-%d",
> >  					kmstest_connector_type_str(connector->connector_type),
> >  					connector->connector_type_id);
> > -				if(!is_dp_dsc_supported(&data)) {
> > +				if(!is_dp_dsc_supported()) {
> >  					igt_debug("DSC not supported on connector %s \n",
> >  						  data.conn_name);
> >  					continue;
> >  				}
> >  				if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
> > -				    !is_dp_fec_supported(&data)) {
> > +				    !is_dp_fec_supported()) {
> >  					igt_debug("DSC cannot be enabled without FEC on %s\n",
> >  						  data.conn_name);
> >  					continue;
> >  				}
> >  				test_conn_cnt++;
> > -				run_test(&data, output, test_basic_dsc_enable);
> > +				data.force_dsc_en = is_force_dsc_enabled();
> > +				run_test(output, test_basic_dsc_enable);
> >  			}
> >  			igt_skip_on(test_conn_cnt == 0);
> >  		}
> 
> Under igt_fixture you close debugfs_fd, but that's not good, since the
> exit handler will be called even during normal process exit, and so the
> exit handler will find unexpectedly that the fd it needs is closed.
> 
> Just leave the closing up to the exit handler as I commented above,
> leaving a comment about this fact under igt_fixture.

Ok will remove the debugfs fd from the igt_fixture()

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

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

* Re: [igt-dev] [PATCH i-g-t v2] tests/kms_dp_dsc: Force a full modeset when we force dsc enable
  2019-04-08 19:06   ` Manasi Navare
@ 2019-04-08 20:39     ` Imre Deak
  2019-04-08 20:48       ` Imre Deak
  2019-04-08 22:17       ` Manasi Navare
  0 siblings, 2 replies; 8+ messages in thread
From: Imre Deak @ 2019-04-08 20:39 UTC (permalink / raw)
  To: Manasi Navare; +Cc: igt-dev, Anusha Srivatsa, Petri Latvala

On Mon, Apr 08, 2019 at 12:06:37PM -0700, Manasi Navare wrote:
> On Mon, Apr 08, 2019 at 03:08:05PM +0300, Imre Deak wrote:
> > On Fri, Apr 05, 2019 at 03:55:49PM -0700, Manasi Navare wrote:
> > > DSC enable gets configured during compute_config and needs
> > > a full modeset to force DSC.
> > > Sometimes in between the tests, if the initial output is same as the
> > > mode being set for DSC then it will not do a full modeset.
> > > So we disable the output before forcing a mode with DSC enable.
> > > 
> > > You need the kernel patch:
> > > https://patchwork.freedesktop.org/series/59084/
> > > 
> > > v2:
> > > * Restore the value of force dsc enable after the test and in igt_exit_handler
> > > * Add igt_install_exit_handler to restore values on fail/exit
> > > 
> > > Fixes: db19bccc1c22 ("test/kms_dp_dsc: Basic KMS test to validate VESA DSC on DP/eDP")
> > > Cc: Petri Latvala <petri.latvala@intel.com>
> > > Cc: Anusha Srivatsa <anusha.srivatsa@intel.com>
> > > Cc: Imre Deak <imre.deak@intel.com>
> > > Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> > > ---
> > >  tests/kms_dp_dsc.c | 133 +++++++++++++++++++++++++++------------------
> > >  1 file changed, 81 insertions(+), 52 deletions(-)
> > > 
> > > diff --git a/tests/kms_dp_dsc.c b/tests/kms_dp_dsc.c
> > > index da93cd74..acaee890 100644
> > > --- a/tests/kms_dp_dsc.c
> > > +++ b/tests/kms_dp_dsc.c
> > > @@ -63,119 +63,147 @@ typedef struct {
> > >  	int crtc;
> > >  	enum pipe pipe;
> > >  	char conn_name[128];
> > > +	bool force_dsc_en;
> > 
> > force_dsc_en_orig?
> 
> Sure, I will rename this
> 
> > 
> > >  } data_t;
> > >  
> > > +data_t data = {};
> > > +
> > 
> > Maybe make only debugfs_fd and force_dsc_en_orig global to reduce the
> > churn? Also init debugfs_fd to -1, so the exit handler knows if it's
> > been closed already.
> 
> But then for restore I also need data.conn_name. So i thought I would make
> the whole thing global.

I'd still avoid the churn (making the review easier) by adding a new
global

	int force_dsc_restore_fd = -1;

using it for restoring the global force_dsc_en_orig. By doing that you
won't need conn_name in the exit handler, see below.

> > >  static inline void manual(const char *expected)
> > >  {
> > >  	igt_debug_manual_check("all", expected);
> > >  }
> > >  
> > > -static bool is_dp_dsc_supported(data_t *data)
> > > +static bool is_dp_dsc_supported(void)
> > >  {
> > >  	char file_name[128] = {0};
> > >  	char buf[512];
> > >  
> > > -	strcpy(file_name, data->conn_name);
> > > +	strcpy(file_name, data.conn_name);
> > >  	strcat(file_name, "/i915_dsc_fec_support");
> > > -	igt_require(igt_debugfs_simple_read(data->debugfs_fd, file_name, buf,
> > > +	igt_require(igt_debugfs_simple_read(data.debugfs_fd, file_name, buf,
> > >  					    sizeof(buf)) > 0);
> > > -	igt_debugfs_read(data->drm_fd, file_name, buf);
> > > +	igt_debugfs_read(data.drm_fd, file_name, buf);
> > >  
> > >  	return strstr(buf, "DSC_Sink_Support: yes");
> > >  }
> > >  
> > > -static bool is_dp_fec_supported(data_t *data)
> > > +static bool is_dp_fec_supported(void)
> > >  {
> > >  	char file_name[128] = {0};
> > >  	char buf[512];
> > >  
> > > -	strcpy(file_name, data->conn_name);
> > > +	strcpy(file_name, data.conn_name);
> > >  	strcat(file_name, "/i915_dsc_fec_support");
> > > -	igt_debugfs_read(data->drm_fd, file_name, buf);
> > > +	igt_debugfs_read(data.drm_fd, file_name, buf);
> > >  
> > >  	return strstr(buf, "FEC_Sink_Support: yes");
> > >  }
> > >  
> > > -static bool is_dp_dsc_enabled(data_t *data)
> > > +static bool is_dp_dsc_enabled(void)
> > >  {
> > >  	char file_name[128] = {0};
> > >  	char buf[512];
> > >  
> > > -	strcpy(file_name, data->conn_name);
> > > +	strcpy(file_name, data.conn_name);
> > >  	strcat(file_name, "/i915_dsc_fec_support");
> > > -	igt_debugfs_read(data->drm_fd, file_name, buf);
> > > +	igt_debugfs_read(data.drm_fd, file_name, buf);
> > >  
> > >  	return strstr(buf, "DSC_Enabled: yes");
> > >  }
> > >  
> > > -static void force_dp_dsc_enable(data_t *data)
> > > +static bool is_force_dsc_enabled(void)
> > > +{
> > > +	char file_name[128] = {0};
> > > +	char buf[512];
> > > +
> > > +	strcpy(file_name, data.conn_name);
> > > +	strcat(file_name, "/i915_dsc_fec_support");
> > > +	igt_debugfs_read(data.drm_fd, file_name, buf);
> > > +
> > > +	return strstr(buf, "Force_DSC_Enable: yes");
> > > +}
> > > +
> > > +static void force_dp_dsc_enable(void)
> > >  {
> > >  	char file_name[128] = {0};
> > >  	int ret;
> > >  
> > > -	strcpy(file_name, data->conn_name);
> > > +	strcpy(file_name, data.conn_name);
> > >  	strcat(file_name, "/i915_dsc_fec_support");
> > > -	igt_debug ("Forcing DSC enable on %s\n", data->conn_name);
> > > -	ret = igt_sysfs_write(data->debugfs_fd, file_name, "1", 1);
> > > +	igt_debug ("Forcing DSC enable on %s\n", data.conn_name);
> > > +	ret = igt_sysfs_write(data.debugfs_fd, file_name, "1", 1);
> > >  	igt_assert_f(ret > 0, "debugfs_write failed");
> > >  }
> > >  
> > > -static void clear_dp_dsc_enable(data_t *data)
> > > +static void restore_dp_dsc_enable(void)
> > 
> > Better named as restore_force_dsc_en()?
> 
> Ok
> 
> > 
> > >  {
> > >  	char file_name[128] = {0};
> > >  	int ret;
> > >  
> > 
> > You need to check if the sig handler was called multiple times for some
> > reason:
> > 
> > 	if (debugfs_fd < 0)
> > 		return;
> 
> Ok will add this check here
>
> > > -	strcpy(file_name, data->conn_name);
> > > +	strcpy(file_name, data.conn_name);
> > >  	strcat(file_name, "/i915_dsc_fec_support");
> > > -	igt_debug ("Clearing DSC enable on %s\n", data->conn_name);
> > > -	ret = igt_sysfs_write(data->debugfs_fd, file_name, "0", 1);
> > > +	igt_debug ("Restoring DSC enable on %s\n", data.conn_name);
> > > +	ret = igt_sysfs_write(data.debugfs_fd, file_name,
> > > +			      data.force_dsc_en ? "1" : "0", 1);

Instead of the above:

static void restore_force_dsc_en(void)
{
	if (force_dsc_restore_fd < 0)
		return;

	igt_debug("Restoring DSC enable\n");
	igt_assert(write(force_dsc_restore_fd, force_dsc_en_orig ? "1" : "0", 1) == 1);

	close(force_dsc_restore_fd);
	force_dsc_restore_fd = -1;
}

> But if I close it here, I cant call restore function in
> update_display() after the test is completed.  
> Probably i dont need it there?

Yes it's needed, we want to do the restore for each connector.

>
> > >  	igt_assert_f(ret > 0, "debugfs_write failed");
> > >  }
> > >  
> > > -static void test_cleanup(data_t *data) {
> > > +static void test_cleanup(void) {
> > >  	igt_plane_t *primary;
> > >  
> > > -	if (data->output) {
> > > -		primary = igt_output_get_plane_type(data->output,
> > > +	if (data.output) {
> > > +		primary = igt_output_get_plane_type(data.output,
> > >  						    DRM_PLANE_TYPE_PRIMARY);
> > >  		igt_plane_set_fb(primary, NULL);
> > > -		igt_display_commit(&data->display);
> > > -		igt_remove_fb(data->drm_fd, &data->fb_test_pattern);
> > > +		igt_display_commit(&data.display);
> > > +		igt_remove_fb(data.drm_fd, &data.fb_test_pattern);
> > >  	}
> > >  }
> > >  
> > > +static void kms_dp_dsc_exit_handler(int sig) {
> > > +
> > > +	restore_dp_dsc_enable();
> > > +}
> > > +
> > >  
> > >  /*
> > >   * Re-probe connectors and do a modeset with DSC
> > >   *
> > >   */
> > > -static void update_display(data_t *data, enum dsc_test_type test_type)
> > > +static void update_display(enum dsc_test_type test_type)
> > >  {
> > >  	igt_plane_t *primary;
> > > -	data->mode = igt_output_get_mode(data->output);
> > > -	data->connector = data->output->config.connector;
> > > +	data.mode = igt_output_get_mode(data.output);
> > > +	data.connector = data.output->config.connector;
> > >  
> > > -	if (data->connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
> > > -	    data->pipe == PIPE_A) {
> > > +	if (data.connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
> > > +	    data.pipe == PIPE_A) {
> > >  		igt_debug("DSC not supported on Pipe A on external DP\n");
> > >  		return;
> > >  	}
> > >  
> > > +	/* Disable the output first */
> > > +	igt_output_set_pipe(data.output, PIPE_NONE);
> > > +	igt_display_commit(&data.display);
> > > +
> > >  	if (test_type == test_basic_dsc_enable) {
> > >  		bool enabled;
> > >  
> > > -		igt_debug("DSC is supported on %s\n", data->conn_name);
> > > -		force_dp_dsc_enable(data);
> > > +		igt_debug("DSC is supported on %s\n", data.conn_name);

Here call a new save_force_dsc_en() function containing:

		force_dsc_en_orig = is_force_dsc_enabled(data);
		strcpy(file_name, data->conn_name);
		strcat(file_name, "/i915_dsc_fec_support");
		force_dsc_restore_fd = openat(igt_debugfs_dir(data->drm_fd),
					      file_name, O_WRONLY);
		igt_assert(force_dsc_restore_fd >= 0);


> > > +		force_dp_dsc_enable();
> > >  
> > > -		igt_create_pattern_fb(data->drm_fd, data->mode->hdisplay,
> > > -				      data->mode->vdisplay,
> > > +		igt_output_set_pipe(data.output, data.pipe);
> > > +		igt_create_pattern_fb(data.drm_fd, data.mode->hdisplay,
> > > +				      data.mode->vdisplay,
> > >  				      DRM_FORMAT_XRGB8888,
> > >  				      LOCAL_DRM_FORMAT_MOD_NONE,
> > > -				      &data->fb_test_pattern);
> > > -		primary = igt_output_get_plane_type(data->output,
> > > +				      &data.fb_test_pattern);
> > > +		primary = igt_output_get_plane_type(data.output,
> > >  						    DRM_PLANE_TYPE_PRIMARY);
> > > -		igt_plane_set_fb(primary, &data->fb_test_pattern);
> > > -		igt_display_commit(&data->display);
> > > +
> > > +		/* Now set the output to the desired mode */
> > > +		igt_plane_set_fb(primary, &data.fb_test_pattern);
> > > +		igt_display_commit(&data.display);
> > >  
> > >  		/*
> > >  		 * Until we have CRC check support, manually check if RGB test
> > > @@ -183,38 +211,37 @@ static void update_display(data_t *data, enum dsc_test_type test_type)
> > >  		 */
> > >  		manual("RGB test pattern without corruption");
> > >  
> > > -		enabled = is_dp_dsc_enabled(data);
> > > -		clear_dp_dsc_enable(data);
> > > +		enabled = is_dp_dsc_enabled();
> > > +		restore_dp_dsc_enable();
> > >  
> > >  		igt_assert_f(enabled,
> > > -			     "Default DSC enable failed on Connector: %s Pipe: %s",
> > > -			     data->conn_name,
> > > -			     kmstest_pipe_name(data->pipe));
> > > +			     "Default DSC enable failed on Connector: %s Pipe: %s\n",
> > > +			     data.conn_name,
> > > +			     kmstest_pipe_name(data.pipe));
> > >  	} else {
> > >  		igt_assert(!"Unknown test type\n");
> > >  	}
> > >  }
> > >  
> > > -static void run_test(data_t *data, igt_output_t *output,
> > > +static void run_test(igt_output_t *output,
> > >  		     enum dsc_test_type test_type)
> > >  {
> > >  	enum pipe pipe;
> > >  
> > > -	for_each_pipe(&data->display, pipe) {
> > > +	for_each_pipe(&data.display, pipe) {
> > >  
> > >  		if (igt_pipe_connector_valid(pipe, output)) {
> > > -			igt_output_set_pipe(output, pipe);
> > > -			data->pipe = pipe;
> > > -			data->output = output;
> > > -			update_display(data, test_type);
> > > -			test_cleanup(data);
> > > +			data.pipe = pipe;
> > > +			data.output = output;
> > > +			update_display(test_type);
> > > +			test_cleanup();
> > >  		}
> > >  	}
> > >  }
> > >  
> > >  igt_main
> > >  {
> > > -	data_t data = {};
> > > +	//data_t data = {};
> > 
> > Leftover line.
> 
> Yes, sorry about that, will clean it up
> 
> > 
> > >  	igt_output_t *output;
> > >  	drmModeRes *res;
> > >  	drmModeConnector *connector;
> > > @@ -225,6 +252,7 @@ igt_main
> > >  		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
> > >  		data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
> > >  		kmstest_set_vt_graphics_mode();
> > > +		igt_install_exit_handler(kms_dp_dsc_exit_handler);
> > 
> > Before this you need to actually save the original value, otherwise the
> > exit handler may restore an uninitialized value in case it's called
> > before you save it.
> 
> Since the value is per connector, I cant save it until I have gone
> through the whole connector type checks.  I will move the
> igt_install_exit_handler(kms_dp_dsc_exit_handler); to before run_test
> call then?

It can stay here based on the above comments.

> > 
> > >  		igt_display_require(&data.display, data.drm_fd);
> > >  		igt_require(res = drmModeGetResources(data.drm_fd));
> > >  	}
> > > @@ -245,19 +273,20 @@ igt_main
> > >  				sprintf(data.conn_name, "%s-%d",
> > >  					kmstest_connector_type_str(connector->connector_type),
> > >  					connector->connector_type_id);
> > > -				if(!is_dp_dsc_supported(&data)) {
> > > +				if(!is_dp_dsc_supported()) {
> > >  					igt_debug("DSC not supported on connector %s \n",
> > >  						  data.conn_name);
> > >  					continue;
> > >  				}
> > >  				if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
> > > -				    !is_dp_fec_supported(&data)) {
> > > +				    !is_dp_fec_supported()) {
> > >  					igt_debug("DSC cannot be enabled without FEC on %s\n",
> > >  						  data.conn_name);
> > >  					continue;
> > >  				}
> > >  				test_conn_cnt++;
> > > -				run_test(&data, output, test_basic_dsc_enable);
> > > +				data.force_dsc_en = is_force_dsc_enabled();
> > > +				run_test(output, test_basic_dsc_enable);
> > >  			}
> > >  			igt_skip_on(test_conn_cnt == 0);
> > >  		}
> > 
> > Under igt_fixture you close debugfs_fd, but that's not good, since the
> > exit handler will be called even during normal process exit, and so the
> > exit handler will find unexpectedly that the fd it needs is closed.
> > 
> > Just leave the closing up to the exit handler as I commented above,
> > leaving a comment about this fact under igt_fixture.
> 
> Ok will remove the debugfs fd from the igt_fixture()

Based on the above you'll still need to close here debugfs_fd, as we'll
now use a separate fd for restoring.

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

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

* Re: [igt-dev] [PATCH i-g-t v2] tests/kms_dp_dsc: Force a full modeset when we force dsc enable
  2019-04-08 20:39     ` Imre Deak
@ 2019-04-08 20:48       ` Imre Deak
  2019-04-08 22:17       ` Manasi Navare
  1 sibling, 0 replies; 8+ messages in thread
From: Imre Deak @ 2019-04-08 20:48 UTC (permalink / raw)
  To: Manasi Navare; +Cc: igt-dev, Anusha Srivatsa, Petri Latvala

On Mon, Apr 08, 2019 at 11:39:27PM +0300, Imre Deak wrote:
> On Mon, Apr 08, 2019 at 12:06:37PM -0700, Manasi Navare wrote:
> > On Mon, Apr 08, 2019 at 03:08:05PM +0300, Imre Deak wrote:
> > > On Fri, Apr 05, 2019 at 03:55:49PM -0700, Manasi Navare wrote:
> > > > DSC enable gets configured during compute_config and needs
> > > > a full modeset to force DSC.
> > > > Sometimes in between the tests, if the initial output is same as the
> > > > mode being set for DSC then it will not do a full modeset.
> > > > So we disable the output before forcing a mode with DSC enable.
> > > > 
> > > > You need the kernel patch:
> > > > https://patchwork.freedesktop.org/series/59084/
> > > > 
> > > > v2:
> > > > * Restore the value of force dsc enable after the test and in igt_exit_handler
> > > > * Add igt_install_exit_handler to restore values on fail/exit

Also, please split the fix restoring force_dsc_en into a separate patch. 

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

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

* Re: [igt-dev] [PATCH i-g-t v2] tests/kms_dp_dsc: Force a full modeset when we force dsc enable
  2019-04-08 20:39     ` Imre Deak
  2019-04-08 20:48       ` Imre Deak
@ 2019-04-08 22:17       ` Manasi Navare
  1 sibling, 0 replies; 8+ messages in thread
From: Manasi Navare @ 2019-04-08 22:17 UTC (permalink / raw)
  To: Imre Deak, igt-dev; +Cc: Anusha Srivatsa, Petri Latvala

Thanks for your feedback Imre, I will make the necessary changes
and split these into two separate patches.

Regards
Manasi

On Mon, Apr 08, 2019 at 11:39:27PM +0300, Imre Deak wrote:
> On Mon, Apr 08, 2019 at 12:06:37PM -0700, Manasi Navare wrote:
> > On Mon, Apr 08, 2019 at 03:08:05PM +0300, Imre Deak wrote:
> > > On Fri, Apr 05, 2019 at 03:55:49PM -0700, Manasi Navare wrote:
> > > > DSC enable gets configured during compute_config and needs
> > > > a full modeset to force DSC.
> > > > Sometimes in between the tests, if the initial output is same as the
> > > > mode being set for DSC then it will not do a full modeset.
> > > > So we disable the output before forcing a mode with DSC enable.
> > > > 
> > > > You need the kernel patch:
> > > > https://patchwork.freedesktop.org/series/59084/
> > > > 
> > > > v2:
> > > > * Restore the value of force dsc enable after the test and in igt_exit_handler
> > > > * Add igt_install_exit_handler to restore values on fail/exit
> > > > 
> > > > Fixes: db19bccc1c22 ("test/kms_dp_dsc: Basic KMS test to validate VESA DSC on DP/eDP")
> > > > Cc: Petri Latvala <petri.latvala@intel.com>
> > > > Cc: Anusha Srivatsa <anusha.srivatsa@intel.com>
> > > > Cc: Imre Deak <imre.deak@intel.com>
> > > > Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> > > > ---
> > > >  tests/kms_dp_dsc.c | 133 +++++++++++++++++++++++++++------------------
> > > >  1 file changed, 81 insertions(+), 52 deletions(-)
> > > > 
> > > > diff --git a/tests/kms_dp_dsc.c b/tests/kms_dp_dsc.c
> > > > index da93cd74..acaee890 100644
> > > > --- a/tests/kms_dp_dsc.c
> > > > +++ b/tests/kms_dp_dsc.c
> > > > @@ -63,119 +63,147 @@ typedef struct {
> > > >  	int crtc;
> > > >  	enum pipe pipe;
> > > >  	char conn_name[128];
> > > > +	bool force_dsc_en;
> > > 
> > > force_dsc_en_orig?
> > 
> > Sure, I will rename this
> > 
> > > 
> > > >  } data_t;
> > > >  
> > > > +data_t data = {};
> > > > +
> > > 
> > > Maybe make only debugfs_fd and force_dsc_en_orig global to reduce the
> > > churn? Also init debugfs_fd to -1, so the exit handler knows if it's
> > > been closed already.
> > 
> > But then for restore I also need data.conn_name. So i thought I would make
> > the whole thing global.
> 
> I'd still avoid the churn (making the review easier) by adding a new
> global
> 
> 	int force_dsc_restore_fd = -1;
> 
> using it for restoring the global force_dsc_en_orig. By doing that you
> won't need conn_name in the exit handler, see below.
> 
> > > >  static inline void manual(const char *expected)
> > > >  {
> > > >  	igt_debug_manual_check("all", expected);
> > > >  }
> > > >  
> > > > -static bool is_dp_dsc_supported(data_t *data)
> > > > +static bool is_dp_dsc_supported(void)
> > > >  {
> > > >  	char file_name[128] = {0};
> > > >  	char buf[512];
> > > >  
> > > > -	strcpy(file_name, data->conn_name);
> > > > +	strcpy(file_name, data.conn_name);
> > > >  	strcat(file_name, "/i915_dsc_fec_support");
> > > > -	igt_require(igt_debugfs_simple_read(data->debugfs_fd, file_name, buf,
> > > > +	igt_require(igt_debugfs_simple_read(data.debugfs_fd, file_name, buf,
> > > >  					    sizeof(buf)) > 0);
> > > > -	igt_debugfs_read(data->drm_fd, file_name, buf);
> > > > +	igt_debugfs_read(data.drm_fd, file_name, buf);
> > > >  
> > > >  	return strstr(buf, "DSC_Sink_Support: yes");
> > > >  }
> > > >  
> > > > -static bool is_dp_fec_supported(data_t *data)
> > > > +static bool is_dp_fec_supported(void)
> > > >  {
> > > >  	char file_name[128] = {0};
> > > >  	char buf[512];
> > > >  
> > > > -	strcpy(file_name, data->conn_name);
> > > > +	strcpy(file_name, data.conn_name);
> > > >  	strcat(file_name, "/i915_dsc_fec_support");
> > > > -	igt_debugfs_read(data->drm_fd, file_name, buf);
> > > > +	igt_debugfs_read(data.drm_fd, file_name, buf);
> > > >  
> > > >  	return strstr(buf, "FEC_Sink_Support: yes");
> > > >  }
> > > >  
> > > > -static bool is_dp_dsc_enabled(data_t *data)
> > > > +static bool is_dp_dsc_enabled(void)
> > > >  {
> > > >  	char file_name[128] = {0};
> > > >  	char buf[512];
> > > >  
> > > > -	strcpy(file_name, data->conn_name);
> > > > +	strcpy(file_name, data.conn_name);
> > > >  	strcat(file_name, "/i915_dsc_fec_support");
> > > > -	igt_debugfs_read(data->drm_fd, file_name, buf);
> > > > +	igt_debugfs_read(data.drm_fd, file_name, buf);
> > > >  
> > > >  	return strstr(buf, "DSC_Enabled: yes");
> > > >  }
> > > >  
> > > > -static void force_dp_dsc_enable(data_t *data)
> > > > +static bool is_force_dsc_enabled(void)
> > > > +{
> > > > +	char file_name[128] = {0};
> > > > +	char buf[512];
> > > > +
> > > > +	strcpy(file_name, data.conn_name);
> > > > +	strcat(file_name, "/i915_dsc_fec_support");
> > > > +	igt_debugfs_read(data.drm_fd, file_name, buf);
> > > > +
> > > > +	return strstr(buf, "Force_DSC_Enable: yes");
> > > > +}
> > > > +
> > > > +static void force_dp_dsc_enable(void)
> > > >  {
> > > >  	char file_name[128] = {0};
> > > >  	int ret;
> > > >  
> > > > -	strcpy(file_name, data->conn_name);
> > > > +	strcpy(file_name, data.conn_name);
> > > >  	strcat(file_name, "/i915_dsc_fec_support");
> > > > -	igt_debug ("Forcing DSC enable on %s\n", data->conn_name);
> > > > -	ret = igt_sysfs_write(data->debugfs_fd, file_name, "1", 1);
> > > > +	igt_debug ("Forcing DSC enable on %s\n", data.conn_name);
> > > > +	ret = igt_sysfs_write(data.debugfs_fd, file_name, "1", 1);
> > > >  	igt_assert_f(ret > 0, "debugfs_write failed");
> > > >  }
> > > >  
> > > > -static void clear_dp_dsc_enable(data_t *data)
> > > > +static void restore_dp_dsc_enable(void)
> > > 
> > > Better named as restore_force_dsc_en()?
> > 
> > Ok
> > 
> > > 
> > > >  {
> > > >  	char file_name[128] = {0};
> > > >  	int ret;
> > > >  
> > > 
> > > You need to check if the sig handler was called multiple times for some
> > > reason:
> > > 
> > > 	if (debugfs_fd < 0)
> > > 		return;
> > 
> > Ok will add this check here
> >
> > > > -	strcpy(file_name, data->conn_name);
> > > > +	strcpy(file_name, data.conn_name);
> > > >  	strcat(file_name, "/i915_dsc_fec_support");
> > > > -	igt_debug ("Clearing DSC enable on %s\n", data->conn_name);
> > > > -	ret = igt_sysfs_write(data->debugfs_fd, file_name, "0", 1);
> > > > +	igt_debug ("Restoring DSC enable on %s\n", data.conn_name);
> > > > +	ret = igt_sysfs_write(data.debugfs_fd, file_name,
> > > > +			      data.force_dsc_en ? "1" : "0", 1);
> 
> Instead of the above:
> 
> static void restore_force_dsc_en(void)
> {
> 	if (force_dsc_restore_fd < 0)
> 		return;
> 
> 	igt_debug("Restoring DSC enable\n");
> 	igt_assert(write(force_dsc_restore_fd, force_dsc_en_orig ? "1" : "0", 1) == 1);
> 
> 	close(force_dsc_restore_fd);
> 	force_dsc_restore_fd = -1;
> }
> 
> > But if I close it here, I cant call restore function in
> > update_display() after the test is completed.  
> > Probably i dont need it there?
> 
> Yes it's needed, we want to do the restore for each connector.
> 
> >
> > > >  	igt_assert_f(ret > 0, "debugfs_write failed");
> > > >  }
> > > >  
> > > > -static void test_cleanup(data_t *data) {
> > > > +static void test_cleanup(void) {
> > > >  	igt_plane_t *primary;
> > > >  
> > > > -	if (data->output) {
> > > > -		primary = igt_output_get_plane_type(data->output,
> > > > +	if (data.output) {
> > > > +		primary = igt_output_get_plane_type(data.output,
> > > >  						    DRM_PLANE_TYPE_PRIMARY);
> > > >  		igt_plane_set_fb(primary, NULL);
> > > > -		igt_display_commit(&data->display);
> > > > -		igt_remove_fb(data->drm_fd, &data->fb_test_pattern);
> > > > +		igt_display_commit(&data.display);
> > > > +		igt_remove_fb(data.drm_fd, &data.fb_test_pattern);
> > > >  	}
> > > >  }
> > > >  
> > > > +static void kms_dp_dsc_exit_handler(int sig) {
> > > > +
> > > > +	restore_dp_dsc_enable();
> > > > +}
> > > > +
> > > >  
> > > >  /*
> > > >   * Re-probe connectors and do a modeset with DSC
> > > >   *
> > > >   */
> > > > -static void update_display(data_t *data, enum dsc_test_type test_type)
> > > > +static void update_display(enum dsc_test_type test_type)
> > > >  {
> > > >  	igt_plane_t *primary;
> > > > -	data->mode = igt_output_get_mode(data->output);
> > > > -	data->connector = data->output->config.connector;
> > > > +	data.mode = igt_output_get_mode(data.output);
> > > > +	data.connector = data.output->config.connector;
> > > >  
> > > > -	if (data->connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
> > > > -	    data->pipe == PIPE_A) {
> > > > +	if (data.connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
> > > > +	    data.pipe == PIPE_A) {
> > > >  		igt_debug("DSC not supported on Pipe A on external DP\n");
> > > >  		return;
> > > >  	}
> > > >  
> > > > +	/* Disable the output first */
> > > > +	igt_output_set_pipe(data.output, PIPE_NONE);
> > > > +	igt_display_commit(&data.display);
> > > > +
> > > >  	if (test_type == test_basic_dsc_enable) {
> > > >  		bool enabled;
> > > >  
> > > > -		igt_debug("DSC is supported on %s\n", data->conn_name);
> > > > -		force_dp_dsc_enable(data);
> > > > +		igt_debug("DSC is supported on %s\n", data.conn_name);
> 
> Here call a new save_force_dsc_en() function containing:
> 
> 		force_dsc_en_orig = is_force_dsc_enabled(data);
> 		strcpy(file_name, data->conn_name);
> 		strcat(file_name, "/i915_dsc_fec_support");
> 		force_dsc_restore_fd = openat(igt_debugfs_dir(data->drm_fd),
> 					      file_name, O_WRONLY);
> 		igt_assert(force_dsc_restore_fd >= 0);
> 
> 
> > > > +		force_dp_dsc_enable();
> > > >  
> > > > -		igt_create_pattern_fb(data->drm_fd, data->mode->hdisplay,
> > > > -				      data->mode->vdisplay,
> > > > +		igt_output_set_pipe(data.output, data.pipe);
> > > > +		igt_create_pattern_fb(data.drm_fd, data.mode->hdisplay,
> > > > +				      data.mode->vdisplay,
> > > >  				      DRM_FORMAT_XRGB8888,
> > > >  				      LOCAL_DRM_FORMAT_MOD_NONE,
> > > > -				      &data->fb_test_pattern);
> > > > -		primary = igt_output_get_plane_type(data->output,
> > > > +				      &data.fb_test_pattern);
> > > > +		primary = igt_output_get_plane_type(data.output,
> > > >  						    DRM_PLANE_TYPE_PRIMARY);
> > > > -		igt_plane_set_fb(primary, &data->fb_test_pattern);
> > > > -		igt_display_commit(&data->display);
> > > > +
> > > > +		/* Now set the output to the desired mode */
> > > > +		igt_plane_set_fb(primary, &data.fb_test_pattern);
> > > > +		igt_display_commit(&data.display);
> > > >  
> > > >  		/*
> > > >  		 * Until we have CRC check support, manually check if RGB test
> > > > @@ -183,38 +211,37 @@ static void update_display(data_t *data, enum dsc_test_type test_type)
> > > >  		 */
> > > >  		manual("RGB test pattern without corruption");
> > > >  
> > > > -		enabled = is_dp_dsc_enabled(data);
> > > > -		clear_dp_dsc_enable(data);
> > > > +		enabled = is_dp_dsc_enabled();
> > > > +		restore_dp_dsc_enable();
> > > >  
> > > >  		igt_assert_f(enabled,
> > > > -			     "Default DSC enable failed on Connector: %s Pipe: %s",
> > > > -			     data->conn_name,
> > > > -			     kmstest_pipe_name(data->pipe));
> > > > +			     "Default DSC enable failed on Connector: %s Pipe: %s\n",
> > > > +			     data.conn_name,
> > > > +			     kmstest_pipe_name(data.pipe));
> > > >  	} else {
> > > >  		igt_assert(!"Unknown test type\n");
> > > >  	}
> > > >  }
> > > >  
> > > > -static void run_test(data_t *data, igt_output_t *output,
> > > > +static void run_test(igt_output_t *output,
> > > >  		     enum dsc_test_type test_type)
> > > >  {
> > > >  	enum pipe pipe;
> > > >  
> > > > -	for_each_pipe(&data->display, pipe) {
> > > > +	for_each_pipe(&data.display, pipe) {
> > > >  
> > > >  		if (igt_pipe_connector_valid(pipe, output)) {
> > > > -			igt_output_set_pipe(output, pipe);
> > > > -			data->pipe = pipe;
> > > > -			data->output = output;
> > > > -			update_display(data, test_type);
> > > > -			test_cleanup(data);
> > > > +			data.pipe = pipe;
> > > > +			data.output = output;
> > > > +			update_display(test_type);
> > > > +			test_cleanup();
> > > >  		}
> > > >  	}
> > > >  }
> > > >  
> > > >  igt_main
> > > >  {
> > > > -	data_t data = {};
> > > > +	//data_t data = {};
> > > 
> > > Leftover line.
> > 
> > Yes, sorry about that, will clean it up
> > 
> > > 
> > > >  	igt_output_t *output;
> > > >  	drmModeRes *res;
> > > >  	drmModeConnector *connector;
> > > > @@ -225,6 +252,7 @@ igt_main
> > > >  		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
> > > >  		data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
> > > >  		kmstest_set_vt_graphics_mode();
> > > > +		igt_install_exit_handler(kms_dp_dsc_exit_handler);
> > > 
> > > Before this you need to actually save the original value, otherwise the
> > > exit handler may restore an uninitialized value in case it's called
> > > before you save it.
> > 
> > Since the value is per connector, I cant save it until I have gone
> > through the whole connector type checks.  I will move the
> > igt_install_exit_handler(kms_dp_dsc_exit_handler); to before run_test
> > call then?
> 
> It can stay here based on the above comments.
> 
> > > 
> > > >  		igt_display_require(&data.display, data.drm_fd);
> > > >  		igt_require(res = drmModeGetResources(data.drm_fd));
> > > >  	}
> > > > @@ -245,19 +273,20 @@ igt_main
> > > >  				sprintf(data.conn_name, "%s-%d",
> > > >  					kmstest_connector_type_str(connector->connector_type),
> > > >  					connector->connector_type_id);
> > > > -				if(!is_dp_dsc_supported(&data)) {
> > > > +				if(!is_dp_dsc_supported()) {
> > > >  					igt_debug("DSC not supported on connector %s \n",
> > > >  						  data.conn_name);
> > > >  					continue;
> > > >  				}
> > > >  				if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
> > > > -				    !is_dp_fec_supported(&data)) {
> > > > +				    !is_dp_fec_supported()) {
> > > >  					igt_debug("DSC cannot be enabled without FEC on %s\n",
> > > >  						  data.conn_name);
> > > >  					continue;
> > > >  				}
> > > >  				test_conn_cnt++;
> > > > -				run_test(&data, output, test_basic_dsc_enable);
> > > > +				data.force_dsc_en = is_force_dsc_enabled();
> > > > +				run_test(output, test_basic_dsc_enable);
> > > >  			}
> > > >  			igt_skip_on(test_conn_cnt == 0);
> > > >  		}
> > > 
> > > Under igt_fixture you close debugfs_fd, but that's not good, since the
> > > exit handler will be called even during normal process exit, and so the
> > > exit handler will find unexpectedly that the fd it needs is closed.
> > > 
> > > Just leave the closing up to the exit handler as I commented above,
> > > leaving a comment about this fact under igt_fixture.
> > 
> > Ok will remove the debugfs fd from the igt_fixture()
> 
> Based on the above you'll still need to close here debugfs_fd, as we'll
> now use a separate fd for restoring.
> 
> > 
> > Manasi
> > > 
> > > --Imre
> > > 
> > > > -- 
> > > > 2.19.1
> > > > 
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

end of thread, other threads:[~2019-04-08 22:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-05 22:55 [igt-dev] [PATCH i-g-t v2] tests/kms_dp_dsc: Force a full modeset when we force dsc enable Manasi Navare
2019-04-05 23:30 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/kms_dp_dsc: Force a full modeset when we force dsc enable (rev2) Patchwork
2019-04-06 23:22 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-04-08 12:08 ` [igt-dev] [PATCH i-g-t v2] tests/kms_dp_dsc: Force a full modeset when we force dsc enable Imre Deak
2019-04-08 19:06   ` Manasi Navare
2019-04-08 20:39     ` Imre Deak
2019-04-08 20:48       ` Imre Deak
2019-04-08 22:17       ` Manasi Navare

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.