<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;" align="Left">
[AMD Official Use Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Thanks Petri, updated.</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Petri Latvala <petri.latvala@intel.com><br>
<b>Sent:</b> Wednesday, April 6, 2022 10:57 AM<br>
<b>To:</b> Zhang, Dingchen (David) <Dingchen.Zhang@amd.com><br>
<b>Cc:</b> igt-dev@lists.freedesktop.org <igt-dev@lists.freedesktop.org><br>
<b>Subject:</b> Re: [igt-dev] [PATCH] lib/igt_amd: return negative if PSR state debugfs open fails</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">On Wed, Apr 06, 2022 at 10:52:13AM -0400, David Zhang wrote:<br>
> [why & how]<br>
> The PSR state read helper should return an integer which is not<br>
> the same as PSR state enumeration item for the case of debugfs<br>
> interface opening fail. Currently it return false which is casted<br>
> to 0 that is the same as PSR_STATE0, this is incorrect.<br>
> <br>
> Instead of returning 0, a negative (e.g. -1) value is returned<br>
> when debugfs interface of PSR state opening fails. And adding the<br>
> check of such negative value in amd_psr test case as well.<br>
> <br>
> Cc: Rodrigo Siqueira <rodrigo.siqueira@amd.com><br>
> Cc: Harry Wentland <harry.wentland@amd.com><br>
> Cc: Leo Li <sunpeng.li@amd.com><br>
> Cc: Aurabindo Pillai <aurabindo.pillai@amd.com><br>
> Cc: Wayne Lin <wayne.lin@amd.com><br>
> <br>
> Signed-off-by: David Zhang <dingchen.zhang@amd.com><br>
> Rivewed-by: Rodrigo Siqueira <rodrigo.siqueira@amd.com><br>
^^^<br>
typo<br>
<br>
<br>
-- <br>
Petri Latvala<br>
<br>
<br>
<br>
> ---<br>
> lib/igt_amd.c | 2 +-<br>
> tests/amdgpu/amd_psr.c | 2 ++<br>
> 2 files changed, 3 insertions(+), 1 deletion(-)<br>
> <br>
> diff --git a/lib/igt_amd.c b/lib/igt_amd.c<br>
> index 888da44a..664602da 100644<br>
> --- a/lib/igt_amd.c<br>
> +++ b/lib/igt_amd.c<br>
> @@ -1064,7 +1064,7 @@ int igt_amd_read_psr_state(int drm_fd, char *connector_name)<br>
> fd = igt_debugfs_connector_dir(drm_fd, connector_name, O_RDONLY);<br>
> if (fd < 0) {<br>
> igt_info("Couldn't open connector %s debugfs directory\n", connector_name);<br>
> - return false;<br>
> + return -1;<br>
> }<br>
> <br>
> ret = igt_debugfs_simple_read(fd, DEBUGFS_EDP_PSR_STATE, buf, sizeof(buf));<br>
> diff --git a/tests/amdgpu/amd_psr.c b/tests/amdgpu/amd_psr.c<br>
> index b9d8a53b..d21d41e3 100644<br>
> --- a/tests/amdgpu/amd_psr.c<br>
> +++ b/tests/amdgpu/amd_psr.c<br>
> @@ -179,6 +179,7 @@ static void run_check_psr(data_t *data, bool test_null_crtc) {<br>
> continue;<br>
> <br>
> psr_state = igt_amd_read_psr_state(data->fd, output->name);<br>
> + igt_fail_on_f(psr_state < 0, "Open PSR state debugfs failed\n");<br>
> igt_fail_on_f(psr_state < 1, "PSR was not enabled for connector %s\n", output->name);<br>
> igt_fail_on_f(psr_state == 0xff, "PSR is invalid for connector %s\n", output->name);<br>
> igt_fail_on_f(psr_state != 5, "PSR state is expected to be at 5 on a "<br>
> @@ -295,6 +296,7 @@ static void run_check_psr_su_mpo(data_t *data)<br>
> /* check PSR state */<br>
> if (i > PSR_SETTLE_DELAY * frame_rate) {<br>
> psr_state = igt_amd_read_psr_state(data->fd, data->output->name);<br>
> + igt_fail_on_f(psr_state < 0, "Open PSR state debugfs failed\n");<br>
> igt_fail_on_f(psr_state == PSR_STATE0,<br>
> "PSR was not enabled for connector %s\n", data->output->name);<br>
> igt_fail_on_f(psr_state == PSR_STATE_INVALID,<br>
> -- <br>
> 2.25.1<br>
> <br>
</div>
</span></font></div>
</div>
</body>
</html>