Mesa (staging/21.0): intel/mi_builder: fix self modifying batches

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jan 15 17:20:59 UTC 2021


Module: Mesa
Branch: staging/21.0
Commit: 22fff81b4bd3adc0af78536aa0e405c92b944f45
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=22fff81b4bd3adc0af78536aa0e405c92b944f45

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Mon Aug 31 16:42:32 2020 +0300

intel/mi_builder: fix self modifying batches

So far we only write a maximum of 4 dwords further into the batch and
it seems just going over the CS prefetch was enough.

Turns out writing more dwords can delay the writes and we start
prefetching stuff that hasn't landed in memory yet.

This fixes the issue by stalling the CS to ensure the writes have
landed before we go over the prefetch.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Fixes: 796fccce631bf8 ("intel/mi-builder: add framework for self modifying batches")
Reviewed-by: Marcin Ślusarz <marcin.slusarz at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8525>
(cherry picked from commit d8154c40063d0d6114370c30c800676039e358ee)

---

 .pick_status.json                 | 2 +-
 src/intel/common/gen_mi_builder.h | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/.pick_status.json b/.pick_status.json
index 7d65d86d7b9..44ba0d41035 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -112,7 +112,7 @@
         "description": "intel/mi_builder: fix self modifying batches",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "796fccce631bf8ecb6ce2fd1a68f219788693a6e"
     },
diff --git a/src/intel/common/gen_mi_builder.h b/src/intel/common/gen_mi_builder.h
index ddd8459ef07..47fb98e99f7 100644
--- a/src/intel/common/gen_mi_builder.h
+++ b/src/intel/common/gen_mi_builder.h
@@ -932,6 +932,13 @@ gen_mi_store_address(struct gen_mi_builder *b,
 static inline void
 gen_mi_self_mod_barrier(struct gen_mi_builder *b)
 {
+   /* First make sure all the memory writes from previous modifying commands
+    * have landed. We want to do this before going through the CS cache,
+    * otherwise we could be fetching memory that hasn't been written to yet.
+    */
+   gen_mi_builder_emit(b, GENX(PIPE_CONTROL), pc) {
+      pc.CommandStreamerStallEnable = true;
+   }
    /* Documentation says Gen11+ should be able to invalidate the command cache
     * but experiment show it doesn't work properly, so for now just get over
     * the CS prefetch.



More information about the mesa-commit mailing list