Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Hersen Wu <hersenxs.wu@amd.com>
To: <igt-dev@lists.freedesktop.org>, <rodrigo.siqueira@amd.com>,
	<aurabindo.pillai@amd.com>, <alex.hung@amd.com>,
	<hamza.mahfooz@amd.com>, <sunpeng.li@amd.com>,
	<wayne.lin@amd.com>
Cc: <markyacoub@google.com>, Hersen Wu <Hersenxs.Wu@amd.com>
Subject: [PATCH] [i-g-t] tests/amdgpu/amd_ilr: Fix eDP PSR not be re-enabled after test
Date: Mon, 25 Mar 2024 09:19:26 -0400	[thread overview]
Message-ID: <20240325131926.42203-1-hersenxs.wu@amd.com> (raw)

From: Hersen Wu <Hersenxs.Wu@amd.com>

At end of test, with disallow_edp_enter_psr = 0, run DPMS off, on
for eDP. This will trigger DRM kernel driver enable eDP PSR.

Signed-off-by: Hersen Wu <Hersenxs.Wu@amd.com>
---
 lib/igt_amd.c          |  5 ---
 tests/amdgpu/amd_ilr.c | 73 ++++++++++++++++++++++++++++++++++--------
 2 files changed, 60 insertions(+), 18 deletions(-)

diff --git a/lib/igt_amd.c b/lib/igt_amd.c
index 623883dbc..d10c3c1f2 100644
--- a/lib/igt_amd.c
+++ b/lib/igt_amd.c
@@ -1183,11 +1183,6 @@ void igt_amd_disallow_edp_enter_psr(int drm_fd, char *connector_name, bool enabl
 	const char *allow_edp_psr = "1";
 	const char *dis_allow_edp_psr = "0";
 
-	/* if current psr is not enabled, skip this debugfs */
-	if (!igt_amd_psr_support_drv(drm_fd, connector_name, PSR_MODE_1) &&
-		!igt_amd_psr_support_drv(drm_fd, connector_name, PSR_MODE_2))
-		return;
-
 	fd = igt_debugfs_connector_dir(drm_fd, connector_name, O_RDONLY);
 	igt_assert(fd >= 0);
 	ret = openat(fd, DEBUGFS_DISALLOW_EDP_ENTER_PSR, O_WRONLY);
diff --git a/tests/amdgpu/amd_ilr.c b/tests/amdgpu/amd_ilr.c
index 46ad6f60a..f63a4f782 100644
--- a/tests/amdgpu/amd_ilr.c
+++ b/tests/amdgpu/amd_ilr.c
@@ -199,28 +199,33 @@ static void test_flow(data_t *data, enum sub_test option)
 	igt_enable_connectors(data->drm_fd);
 
 	for_each_connected_output(&data->display, output) {
-		if (!igt_amd_output_has_ilr_setting(data->drm_fd, output->name) ||
+		if ((output->config.connector->connector_type != DRM_MODE_CONNECTOR_eDP) ||
+			!igt_amd_output_has_ilr_setting(data->drm_fd, output->name) ||
 			!igt_amd_output_has_link_settings(data->drm_fd, output->name)) {
 			igt_info("Skipping output: %s\n", output->name);
 			continue;
 		}
 
-		/* igt_amd_output_has_ilr_setting only checks if debugfs
-		 * exist. ilr settings could be all 0s -- not supported.
-		 * IGT needs to check if ilr settings values are supported.
-		 */
-		igt_amd_read_ilr_setting(data->drm_fd, output->name, data->supported_ilr);
-		if (data->supported_ilr[0] == 0)
-			continue;
-
 		igt_info("Testing on output: %s\n", output->name);
 
+		/* states under /sys/kernel/debug/dri/0/eDP-1:
+		 * psr_capability.driver_support (drv_support_psr): yes
+		 * ilr_setting (intermediate link rates capabilities,
+		 * ilr_cap): yes/no
+		 * kernel driver disallow_edp_enter_psr (dis_psr): no
+		 */
+
 		/* Init only if display supports ilr link settings */
 		test_init(data, output);
 
+		/* eDP enter power saving mode within test_init
+		 * drv_support_psr: yes; ilr_cap: no; dis_psr: no
+		 */
+
 		/* Disable eDP PSR to avoid timeout when reading CRC */
 		igt_amd_disallow_edp_enter_psr(data->drm_fd, output->name, true);
 
+		/* drv_support_psr: yes; ilr_cap: no; dis_psr: yes */
 		mode = igt_output_get_mode(output);
 		igt_assert(mode);
 
@@ -229,8 +234,30 @@ static void test_flow(data_t *data, enum sub_test option)
 				      mode->vdisplay, DRM_FORMAT_XRGB8888,
 				      0, &data->fb);
 		igt_plane_set_fb(data->primary, &data->fb);
+
+		/* drv_support_psr: yes; ilr_cap: no; dis_psr: yes
+		 * commit stream. eDP exit power saving mode.
+		 */
 		igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
 
+		/* drv_support_psr: no; ilr_cap: yes; dis_psr: yes.
+		 * With dis_psr yes, drm kernel driver
+		 * disable psr, psr_en is set to no.
+		 */
+
+		/* igt_amd_output_has_ilr_setting only checks if debugfs
+		 * exist. ilr settings could be all 0s -- not supported.
+		 * IGT needs to check if ilr settings values are supported.
+		 * Supported_ilr is read from DPCD registers. Make sure
+		 * eDP exiting power saving mode before reading supported_ilr.
+		 */
+		igt_amd_read_ilr_setting(data->drm_fd, output->name, data->supported_ilr);
+		if (data->supported_ilr[0] == 0) {
+			/* Enable PSR after reading eDP Rx CRC */
+			igt_amd_disallow_edp_enter_psr(data->drm_fd, output->name, false);
+			continue;
+		}
+
 		/* Collect info of Reported Lane Count & ILR */
 		igt_amd_read_link_settings(data->drm_fd, output->name, data->lane_count,
 					   data->link_rate, data->link_spread_spectrum);
@@ -247,18 +274,38 @@ static void test_flow(data_t *data, enum sub_test option)
 				break;
 		}
 
+		/* drv_support_psr: no; ilr_cap: yes; dis_psr: yes */
+		kmstest_set_connector_dpms(data->drm_fd,
+			output->config.connector, DRM_MODE_DPMS_OFF);
+
+		/* eDP enter power saving mode.
+		 * drv_support_psr: no; ilr_cap: no; dis_psr: yes.
+		 */
+
+		/* Enable PSR after reading eDP Rx CRC */
+		igt_amd_disallow_edp_enter_psr(data->drm_fd, output->name, false);
+
+		/* drv_support_psr: no; ilr_cap: yes: dis_psr: no */
+
+		/* eDP exit power saving mode and setup psr */
+		kmstest_set_connector_dpms(data->drm_fd,
+			output->config.connector, DRM_MODE_DPMS_ON);
+
+		/* drv_support_psr: yes; ilr_cap: yes: dis_psr: no */
+
 		/* Reset preferred link settings*/
 		memset(data->supported_ilr, 0, sizeof(data->supported_ilr));
 		igt_amd_write_ilr_setting(data->drm_fd, output->name, 0, 0);
 
+		/* drv_support_psr: yes; ilr_cap: yes; dis_psr: no */
+
+		/* commit 0 stream. eDP enter power saving mode */
 		igt_remove_fb(data->drm_fd, &data->fb);
 
-		test_fini(data);
+		/* drv_support_psr: yes; ilr_cap: no; dis_psr: no */
 
-		/* Enable eDP PSR */
-		igt_amd_disallow_edp_enter_psr(data->drm_fd, output->name, false);
+		test_fini(data);
 	}
