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