diff mbox

[RFC,5/8] drm/i915/context: implement context switch wait

Message ID 1298745018-5937-6-git-send-email-bwidawsk@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ben Widawsky Feb. 26, 2011, 6:30 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_context.c b/drivers/gpu/drm/i915/i915_context.c
index babceca..45b5181 100644
--- a/drivers/gpu/drm/i915/i915_context.c
+++ b/drivers/gpu/drm/i915/i915_context.c
@@ -66,6 +66,29 @@  static void context_destroy_id(struct drm_i915_gem_context *ctx)
 	spin_unlock(&file_priv->context_idr_lock);
 }
 
+static int wait_for_context_switch(struct intel_ring_buffer *ring)
+{
+	struct drm_i915_gem_request *request;
+	int ret;
+
+	request = kzalloc(sizeof(*request), GFP_KERNEL);
+	if (request == NULL) {
+		ret = -ENOMEM;
+		goto out;
+	}
+
+	ret = i915_add_request(ring, NULL, request);
+	if (ret) {
+		kfree(request);
+		goto out;
+	}
+
+	ret = i915_wait_request(ring, request->seqno);
+
+out:
+	return ret;
+}
+
 /*
  * Initialize a context for the given ring.
  * @wait_for_switch: whether or not to wait for the context switch instruction