-
 }
 
 igt_main
-- 
2.25.1


             reply	other threads:[~2024-03-25 13:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25 13:19 Hersen Wu [this message]
2024-03-25 14:03 ` ✓ CI.xeBAT: success for tests/amdgpu/amd_ilr: Fix eDP PSR not be re-enabled after test (rev3) Patchwork
2024-03-25 14:11 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-03-28  3:58 ` [PATCH] [i-g-t] tests/amdgpu/amd_ilr: Fix eDP PSR not be re-enabled after test Lin, Wayne
2024-04-01 23:31   ` Wu, Hersen
  -- strict thread matches above, loose matches on Subject: below --
2024-04-03 14:28 Hersen Wu
2024-04-03 18:57 ` Kamil Konieczny
2024-04-02 15:20 Hersen Wu
2024-04-03  8:42 ` Lin, Wayne
2024-03-25 12:08 Hersen Wu
2024-03-19  1:17 Hersen Wu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240325131926.42203-1-hersenxs.wu@amd.com \
    --to=hersenxs.wu@amd.com \
    --cc=alex.hung@amd.com \
    --cc=aurabindo.pillai@amd.com \
    --cc=hamza.mahfooz@amd.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=markyacoub@google.com \
    --cc=rodrigo.siqueira@amd.com \
    --cc=sunpeng.li@amd.com \
    --cc=wayne.lin@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox