[igt-dev] [PATCH i-g-t v3 1/4] lib/ioctl_wrapper: use defines for get_param instead of param number

Daniele Ceraolo Spurio daniele.ceraolospurio at intel.com
Fri Jan 11 17:54:56 UTC 2019



On 01/11/2019 08:15 AM, Lukasz Kalamarz wrote:
> In lib code there were few functions using param number instead of
> defines. This could lead to some issues (i.e. stolen support
> pointing on different parameter) and we would like to avoid them.

The 3 defines you're touching are part of the published kernel uapi, so 
there is no way for them to change and cause issues. The change is still 
worth doing IMO since defines are better than hard-coded numbers.

> v2: Rebased patch
> 
> Signed-off-by: Lukasz Kalamarz <lukasz.kalamarz at intel.com>
> Cc: Michal Winiarski <michal.winiarski at intel.com>
> Cc: Katarzyna Dec <katarzyna.dec at intel.com>
> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio at intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>

All 3 defs are in the i915_drm.h file in IGT, so with a cleaned commit 
message:

Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio at intel.com>

> ---
>   lib/ioctl_wrappers.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
> index 9f255508..f71f0e32 100644
> --- a/lib/ioctl_wrappers.c
> +++ b/lib/ioctl_wrappers.c
> @@ -708,12 +708,12 @@ bool gem_mmap__has_wc(int fd)
>   		has_wc = 0;
>   
>   		memset(&gp, 0, sizeof(gp));
> -		gp.param = 40; /* MMAP_GTT_VERSION */
> +		gp.param = I915_PARAM_MMAP_GTT_VERSION;
>   		gp.value = &gtt_version;
>   		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
>   
>   		memset(&gp, 0, sizeof(gp));
> -		gp.param = 30; /* MMAP_VERSION */
> +		gp.param = I915_PARAM_MMAP_VERSION;
>   		gp.value = &mmap_version;
>   		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
>   
> @@ -964,7 +964,7 @@ static int gem_gtt_type(int fd)
>   	int val = 0;
>   
>   	memset(&gp, 0, sizeof(gp));
> -	gp.param = 18; /* HAS_ALIASING_PPGTT */
> +	gp.param = I915_PARAM_HAS_ALIASING_PPGTT;
>   	gp.value = &val;
>   
>   	if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)))
> 


More information about the igt-dev mailing list