[Intel-gfx] [PATCH i-g-t] lib: Moving gem_execbuf_wr to ioctl_wrappers

Petri Latvala petri.latvala at intel.com
Wed May 31 14:19:12 UTC 2017


On Thu, May 25, 2017 at 11:25:54AM +0100, Tvrtko Ursulin wrote:
> 
> On 25/05/2017 08:40, Lukasz Fiedorowicz wrote:
> > gem_execbuf_wr was duplicated in multiple places.
> > Moving everything to lib/
> > 
> > Signed-off-by: Lukasz Fiedorowicz <lukasz.fiedorowicz at intel.com>
> > ---
> >  benchmarks/gem_busy.c    | 16 ----------------
> >  benchmarks/gem_latency.c | 16 ----------------
> >  benchmarks/gem_wsim.c    | 16 ----------------
> >  lib/ioctl_wrappers.c     | 33 +++++++++++++++++++++++++++++++++
> >  lib/ioctl_wrappers.h     |  2 ++
> >  tests/gem_exec_fence.c   | 16 ----------------
> >  tests/gem_exec_nop.c     | 16 ----------------
> >  7 files changed, 35 insertions(+), 80 deletions(-)
> > 
> > diff --git a/benchmarks/gem_busy.c b/benchmarks/gem_busy.c
> > index bda3e13..c1cee6c 100644
> > --- a/benchmarks/gem_busy.c
> > +++ b/benchmarks/gem_busy.c
> > @@ -45,8 +45,6 @@
> >  #include "intel_chipset.h"
> >  #include "igt_stats.h"
> > 
> > -#define LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR       DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2)
> > -
> >  #define LOCAL_I915_EXEC_NO_RELOC (1<<11)
> >  #define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
> > 
> > @@ -73,20 +71,6 @@ static bool gem_busy(int fd, uint32_t handle)
> >  	return busy.busy != 0;
> >  }
> > 
> > -static int __gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
> > -{
> > -	int err = 0;
> > -	if (igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR, execbuf))
> > -		err = -errno;
> > -	errno = 0;
> > -	return err;
> > -}
> > -
> > -static void gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
> > -{
> > -	igt_assert_eq(__gem_execbuf_wr(fd, execbuf), 0);
> > -}
> > -
> >  static bool gem_wait__busy(int fd, uint32_t handle)
> >  {
> >  	struct drm_i915_gem_wait wait;
> > diff --git a/benchmarks/gem_latency.c b/benchmarks/gem_latency.c
> > index 7975ade..6cb16ba 100644
> > --- a/benchmarks/gem_latency.c
> > +++ b/benchmarks/gem_latency.c
> > @@ -45,8 +45,6 @@
> >  #include <sys/resource.h>
> >  #include "drm.h"
> > 
> > -#define LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR       DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2)
> > -
> >  #define LOCAL_I915_EXEC_FENCE_IN              (1<<16)
> >  #define LOCAL_I915_EXEC_FENCE_OUT             (1<<17)
> > 
> > @@ -103,20 +101,6 @@ inline static uint32_t read_timestamp(void)
> >  }
> >  #endif
> > 
> > -static int __gem_execbuf_wr(int _fd, struct drm_i915_gem_execbuffer2 *execbuf)
> > -{
> > -	int err = 0;
> > -	if (igt_ioctl(_fd, LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR, execbuf))
> > -		err = -errno;
> > -	errno = 0;
> > -	return err;
> > -}
> > -
> > -static void gem_execbuf_wr(int _fd, struct drm_i915_gem_execbuffer2 *execbuf)
> > -{
> > -	igt_assert_eq(__gem_execbuf_wr(_fd, execbuf), 0);
> > -}
> > -
> >  struct consumer {
> >  	pthread_t thread;
> > 
> > diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
> > index b366a5d..485de15 100644
> > --- a/benchmarks/gem_wsim.c
> > +++ b/benchmarks/gem_wsim.c
> > @@ -1481,22 +1481,6 @@ static void init_status_page(struct workload *wrk, unsigned int flags)
> >  	}
> >  }
> > 
> > -#define LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR       DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2)
> > -
> > -static int __gem_execbuf_wr(int gemfd, struct drm_i915_gem_execbuffer2 *execbuf)
> > -{
> > -	int err = 0;
> > -	if (igt_ioctl(gemfd, LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR, execbuf))
> > -		err = -errno;
> > -	errno = 0;
> > -	return err;
> > -}
> > -
> > -static void gem_execbuf_wr(int gemfd, struct drm_i915_gem_execbuffer2 *execbuf)
> > -{
> > -	igt_assert_eq(__gem_execbuf_wr(gemfd, execbuf), 0);
> > -}
> > -
> >  static void
> >  do_eb(struct workload *wrk, struct w_step *w, enum intel_engine_id engine,
> >        unsigned int flags)
> > diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
> > index 48bdcc5..0816a7b 100644
> > --- a/lib/ioctl_wrappers.c
> > +++ b/lib/ioctl_wrappers.c
> > @@ -624,6 +624,39 @@ void gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
> >  	igt_assert_eq(__gem_execbuf(fd, execbuf), 0);
> >  }
> > 
> > +#define LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR \
> > +    DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2)
> > +
> > +/**
> > + * __gem_execbuf_wr:
> > + * @fd: open i915 drm file descriptor
> > + * @execbuf: execbuffer data structure
> > + *
> > + * This wraps the EXECBUFFER2_WR ioctl, which submits a batchbuffer for the gpu to
> > + * run. This is allowed to fail, with -errno returned.
> > + */
> > +int __gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
> > +{
> > +	int err = 0;
> > +	if (igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR, execbuf))
> > +		err = -errno;
> > +	errno = 0;
> > +	return err;
> > +}
> > +
> > +/**
> > + * gem_execbuf_wr:
> > + * @fd: open i915 drm file descriptor
> > + * @execbuf: execbuffer data structure
> > + *
> > + * This wraps the EXECBUFFER2_WR ioctl, which submits a batchbuffer for the gpu to
> > + * run.
> > + */
> > +void gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
> > +{
> > +	igt_assert_eq(__gem_execbuf_wr(fd, execbuf), 0);
> > +}
> > +
> >  /**
> >   * __gem_mmap__gtt:
> >   * @fd: open i915 drm file descriptor
> > diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
> > index d6d8bad..e1279d9 100644
> > --- a/lib/ioctl_wrappers.h
> > +++ b/lib/ioctl_wrappers.h
> > @@ -74,6 +74,8 @@ uint32_t __gem_create_stolen(int fd, uint64_t size);
> >  uint32_t gem_create_stolen(int fd, uint64_t size);
> >  uint32_t __gem_create(int fd, int size);
> >  uint32_t gem_create(int fd, uint64_t size);
> > +void gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf);
> > +int __gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf);
> >  void gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf);
> >  int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf);
> > 
> > diff --git a/tests/gem_exec_fence.c b/tests/gem_exec_fence.c
> > index 05e55f0..82b0c89 100644
> > --- a/tests/gem_exec_fence.c
> > +++ b/tests/gem_exec_fence.c
> > @@ -31,10 +31,8 @@
> > 
> >  IGT_TEST_DESCRIPTION("Check that execbuf waits for explicit fences");
> > 
> > -#define LOCAL_PARAM_HAS_EXEC_FENCE 44
> >  #define LOCAL_EXEC_FENCE_IN (1 << 16)
> >  #define LOCAL_EXEC_FENCE_OUT (1 << 17)
> > -#define LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR       DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2)
> > 
> >  #ifndef SYNC_IOC_MERGE
> >  struct sync_merge_data {
> > @@ -101,20 +99,6 @@ static void store(int fd, unsigned ring, int fence, uint32_t target, unsigned of
> >  	gem_close(fd, obj[BATCH].handle);
> >  }
> > 
> > -static int __gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
> > -{
> > -	int err = 0;
> > -	if (igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR, execbuf))
> > -		err = -errno;
> > -	errno = 0;
> > -	return err;
> > -}
> > -
> > -static void gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
> > -{
> > -	igt_assert_eq(__gem_execbuf_wr(fd, execbuf), 0);
> > -}
> > -
> >  static bool fence_busy(int fence)
> >  {
> >  	return poll(&(struct pollfd){fence, POLLIN}, 1, 0) == 0;
> > diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
> > index 440e357..45ab47d 100644
> > --- a/tests/gem_exec_nop.c
> > +++ b/tests/gem_exec_nop.c
> > @@ -489,22 +489,6 @@ static void sequential(int fd, uint32_t handle, unsigned flags, int timeout)
> >  }
> > 
> >  #define LOCAL_EXEC_FENCE_OUT (1 << 17)
> > -#define LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR       DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2)
> > -
> > -static int __gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
> > -{
> > -	int err = 0;
> > -	if (igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR, execbuf))
> > -		err = -errno;
> > -	errno = 0;
> > -	return err;
> > -}
> > -
> > -static void gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
> > -{
> > -	igt_assert_eq(__gem_execbuf_wr(fd, execbuf), 0);
> > -}
> > -
> >  static bool fence_enable_signaling(int fence)
> >  {
> >  	return poll(&(struct pollfd){fence, POLLIN}, 1, 0) == 0;
> > 
> 
> LGTM!
> 
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>


Pushed this, thanks.

-- 
Petri Latvala


More information about the Intel-gfx mailing list