[igt-dev] [PATCH i-g-t v6 6/9] igt/lib: Add wrapper to check if gtt mapping is available

Chris Wilson chris at chris-wilson.co.uk
Fri Jun 14 09:47:35 UTC 2019


Quoting Antonio Argenziano (2019-06-13 22:54:45)
> Add wrapper to get mmap_gtt version number and another to check if
> gtt mapping is at all available.
> 
> v2:
>         - Check errno only after failed syscall. (Chris)
> 
> Cc: Katarzyna Dec <katarzyna.dec at intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Matthew Auld <matthew.auld at intel.com>
> Signed-off-by: Antonio Argenziano <antonio.argenziano at intel.com>
> Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio at intel.com>
> ---
>  lib/i915/gem_mman.c | 40 +++++++++++++++++++++++++++++++++++++++-
>  lib/i915/gem_mman.h | 11 +++++++++++
>  2 files changed, 50 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
> index 0631bf40..2b3947de 100644
> --- a/lib/i915/gem_mman.c
> +++ b/lib/i915/gem_mman.c
> @@ -40,6 +40,41 @@
>  #define VG(x) do {} while (0)
>  #endif
>  
> +/**
> + * gem_mmap__gtt_version:
> + * @fd: open i915 drm file descriptor
> + *
> + * This wraps I915_PARAM_MMAP_GTT_VERSION. It will return the supported feature
> + * set for gtt mapping. Since the mappable aperture in not always present, this
> + * function will return '-1' in case there is none.
> + */
> +static int gem_mmap__gtt_version(int fd)
> +{
> +       static int gtt_version = ~0;

Ahem.

> +       if (gtt_version == ~0) {
> +                       struct drm_i915_getparam gp;
> +
> +                       gtt_version = 0;
> +
> +                       memset(&gp, 0, sizeof(gp));
> +                       gp.param = I915_PARAM_MMAP_GTT_VERSION;
> +                       gp.value = &gtt_version;
> +
> +                       if(ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp) && errno == -ENODEV)
> +                               gtt_version = -1; /* No mappable aperture */

Hahaha, no?

MMAP_GTT == MMAP_OFFSET so when we extend MMAP_GTT ioctl with
the MMAP_OFFSET struct, we bump the MMAP_GTT_VERSION
-Chris


More information about the igt-dev mailing list