[igt-dev] [PATCH i-g-t v5 1/2] tests/kms_content_protection: Test Cleanup

Karthik B S karthik.b.s at intel.com
Wed Sep 28 12:36:02 UTC 2022


On 9/28/2022 3:21 PM, Kamil Konieczny wrote:
> Hi Karthik,
Hi Kamil,
>
> On 2022-09-28 at 10:04:40 +0530, Karthik B S wrote:
>> This patch includes:
>>      1.Add a modeset before checking output is HDCP capable.
>>        Test currently skips on multidisplay MST because we're checking
>>        if output is HDCP capable before doing a modeset on the output.
>>      2.Call igt_display_reset before starting the subtest.
>>      3.test_fini function added to prepare test for converting to dynamic.
>>      4.Remove redundant mode override.
>>      5.Try other pipe/output combo for MST if failure is seen on one.
> These looks like fix and cleanup, please split out part 1. and 5.
> into separate patch.
Thank you for the review. Sure, will split this patch.
> I will not comment on kms parts, only some things spotted, see
> below.
>
>> v2: -Update commit style in test_content_protection_cleanup.
>>
>> v3: -Declare 'pipe' variable in this patch which otherwise causes
>>       failure when patch is compiled individually.
>>
>> Signed-off-by: Karthik B S <karthik.b.s at intel.com>
>> Reviewed-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
>> ---
>>   tests/kms_content_protection.c | 182 +++++++++++++++++----------------
>>   1 file changed, 94 insertions(+), 88 deletions(-)
>>
>> diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
>> index 3041f1cd..c32767c8 100644
>> --- a/tests/kms_content_protection.c
>> +++ b/tests/kms_content_protection.c
>> @@ -170,18 +170,15 @@ static void modeset_with_fb(const enum pipe pipe, igt_output_t *output,
>>   			    enum igt_commit_style s)
>>   {
>>   	igt_display_t *display = &data.display;
>> -	drmModeModeInfo mode;
>> +	drmModeModeInfo *mode;
>>   	igt_plane_t *primary;
>>   
>> -	igt_assert(kmstest_get_connector_default_mode(
>> -			display->drm_fd, output->config.connector, &mode));
>> -
>> -	igt_output_override_mode(output, &mode);
>> +	mode = igt_output_get_mode(output);
>>   	igt_output_set_pipe(output, pipe);
>>   
>>   	primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
>>   	igt_plane_set_fb(primary, &data.red);
>> -	igt_fb_set_size(&data.red, primary, mode.hdisplay, mode.vdisplay);
>> +	igt_fb_set_size(&data.red, primary, mode->hdisplay, mode->vdisplay);
>>   
>>   	igt_display_commit2(display, s);
>>   
>> @@ -317,90 +314,61 @@ static bool write_srm_as_fw(const __u8 *srm, int len)
>>   }
>>   
>>   static void test_content_protection_on_output(igt_output_t *output,
>> +					      enum pipe pipe,
>>   					      enum igt_commit_style s,
>>   					      int content_type)
>>   {
>>   	igt_display_t *display = &data.display;
>> -	igt_plane_t *primary;
>> -	enum pipe pipe;
>>   	bool ret;
>>   
>> -	for_each_pipe(display, pipe) {
>> -		if (!igt_pipe_connector_valid(pipe, output))
>> -			continue;
>> -
>> -		/*
>> -		 * If previous subtest of connector failed, pipe
>> -		 * attached to that connector is not released.
>> -		 * Because of that we have to choose the non
>> -		 * attached pipe for this subtest.
>> -		 */
>> -		if (!igt_pipe_is_free(display, pipe))
>> -			continue;
>> -
>> -		modeset_with_fb(pipe, output, s);
>> -		test_cp_enable_with_retry(output, s, 3, content_type, false,
>> -					  false);
>> -
>> -		if (data.cp_tests & CP_TYPE_CHANGE) {
>> -			/* Type 1 -> Type 0 */
>> -			test_cp_enable_with_retry(output, s, 3,
>> -						  HDCP_CONTENT_TYPE_0, false,
>> -						  true);
>> -			/* Type 0 -> Type 1 */
>> -			test_cp_enable_with_retry(output, s, 3,
>> -						  content_type, false,
>> -						  true);
>> -		}
>> -
>> -		if (data.cp_tests & CP_MEI_RELOAD) {
>> -			igt_assert_f(!igt_kmod_unload("mei_hdcp", 0),
>> -				     "mei_hdcp unload failed");
>> +	test_cp_enable_with_retry(output, s, 3, content_type, false,
>> +				  false);
>> +
>> +	if (data.cp_tests & CP_TYPE_CHANGE) {
>> +		/* Type 1 -> Type 0 */
>> +		test_cp_enable_with_retry(output, s, 3,
>> +					  HDCP_CONTENT_TYPE_0, false,
>> +					  true);
>> +		/* Type 0 -> Type 1 */
>> +		test_cp_enable_with_retry(output, s, 3,
>> +					  content_type, false,
>> +					  true);
>> +	}
>>   
>> -			/* Expected to fail */
>> -			test_cp_enable_with_retry(output, s, 3,
>> -						  content_type, true, false);
>> +	if (data.cp_tests & CP_MEI_RELOAD) {
>> +		igt_assert_f(!igt_kmod_unload("mei_hdcp", 0),
>> +			     "mei_hdcp unload failed");
>>   
>> -			igt_assert_f(!igt_kmod_load("mei_hdcp", NULL),
>> -				     "mei_hdcp load failed");
>> +		/* Expected to fail */
>> +		test_cp_enable_with_retry(output, s, 3,
>> +					  content_type, true, false);
>>   
>> -			/* Expected to pass */
>> -			test_cp_enable_with_retry(output, s, 3,
>> -						  content_type, false, false);
>> -		}
>> +		igt_assert_f(!igt_kmod_load("mei_hdcp", NULL),
>> +			     "mei_hdcp load failed");
>>   
>> -		if (data.cp_tests & CP_LIC)
>> -			test_cp_lic(output);
>> +		/* Expected to pass */
>> +		test_cp_enable_with_retry(output, s, 3,
>> +					  content_type, false, false);
>> +	}
>>   
>> -		if (data.cp_tests & CP_DPMS) {
>> -			igt_pipe_set_prop_value(display, pipe,
>> -						IGT_CRTC_ACTIVE, 0);
>> -			igt_display_commit2(display, s);
>> +	if (data.cp_tests & CP_LIC)
>> +		test_cp_lic(output);
>>   
>> -			igt_pipe_set_prop_value(display, pipe,
>> -						IGT_CRTC_ACTIVE, 1);
>> -			igt_display_commit2(display, s);
>> +	if (data.cp_tests & CP_DPMS) {
>> +		igt_pipe_set_prop_value(display, pipe,
>> +					IGT_CRTC_ACTIVE, 0);
>> +		igt_display_commit2(display, s);
>>   
>> -			ret = wait_for_prop_value(output, CP_ENABLED,
>> -						  KERNEL_AUTH_TIME_ALLOWED_MSEC);
>> -			if (!ret)
>> -				test_cp_enable_with_retry(output, s, 2,
>> -							  content_type, false,
>> -							  false);
>> -		}
>> +		igt_pipe_set_prop_value(display, pipe,
>> +					IGT_CRTC_ACTIVE, 1);
>> +		igt_display_commit2(display, s);
>>   
>> -		test_cp_disable(output, s);
>> -		primary = igt_output_get_plane_type(output,
>> -						    DRM_PLANE_TYPE_PRIMARY);
>> -		igt_plane_set_fb(primary, NULL);
>> -		igt_output_set_pipe(output, PIPE_NONE);
>> -
>> -		/*
>> -		 * Testing a output with a pipe is enough for HDCP
>> -		 * testing. No ROI in testing the connector with other
>> -		 * pipes. So Break the loop on pipe.
>> -		 */
>> -		break;
>> +		ret = wait_for_prop_value(output, CP_ENABLED,
>> +					  KERNEL_AUTH_TIME_ALLOWED_MSEC);
>> +		if (!ret)
>> +			test_cp_enable_with_retry(output, s, 2,
>> +						  content_type, false,
>> +						  false);
>>   	}
>>   }
>>   
>> @@ -458,7 +426,8 @@ static bool sink_hdcp2_capable(igt_output_t *output)
>>   	return strstr(buf, "HDCP2.2");
>>   }
>>   
>> -static void prepare_modeset_on_mst_output(igt_output_t *output)
>> +static void
>> +prepare_modeset_on_mst_output(igt_output_t *output)
> Please drop this and keep old line here. Do not mix cosmetic
> changes with functional cleanup. Smaller patches are easier
> to review.
Sure, will update this.
>
>>   {
>>   	drmModeModeInfo *mode;
>>   	igt_plane_t *primary;
>> @@ -477,7 +446,8 @@ static void prepare_modeset_on_mst_output(igt_output_t *output)
>>   	igt_plane_set_size(primary, width, height);
>>   }
>>   
>> -static bool output_hdcp_capable(igt_output_t *output, int content_type)
>> +static bool
>> +output_hdcp_capable(igt_output_t *output, int content_type)
> Same here.
Sure.
>
>>   {
>>   		if (!output->props[IGT_CONNECTOR_CONTENT_PROTECTION])
>>   			return false;
>> @@ -499,22 +469,53 @@ static bool output_hdcp_capable(igt_output_t *output, int content_type)
>>   		return true;
>>   }
>>   
>> +static void
>> +test_fini(igt_output_t *output, enum igt_commit_style s)
> I would prefere to have it in one line but I see that below
> is used other convention so it may stay.
Okay.
>
>> +{
>> +	igt_plane_t *primary;
>> +
>> +	test_cp_disable(output, s);
>> +	primary = igt_output_get_plane_type(output,
>> +					    DRM_PLANE_TYPE_PRIMARY);
>> +	igt_plane_set_fb(primary, NULL);
>> +	igt_output_set_pipe(output, PIPE_NONE);
>> +	igt_display_commit2(&data.display, s);
>> +}
>> +
>>   static void
>>   test_content_protection(enum igt_commit_style s, int content_type)
>>   {
>>   	igt_display_t *display = &data.display;
>>   	igt_output_t *output;
>>   	int valid_tests = 0;
>> +	enum pipe pipe;
>>   
>>   	if (data.cp_tests & CP_MEI_RELOAD)
>>   		igt_require_f(igt_kmod_is_loaded("mei_hdcp"),
>>   			      "mei_hdcp module is not loaded\n");
>>   
>>   	for_each_connected_output(display, output) {
>> -		if (!output_hdcp_capable(output, content_type))
>> -			continue;
>> +		for_each_pipe(display, pipe) {
>> +			if (!igt_pipe_connector_valid(pipe, output))
>> +				continue;
>> +
>> +			igt_display_reset(display);
>> +			modeset_with_fb(pipe, output, s);
>> +
>> +			if (!output_hdcp_capable(output, content_type))
>> +				continue;
>> +
>> +			test_content_protection_on_output(output, pipe, s, content_type);
> Here should be increasing valid_tests var, see below.
>
>> +			test_fini(output, s);
>> +
>> +			/*
>> +			 * Testing a output with a pipe is enough for HDCP
>> +			 * testing. No ROI in testing the connector with other
>> +			 * pipes. So Break the loop on pipe.
>> +			 */
>> +			break;
>> +		}
>>   
>> -		test_content_protection_on_output(output, s, content_type);
>>   		valid_tests++;
> --------------- ^
>
> imho this one also should be moved after call to
> test_content_protection_on_output()

Sure will move this.

Thanks,
Karthik.B.S
>
> Regards,
> Kamil
>
>>   	}
>>   
>> @@ -596,6 +597,7 @@ test_content_protection_mst(int content_type)
>>   	igt_output_t *output;
>>   	int valid_outputs = 0, dp_mst_outputs = 0, ret, count, max_pipe = 0, i;
>>   	enum pipe pipe;
>> +	bool pipe_found;
>>   	igt_output_t *mst_output[IGT_MAX_PIPES], *hdcp_mst_output[IGT_MAX_PIPES];
>>   
>>   	for_each_pipe(display, pipe)
>> @@ -607,16 +609,20 @@ test_content_protection_mst(int content_type)
>>   		if (!output_is_dp_mst(output, dp_mst_outputs))
>>   			continue;
>>   
>> -		igt_assert_f(igt_pipe_connector_valid(pipe, output), "Output-pipe combination invalid\n");
>> +		pipe_found = false;
>> +		for_each_pipe(display, pipe) {
>> +			if (igt_pipe_is_free(display, pipe) &&
>> +			    igt_pipe_connector_valid(pipe, output)) {
>> +				pipe_found = true;
>> +				break;
>> +			}
>> +		}
>> +
>> +		igt_assert_f(pipe_found, "No valid pipe found for %s\n", output->name);
>>   
>>   		igt_output_set_pipe(output, pipe);
>>   		prepare_modeset_on_mst_output(output);
>>   		mst_output[dp_mst_outputs++] = output;
>> -
>> -		pipe++;
>> -
>> -		if (pipe > max_pipe)
>> -			break;
>>   	}
>>   
>>   	igt_require_f(dp_mst_outputs > 1, "No DP MST set up with >= 2 outputs found in a single topology\n");
>> @@ -694,7 +700,7 @@ static void test_content_protection_cleanup(void)
>>   			continue;
>>   
>>   		igt_info("CP Prop being UNDESIRED on %s\n", output->name);
>> -		test_cp_disable(output, COMMIT_ATOMIC);
>> +		test_cp_disable(output, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
>>   	}
>>   
>>   	igt_remove_fb(data.drm_fd, &data.red);
>> -- 
>> 2.22.0
>>



More information about the igt-dev mailing list