Mesa (staging/22.1): ac/surface: fix an addrlib race condition on gfx9
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Apr 25 04:07:33 UTC 2022
Module: Mesa
Branch: staging/22.1
Commit: acc3752a103c3168935d31d1b65d5400c1222e80
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=acc3752a103c3168935d31d1b65d5400c1222e80
Author: Marek Olšák <marek.olsak at amd.com>
Date: Fri Apr 22 02:16:23 2022 -0400
ac/surface: fix an addrlib race condition on gfx9
Addrlib calls GetMetaEquation, which generates and saves address equations
in a global table that is not thread safe.
Fixes: df2cbdd2e32 - amd/addrlib: expose DCC address equations to drivers
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6361
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16091>
(cherry picked from commit c4ca059dee4c902c1a736b3f77bd938679411c0d)
---
.pick_status.json | 2 +-
src/amd/common/ac_surface.c | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/.pick_status.json b/.pick_status.json
index 6f9bbb01f0e..a5b10d22730 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -553,7 +553,7 @@
"description": "ac/surface: fix an addrlib race condition on gfx9",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": "df2cbdd2e321d198e973be21eea25e9b296cceff"
},
diff --git a/src/amd/common/ac_surface.c b/src/amd/common/ac_surface.c
index 7d21f817f7a..58348a02698 100644
--- a/src/amd/common/ac_surface.c
+++ b/src/amd/common/ac_surface.c
@@ -93,6 +93,7 @@
struct ac_addrlib {
ADDR_HANDLE handle;
+ simple_mtx_t lock;
};
bool ac_modifier_has_dcc(uint64_t modifier)
@@ -503,11 +504,13 @@ struct ac_addrlib *ac_addrlib_create(const struct radeon_info *info,
}
addrlib->handle = addrCreateOutput.hLib;
+ simple_mtx_init(&addrlib->lock, mtx_plain);
return addrlib;
}
void ac_addrlib_destroy(struct ac_addrlib *addrlib)
{
+ simple_mtx_destroy(&addrlib->lock);
AddrDestroy(addrlib->handle);
free(addrlib);
}
@@ -1829,7 +1832,12 @@ static int gfx9_compute_miptree(struct ac_addrlib *addrlib, const struct radeon_
din.dataSurfaceSize = out.surfSize;
din.firstMipIdInTail = out.firstMipIdInTail;
+ if (info->chip_class == GFX9)
+ simple_mtx_lock(&addrlib->lock);
ret = Addr2ComputeDccInfo(addrlib->handle, &din, &dout);
+ if (info->chip_class == GFX9)
+ simple_mtx_unlock(&addrlib->lock);
+
if (ret != ADDR_OK)
return ret;
@@ -1910,7 +1918,12 @@ static int gfx9_compute_miptree(struct ac_addrlib *addrlib, const struct radeon_
assert(surf->tile_swizzle == 0);
assert(surf->u.gfx9.color.dcc.pipe_aligned || surf->u.gfx9.color.dcc.rb_aligned);
+ if (info->chip_class == GFX9)
+ simple_mtx_lock(&addrlib->lock);
ret = Addr2ComputeDccInfo(addrlib->handle, &din, &dout);
+ if (info->chip_class == GFX9)
+ simple_mtx_unlock(&addrlib->lock);
+
if (ret != ADDR_OK)
return ret;
@@ -2010,7 +2023,12 @@ static int gfx9_compute_miptree(struct ac_addrlib *addrlib, const struct radeon_
else
cin.swizzleMode = in->swizzleMode;
+ if (info->chip_class == GFX9)
+ simple_mtx_lock(&addrlib->lock);
ret = Addr2ComputeCmaskInfo(addrlib->handle, &cin, &cout);
+ if (info->chip_class == GFX9)
+ simple_mtx_unlock(&addrlib->lock);
+
if (ret != ADDR_OK)
return ret;
More information about the mesa-commit
mailing list