Module: Mesa Branch: main Commit: 4c8fad4fd884c852de0d7e4b43f87fc350fa46a9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4c8fad4fd884c852de0d7e4b43f87fc350fa46a9
Author: Christian Gmeiner <[email protected]> Date: Mon Oct 23 09:51:19 2023 +0200 etnaviv: drm: Be able to mark end of context init Add etna_cmd_stream_mark_end_of_context_init(..) which stores the current offset of the cmd stream as offset_end_of_context_init. This information will be used to downgrade a cmd stream flush to a noop. Signed-off-by: Christian Gmeiner <[email protected]> Reviewed-by: Lucas Stach <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25849> --- src/etnaviv/drm/etnaviv_cmd_stream.c | 16 ++++++++++++++++ src/etnaviv/drm/etnaviv_drmif.h | 2 ++ src/etnaviv/drm/etnaviv_priv.h | 1 + 3 files changed, 19 insertions(+) diff --git a/src/etnaviv/drm/etnaviv_cmd_stream.c b/src/etnaviv/drm/etnaviv_cmd_stream.c index 657ef0c0514..89e28e21b1a 100644 --- a/src/etnaviv/drm/etnaviv_cmd_stream.c +++ b/src/etnaviv/drm/etnaviv_cmd_stream.c @@ -230,6 +230,9 @@ void etna_cmd_stream_flush(struct etna_cmd_stream *stream, int in_fence_fd, if (gpu->dev->use_softpin) req.flags |= ETNA_SUBMIT_SOFTPIN; + if (stream->offset == priv->offset_end_of_context_init && !out_fence_fd) + is_noop = true; + if (unlikely(is_noop)) ret = 0; else @@ -254,6 +257,7 @@ void etna_cmd_stream_flush(struct etna_cmd_stream *stream, int in_fence_fd, priv->submit.nr_relocs = 0; priv->submit.nr_pmrs = 0; priv->nr_bos = 0; + priv->offset_end_of_context_init = 0; } void etna_cmd_stream_reloc(struct etna_cmd_stream *stream, @@ -284,6 +288,18 @@ void etna_cmd_stream_ref_bo(struct etna_cmd_stream *stream, struct etna_bo *bo, bo2idx(stream, bo, flags); } +void etna_cmd_stream_mark_end_of_context_init(struct etna_cmd_stream *stream) +{ + struct etna_cmd_stream_priv *priv = etna_cmd_stream_priv(stream); + + /* + * All commands before the end of context init are guaranteed to only alter GPU internal + * state and have no externally visible side effects, so we can skip the submit if the + * command buffer contains only context init commands. + */ + priv->offset_end_of_context_init = stream->offset; +} + void etna_cmd_stream_perf(struct etna_cmd_stream *stream, const struct etna_perf *p) { struct etna_cmd_stream_priv *priv = etna_cmd_stream_priv(stream); diff --git a/src/etnaviv/drm/etnaviv_drmif.h b/src/etnaviv/drm/etnaviv_drmif.h index 9b492455c3e..ad77039fe01 100644 --- a/src/etnaviv/drm/etnaviv_drmif.h +++ b/src/etnaviv/drm/etnaviv_drmif.h @@ -206,6 +206,8 @@ void etna_cmd_stream_reloc(struct etna_cmd_stream *stream, const struct etna_rel void etna_cmd_stream_ref_bo(struct etna_cmd_stream *stream, struct etna_bo *bo, uint32_t flags); +void etna_cmd_stream_mark_end_of_context_init(struct etna_cmd_stream *stream); + /* performance monitoring functions: */ diff --git a/src/etnaviv/drm/etnaviv_priv.h b/src/etnaviv/drm/etnaviv_priv.h index 0f34c63e16c..630f91cd01e 100644 --- a/src/etnaviv/drm/etnaviv_priv.h +++ b/src/etnaviv/drm/etnaviv_priv.h @@ -134,6 +134,7 @@ struct etna_cmd_stream_priv { struct etna_pipe *pipe; uint32_t last_timestamp; + uint32_t offset_end_of_context_init; /* submit ioctl related tables: */ struct {
