[PATCH 29/49] drm/i915/bdw: Pin context pages at context create time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Oscar Mateo <oscar.mateo@xxxxxxxxx>

For the moment, this is simple and works allright. When we start
having a lot of contexts, this is going to become problematic.

Signed-off-by: Oscar Mateo <oscar.mateo@xxxxxxxxx>
---
 drivers/gpu/drm/i915/i915_lrc.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_lrc.c b/drivers/gpu/drm/i915/i915_lrc.c
index d5afb0d..74ab558 100644
--- a/drivers/gpu/drm/i915/i915_lrc.c
+++ b/drivers/gpu/drm/i915/i915_lrc.c
@@ -41,6 +41,8 @@
 #include <drm/i915_drm.h>
 #include "i915_drv.h"
 
+#define GEN8_CONTEXT_ALIGN 4096
+
 #define GEN8_LR_CONTEXT_SIZE (21 * PAGE_SIZE)
 
 #define RING_ELSP(ring)			((ring)->mmio_base+0x230)
@@ -86,6 +88,7 @@ void gen8_gem_context_free(struct i915_hw_context *ctx)
 		ctx->ringbuf->obj = NULL;
 		kfree(ctx->ringbuf);
 		ctx->ringbuf = NULL;
+		i915_gem_object_ggtt_unpin(ctx->obj);
 	}
 }
 
@@ -108,10 +111,18 @@ gen8_gem_create_context(struct drm_device *dev,
 	if (IS_ERR_OR_NULL(ctx))
 		return ctx;
 
+	if (file_priv) {
+		ret = i915_gem_obj_ggtt_pin(ctx->obj, GEN8_CONTEXT_ALIGN, 0);
+		if (ret) {
+			DRM_DEBUG_DRIVER("Couldn't pin %d\n", ret);
+			i915_gem_context_unreference(ctx);
+			return ERR_PTR(ret);
+		}
+	}
+
 	ring_obj = i915_gem_alloc_object(dev, 32 * PAGE_SIZE);
 	if (!ring_obj) {
-		if (!file_priv)
-			i915_gem_object_ggtt_unpin(ctx->obj);
+		i915_gem_object_ggtt_unpin(ctx->obj);
 		i915_gem_context_unreference(ctx);
 		return ERR_PTR(-ENOMEM);
 	}
@@ -124,8 +135,7 @@ gen8_gem_create_context(struct drm_device *dev,
 	ret = i915_gem_obj_ggtt_pin(ring_obj, PAGE_SIZE, PIN_MAPPABLE);
 	if (ret) {
 		drm_gem_object_unreference(&ring_obj->base);
-		if (!file_priv)
-			i915_gem_object_ggtt_unpin(ctx->obj);
+		i915_gem_object_ggtt_unpin(ctx->obj);
 		i915_gem_context_unreference(ctx);
 		return ERR_PTR(ret);
 	}
@@ -272,8 +282,7 @@ destroy_ring_obj:
 	i915_gem_object_ggtt_unpin(ring_obj);
 	drm_gem_object_unreference(&ring_obj->base);
 	ctx->ringbuf->obj = NULL;
-	if (!file_priv)
-		i915_gem_object_ggtt_unpin(ctx->obj);
+	i915_gem_object_ggtt_unpin(ctx->obj);
 	i915_gem_context_unreference(ctx);
 
 	return ERR_PTR(ret);
-- 
1.9.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux