[igt-dev] [PATCH i-g-t v4 4/4] tests/i915/gem_mmap_offset: Add new API test for gem_mmap_offset

Chris Wilson chris at chris-wilson.co.uk
Fri Nov 22 08:07:15 UTC 2019


Quoting Zbigniew Kempczyński (2019-11-22 07:48:46)
> From: Lukasz Kalamarz <lukasz.kalamarz at intel.com>
> 
> Few simple tests which tries to create / mmap buffer objects
> in system / device memory regions.
> 
> Signed-off-by: Lukasz Kalamarz <lukasz.kalamarz at intel.com>
> Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Vanshidhar Konda <vanshidhar.r.konda at intel.com>
> ---
>  tests/Makefile.sources       |   3 +
>  tests/i915/gem_mmap_offset.c | 163 +++++++++++++++++++++++++++++++++++
>  tests/meson.build            |   1 +
>  3 files changed, 167 insertions(+)
>  create mode 100644 tests/i915/gem_mmap_offset.c
> 
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index 27801c89..9c6c3933 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -320,6 +320,9 @@ gem_mmap_SOURCES = i915/gem_mmap.c
>  TESTS_progs += gem_mmap_gtt
>  gem_mmap_gtt_SOURCES = i915/gem_mmap_gtt.c
>  
> +TESTS_progs += gem_mmap_offset
> +gem_mmap_offset_SOURCES = i915/gem_mmap_offset.c
> +
>  TESTS_progs += gem_mmap_offset_exhaustion
>  gem_mmap_offset_exhaustion_SOURCES = i915/gem_mmap_offset_exhaustion.c
>  
> diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
> new file mode 100644
> index 00000000..a4432f93
> --- /dev/null
> +++ b/tests/i915/gem_mmap_offset.c
> @@ -0,0 +1,163 @@
> +/*
> + * Copyright © 2019 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + */
> +
> +#include "igt.h"
> +#include <errno.h>
> +#include <sys/stat.h>
> +#include <sys/ioctl.h>
> +#include "drm.h"
> +
> +IGT_TEST_DESCRIPTION("Basic MMAP_OFFSET IOCTL tests for mem regions\n");
> +
> +static int mmap_offset_ioctl(int fd, struct local_i915_gem_mmap_offset *arg)
> +{
> +       int err = 0;
> +
> +       if (igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_MMAP_OFFSET, arg))
> +               err = -errno;

igt_assume(err);

> +
> +       errno = 0;
> +       return err;
> +}
> +
> +static void
> +mmap_offset_bad_object(int fd, struct local_i915_query_memory_region_info *regions)
> +{
> +       const char *region_name;
> +       struct local_i915_memory_region_info *mem_region;
> +       uint32_t region, obj_size, batch_size, real_handle;
> +       uint32_t handles[20];
> +
> +       for_each_memory_region(regions, mem_region) {
> +               int i = 0;
> +
> +               region = mem_region->id;
> +               region_name = memory_region_name(region);
> +               if (IS_STOLEN_MEMORY_REGION(region)) {

We have a query interface, why do we need to hardcode caps?
That does not bode well for the design.

The test is supposed to be agnostic: for a set of supported memory
regions as reported by the kernel, verify the supported api.
-Chris


More information about the igt-dev mailing list