[Intel-gfx] [PATCH 16/50] drm/i915: Option to skip backing object allocation during context creation

oscar.mateo at intel.com oscar.mateo at intel.com
Fri May 9 14:08:46 CEST 2014


From: Oscar Mateo <oscar.mateo at intel.com>

Allocating only the RCS backing object won't be enough for LRCs, so
give callers the opportunity to skip it.

No functional changes.

Signed-off-by: Oscar Mateo <oscar.mateo at intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h         |  3 ++-
 drivers/gpu/drm/i915/i915_gem_context.c | 15 ++++++++-------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 2d5a65d..6f45bf0 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2388,7 +2388,8 @@ void i915_gem_object_ggtt_unpin(struct drm_i915_gem_object *obj);
 int __must_check i915_gem_context_init(struct drm_device *dev);
 void i915_gem_context_fini(struct drm_device *dev);
 struct i915_hw_context *i915_gem_create_context(struct drm_device *dev,
-		struct drm_i915_file_private *file_priv, bool create_vm);
+		struct drm_i915_file_private *file_priv,
+		bool create_vm, bool create_obj);
 void i915_gem_context_reset(struct drm_device *dev);
 int i915_gem_context_open(struct drm_device *dev, struct drm_file *file);
 int i915_gem_context_enable(struct drm_i915_private *dev_priv);
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index b2abe9a..2d47532 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -221,7 +221,8 @@ create_vm_for_ctx(struct drm_device *dev, struct i915_hw_context *ctx)
 
 static struct i915_hw_context *
 __create_hw_context(struct drm_device *dev,
-		  struct drm_i915_file_private *file_priv)
+		struct drm_i915_file_private *file_priv,
+		bool create_obj)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct i915_hw_context *ctx;
@@ -235,7 +236,7 @@ __create_hw_context(struct drm_device *dev,
 	kref_init(&ctx->ref);
 	list_add_tail(&ctx->link, &dev_priv->context_list);
 
-	if (dev_priv->hw_context_size) {
+	if (dev_priv->hw_context_size && create_obj) {
 		ctx->engine[RCS].obj = ctx_obj = i915_gem_alloc_object(dev,
 							dev_priv->hw_context_size);
 		if (ctx_obj == NULL) {
@@ -291,7 +292,7 @@ err_out:
 struct i915_hw_context *
 i915_gem_create_context(struct drm_device *dev,
 			struct drm_i915_file_private *file_priv,
-			bool create_vm)
+			bool create_vm, bool create_obj)
 {
 	const bool is_global_default_ctx = file_priv == NULL;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -301,7 +302,7 @@ i915_gem_create_context(struct drm_device *dev,
 
 	BUG_ON(!mutex_is_locked(&dev->struct_mutex));
 
-	ctx = __create_hw_context(dev, file_priv);
+	ctx = __create_hw_context(dev, file_priv, create_obj);
 	if (IS_ERR(ctx))
 		return ctx;
 
@@ -415,7 +416,7 @@ int i915_gem_context_init(struct drm_device *dev)
 		}
 	}
 
-	ctx = i915_gem_create_context(dev, NULL, USES_PPGTT(dev));
+	ctx = i915_gem_create_context(dev, NULL, USES_PPGTT(dev), true);
 	if (IS_ERR(ctx)) {
 		DRM_ERROR("Failed to create default global context (error %ld)\n",
 			  PTR_ERR(ctx));
@@ -519,7 +520,7 @@ int i915_gem_context_open(struct drm_device *dev, struct drm_file *file)
 
 	mutex_lock(&dev->struct_mutex);
 	file_priv->private_default_ctx =
-		i915_gem_create_context(dev, file_priv, USES_FULL_PPGTT(dev));
+		i915_gem_create_context(dev, file_priv, USES_FULL_PPGTT(dev), true);
 	mutex_unlock(&dev->struct_mutex);
 
 	if (IS_ERR(file_priv->private_default_ctx)) {
@@ -775,7 +776,7 @@ 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));
+	ctx = i915_gem_create_context(dev, file_priv, USES_FULL_PPGTT(dev), true);
 	mutex_unlock(&dev->struct_mutex);
 	if (IS_ERR(ctx))
 		return PTR_ERR(ctx);
-- 
1.9.0




More information about the Intel-gfx mailing list