summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Widawsky <benjamin.widawsky@intel.com>2013-12-26 09:09:16 -0800
committerBen Widawsky <benjamin.widawsky@intel.com>2013-12-26 11:12:51 -0800
commit39c161c53546b7d2d87d4fa6b79b008e22e6a952 (patch)
treeae9fd48cd4cb57945b9cd57f558a822ea7763dec
parent2e07a5f48953db37a954491c99b195cb6f98a974 (diff)
drm/i915: Supplant the default contextreplace-ctx
The per file default context was introduced to enforce process isolation between DRM clients. Prior to this, clients which did not opt-in would receive the previous client's GPU state, and further, corrupt the previous client's GPU state. Unfortunately, this came at the cost of maintaining per client contexts. Contexts take up both memory, and GTT space. Mesa makes heavy use of contexts, and in all likelihood has no care for the default context. It should not get penalized (the extra resources used by the default context) for actually using contexts. This patch adds a flag to the context creation IOCTL which tells the i915 driver NOT to supplant the default context. The normal behavior should be to replace the default context, if using contexts. Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
-rw-r--r--drivers/gpu/drm/i915/i915_gem_context.c13
-rw-r--r--include/uapi/drm/i915_drm.h3
2 files changed, 13 insertions, 3 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index efe62cf60b48..f00c32248fa8 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -749,6 +749,7 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
struct drm_i915_gem_context_create *args = data;
struct drm_i915_file_private *file_priv = file->driver_priv;
struct i915_hw_context *ctx;
+ bool replace = (args->flags & I915_CTX_KEEP_DEAFAULT) == 0;
int ret;
if (!(dev->driver->driver_features & DRIVER_GEM))
@@ -761,12 +762,20 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
if (ret)
return ret;
- ctx = i915_gem_create_context(dev, file_priv, USES_FULL_PPGTT(dev),
- false);
+ if (replace)
+ if (file_priv->private_default_ctx->id != DEFAULT_CONTEXT_ID)
+ DRM_DEBUG_DRIVER("Replacing a non-default context\n");
+
+ ctx = i915_gem_create_context(dev, file_priv, USES_FULL_PPGTT(dev), false);
mutex_unlock(&dev->struct_mutex);
if (IS_ERR(ctx))
return PTR_ERR(ctx);
+ if (replace) {
+ i915_gem_context_unreference(file_priv->private_default_ctx->id);
+ file_priv->private_default_ctx->id = ctx;
+ }
+
args->ctx_id = ctx->id;
DRM_DEBUG_DRIVER("HW context %d created\n", args->ctx_id);
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index 52aed893710a..bb34aa8cf070 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -1020,7 +1020,8 @@ struct drm_i915_gem_wait {
struct drm_i915_gem_context_create {
/* output: id of new context*/
__u32 ctx_id;
- __u32 pad;
+#define I915_CTX_KEEP_DEFAULT (1<<0)
+ __u32 flags;
};
struct drm_i915_gem_context_destroy {