diff options
author | Mika Kuoppala <mika.kuoppala@intel.com> | 2016-11-08 12:31:06 +0200 |
---|---|---|
committer | Mika Kuoppala <mika.kuoppala@intel.com> | 2016-11-11 16:33:10 +0200 |
commit | 773ac7cc60357b91a5747217b926cca7ef71a5c1 (patch) | |
tree | fdb1a68a15b3fd816e70838a747c23bc92bcb545 /lib/igt_gt.c | |
parent | 1af5605a35a82932c13711675bfa5f034f7920fa (diff) |
lib: substitute cxt BAN_PERIOD with BANNABLE
Context BAN_PERIOD will get depracated so subsitute it with BANNABLE
property. Make ctx param test to accept both variants for now
until kernel changes have landed, to not break BAT.
v2: check against - EINVAL on get/set ban as it can return -EPERM
v3: better naming for get/set (Chris)
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
Diffstat (limited to 'lib/igt_gt.c')
-rw-r--r-- | lib/igt_gt.c | 77 |
1 files changed, 46 insertions, 31 deletions
diff --git a/lib/igt_gt.c b/lib/igt_gt.c index a1659323..468c7711 100644 --- a/lib/igt_gt.c +++ b/lib/igt_gt.c @@ -119,11 +119,43 @@ void igt_require_hang_ring(int fd, int ring) igt_skip("hang injection disabled by user"); gem_require_ring(fd, ring); - gem_context_require_ban_period(fd); + gem_context_require_bannable(fd); if (!igt_check_boolean_env_var("IGT_HANG_WITHOUT_RESET", false)) igt_require(has_gpu_reset(fd)); } +static unsigned context_get_ban(int fd, unsigned ctx) +{ + struct local_i915_gem_context_param param; + + param.param = LOCAL_CONTEXT_PARAM_BANNABLE; + param.value = 0; + param.size = 0; + + if (__gem_context_get_param(fd, ¶m) == -EINVAL) { + igt_assert(param.value == 0); + param.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD; + gem_context_get_param(fd, ¶m); + } + + return param.value; +} + +static void context_set_ban(int fd, unsigned ctx, unsigned ban) +{ + struct local_i915_gem_context_param param; + + param.value = ban; + param.size = 0; + param.param = LOCAL_CONTEXT_PARAM_BANNABLE; + + if(__gem_context_set_param(fd, ¶m) == -EINVAL) { + igt_assert(param.value == ban); + param.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD; + gem_context_set_param(fd, ¶m); + } +} + igt_hang_t igt_allow_hang(int fd, unsigned ctx, unsigned flags) { struct local_i915_gem_context_param param; @@ -131,7 +163,7 @@ igt_hang_t igt_allow_hang(int fd, unsigned ctx, unsigned flags) if (!igt_check_boolean_env_var("IGT_HANG", true)) igt_skip("hang injection disabled by user"); - gem_context_require_ban_period(fd); + gem_context_require_bannable(fd); if (!igt_check_boolean_env_var("IGT_HANG_WITHOUT_RESET", false)) igt_require(has_gpu_reset(fd)); @@ -148,16 +180,9 @@ igt_hang_t igt_allow_hang(int fd, unsigned ctx, unsigned flags) __gem_context_set_param(fd, ¶m); } - param.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD; - param.value = 0; - gem_context_get_param(fd, ¶m); - ban = param.value; - - if ((flags & HANG_ALLOW_BAN) == 0) { - param.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD; - param.value = 0; - gem_context_set_param(fd, ¶m); - } + ban = context_get_ban(fd, ctx); + if ((flags & HANG_ALLOW_BAN) == 0) + context_set_ban(fd, ctx, 0); return (struct igt_hang){ 0, ctx, ban, flags }; } @@ -166,13 +191,11 @@ void igt_disallow_hang(int fd, igt_hang_t arg) { struct local_i915_gem_context_param param; - param.context = arg.ctx; - param.size = 0; - param.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD; - param.value = arg.ban; - gem_context_set_param(fd, ¶m); + context_set_ban(fd, arg.ctx, arg.ban); if ((arg.flags & HANG_ALLOW_CAPTURE) == 0) { + param.context = arg.ctx; + param.size = 0; param.param = LOCAL_CONTEXT_PARAM_NO_ERROR_CAPTURE; param.value = 0; if (__gem_context_set_param(fd, ¶m)) @@ -227,16 +250,10 @@ igt_hang_t igt_hang_ctx(int fd, __gem_context_set_param(fd, ¶m); } - param.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD; - param.value = 0; - gem_context_get_param(fd, ¶m); - ban = param.value; + ban = context_get_ban(fd, ctx); - if ((flags & HANG_ALLOW_BAN) == 0) { - param.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD; - param.value = 0; - gem_context_set_param(fd, ¶m); - } + if ((flags & HANG_ALLOW_BAN) == 0) + context_set_ban(fd, ctx, 0); memset(&reloc, 0, sizeof(reloc)); memset(&exec, 0, sizeof(exec)); @@ -323,13 +340,11 @@ void igt_post_hang_ring(int fd, igt_hang_t arg) I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); gem_close(fd, arg.handle); - param.context = arg.ctx; - param.size = 0; - param.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD; - param.value = arg.ban; - gem_context_set_param(fd, ¶m); + context_set_ban(fd, arg.ctx, arg.ban); if ((arg.flags & HANG_ALLOW_CAPTURE) == 0) { + param.context = arg.ctx; + param.size = 0; param.param = LOCAL_CONTEXT_PARAM_NO_ERROR_CAPTURE; param.value = 0; if (__gem_context_set_param(fd, ¶m)) |