[igt-dev] [RFC PATCH i-g-t] lib/i915: Restrict mmap types to GTT if no MMAP_OFFSET support

Chris Wilson chris at chris-wilson.co.uk
Thu Feb 20 16:09:14 UTC 2020


Quoting Janusz Krzysztofik (2020-02-20 15:32:03)
> Commit b0da8bb705c0 ("lib/i915: for_each_mmap_offset_type()")
> introduced a macro that makes it easy to repeat a test body within a
> loop for each mmap-offset mapping type supported by v4 of i915 MMAP_GTT
> API. However, when run on an older version of the driver, those
> subtests are believed to be still repeated for each known mmap-offset
> mapping type while effectively exercising GTT mapping type only.  As
> that may be confusing, fix it.
> 
> It has been assumed that the modified macro is still suitable for use
> inside gem_mmap_offset test itself.  Would that not be case,
> gem_mmap_offset could redefine the macro back to its initial form for
> internal use.
> 
> Suggested-by: Michał Winiarski <michal.winiarski at intel.com>
> Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik at linux.intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  lib/i915/gem_mman.h          |  5 +++--
>  tests/i915/gem_ctx_sseu.c    |  2 +-
>  tests/i915/gem_exec_params.c |  2 +-
>  tests/i915/gem_madvise.c     | 18 ++++++++++++++----
>  tests/i915/gem_mmap_offset.c | 10 +++++-----
>  tests/i915/i915_pm_rpm.c     |  2 +-
>  6 files changed, 25 insertions(+), 14 deletions(-)
> 
> diff --git a/lib/i915/gem_mman.h b/lib/i915/gem_mman.h
> index 4fc6a0186..491767023 100644
> --- a/lib/i915/gem_mman.h
> +++ b/lib/i915/gem_mman.h
> @@ -101,9 +101,10 @@ extern const struct mmap_offset {
>         unsigned int domain;
>  } mmap_offset_types[];
>  
> -#define for_each_mmap_offset_type(__t) \
> +#define for_each_mmap_offset_type(fd, __t) \
>         for (const struct mmap_offset *__t = mmap_offset_types; \
> -            (__t)->name; \
> +            (__t)->name && (gem_has_mmap_offset(fd) || \
> +                            (__t)->type == I915_MMAP_OFFSET_GTT); \

Sigh.

extern bool gem_has_mmap_offset_type(int i915, const struct mmap_offset *t);

&& gem_has_mmap_offset_type(fd, t)

in case we need to fix it again in future.
-Chris


More information about the igt-dev mailing list