summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Harrison <John.C.Harrison@Intel.com>2015-11-24 12:03:11 +0000
committerJohn Harrison <John.C.Harrison@Intel.com>2016-04-14 17:56:19 +0100
commit74cde450280e4cfd5fcbdef32b9af1c14f26ea31 (patch)
treeeca82eba26b98616144fe69b93d684f5a59d0cdf
parentcc9a53f076d4e958e595e1daaff2c286ce1b7bb1 (diff)
drm/i915: Add wrapper for context priority interface
There is an EGL extension to set execution priority per context. This can be implemented via the i915 per context priority parameter. This patch adds a wrapper to connect the two together in a way that can be updated as necessary without breaking one side or the other. Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
-rw-r--r--include/drm/i915_drm.h1
-rw-r--r--intel/intel_bufmgr.h5
-rw-r--r--intel/intel_bufmgr_gem.c70
3 files changed, 76 insertions, 0 deletions
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
index c4ce6b2c6f89..8d9f06360942 100644
--- a/include/drm/i915_drm.h
+++ b/include/drm/i915_drm.h
@@ -1167,6 +1167,7 @@ struct drm_i915_gem_context_param {
#define I915_CONTEXT_PARAM_BAN_PERIOD 0x1
#define I915_CONTEXT_PARAM_NO_ZEROMAP 0x2
#define I915_CONTEXT_PARAM_GTT_SIZE 0x3
+#define I915_CONTEXT_PARAM_PRIORITY 0x4
__u64 value;
};
diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h
index a1abbcd2b066..49d41256fd67 100644
--- a/intel/intel_bufmgr.h
+++ b/intel/intel_bufmgr.h
@@ -209,6 +209,11 @@ int drm_intel_gem_bo_wait(drm_intel_bo *bo, int64_t timeout_ns);
drm_intel_context *drm_intel_gem_context_create(drm_intel_bufmgr *bufmgr);
void drm_intel_gem_context_destroy(drm_intel_context *ctx);
+int drm_intel_gem_context_get_priority(drm_intel_context *ctx, int *priority);
+#define DRM_INTEL_CTX_SET_PRIORITY_EGL_LOW (0x10001)
+#define DRM_INTEL_CTX_SET_PRIORITY_EGL_MEDIUM (0x10002)
+#define DRM_INTEL_CTX_SET_PRIORITY_EGL_HIGH (0x10003)
+int drm_intel_gem_context_set_priority(drm_intel_context *ctx, int priority);
int drm_intel_gem_bo_context_exec(drm_intel_bo *bo, drm_intel_context *ctx,
int used, unsigned int flags);
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index 0a4012beec58..591ccd5486e7 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -3154,6 +3154,76 @@ drm_intel_gem_context_destroy(drm_intel_context *ctx)
}
int
+drm_intel_gem_context_get_priority(drm_intel_context *ctx, int *priority)
+{
+ drm_intel_bufmgr_gem *bufmgr_gem;
+ struct drm_i915_gem_context_param ctxparam;
+ int ret;
+
+ if ((ctx == NULL) || (priority == NULL))
+ return -EINVAL;
+
+ memclear(ctxparam);
+
+ bufmgr_gem = (drm_intel_bufmgr_gem *)ctx->bufmgr;
+ ctxparam.ctx_id = ctx->ctx_id;
+ ctxparam.param = I915_CONTEXT_PARAM_PRIORITY;
+ ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM,
+ &ctxparam);
+ if (ret != 0) {
+ int err = errno;
+ *priority = 0;
+ fprintf(stderr, "DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM failed: %s\n",
+ strerror(err));
+ return -err;
+ }
+
+ *priority = (int) ctxparam.value;
+
+ return 0;
+}
+
+int
+drm_intel_gem_context_set_priority(drm_intel_context *ctx, int priority)
+{
+ drm_intel_bufmgr_gem *bufmgr_gem;
+ struct drm_i915_gem_context_param ctxparam;
+ int ret;
+
+ if (ctx == NULL)
+ return -EINVAL;
+
+ memclear(ctxparam);
+
+ switch (priority) {
+ case DRM_INTEL_CTX_SET_PRIORITY_EGL_LOW:
+ priority = -500;
+ break;
+ case DRM_INTEL_CTX_SET_PRIORITY_EGL_MEDIUM:
+ priority = -0;
+ break;
+ case DRM_INTEL_CTX_SET_PRIORITY_EGL_HIGH:
+ priority = 500;
+ break;
+ }
+
+ bufmgr_gem = (drm_intel_bufmgr_gem *)ctx->bufmgr;
+ ctxparam.ctx_id = ctx->ctx_id;
+ ctxparam.param = I915_CONTEXT_PARAM_PRIORITY;
+ ctxparam.value = priority;
+ ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM,
+ &ctxparam);
+ if (ret != 0) {
+ int err = errno;
+ fprintf(stderr, "DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM failed: %s\n",
+ strerror(err));
+ return -err;
+ }
+
+ return 0;
+}
+
+int
drm_intel_get_reset_stats(drm_intel_context *ctx,
uint32_t *reset_count,
uint32_t *active,