[igt-dev] [PATCH i-g-t 05/17] gem_wsim: Use IGT uapi headers

Tvrtko Ursulin
2018-10-18T15:28:29Z

We are moving towards bumping the uAPI headers more often instead of using
too much local struct/ioctl/param definitions since the latter are more
challenging for rebase and maintenance.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
benchmarks/gem_wsim.c | 68 +++++++++++--------------------------------
1 file changed, 17 insertions(+), 51 deletions(-)

diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
index e1c73855150b..adfc2b1bc819 100644
--- a/benchmarks/gem_wsim.c
+++ b/benchmarks/gem_wsim.c
@@ -41,7 +41,6 @@
#include <limits.h>
#include <pthread.h>

-
#include "intel_chipset.h"
#include "intel_reg.h"
#include "drm.h"
@@ -56,23 +55,6 @@

#include "ewma.h"

-#define LOCAL_I915_EXEC_FENCE_IN (1<<16)
-#define LOCAL_I915_EXEC_FENCE_OUT (1<<17)
-
-struct local_drm_i915_gem_context_create_v2 {
- /* output: id of new context*/
- __u32 ctx_id;
- __u32 flags;
-#define LOCAL_I915_GEM_CONTEXT_SHARE_GTT 0x1
-#define LOCAL_I915_GEM_CONTEXT_SINGLE_TIMELINE 0x2
- __u32 share_ctx;
- __u32 pad;
-};
-
-#define LOCAL_DRM_IOCTL_I915_GEM_CONTEXT_CREATE DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct local_drm_i915_gem_context_create_v2)
-
-#define LOCAL_I915_CONTEXT_PARAM_ENGINES 0x7
-
enum intel_engine_id {
RCS,
BCS,
@@ -873,7 +855,7 @@ eb_update_flags(struct w_step *w, enum intel_engine_id engine,

igt_assert(w->emit_fence <= 0);
if (w->emit_fence)
- w->eb.flags |= LOCAL_I915_EXEC_FENCE_OUT;
+ w->eb.flags |= I915_EXEC_FENCE_OUT;
}

static struct drm_i915_gem_exec_object2 *
@@ -1079,24 +1061,23 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)
continue;

if (flags & I915) {
- struct local_drm_i915_gem_context_create_v2 args = { };
+ struct drm_i915_gem_context_create_v2 args = { };

/* Find existing context to share ppgtt with. */
for (j = 0; j < wrk->nr_ctxs; j++) {
if (!wrk->ctx_list[j].id)
continue;

- args.flags |= LOCAL_I915_GEM_CONTEXT_SHARE_GTT;
+ args.flags |= I915_GEM_CONTEXT_SHARE_GTT;
args.share_ctx = share_ctx =
wrk->ctx_list[j].id;
break;
}

if (!ctx->targets_instance)
- args.flags |= LOCAL_I915_GEM_CONTEXT_SINGLE_TIMELINE;
+ args.flags |= I915_GEM_CONTEXT_SINGLE_TIMELINE;

- drmIoctl(fd, LOCAL_DRM_IOCTL_I915_GEM_CONTEXT_CREATE,
- &args);
+ drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &args);

ctx_id = args.ctx_id;
} else {
@@ -1125,16 +1106,15 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)
*/
if ((flags & I915) && ctx->wants_balance &&
ctx->targets_instance) {
- struct local_drm_i915_gem_context_create_v2 args = {};
+ struct drm_i915_gem_context_create_v2 args = {};

igt_assert(share_ctx);

- args.flags = LOCAL_I915_GEM_CONTEXT_SINGLE_TIMELINE |
- LOCAL_I915_GEM_CONTEXT_SHARE_GTT;
+ args.flags = I915_GEM_CONTEXT_SINGLE_TIMELINE |
+ I915_GEM_CONTEXT_SHARE_GTT;
args.share_ctx = share_ctx;

- drmIoctl(fd, LOCAL_DRM_IOCTL_I915_GEM_CONTEXT_CREATE,
- &args);
+ drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &args);

igt_assert(args.ctx_id);
ctx_id = args.ctx_id;
@@ -1144,24 +1124,10 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)
}

if (ctx->wants_balance) {
- #define LOCAL_I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE 0
-
- struct local_i915_user_extension {
- __u64 next_extension;
- __u64 name;
- };
-
- struct local_i915_context_engines_load_balance {
- struct local_i915_user_extension base;
-
- __u64 flags; /* all undefined flags must be zero */
- __u64 engines_mask;
-
- __u64 mbz[4]; /* reserved for future use; must be zero */
- } load_balance = {
- .base.name = LOCAL_I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE,
- .engines_mask = -1,
- };
+ struct i915_context_engines_load_balance load_balance =
+ { .base.name = I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE,
+ .engines_mask = -1,
+ };

struct local_i915_context_param_engines {
__u64 extensions;
@@ -1182,7 +1148,7 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)

struct drm_i915_gem_context_param param = {
.ctx_id = ctx_id,
- .param = LOCAL_I915_CONTEXT_PARAM_ENGINES,
+ .param = I915_CONTEXT_PARAM_ENGINES,
.size = sizeof(set_engines),
.value = to_user_pointer(&set_engines),
};
@@ -1994,16 +1960,16 @@ do_eb(struct workload *wrk, struct w_step *w, enum intel_engine_id engine,
igt_assert(tgt >= 0 && tgt < w->idx);
igt_assert(wrk->steps[tgt].emit_fence > 0);

- w->eb.flags |= LOCAL_I915_EXEC_FENCE_IN;
+ w->eb.flags |= I915_EXEC_FENCE_IN;
w->eb.rsvd2 = wrk->steps[tgt].emit_fence;
}

- if (w->eb.flags & LOCAL_I915_EXEC_FENCE_OUT)
+ if (w->eb.flags & I915_EXEC_FENCE_OUT)
gem_execbuf_wr(fd, &w->eb);
else
gem_execbuf(fd, &w->eb);

- if (w->eb.flags & LOCAL_I915_EXEC_FENCE_OUT) {
+ if (w->eb.flags & I915_EXEC_FENCE_OUT) {
w->emit_fence = w->eb.rsvd2 >> 32;
igt_assert(w->emit_fence > 0);