summaryrefslogtreecommitdiff
path: root/src/gallium/winsys/amdgpu/drm
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2021-08-19 15:44:55 -0400
committerMarge Bot <eric+marge@anholt.net>2021-09-10 23:32:03 +0000
commitaf7c6720de78c2249a4bf2c34f286865f12df0b5 (patch)
tree6d5470aab5c940742a25a4d0165c07ba9029cb05 /src/gallium/winsys/amdgpu/drm
parent64a06f8167d2e04b654a1e67affa363e6fd8123c (diff)
winsys/amdgpu: include CS ioctl overhead in RADEON_NOOP
submit an empty IB instead of skipping the ioctl Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12812>
Diffstat (limited to 'src/gallium/winsys/amdgpu/drm')
-rw-r--r--src/gallium/winsys/amdgpu/drm/amdgpu_cs.c26
-rw-r--r--src/gallium/winsys/amdgpu/drm/amdgpu_cs.h1
2 files changed, 23 insertions, 4 deletions
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
index fd58e69a0d7..6452d2ba4a8 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
@@ -811,6 +811,9 @@ static bool amdgpu_get_new_ib(struct amdgpu_winsys *ws,
rcs->current.buf = (uint32_t*)(ib->ib_mapped + ib->used_ib_space);
+ if (ib->ib_type == IB_MAIN)
+ cs->csc->ib_main_addr = rcs->current.buf;
+
ib_size = ib->big_ib_buffer->size - ib->used_ib_space;
rcs->current.max_dw = ib_size / 4 - amdgpu_cs_epilog_dws(cs);
rcs->gpu_address = info->va_start;
@@ -1463,6 +1466,8 @@ static void amdgpu_cs_submit_ib(void *job, void *gdata, int thread_index)
if (acs->ring_type == RING_GFX)
ws->gfx_bo_list_counter += cs->num_real_buffers;
+ bool noop = false;
+
if (acs->stop_exec_on_failure && acs->ctx->num_rejected_cs) {
r = -ECANCELED;
} else {
@@ -1572,10 +1577,23 @@ static void amdgpu_cs_submit_ib(void *job, void *gdata, int thread_index)
cs->ib[IB_MAIN].flags &= ~AMDGPU_IB_FLAGS_SECURE;
}
+ /* Apply RADEON_NOOP. */
+ if (acs->noop) {
+ if (acs->ring_type == RING_GFX) {
+ /* Reduce the IB size and fill it with NOP to make it like an empty IB. */
+ unsigned noop_size = MIN2(cs->ib[IB_MAIN].ib_bytes, ws->info.ib_alignment);
+
+ cs->ib_main_addr[0] = PKT3(PKT3_NOP, noop_size / 4 - 2, 0);
+ cs->ib[IB_MAIN].ib_bytes = noop_size;
+ } else {
+ noop = true;
+ }
+ }
+
assert(num_chunks <= ARRAY_SIZE(chunks));
- r = acs->noop ? 0 : amdgpu_cs_submit_raw2(ws->dev, acs->ctx->ctx, bo_list,
- num_chunks, chunks, &seq_no);
+ r = noop ? 0 : amdgpu_cs_submit_raw2(ws->dev, acs->ctx->ctx, bo_list,
+ num_chunks, chunks, &seq_no);
}
if (r) {
@@ -1589,7 +1607,7 @@ static void amdgpu_cs_submit_ib(void *job, void *gdata, int thread_index)
acs->ctx->num_rejected_cs++;
ws->num_total_rejected_cs++;
- } else if (!acs->noop) {
+ } else if (!noop) {
/* Success. */
uint64_t *user_fence = NULL;
@@ -1611,7 +1629,7 @@ static void amdgpu_cs_submit_ib(void *job, void *gdata, int thread_index)
cleanup:
/* If there was an error, signal the fence, because it won't be signalled
* by the hardware. */
- if (r || acs->noop)
+ if (r || noop)
amdgpu_fence_signalled(cs->fence);
cs->error_code = r;
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.h b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.h
index 55b573ea694..1ce8e5baec4 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.h
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.h
@@ -95,6 +95,7 @@ struct amdgpu_fence_list {
struct amdgpu_cs_context {
struct drm_amdgpu_cs_chunk_ib ib[IB_NUM];
+ uint32_t *ib_main_addr; /* the beginning of IB before chaining */
/* Buffers. */
unsigned max_real_buffers;