[PATCH i-g-t 1/7] tests/intel/kms_dp_linktrain_fallback: refactor find_mst_outputs

Nautiyal, Ankit K ankit.k.nautiyal at intel.com
Thu Feb 13 05:00:01 UTC 2025


On 2/11/2025 11:35 PM, Kunal Joshi wrote:
> refactor find_mst_outputs to improve error handling
>
> v2: change return type to int (Ankit)
>
> Signed-off-by: Kunal Joshi <kunal1.joshi at intel.com>

Reviewed-by: Ankit Nautiyal <ankit.k.nautiyal at intel.com>


> ---
>   tests/intel/kms_dp_linktrain_fallback.c | 23 ++++++++++++++++-------
>   1 file changed, 16 insertions(+), 7 deletions(-)
>
> diff --git a/tests/intel/kms_dp_linktrain_fallback.c b/tests/intel/kms_dp_linktrain_fallback.c
> index 415005774..edf9409b6 100644
> --- a/tests/intel/kms_dp_linktrain_fallback.c
> +++ b/tests/intel/kms_dp_linktrain_fallback.c
> @@ -47,26 +47,33 @@ typedef int (*condition_check_fn)(int drm_fd, igt_output_t *output);
>   
>   IGT_TEST_DESCRIPTION("Test link training fallback");
>   
> -static void find_mst_outputs(int drm_fd, data_t *data,
> -			     igt_output_t *output,
> -			     igt_output_t *mst_outputs[],
> -			     int *num_mst_outputs)
> +static int find_mst_outputs(int drm_fd, igt_display_t *display,
> +			    igt_output_t *output,
> +			    igt_output_t *mst_outputs[],
> +			    int *num_mst_outputs)
>   {
>   	int output_root_id, root_id;
>   	igt_output_t *connector_output;
>   
> +	if (!igt_check_output_is_dp_mst(output))
> +		return -EINVAL;
> +
>   	output_root_id = igt_get_dp_mst_connector_id(output);
> +	if (output_root_id == -EINVAL)
> +		return -EINVAL;
>   	/*
>   	 * If output is MST check all other connected output which shares
>   	 * same path and fill mst_outputs and num_mst_outputs
>   	 */
> -	for_each_connected_output(&data->display, connector_output) {
> +	for_each_connected_output(display, connector_output) {
>   		if (!igt_check_output_is_dp_mst(connector_output))
>   			continue;
> +
>   		root_id = igt_get_dp_mst_connector_id(connector_output);
>   		if (((*num_mst_outputs) < IGT_MAX_PIPES) && root_id == output_root_id)
>   			mst_outputs[(*num_mst_outputs)++] = connector_output;
>   	}
> +	return 0;
>   }
>   
>   static bool setup_mst_outputs(data_t *data, igt_output_t *mst_output[],
> @@ -83,8 +90,10 @@ static bool setup_mst_outputs(data_t *data, igt_output_t *mst_output[],
>   		    traversed_mst_outputs[i] == data->output->config.connector->connector_id)
>   			return false;
>   
> -	find_mst_outputs(data->drm_fd, data, data->output,
> -			 mst_output, output_count);
> +	igt_assert_f(find_mst_outputs(data->drm_fd, &data->display,
> +				      data->output, mst_output,
> +				      output_count) == 0,
> +				      "Unable to find mst outputs or given optput is not mst\n");
>   
>   	for (i = 0; i < *output_count; i++) {
>   		output = mst_output[i];


More information about the igt-dev mailing list