@@ -597,6 +597,7 @@ struct i915_hw_context {
struct intel_engine *last_ring;
struct {
struct drm_i915_gem_object *obj;
+ struct intel_ringbuffer *ringbuf;
} engine[I915_NUM_RINGS];
struct i915_ctx_hang_stats hang_stats;
struct i915_address_space *vm;
@@ -185,6 +185,8 @@ void i915_gem_context_free(struct kref *ctx_ref)
for (i = 0; i < I915_NUM_RINGS; i++) {
struct drm_i915_gem_object *ctx_obj = ctx->engine[i].obj;
+ struct intel_ringbuffer *ringbuf = ctx->engine[i].ringbuf;
+
if (ctx_obj) {
if (i == RCS) {
/* We refcount even the aliasing PPGTT to keep the
@@ -197,6 +199,9 @@ void i915_gem_context_free(struct kref *ctx_ref)
* space, in case we're bound in the PPGTT */
drm_gem_object_unreference(&ctx_obj->base);
}
+
+ if (ringbuf)
+ intel_destroy_ring_buffer(ringbuf);
}
if (ppgtt)
@@ -95,6 +95,25 @@ int gen8_create_lr_context(struct i915_hw_context *ctx,
return ret;
}
+ if (!file_priv) {
+ ring->default_ringbuf.size = 32 * PAGE_SIZE;
+
+ /* TODO: For now we put this in the mappable region so that we can reuse
+ * the existing ringbuffer code which ioremaps it. When we start
+ * creating many contexts, this will no longer work and we must switch
+ * to a kmapish interface.
+ */
+ ret = intel_allocate_ring_buffer(dev, &ring->default_ringbuf);
+ if (ret) {
+ DRM_DEBUG_DRIVER("Failed to allocate ringbuffer %s: %d\n",
+ ring->name, ret);
+ i915_gem_object_ggtt_unpin(ctx_obj);
+ drm_gem_object_unreference(&ctx_obj->base);
+ return ret;
+ }
+ ctx->engine[ring->id].ringbuf = &ring->default_ringbuf;
+ }
+
ctx->engine[ring->id].obj = ctx_obj;
return 0;