From af8b13e88cfbe6331e8383dea062ed095085f3ee Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Fri, 31 May 2024 20:56:41 +0200 Subject: [PATCH] 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 --- repos/libports/ports/mesa.hash | 2 +- repos/libports/ports/mesa.port | 1 + .../lib/mesa/patches/iris_bufmgr_zero.patch | 25 +++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 repos/libports/src/lib/mesa/patches/iris_bufmgr_zero.patch diff --git a/repos/libports/ports/mesa.hash b/repos/libports/ports/mesa.hash index 83e694f970..fff057f156 100644 --- a/repos/libports/ports/mesa.hash +++ b/repos/libports/ports/mesa.hash @@ -1 +1 @@ -789aefc660587ea3b3376a0b8ed076a75214ba05 +aa79191d2f974902ddcf8f081ca84955037f33c9 diff --git a/repos/libports/ports/mesa.port b/repos/libports/ports/mesa.port index 2fd34a0769..6612533d1c 100644 --- a/repos/libports/ports/mesa.port +++ b/repos/libports/ports/mesa.port @@ -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 \ diff --git a/repos/libports/src/lib/mesa/patches/iris_bufmgr_zero.patch b/repos/libports/src/lib/mesa/patches/iris_bufmgr_zero.patch new file mode 100644 index 0000000000..d411de3a2a --- /dev/null +++ b/repos/libports/src/lib/mesa/patches/iris_bufmgr_zero.patch @@ -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; +