[igt-dev] [i-g-t] lib/i915: Use FIXED mapping only for discrete memory

Daniel Vetter daniel.vetter at ffwll.ch
Mon Aug 30 15:59:21 UTC 2021


On Fri, Aug 27, 2021 at 3:07 PM Tejas Upadhyay
<tejaskumarx.surendrakumar.upadhyay at intel.com> wrote:
>
> The FIXED mapping is only used for discrete, and mapping type
> is pre-defined. This disables the other type of mmap
> offsets when discrete memory is used.
>
> Taken from kernel commit:
> commit 7961c5b60f23 ("drm/i915: Add TTM offset argument to mmap.")
>
> Signed-off-by: Tejas Upadhyay <tejaskumarx.surendrakumar.upadhyay at intel.com>
> ---
>  include/drm-uapi/i915_drm.h | 1 +
>  lib/i915/gem_mman.c         | 8 +++++++-
>  2 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/include/drm-uapi/i915_drm.h b/include/drm-uapi/i915_drm.h
> index a1c0030c..b46367f2 100644
> --- a/include/drm-uapi/i915_drm.h
> +++ b/include/drm-uapi/i915_drm.h
> @@ -871,6 +871,7 @@ struct drm_i915_gem_mmap_offset {
>  #define I915_MMAP_OFFSET_WC  1
>  #define I915_MMAP_OFFSET_WB  2
>  #define I915_MMAP_OFFSET_UC  3
> +#define I915_MMAP_OFFSET_FIXED 4
>
>         /*
>          * Zero-terminated chain of extensions.
> diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
> index 0406a0b9..1917c24d 100644
> --- a/lib/i915/gem_mman.c
> +++ b/lib/i915/gem_mman.c
> @@ -75,7 +75,13 @@ bool gem_has_legacy_mmap(int fd)
>
>  bool gem_has_mmap_offset_type(int fd, const struct mmap_offset *t)

Please document any library functions that you touch/update,
especially when they're not yet documented.

It would be really good to document an entire file, because currently
the igt doc situation in the gem area is very bad.
-Daniel

>  {
> -       return gem_has_mmap_offset(fd) || t->type == I915_MMAP_OFFSET_GTT;
> +       if (gem_has_mmap_offset(fd))
> +               if (!gem_has_lmem(fd))
> +                       return !(t->type == I915_MMAP_OFFSET_FIXED);
> +               else
> +                       return !(t->type != I915_MMAP_OFFSET_FIXED);
> +       else
> +               return false;
>  }
>
>  /**
> --
> 2.31.1
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the igt-dev mailing list