mesa: zero buffer objects upon release

Freshly allocated BOs from libdrm have to be zeroed. Since the libdrm/iris
caches VRAM allocations, we don't want to attach/detach parts of dataspaces at
every allocation. Some objects are used long (through caching in the iris
Gallium driver). Therefore, zero object on release where the region might
already be mapped.

issue #5224
This commit is contained in:
Sebastian Sumpf 2024-05-31 20:56:41 +02:00 committed by Norman Feske
parent 138f5fe61a
commit af8b13e88c
3 changed files with 27 additions and 1 deletions

View File

@ -1 +1 @@
789aefc660587ea3b3376a0b8ed076a75214ba05
aa79191d2f974902ddcf8f081ca84955037f33c9

View File

@ -17,6 +17,7 @@ PATCHES := src/lib/mesa/patches/dri2.patch \
src/lib/mesa/patches/etnaviv.patch \
src/lib/mesa/patches/intel_gen.patch \
src/lib/mesa/patches/iris_bufmgr.patch \
src/lib/mesa/patches/iris_bufmgr_zero.patch \
src/lib/mesa/patches/iris_utrace.patch \
src/lib/mesa/patches/lima.patch \
src/lib/mesa/patches/loader_fds.patch \

View File

@ -0,0 +1,25 @@
Freshly allocated BOs from libdrm have to be zeroed. Since the libdrm/iris
caches VRAM allocations, we don't want to attach/detach parts of dataspaces at
every allocation. Some objects are used long (through caching in the iris
Gallium driver). Therefore, zero on object release where the region might
already be mapped.
diff --git a/src/lib/mesa/src/gallium/drivers/iris/iris_bufmgr.c b/src/lib/mesa/src/gallium/drivers/iris/iris_bufmgr.c
index 98483f3..759e986 100644
--- a/src/lib/mesa/src/gallium/drivers/iris/iris_bufmgr.c
+++ b/src/lib/mesa/src/gallium/drivers/iris/iris_bufmgr.c
@@ -1461,6 +1461,15 @@ bo_close(struct iris_bo *bo)
simple_mtx_assert_locked(&bufmgr->lock);
assert(iris_bo_is_real(bo));
+#ifdef __GENODE__
+ /*
+ * Zero buffers released here because they will get re-used and we want to
+ * avoid attach/detach RM cycle if they are already mapped.
+ */
+ bo->zeroed = false;
+ zero_bo(bo->bufmgr, BO_ALLOC_ZEROED|MAP_ASYNC, bo);
+#endif
+
if (iris_bo_is_external(bo)) {
struct hash_entry *entry;