[igt-dev] [PATCH i-g-t 02/18] lib/intel_batchbuffer: Add control over fencing in intel_bb
Dominik Grzegorzek
dominik.grzegorzek at intel.com
Tue Sep 29 11:28:54 UTC 2020
From: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
>From default intel_bb uses fencing to track subsequent execs.
It is required to properly sync intel_bb. Unfortunately this
also has some drawback, when we want to use same intel_bb to
schedule some time consuming job then run something else. Fencing
as turned on from default will serialize such execs. To avoid that
add possibility to turn on / off fencing in the intel_bb.
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
lib/intel_batchbuffer.c | 47 ++++++++++++++++++++++++++++++++---------
lib/intel_batchbuffer.h | 2 ++
2 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index be764646..079d6389 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -1266,6 +1266,7 @@ __intel_bb_create(int i915, uint32_t size, bool do_relocs)
ibb->ptr = ibb->batch;
ibb->prng = (uint32_t) to_user_pointer(ibb);
ibb->fence = -1;
+ ibb->use_fences = true;
gtt_size = gem_aperture_size(i915);
if (!gem_uses_full_ppgtt(i915))
@@ -1513,6 +1514,26 @@ void intel_bb_set_debug(struct intel_bb *ibb, bool debug)
ibb->debug = debug;
}
+/**
+ * intel_bb_set_fencing:
+ * @ibb: pointer to intel_bb
+ * @use_fences: true / false
+ *
+ * Sets using fences to true / false.
+ */
+void intel_bb_set_fencing(struct intel_bb *ibb, bool use_fences)
+{
+ if (use_fences == ibb->use_fences)
+ return;
+
+ if (use_fences == false && ibb->fence >= 0) {
+ close(ibb->fence);
+ ibb->fence = -1;
+ }
+
+ ibb->use_fences = use_fences;
+}
+
/**
* intel_bb_set_dump_base64:
* @ibb: pointer to intel_bb
@@ -2058,7 +2079,11 @@ int __intel_bb_exec(struct intel_bb *ibb, uint32_t end_offset,
execbuf.buffer_count = ibb->num_objects;
execbuf.batch_len = end_offset;
execbuf.rsvd1 = ibb->ctx = ctx;
- execbuf.flags = flags | I915_EXEC_BATCH_FIRST | I915_EXEC_FENCE_OUT;
+ execbuf.flags = flags | I915_EXEC_BATCH_FIRST;
+
+ if (ibb->use_fences)
+ execbuf.flags |= I915_EXEC_FENCE_OUT;
+
if (ibb->enforce_relocs)
execbuf.flags &= ~I915_EXEC_NO_RELOC;
execbuf.rsvd2 = 0;
@@ -2077,15 +2102,17 @@ int __intel_bb_exec(struct intel_bb *ibb, uint32_t end_offset,
update_offsets(ibb, objects);
/* Save/merge fences */
- fence = execbuf.rsvd2 >> 32;
-
- if (ibb->fence < 0) {
- ibb->fence = fence;
- } else {
- new_fence = sync_fence_merge(ibb->fence, fence);
- close(ibb->fence);
- close(fence);
- ibb->fence = new_fence;
+ if (ibb->use_fences) {
+ fence = execbuf.rsvd2 >> 32;
+
+ if (ibb->fence < 0) {
+ ibb->fence = fence;
+ } else {
+ new_fence = sync_fence_merge(ibb->fence, fence);
+ close(ibb->fence);
+ close(fence);
+ ibb->fence = new_fence;
+ }
}
if (sync || ibb->debug)
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index 8b9c1ed9..cbfbe25f 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -446,6 +446,7 @@ struct intel_bb {
uint32_t *ptr;
uint64_t alignment;
int fence;
+ bool use_fences;
uint32_t prng;
uint64_t gtt_size;
@@ -497,6 +498,7 @@ int intel_bb_sync(struct intel_bb *ibb);
void intel_bb_print(struct intel_bb *ibb);
void intel_bb_dump(struct intel_bb *ibb, const char *filename);
void intel_bb_set_debug(struct intel_bb *ibb, bool debug);
+void intel_bb_set_fencing(struct intel_bb *ibb, bool use_fences);
void intel_bb_set_dump_base64(struct intel_bb *ibb, bool dump);
static inline uint64_t
--
2.20.1
More information about the igt-dev
mailing list