panfrost: Move bo->label assignment into the lock

We already took the lock, we just unlocked too early. Since the label is
reset in the BO cache, this is racy. Minimal impact in practice but is
still /wrong/ and caught by helgrind.

Fixes: 3fa1f93dac ("panfrost: Label all BOs in userspace")
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12525>
(cherry picked from commit bd15e5e6af)
This commit is contained in:
Alyssa Rosenzweig 2021-08-12 23:25:49 +00:00 committed by Dylan Baker
parent a8c39e9a68
commit a56b5e1fcd
2 changed files with 5 additions and 2 deletions

View file

@ -1237,7 +1237,7 @@
"description": "panfrost: Move bo->label assignment into the lock",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "3fa1f93dace64d9f71869e08f3665f3e48b07286"
},

View file

@ -270,7 +270,9 @@ panfrost_bo_cache_put(struct panfrost_bo *bo)
if (bo->flags & PAN_BO_SHARED)
return false;
/* Must be first */
pthread_mutex_lock(&dev->bo_cache.lock);
struct list_head *bucket = pan_bucket(dev, MAX2(bo->size, 4096));
struct drm_panfrost_madvise madv;
struct timespec time;
@ -293,11 +295,12 @@ panfrost_bo_cache_put(struct panfrost_bo *bo)
* lock.
*/
panfrost_bo_cache_evict_stale_bos(dev);
pthread_mutex_unlock(&dev->bo_cache.lock);
/* Update the label to help debug BO cache memory usage issues */
bo->label = "Unused (BO cache)";
/* Must be last */
pthread_mutex_unlock(&dev->bo_cache.lock);
return true;
}