Re: [igt-dev] [RFC 2/5] lib/ioctl_wrappers: add mmap_offset support

Chris Wilson
2019-02-21T19:48:08Z

Quoting Antonio Argenziano (2019-02-21 19:27:42)
> From: "Kalamarz, Lukasz" <lukasz.kalamarz@intel.com>
>
> With recently proposed changes, IGT need to start supporting new
> way of mmaping object, which will be used from now by default.
> This patch modify gem_mmap_wc and gem_mmap functions to be
> in sync with those changes.
>
> Signed-off-by: Lukasz Kalamarz <lukasz.kalamarz@intel.com>
> Cc: Janulgue Abdiel <abdiel.janulgue@intel.com>
> Cc: Matthew Auld <matthew.auld@intel.com>
> Cc: Michal Winiarski <michal.winiarski@intel.com>
> Cc: Antonio Argenziano <antonio.argenziano@intel.com>
> Cc: Daniele Spurio Ceraolo <daniele.ceraolospurio@intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> ---
> lib/ioctl_wrappers.c | 150 +++++++++++++++++++++++++++++++++++++------
> 1 file changed, 129 insertions(+), 21 deletions(-)
>
> diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
> index 404c2fbf..d9b46088 100644
> --- a/lib/ioctl_wrappers.c
> +++ b/lib/ioctl_wrappers.c
> @@ -641,6 +641,24 @@ void gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
> igt_assert_eq(__gem_execbuf_wr(fd, execbuf), 0);
> }
>
> +static bool has_mmap_offset(int fd)
> +{
> + static int has_mmap_offset = -1;

a) nothing new in ioctl_wrappers, please

b) do not repeat the mistakes of using static, assuming all fd are the
same. Just don't call has_mmap_offset() more than is strictly required.
-Chris