Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Suraj Kandpal <suraj.kandpal@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: pranay.samala@intel.com, ankit.k.nautiyal@intel.com,
	jeevan.b@intel.com, Suraj Kandpal <suraj.kandpal@intel.com>
Subject: [PATCH i-g-t 4/5] tests/kms_content_protection: Add retry logic for mst usecase
Date: Thu, 22 Aug 2024 11:41:49 +0530	[thread overview]
Message-ID: <20240822061150.4127413-5-suraj.kandpal@intel.com> (raw)
In-Reply-To: <20240822061150.4127413-1-suraj.kandpal@intel.com>

Add mst retry logic where it retries 3 times before failing the test.
After every retry mst setup needs to be disabled so we need to add a
function which disables mst in one commit.

--v2
-Fix enum declaration name [Jeevan]
-Add more elaborate debug message [Jeevan]

--v3
-Instead of removing wait time for subsequent CP connector status
check reduce it to 100msec

Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com>
---
 tests/kms_content_protection.c | 83 +++++++++++++++++++++++++++++-----
 1 file changed, 72 insertions(+), 11 deletions(-)

diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
index 473686939..d6c8344e2 100644
--- a/tests/kms_content_protection.c
+++ b/tests/kms_content_protection.c
@@ -124,6 +124,7 @@ struct data {
 #define LIC_PERIOD_MSEC				(4 * 1000)
 /* Kernel retry count=3, Max time per authentication allowed = 6Sec */
 #define KERNEL_AUTH_TIME_ALLOWED_MSEC		(3 *  6 * 1000)
+#define KERNEL_AUTH_TIME_ADDITIONAL_MSEC	100
 #define KERNEL_DISABLE_TIME_ALLOWED_MSEC	(1 * 1000)
 #define FLIP_EVENT_POLLING_TIMEOUT_MSEC		1000
 
@@ -278,6 +279,36 @@ static bool test_cp_enable(igt_output_t *output, enum igt_commit_style commit_st
 	return ret;
 }
 
+static void test_mst_cp_disable(igt_output_t *hdcp_mst_output[],
+				enum igt_commit_style commit_style,
+				int valid_outputs)
+{
+	igt_display_t *display = &data.display;
+	igt_plane_t *primary;
+	bool ret;
+	int count;
+	u64 val;
+
+	for (count = 0; count < valid_outputs; count++) {
+		primary = igt_output_get_plane_type(hdcp_mst_output[count], DRM_PLANE_TYPE_PRIMARY);
+		igt_plane_set_fb(primary, &data.red);
+		igt_output_set_prop_value(hdcp_mst_output[count], IGT_CONNECTOR_CONTENT_PROTECTION,
+					  CP_UNDESIRED);
+	}
+
+	igt_display_commit2(display, commit_style);
+
+	ret = wait_for_prop_value(hdcp_mst_output[0], CP_UNDESIRED,
+				  KERNEL_DISABLE_TIME_ALLOWED_MSEC);
+	for (count = 1; count < valid_outputs; count++) {
+		val = igt_output_get_prop(hdcp_mst_output[count],
+					  IGT_CONNECTOR_CONTENT_PROTECTION);
+		ret &= (val == CP_UNDESIRED);
+	}
+
+	igt_assert_f(ret, "Content Protection not cleared on all MST outputs\n");
+}
+
 static void test_cp_disable(igt_output_t *output, enum igt_commit_style commit_style)
 {
 	igt_display_t *display = &data.display;
@@ -631,6 +662,46 @@ static void test_cp_lic_on_mst(igt_output_t *mst_outputs[], int valid_outputs, b
 	}
 }
 
+static bool
+test_mst_cp_enable_with_retry(igt_output_t *hdcp_mst_output[], int valid_outputs,
+			      int retries, int content_type)
+{
+	igt_display_t *display = &data.display;
+	int retry_orig = retries, count;
+	bool ret;
+
+	do {
+		if (retry_orig != retries)
+			test_mst_cp_disable(hdcp_mst_output, COMMIT_ATOMIC, valid_outputs);
+
+		for (count = 0; count < valid_outputs; count++) {
+			igt_output_set_prop_value(hdcp_mst_output[count],
+						  IGT_CONNECTOR_CONTENT_PROTECTION, CP_DESIRED);
+
+			if (hdcp_mst_output[count]->props[IGT_CONNECTOR_HDCP_CONTENT_TYPE])
+				igt_output_set_prop_value(hdcp_mst_output[count],
+							  IGT_CONNECTOR_HDCP_CONTENT_TYPE,
+							  content_type);
+		}
+
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		ret = wait_for_prop_value(hdcp_mst_output[0], CP_ENABLED,
+					  KERNEL_AUTH_TIME_ALLOWED_MSEC);
+		for (count = 1; count < valid_outputs; count++)
+			ret &= wait_for_prop_value(hdcp_mst_output[count], CP_ENABLED,
+						  KERNEL_AUTH_TIME_ADDITIONAL_MSEC);
+
+		retries -= 1;
+		if (!ret || retries)
+			igt_debug("Retry %d/3\n", 3 - retries);
+	} while (retries && !ret);
+
+	igt_assert_f(ret, "Content Protection not enabled on MST outputs\n");
+
+	return ret;
+}
+
 static void
 test_content_protection_mst(int content_type)
 {
@@ -685,19 +756,9 @@ test_content_protection_mst(int content_type)
 		igt_require_f(ret == 0, "Commit failure during MST modeset\n");
 	}
 
-	for (count = 0; count < valid_outputs; count++) {
-		igt_output_set_prop_value(hdcp_mst_output[count], IGT_CONNECTOR_CONTENT_PROTECTION, CP_DESIRED);
-
-		if (output->props[IGT_CONNECTOR_HDCP_CONTENT_TYPE])
-			igt_output_set_prop_value(hdcp_mst_output[count], IGT_CONNECTOR_HDCP_CONTENT_TYPE, content_type);
-	}
-
 	igt_display_commit2(display, COMMIT_ATOMIC);
 
-	for (count = 0; count < valid_outputs; count++) {
-		ret = wait_for_prop_value(hdcp_mst_output[count], CP_ENABLED, KERNEL_AUTH_TIME_ALLOWED_MSEC);
-		igt_assert_f(ret, "Content Protection not enabled on %s\n", hdcp_mst_output[count]->name);
-	}
+	ret = test_mst_cp_enable_with_retry(hdcp_mst_output, valid_outputs, 2, content_type);
 
 	if (data.cp_tests & CP_LIC)
 		test_cp_lic_on_mst(hdcp_mst_output, valid_outputs, 0);
-- 
2.43.2


  parent reply	other threads:[~2024-08-22  6:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-22  6:11 [PATCH i-g-t 0/5] Improve MST HDCP tests Suraj Kandpal
2024-08-22  6:11 ` [PATCH i-g-t 1/5] tests/kms_content_protection: Move HDCP output checks earlier Suraj Kandpal
2024-08-22  6:11 ` [PATCH i-g-t 2/5] tests/kms_content_protection: Move try commit call Suraj Kandpal
2024-08-22  6:11 ` [PATCH i-g-t 3/5] tests/kms_content_protection: Rename igt_commit_style variable Suraj Kandpal
2024-08-22  6:11 ` Suraj Kandpal [this message]
2024-08-23  4:32   ` [PATCH i-g-t 4/5] tests/kms_content_protection: Add retry logic for mst usecase B, Jeevan
2024-08-22  6:11 ` [PATCH i-g-t 5/5] tests/kms_content_protection: Set screen red/green based on CP Status Suraj Kandpal
2024-08-22  7:25 ` ✓ CI.xeBAT: success for Improve MST HDCP tests (rev3) Patchwork
2024-08-22  7:25 ` ✓ Fi.CI.BAT: " Patchwork
2024-08-22 10:57 ` ✗ CI.xeFULL: failure " Patchwork
2024-08-23  5:08 ` ✗ Fi.CI.IGT: " Patchwork
2024-08-27  5:21 ` [PATCH i-g-t 0/5] Improve MST HDCP tests B, Jeevan
  -- strict thread matches above, loose matches on Subject: below --
2024-08-27  6:18 Suraj Kandpal
2024-08-27  6:19 ` [PATCH i-g-t 4/5] tests/kms_content_protection: Add retry logic for mst usecase Suraj Kandpal
2024-08-20  8:12 [PATCH i-g-t 0/5] Improve MST HDCP tests Suraj Kandpal
2024-08-20  8:12 ` [PATCH i-g-t 4/5] tests/kms_content_protection: Add retry logic for mst usecase Suraj Kandpal

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=20240822061150.4127413-5-suraj.kandpal@intel.com \
    --to=suraj.kandpal@intel.com \
    --cc=ankit.k.nautiyal@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jeevan.b@intel.com \
    --cc=pranay.samala@intel.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