[igt-dev] [PATCH i-g-t v5 3/4] lib/igt_v3d: Rework igt_v3d_get_param()

Kamil Konieczny kamil.konieczny at linux.intel.com
Thu Jan 26 09:00:11 UTC 2023


On 2023-01-12 at 16:37:41 -0300, Maíra Canal wrote:
> Instead of assuming that igt_v3d_get_param() will succeed, allow the
> ioctl to fail and return 0. This way, it will be possible to check if the
> kernel has the capabilities needed by the test by checking if the return
> of the igt_v3d_get_param() function is different than zero.
> 
> Signed-off-by: Maíra Canal <mcanal at igalia.com>

Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>

> ---
>  lib/igt_v3d.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/igt_v3d.c b/lib/igt_v3d.c
> index 68d11d7f..5d112416 100644
> --- a/lib/igt_v3d.c
> +++ b/lib/igt_v3d.c
> @@ -86,14 +86,27 @@ igt_v3d_get_bo_offset(int fd, uint32_t handle)
>  	return get.offset;
>  }
>  
> +/**
> + * igt_v3d_get_param:
> + * @fd: device file descriptor
> + * @param: v3d parameter
> + *
> + * This wraps the GET_PARAM ioctl.
> + *
> + * Returns the current value of the parameter. If the parameter is
> + * invalid, returns 0.
> + */
>  uint32_t
>  igt_v3d_get_param(int fd, enum drm_v3d_param param)
>  {
>  	struct drm_v3d_get_param get = {
>  		.param = param,
>  	};
> +	int ret;
>  
> -	do_ioctl(fd, DRM_IOCTL_V3D_GET_PARAM, &get);
> +	ret = igt_ioctl(fd, DRM_IOCTL_V3D_GET_PARAM, &get);
> +	if (ret)
> +		return 0;
>  
>  	return get.value;
>  }
> -- 
> 2.39.0
> 


More information about the igt-dev mailing list