[PATCH v5 1/4] lib/ioctl_wrappers: let the caller handle capability check result

Kamil Konieczny kamil.konieczny at linux.intel.com
Thu Apr 3 16:59:55 UTC 2025


Hi André,
On 2025-04-01 at 23:29:19 -0300, André Almeida wrote:
> From: Melissa Wen <mwen at igalia.com>
> 
> Rework igt_has_drm_cap to just check if a DRM capability is supported
> and let the called decide what to do from this check. It prevents the
> test fails because of an assert done when it's called in
> igt_subtest_with_dynamics.
> 
> Signed-off-by: Melissa Wen <mwen at igalia.com>
> ---
>  lib/ioctl_wrappers.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
> index 146973f0d..15eeb9aa4 100644
> --- a/lib/ioctl_wrappers.c
> +++ b/lib/ioctl_wrappers.c
> @@ -1292,10 +1292,10 @@ int __kms_addfb(int fd, uint32_t handle,
>   */
>  bool igt_has_drm_cap(int fd, uint64_t capability)
>  {
> -	struct drm_get_cap cap = { .capability = capability };
> -
> -	igt_assert(drmIoctl(fd, DRM_IOCTL_GET_CAP, &cap) == 0);
> -	return cap.value;
> +	uint64_t value;
> +	if (drmGetCap(fd, capability, &value))
> +		return false;
> +	return value ? true : false;

So this will mix an error, for example due to bad fd, with the
capability not available. Why not writing this into new function?
Like:

/* description here */
int __igt_has_drm_cap(int fd, uint64_t capability)
{
	struct drm_get_cap cap = { .capability = capability };
	uint64_t value = 0;

	if (drmGetCap(fd, capability, &value))
		return -errno;

	return value ? 1 : 0;
}

or you could just fills caps:

/* description here */
int __igt_get_drm_cap(int fd, uint64_t cap_query, uint64_t &cap_value)
{
	....

	if (drmGetCap(fd, cap_query, &cap_value))
		return -errno;

	return 0;
}

Regards,
Kamil

>  
>  /**
> -- 
> 2.49.0
> 


More information about the igt-dev mailing list