[Intel-gfx] [PATCH i-g-t v4] lib/i915/gem_mman: Add a helper for obtaining MMAP_GTT interface version

Janusz Krzysztofik janusz.krzysztofik at linux.intel.com
Fri May 31 09:42:40 UTC 2019


On Friday, May 31, 2019 11:35:39 AM CEST Chris Wilson wrote:
> Quoting Janusz Krzysztofik (2019-05-31 10:29:16)
> > From: Janusz Krzysztofik <janusz.krzysztofik at intel.com>
> > 
> > If a test calls a function which depends on availability of a specific
> > version of MMAP_GTT interface, an error may occur on unsupported hardware.
> > That may negatively affect results reported by a test framework even if
> > that test ignores the failure and succeedes.
> > 
> > This helper wraps up an IOCTL call which returns a version number of
> > MMAP_GTT interface.  It may be used by tests which should adjust their
> > scope depending on availability of a specific version of MMAP_GTT
> > interface.
> > 
> > Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik at intel.com>
> > Cc: Antonio Argenziano <antonio.argenziano at intel.com>
> > Cc: Michal Wajdeczko <michal.wajdeczko at intel.com>
> > ---
> > Changelog:
> > v3 -> v4:
> > - return errno value on failure (Chris - thanks!),
> > - clear errno before return, as other helpers do,
> > - reword the helper documentation and commit message again (Chris -
> >   thanks!).
> > 
> > v2 (internal) -> v3:
> > - make the code less obsucre, more explicit (Antonio - thanks!),
> > - reword the helper documentation and commit message.
> > 
> > v1 (internal) -> v2 (internal):
> > - minimize future potential conflicts with 
> >   https://patchwork.freedesktop.org/patch/294053/?series=58551&rev=1
> >   (no progress with than one so not waiting for it any longer):
> >   - convert the helper to a drop-in replacement of the one from the
> >     above mentioned patch, returning mappable aperture version, not
> >     only information on its availability,
> >   - drop any other wrappers,
> > - document the helper,
> > - reword commit message.
> > 
> >  lib/i915/gem_mman.c | 25 +++++++++++++++++++++++++
> >  lib/i915/gem_mman.h |  1 +
> >  2 files changed, 26 insertions(+)
> > 
> > diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
> > index 3cf9a6bb..2c3d6971 100644
> > --- a/lib/i915/gem_mman.c
> > +++ b/lib/i915/gem_mman.c
> > @@ -40,6 +40,31 @@
> >  #define VG(x) do {} while (0)
> >  #endif
> >  
> > +/**
> > + * gem_mmap__gtt_version:
> > + * @fd: open i915 drm file descriptor
> > + *
> > + * This functions wraps up an IOCTL to obtain MMAP_GTT interface version
> > + *
> > + * Returns: MMAP_GTT interface version, kernel error code on failure.
> > + */
> > +int gem_mmap__gtt_version(int fd)
> > +{
> > +       int gtt_version, ret;
> > +       struct drm_i915_getparam gp = {
> > +               .param = I915_PARAM_MMAP_GTT_VERSION,
> > +               .value = &gtt_version,
> > +       };
> > +
> > +       if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp))
> > +               ret = errno;
> 
> ret = -errno; :)

Sorry.

> Petri also like it when we then say igt_assume(ret);
> 
> Or one could use
> 
> {
> 	int result = -EIO;
> 	struct ... gp = {
> 		.param = I915_PARAM_MMAP_GTT_VERSION,
> 		.value = &result,
> 	};
> 
> 	if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp)) {
> 		result = -errno;
> 		igt_assume(result);

OK, I'll learn what igt_assume() is first then use it.

Thanks,
Janusz

> 	}
> 
> 	errno = 0;
> 	return result;
> }
> 
> Now just put it to use somewhere.
> -Chris
> 






More information about the Intel-gfx mailing list