Mesa (main): iris: sprinkle some assertions for bufmgr->lock
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Jan 29 05:31:22 UTC 2022
Module: Mesa
Branch: main
Commit: 83788b864da9685f756ec4895f8cdcc95d8bd50d
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=83788b864da9685f756ec4895f8cdcc95d8bd50d
Author: Paulo Zanoni <paulo.r.zanoni at intel.com>
Date: Tue Nov 16 17:47:56 2021 -0800
iris: sprinkle some assertions for bufmgr->lock
Assert the lock is held when we need it to be held. Also hold the lock
during bufmgr destruction to keep the asserts happy.
Now the only place where we're not holding the lock while manipulating
bufmgr data structures is iris_bufmgr_create(), but this shouldn't
trigger any of the new assertions.
Reviewed-by: Marcin Ślusarz <marcin.slusarz at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13486>
---
src/gallium/drivers/iris/iris_bufmgr.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c
index ebed227719e..947b84275f4 100644
--- a/src/gallium/drivers/iris/iris_bufmgr.c
+++ b/src/gallium/drivers/iris/iris_bufmgr.c
@@ -386,6 +386,8 @@ vma_alloc(struct iris_bufmgr *bufmgr,
uint64_t size,
uint64_t alignment)
{
+ simple_mtx_assert_locked(&bufmgr->lock);
+
/* Force minimum alignment based on device requirements */
assert((alignment & (alignment - 1)) == 0);
alignment = MAX2(alignment, bufmgr->vma_min_align);
@@ -411,6 +413,8 @@ vma_free(struct iris_bufmgr *bufmgr,
uint64_t address,
uint64_t size)
{
+ simple_mtx_assert_locked(&bufmgr->lock);
+
if (address == IRIS_BORDER_COLOR_POOL_ADDRESS)
return;
@@ -873,6 +877,8 @@ alloc_bo_from_cache(struct iris_bufmgr *bufmgr,
struct iris_bo *bo = NULL;
+ simple_mtx_assert_locked(&bufmgr->lock);
+
list_for_each_entry_safe(struct iris_bo, cur, &bucket->head, head) {
assert(iris_bo_is_real(cur));
@@ -1292,6 +1298,7 @@ bo_close(struct iris_bo *bo)
{
struct iris_bufmgr *bufmgr = bo->bufmgr;
+ simple_mtx_assert_locked(&bufmgr->lock);
assert(iris_bo_is_real(bo));
if (iris_bo_is_external(bo)) {
@@ -1349,6 +1356,7 @@ bo_free(struct iris_bo *bo)
{
struct iris_bufmgr *bufmgr = bo->bufmgr;
+ simple_mtx_assert_locked(&bufmgr->lock);
assert(iris_bo_is_real(bo));
if (!bo->real.userptr && bo->real.map)
@@ -1370,6 +1378,8 @@ cleanup_bo_cache(struct iris_bufmgr *bufmgr, time_t time)
{
int i;
+ simple_mtx_assert_locked(&bufmgr->lock);
+
if (bufmgr->time == time)
return;
@@ -1736,6 +1746,7 @@ iris_bufmgr_destroy(struct iris_bufmgr *bufmgr)
pb_slabs_deinit(&bufmgr->bo_slabs[i]);
}
+ simple_mtx_lock(&bufmgr->lock);
/* Free any cached buffer objects we were going to reuse */
for (int i = 0; i < bufmgr->num_buckets; i++) {
struct bo_cache_bucket *bucket = &bufmgr->cache_bucket[i];
@@ -1783,6 +1794,8 @@ iris_bufmgr_destroy(struct iris_bufmgr *bufmgr)
close(bufmgr->fd);
+ simple_mtx_unlock(&bufmgr->lock);
+
simple_mtx_destroy(&bufmgr->lock);
simple_mtx_destroy(&bufmgr->bo_deps_lock);
@@ -1920,11 +1933,14 @@ out:
static void
iris_bo_mark_exported_locked(struct iris_bo *bo)
{
+ struct iris_bufmgr *bufmgr = bo->bufmgr;
+
/* We cannot export suballocated BOs. */
assert(iris_bo_is_real(bo));
+ simple_mtx_assert_locked(&bufmgr->lock);
if (!iris_bo_is_external(bo))
- _mesa_hash_table_insert(bo->bufmgr->handle_table, &bo->gem_handle, bo);
+ _mesa_hash_table_insert(bufmgr->handle_table, &bo->gem_handle, bo);
if (!bo->real.exported) {
/* If a BO is going to be used externally, it could be sent to the
More information about the mesa-commit
mailing list