[PATCH i-g-t 1/2] lib/igt_psr: add helper to check of given psr mode can be enabled

Modem, Bhanuprakash bhanuprakash.modem at intel.com
Wed Jan 24 05:30:33 UTC 2024


Hi Kunal,

On 23-01-2024 07:48 pm, Kunal Joshi wrote:
> Check if given psr mode can be enabled by reading enable_psr
> modparam
> 
> Signed-off-by: Kunal Joshi <kunal1.joshi at intel.com>
> ---
>   lib/igt_psr.c | 23 +++++++++++++++++++++++
>   lib/igt_psr.h |  1 +
>   2 files changed, 24 insertions(+)
> 
> diff --git a/lib/igt_psr.c b/lib/igt_psr.c
> index 663bac163..181499cf7 100644
> --- a/lib/igt_psr.c
> +++ b/lib/igt_psr.c
> @@ -394,3 +394,26 @@ enum psr_mode psr_get_mode(int debugfs_fd)
>   
>   	return PSR_DISABLED;
>   }
> +
> +/**
> + * is_psr_enable_possible
> + * Check if given psr mode can be enabled by reading enable_psr
> + * modparam
> + *
> + * Returns:
> + * True if given psr mode can be enabled, false otherwise.
> + */
> +bool is_psr_enable_possible(int drm_fd, enum psr_mode mode)
> +{
> +	char *param_value;
> +	int enable_psr;
> +
> +	param_value = __igt_params_get(drm_fd, "enable_psr");
> +	if (!is_i915_device(drm_fd) && !param_value) {

Why do we need a driver check here?

> +		igt_info("Failed to retrieve module parameter enable_psr\n");
> +		return false;
> +	}
> +	enable_psr = atoi(param_value);

It may cause a segmentation fault, if the driver is i915 & param_value 
== NULL.

Hence, NACK to merge this patch.

- Bhanu

> +	free(param_value);
> +	return enable_psr > mode;
> +}
> diff --git a/lib/igt_psr.h b/lib/igt_psr.h
> index 36711c0d4..82a4e8c5e 100644
> --- a/lib/igt_psr.h
> +++ b/lib/igt_psr.h
> @@ -61,5 +61,6 @@ bool i915_psr2_selective_fetch_check(int drm_fd);
>   
>   bool i915_psr2_sel_fetch_to_psr1(int drm_fd);
>   void i915_psr2_sel_fetch_restore(int drm_fd);
> +bool is_psr_enable_possible(int drm_fd, enum psr_mode mode);
>   
>   #endif


More information about the igt-dev mailing list