diff mbox

[i-g-t,1/2] lib/intel_batchbuffer: Add secure batch buffer flushing on ring

Message ID 20170228215824.6423-1-antonio.argenziano@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Antonio Argenziano Feb. 28, 2017, 9:58 p.m. UTC
Added functions for flushing a batch buffer as privileged.

Signed-off-by: Antonio Argenziano <antonio.argenziano@intel.com>
---
 lib/intel_batchbuffer.c | 45 +++++++++++++++++++++++++++++++++++++++++----
 lib/intel_batchbuffer.h |  4 +++-
 2 files changed, 44 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index f1353901..38ce3b69 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -158,15 +158,35 @@  flush_on_ring_common(struct intel_batchbuffer *batch, int ring)
 }
 
 /**
- * intel_batchbuffer_flush_on_ring:
+ * intel_batchbuffer_flush_on_ring_secure:
  * @batch: batchbuffer object
  * @ring: execbuf ring flag
  *
  * Submits the batch for execution on @ring.
  */
 void
-intel_batchbuffer_flush_on_ring(struct intel_batchbuffer *batch, int ring)
+intel_batchbuffer_flush_on_ring_secure(struct intel_batchbuffer *batch, int ring)
+{
+    int flags = 0;
+
+	flags |= ring;
+	flags |= I915_EXEC_SECURE;
+
+    intel_batchbuffer_flush_on_ring(batch, flags);
+
+}
+
+/**
+ * intel_batchbuffer_flush_on_ring:
+ * @batch: batchbuffer object
+ * @flags: execbuf ring flag, plus additional submission flags
+ *
+ * Submits the batch for execution on the engine set in @flags.
+ */
+void
+intel_batchbuffer_flush_on_ring(struct intel_batchbuffer *batch, int flags)
 {
+    int ring = flags & I915_EXEC_RING_MASK;
 	unsigned int used = flush_on_ring_common(batch, ring);
 	drm_intel_context *ctx;
 
@@ -179,9 +199,10 @@  intel_batchbuffer_flush_on_ring(struct intel_batchbuffer *batch, int ring)
 
 	/* XXX bad kernel API */
 	ctx = batch->ctx;
-	if (ring != I915_EXEC_RENDER)
+	if ((ring) != I915_EXEC_RENDER)
 		ctx = NULL;
-	do_or_die(drm_intel_gem_bo_context_exec(batch->bo, ctx, used, ring));
+
+	do_or_die(drm_intel_gem_bo_context_exec(batch->bo, ctx, used, flags));
 
 	intel_batchbuffer_reset(batch);
 }
@@ -224,6 +245,22 @@  intel_batchbuffer_flush_with_context(struct intel_batchbuffer *batch,
 }
 
 /**
+ * intel_batchbuffer_flush_secure:
+ * @batch: batchbuffer object
+ *
+ * Submits the batch, as a secure batch, for execution on the blitter engine,
+ * selecting the right ring depending upon the hardware platform.
+ */
+void
+intel_batchbuffer_flush_secure(struct intel_batchbuffer *batch)
+{
+	int ring = 0;
+	if (HAS_BLT_RING(batch->devid))
+		ring = I915_EXEC_BLT;
+	intel_batchbuffer_flush_on_ring_secure(batch, ring);
+}
+
+/**
  * intel_batchbuffer_flush:
  * @batch: batchbuffer object
  *
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index 869747db..0ed2055a 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -35,7 +35,9 @@  void intel_batchbuffer_free(struct intel_batchbuffer *batch);
 
 
 void intel_batchbuffer_flush(struct intel_batchbuffer *batch);
-void intel_batchbuffer_flush_on_ring(struct intel_batchbuffer *batch, int ring);
+void intel_batchbuffer_flush_secure(struct intel_batchbuffer *batch);
+void intel_batchbuffer_flush_on_ring(struct intel_batchbuffer *batch, int flags);
+void intel_batchbuffer_flush_on_ring_secure(struct intel_batchbuffer *batch, int ring);
 void intel_batchbuffer_flush_with_context(struct intel_batchbuffer *batch,
 					  drm_intel_context *context);