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>
This commit is contained in:
Alyssa Rosenzweig 2021-08-12 23:25:49 +00:00
parent e6924be737
commit bd15e5e6af
1 changed files with 4 additions and 1 deletions

View File

@ -270,7 +270,9 @@ panfrost_bo_cache_put(struct panfrost_bo *bo)
if (bo->flags & PAN_BO_SHARED || dev->debug & PAN_DBG_NO_CACHE)
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;
}