From 35d6e830c79cb2512b66cbbcbc690d2bd5f0b6c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Tue, 11 Apr 2023 12:41:06 -0700 Subject: [PATCH] iris: Move iris_batch i915 specific variables to union MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Saves some bytes when Xe kmd fields are added and makes easier to spot places that are misusing i915 variables. Signed-off-by: José Roberto de Souza Reviewed-by: Lionel Landwerlin Part-of: --- src/gallium/drivers/iris/i915/iris_batch.c | 26 +++++++++---------- .../drivers/iris/i915/iris_kmd_backend.c | 6 ++--- src/gallium/drivers/iris/iris_batch.c | 5 ++-- src/gallium/drivers/iris/iris_batch.h | 8 ++++-- src/gallium/drivers/iris/iris_monitor.c | 2 +- .../drivers/iris/iris_performance_query.c | 2 +- 6 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/gallium/drivers/iris/i915/iris_batch.c b/src/gallium/drivers/iris/i915/iris_batch.c index 9dba596e804..8456fa135ed 100644 --- a/src/gallium/drivers/iris/i915/iris_batch.c +++ b/src/gallium/drivers/iris/i915/iris_batch.c @@ -126,13 +126,13 @@ iris_init_non_engine_contexts(struct iris_context *ice) struct iris_screen *screen = (void *) ice->ctx.screen; iris_foreach_batch(ice, batch) { - batch->ctx_id = iris_create_hw_context(screen->bufmgr, ice->protected); - batch->exec_flags = I915_EXEC_RENDER; - assert(batch->ctx_id); - context_set_priority(screen->bufmgr, batch->ctx_id, ice->priority); + batch->i915.ctx_id = iris_create_hw_context(screen->bufmgr, ice->protected); + batch->i915.exec_flags = I915_EXEC_RENDER; + assert(batch->i915.ctx_id); + context_set_priority(screen->bufmgr, batch->i915.ctx_id, ice->priority); } - ice->batches[IRIS_BATCH_BLITTER].exec_flags = I915_EXEC_BLT; + ice->batches[IRIS_BATCH_BLITTER].i915.exec_flags = I915_EXEC_BLT; ice->has_engines_context = false; } @@ -192,8 +192,8 @@ iris_init_engines_context(struct iris_context *ice) iris_foreach_batch(ice, batch) { unsigned i = batch - &ice->batches[0]; - batch->ctx_id = engines_ctx; - batch->exec_flags = i; + batch->i915.ctx_id = engines_ctx; + batch->i915.exec_flags = i; } ice->has_engines_context = true; @@ -216,7 +216,7 @@ clone_hw_context(struct iris_batch *batch) struct iris_screen *screen = batch->screen; struct iris_bufmgr *bufmgr = screen->bufmgr; struct iris_context *ice = batch->ice; - bool protected = iris_hw_context_get_protected(bufmgr, batch->ctx_id); + bool protected = iris_hw_context_get_protected(bufmgr, batch->i915.ctx_id); uint32_t new_ctx = iris_create_hw_context(bufmgr, protected); if (new_ctx) @@ -243,12 +243,12 @@ iris_i915_replace_batch(struct iris_batch *batch) struct iris_context *ice = batch->ice; if (ice->has_engines_context) { - uint32_t old_ctx = batch->ctx_id; + uint32_t old_ctx = batch->i915.ctx_id; int new_ctx = iris_create_engines_context(ice); if (new_ctx < 0) return false; iris_foreach_batch(ice, bat) { - bat->ctx_id = new_ctx; + bat->i915.ctx_id = new_ctx; /* Notify the context that state must be re-initialized. */ iris_lost_context_state(bat); } @@ -258,8 +258,8 @@ iris_i915_replace_batch(struct iris_batch *batch) if (!new_ctx) return false; - iris_destroy_kernel_context(bufmgr, batch->ctx_id); - batch->ctx_id = new_ctx; + iris_destroy_kernel_context(bufmgr, batch->i915.ctx_id); + batch->i915.ctx_id = new_ctx; /* Notify the context that state must be re-initialized. */ iris_lost_context_state(batch); @@ -279,7 +279,7 @@ void iris_i915_destroy_batch(struct iris_batch *batch) if (batch->ice->has_engines_context && batch != &batch->ice->batches[0]) return; - iris_destroy_kernel_context(bufmgr, batch->ctx_id); + iris_destroy_kernel_context(bufmgr, batch->i915.ctx_id); } void iris_i915_init_batches(struct iris_context *ice) diff --git a/src/gallium/drivers/iris/i915/iris_kmd_backend.c b/src/gallium/drivers/iris/i915/iris_kmd_backend.c index d529700d184..193f371908a 100644 --- a/src/gallium/drivers/iris/i915/iris_kmd_backend.c +++ b/src/gallium/drivers/iris/i915/iris_kmd_backend.c @@ -219,7 +219,7 @@ i915_batch_check_for_reset(struct iris_batch *batch) { struct iris_screen *screen = batch->screen; enum pipe_reset_status status = PIPE_NO_RESET; - struct drm_i915_reset_stats stats = { .ctx_id = batch->ctx_id }; + struct drm_i915_reset_stats stats = { .ctx_id = batch->i915.ctx_id }; if (intel_ioctl(screen->fd, DRM_IOCTL_I915_GET_RESET_STATS, &stats)) DBG("DRM_IOCTL_I915_GET_RESET_STATS failed: %s\n", strerror(errno)); @@ -316,11 +316,11 @@ i915_batch_submit(struct iris_batch *batch) .batch_start_offset = 0, /* This must be QWord aligned. */ .batch_len = ALIGN(batch->primary_batch_size, 8), - .flags = batch->exec_flags | + .flags = batch->i915.exec_flags | I915_EXEC_NO_RELOC | I915_EXEC_BATCH_FIRST | I915_EXEC_HANDLE_LUT, - .rsvd1 = batch->ctx_id, /* rsvd1 is actually the context ID */ + .rsvd1 = batch->i915.ctx_id, /* rsvd1 is actually the context ID */ }; if (iris_batch_num_fences(batch)) { diff --git a/src/gallium/drivers/iris/iris_batch.c b/src/gallium/drivers/iris/iris_batch.c index 7f009f7c3cd..c99334231da 100644 --- a/src/gallium/drivers/iris/iris_batch.c +++ b/src/gallium/drivers/iris/iris_batch.c @@ -814,10 +814,11 @@ _iris_batch_flush(struct iris_batch *batch, const char *file, int line) if (basefile) file = basefile + 5; + uint32_t batch_ctx_id = batch->i915.ctx_id; fprintf(stderr, "%19s:%-3d: %s batch [%u] flush with %5db (%0.1f%%) " "(cmds), %4d BOs (%0.1fMb aperture)\n", - file, line, iris_batch_name_to_string(batch->name), batch->ctx_id, - batch->total_chained_batch_size, + file, line, iris_batch_name_to_string(batch->name), + batch_ctx_id, batch->total_chained_batch_size, 100.0f * batch->total_chained_batch_size / BATCH_SZ, batch->exec_count, (float) batch->aperture_space / (1024 * 1024)); diff --git a/src/gallium/drivers/iris/iris_batch.h b/src/gallium/drivers/iris/iris_batch.h index 664b9ceaa79..8e5b314fda5 100644 --- a/src/gallium/drivers/iris/iris_batch.h +++ b/src/gallium/drivers/iris/iris_batch.h @@ -93,8 +93,12 @@ struct iris_batch { /** Last binder address set in this hardware context. */ uint64_t last_binder_address; - uint32_t ctx_id; - uint32_t exec_flags; + union { + struct { + uint32_t ctx_id; + uint32_t exec_flags; + } i915; + }; /** A list of all BOs referenced by this batch */ struct iris_bo **exec_bos; diff --git a/src/gallium/drivers/iris/iris_monitor.c b/src/gallium/drivers/iris/iris_monitor.c index fa82604a5c7..5661d6100c8 100644 --- a/src/gallium/drivers/iris/iris_monitor.c +++ b/src/gallium/drivers/iris/iris_monitor.c @@ -171,7 +171,7 @@ iris_init_monitor_ctx(struct iris_context *ice) ice, screen->bufmgr, screen->devinfo, - ice->batches[IRIS_BATCH_RENDER].ctx_id, + ice->batches[IRIS_BATCH_RENDER].i915.ctx_id, screen->fd); } diff --git a/src/gallium/drivers/iris/iris_performance_query.c b/src/gallium/drivers/iris/iris_performance_query.c index 6cc8eae0193..ecdc88f5ab4 100644 --- a/src/gallium/drivers/iris/iris_performance_query.c +++ b/src/gallium/drivers/iris/iris_performance_query.c @@ -78,7 +78,7 @@ iris_init_perf_query_info(struct pipe_context *pipe) ice, screen->bufmgr, screen->devinfo, - ice->batches[IRIS_BATCH_RENDER].ctx_id, + ice->batches[IRIS_BATCH_RENDER].i915.ctx_id, screen->fd); return perf_cfg->n_queries;