[Intel-gfx] [RFC] [PATCH 5/8] drm/i915/context: implement context switch wait

Ben Widawsky bwidawsk at gmail.com
Sat Feb 26 19:30:15 CET 2011


This commit is for review readability only.

Function implements the wait for context switch.
---
 drivers/gpu/drm/i915/i915_context.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

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
-- 
1.7.3.4




More information about the Intel-gfx mailing list