[PATCH i-g-t 11/14] lib/igt_kms: add function to reset link params

Imre Deak imre.deak at intel.com
Tue Sep 3 14:26:13 UTC 2024


On Mon, Aug 26, 2024 at 01:36:09AM +0530, Kunal Joshi wrote:
> Writing auto to i915_dp_force_(link_rate/lane_count) and retraing
> afterwards sets max link param's supported by sink.Reset link rate
> and lane count to auto, also installs exit handler to set link rate
> and lane count to auto on exit
> ---
>  lib/igt_kms.c | 36 ++++++++++++++++++++++++++++++++++++
>  lib/igt_kms.h |  1 +
>  2 files changed, 37 insertions(+)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index e0533f6ae..b7511ccfc 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -7000,3 +7000,39 @@ int igt_get_dp_pending_retrain(int drm_fd, igt_output_t *output)
>  	sscanf(buf, "%d", &ret);
>  	return ret;
>  }
> +
> +/**
> + * igt_reset_link_params:
> + * @drm_fd: A drm file descriptor
> + * @output: Target output
> + *
> + * Reset link rate and lane count to auto, also installs exit handler
> + * to set link rate and lane count to auto on exit
> + */
> +void igt_reset_link_params(int drm_fd, igt_output_t *output)
> +{
> +	bool valid;
> +	drmModeConnector *temp;
> +
> +	igt_require_f(output->name, "Invalid output");
> +	valid = true;
> +	valid = valid && connector_attr_set_debugfs(drm_fd, output->config.connector,
> +						    "i915_dp_force_link_rate",
> +						    "auto", "auto");
> +	valid = valid && connector_attr_set_debugfs(drm_fd, output->config.connector,
> +						    "i915_dp_force_lane_count",
> +						    "auto", "auto");

Couldn't the above use the corresponding helpers added? I don't see
those used elsewhere.

> +	valid = valid && connector_attr_set_debugfs(drm_fd, output->config.connector,
> +						    "i915_dp_force_link_retrain",
> +						    "1", "1");

Not sure if this is needed, if the link params are reset before a
modeset. The latter does a link training anyway if needed.


> +	igt_assert_f(valid, "Unable to set attr or install exit handler\n");
> +	dump_connector_attrs();
> +	igt_install_exit_handler(reset_connectors_at_exit);
> +
> +	/*
> +	 * To allow callers to always use GetConnectorCurrent we need to force a
> +	 * redetection here.
> +	 */
> +	temp = drmModeGetConnector(drm_fd, output->config.connector->connector_id);
> +	drmModeFreeConnector(temp);
> +}
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 3d7842b36..847609379 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -1259,5 +1259,6 @@ bool igt_get_dp_link_retrain_disabled(int drm_fd, igt_output_t *output);
>  bool igt_has_force_link_training_failure_debugfs(int drmfd, igt_output_t *output);
>  int igt_get_dp_pending_lt_failures(int drm_fd, igt_output_t *output);
>  int igt_get_dp_pending_retrain(int drm_fd, igt_output_t *output);
> +void igt_reset_link_params(int drm_fd, igt_output_t *output);
>  
>  #endif /* __IGT_KMS_H__ */
> -- 
> 2.34.1
> 


More information about the igt-dev mailing list