diff options
author | Michał Winiarski <michal.winiarski@intel.com> | 2017-10-16 11:05:17 +0200 |
---|---|---|
committer | Arkadiusz Hiler <arkadiusz.hiler@intel.com> | 2017-10-17 10:26:30 +0300 |
commit | 6853f8bad8ce5770d28a621a7e15449930d56d9f (patch) | |
tree | 554b2e5737a43a670213ca8854db2288fbff0858 /lib/i915 | |
parent | 131ad520cb44c7dafacc6ef327d9fa6cda9067ab (diff) |
lib/i915: Extract context priority setparam to a helper
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 <michal.winiarski@intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Katarzyna Dec <katarzyna.dec@intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Katarzyna Dec <katarzyna.dec@intel.com>
Acked-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Diffstat (limited to 'lib/i915')
-rw-r--r-- | lib/i915/gem_context.c | 40 | ||||
-rw-r--r-- | lib/i915/gem_context.h | 6 |
2 files changed, 46 insertions, 0 deletions
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 */ |