[PATCH i-g-t 2/5] lib/intel_blt: Allow forcing multiple runs in blt_mem_copy()
Francois Dugast
francois.dugast at intel.com
Wed Mar 5 13:57:57 UTC 2025
Allowing to run the same copy multiple times presents no functional
advantage but it can be used to keep the copy functions busy longer
while other tests are being performed.
Signed-off-by: Francois Dugast <francois.dugast at intel.com>
---
lib/intel_blt.c | 34 +++++++++++++++++++---------------
lib/intel_blt.h | 3 ++-
2 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/lib/intel_blt.c b/lib/intel_blt.c
index 84318a557..315a2e145 100644
--- a/lib/intel_blt.c
+++ b/lib/intel_blt.c
@@ -1815,10 +1815,10 @@ void blt_mem_init(int fd, struct blt_mem_data *mem)
mem->driver = get_intel_driver(fd);
}
-static void emit_blt_mem_copy(int fd, uint64_t ahnd, const struct blt_mem_data *mem)
+static void emit_blt_mem_copy(int fd, uint64_t ahnd, const struct blt_mem_data *mem, int ncopies)
{
uint64_t dst_offset, src_offset;
- int i;
+ int i, j;
uint32_t *batch;
uint32_t optype;
@@ -1831,16 +1831,18 @@ static void emit_blt_mem_copy(int fd, uint64_t ahnd, const struct blt_mem_data *
optype = mem->src.type == M_MATRIX ? 1 << 17 : 0;
i = 0;
- batch[i++] = MEM_COPY_CMD | optype;
- batch[i++] = mem->src.width - 1;
- batch[i++] = mem->src.height - 1;
- batch[i++] = mem->src.pitch - 1;
- batch[i++] = mem->dst.pitch - 1;
- batch[i++] = src_offset;
- batch[i++] = src_offset << 32;
- batch[i++] = dst_offset;
- batch[i++] = dst_offset << 32;
- batch[i++] = mem->src.mocs_index << MEM_COPY_MOCS_SHIFT | mem->dst.mocs_index;
+ for (j = 0; j < ncopies; j++) {
+ batch[i++] = MEM_COPY_CMD | optype;
+ batch[i++] = mem->src.width - 1;
+ batch[i++] = mem->src.height - 1;
+ batch[i++] = mem->src.pitch - 1;
+ batch[i++] = mem->dst.pitch - 1;
+ batch[i++] = src_offset;
+ batch[i++] = src_offset << 32;
+ batch[i++] = dst_offset;
+ batch[i++] = dst_offset << 32;
+ batch[i++] = mem->src.mocs_index << MEM_COPY_MOCS_SHIFT | mem->dst.mocs_index;
+ }
batch[i++] = MI_BATCH_BUFFER_END;
munmap(batch, mem->bb.size);
@@ -1853,6 +1855,7 @@ static void emit_blt_mem_copy(int fd, uint64_t ahnd, const struct blt_mem_data *
* @e: blitter engine for @ctx
* @ahnd: allocator handle
* @blt: blitter data for mem-copy.
+ * @ncopies: how many times copy is run, > 1 can be used to stress the copy function
*
* Function does mem blit between @src and @dst described in @blt object.
*
@@ -1862,7 +1865,8 @@ static void emit_blt_mem_copy(int fd, uint64_t ahnd, const struct blt_mem_data *
int blt_mem_copy(int fd, const intel_ctx_t *ctx,
const struct intel_execution_engine2 *e,
uint64_t ahnd,
- const struct blt_mem_data *mem)
+ const struct blt_mem_data *mem,
+ int ncopies)
{
struct drm_i915_gem_execbuffer2 execbuf = {};
struct drm_i915_gem_exec_object2 obj[3] = {};
@@ -1875,7 +1879,7 @@ int blt_mem_copy(int fd, const intel_ctx_t *ctx,
0, mem->dst.pat_index);
bb_offset = get_offset(ahnd, mem->bb.handle, mem->bb.size, 0);
- emit_blt_mem_copy(fd, ahnd, mem);
+ emit_blt_mem_copy(fd, ahnd, mem, ncopies);
if (mem->driver == INTEL_DRIVER_XE) {
intel_ctx_xe_exec(ctx, ahnd, CANONICAL(bb_offset));
@@ -1944,7 +1948,7 @@ void blt_bo_copy(int fd, uint32_t src_handle, uint32_t dst_handle, const intel_c
blt_set_batch(&mem.bb, bb, bb_size, region);
igt_assert(mem.src.width == mem.dst.width);
- blt_mem_copy(fd, ctx, NULL, ahnd, &mem);
+ blt_mem_copy(fd, ctx, NULL, ahnd, &mem, 1);
result = memcmp(mem.src.ptr, mem.dst.ptr, mem.src.size);
intel_allocator_bind(ahnd, 0, 0);
diff --git a/lib/intel_blt.h b/lib/intel_blt.h
index 4357d70eb..217cade02 100644
--- a/lib/intel_blt.h
+++ b/lib/intel_blt.h
@@ -269,7 +269,8 @@ void blt_mem_init(int fd, struct blt_mem_data *mem);
int blt_mem_copy(int fd, const intel_ctx_t *ctx,
const struct intel_execution_engine2 *e,
uint64_t ahnd,
- const struct blt_mem_data *mem);
+ const struct blt_mem_data *mem,
+ int ncopies);
void blt_bo_copy(int fd, uint32_t src_handle, uint32_t dst_handle, const intel_ctx_t *ctx,
uint32_t size, uint32_t width, uint32_t height, uint32_t region);
--
2.43.0
More information about the igt-dev
mailing list