From 6853f8bad8ce5770d28a621a7e15449930d56d9f Mon Sep 17 00:00:00 2001 From: Michał Winiarski Date: Mon, 16 Oct 2017 11:05:17 +0200 Subject: lib/i915: Extract context priority setparam to a helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Another example of something that is used across different tests, and should be moved to lib. v2: Break the trend of expanding ioctl_wrappers Signed-off-by: Michał Winiarski Cc: Arkadiusz Hiler Cc: Chris Wilson Cc: Katarzyna Dec Cc: Petri Latvala Reviewed-by: Chris Wilson Reviewed-by: Katarzyna Dec Acked-by: Arkadiusz Hiler --- lib/i915/gem_context.c | 40 ++++++++++++++++++++++++++++++++++++++++ lib/i915/gem_context.h | 6 ++++++ 2 files changed, 46 insertions(+) (limited to 'lib/i915') diff --git a/lib/i915/gem_context.c b/lib/i915/gem_context.c index ba826ae3..6d9edf5e 100644 --- a/lib/i915/gem_context.c +++ b/lib/i915/gem_context.c @@ -197,3 +197,43 @@ void gem_context_require_bannable(int fd) igt_require(has_ban_period || has_bannable); } + +#define LOCAL_I915_CONTEXT_PARAM_PRIORITY 0x6 + +/** + * __gem_context_set_priority: + * @fd: open i915 drm file descriptor + * @ctx_id: i915 context id + * @prio: desired context priority + * + * This function modifies priority property of the context. + * It is used by the scheduler to decide on the ordering of requests submitted + * to the hardware. + * + * Returns: An integer equal to zero for success and negative for failure + */ +int __gem_context_set_priority(int fd, uint32_t ctx_id, int prio) +{ + struct local_i915_gem_context_param p; + + memset(&p, 0, sizeof(p)); + p.context = ctx_id; + p.size = 0; + p.param = LOCAL_I915_CONTEXT_PARAM_PRIORITY; + p.value = prio; + + return __gem_context_set_param(fd, &p); +} + +/** + * gem_context_set_priority: + * @fd: open i915 drm file descriptor + * @ctx_id: i915 context id + * @prio: desired context priority + * + * Like __gem_context_set_priority(), except we assert on failure. + */ +void gem_context_set_priority(int fd, uint32_t ctx_id, int prio) +{ + igt_assert(__gem_context_set_priority(fd, ctx_id, prio) == 0); +} diff --git a/lib/i915/gem_context.h b/lib/i915/gem_context.h index 06b2ca99..a2339c4b 100644 --- a/lib/i915/gem_context.h +++ b/lib/i915/gem_context.h @@ -45,4 +45,10 @@ void gem_context_set_param(int fd, struct local_i915_gem_context_param *p); int __gem_context_set_param(int fd, struct local_i915_gem_context_param *p); int __gem_context_get_param(int fd, struct local_i915_gem_context_param *p); +#define LOCAL_I915_CONTEXT_MAX_USER_PRIORITY 1023 +#define LOCAL_I915_CONTEXT_DEFAULT_PRIORITY 0 +#define LOCAL_I915_CONTEXT_MIN_USER_PRIORITY -1023 +int __gem_context_set_priority(int fd, uint32_t ctx, int prio); +void gem_context_set_priority(int fd, uint32_t ctx, int prio); + #endif /* GEM_CONTEXT_H */ -- cgit v1.2.3