[igt-dev] [PATCH i-g-t] i915: Handle the case where legacy mmap is not available

Dixit, Ashutosh ashutosh.dixit at intel.com
Thu Jun 24 01:30:16 UTC 2021


On Tue, 11 May 2021 02:00:00 -0700, Maarten Lankhorst wrote:
>
> @@ -84,10 +93,14 @@ void *__gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot)
>  {
>	struct drm_i915_gem_mmap_gtt mmap_arg;
>	void *ptr;
> +	int ret;
>
>	memset(&mmap_arg, 0, sizeof(mmap_arg));
>	mmap_arg.handle = handle;
> -	if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg))
> +	ret = igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg);
> +	if (ret == -1 && errno == EOPNOTSUPP)

What is the handler for DRM_IOCTL_I915_GEM_MMAP_GTT ioctl in i915 (in the
kernel)? I am unable to find it so for now I am just assuming that it will
just get routed to the handler for DRM_IOCTL_I915_GEM_MMAP and return
EOPNOTSUPP for Gen12+ which is what the code above seems to be assuming.

> diff --git a/tests/i915/gem_mmap.c b/tests/i915/gem_mmap.c
> index 7c36571c9bad..fdddd306acb5 100644
> --- a/tests/i915/gem_mmap.c
> +++ b/tests/i915/gem_mmap.c
> @@ -154,8 +154,10 @@ igt_main
>	uint8_t buf[OBJECT_SIZE];
>	uint8_t *addr;
>
> -	igt_fixture
> +	igt_fixture {
>		fd = drm_open_driver(DRIVER_INTEL);
> +		igt_require(gem_has_legacy_mmap(fd));
> +	}
>
>	igt_subtest("bad-object") {
>		uint32_t real_handle = gem_create(fd, 4096);
> diff --git a/tests/i915/gem_mmap_wc.c b/tests/i915/gem_mmap_wc.c
> index 4a2192b30689..ad2d510fcf09 100644
> --- a/tests/i915/gem_mmap_wc.c
> +++ b/tests/i915/gem_mmap_wc.c
> @@ -504,6 +504,7 @@ igt_main
>
>	igt_fixture {
>		fd = drm_open_driver(DRIVER_INTEL);
> +		igt_require(gem_has_legacy_mmap(fd));

I believe we also need to add this igt_require in other places where
DRM_IOCTL_I915_GEM_MMAP and DRM_IOCTL_I915_GEM_MMAP_GTT ioctls are being
calld directly without calling the functions in gem_mman.*. Looks like we
should at least add this igt_require to:

* tests/i915/gem_tiled_wc.c, and
* test/i915/gem_mmap_gtt.c

The remaining references are in overlay/ and tools/ so maybe we can figure
out what to do for these later?

With the above igt_require added to the two files above, this is:

Reviewed-by: Ashutosh Dixit <ashutosh.dixit at intel.com>


More information about the igt-dev mailing list