@@ -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);