From 1b1f8592c03c7e98b7baf89cb4d012bb7af546ac Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Fri, 10 Dec 2021 23:55:35 +0100 Subject: [PATCH] etnaviv: drm: properly handle reviving BOs via a lookup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a BO is removed from a cache bucket list via a lookup, we must handle it in the same way as if a allocation from the cache happened: tell valgrind that the buffer is active again and take a reference to the etna_device, which the BO had given up while being in the cache. Cc: mesa-stable Signed-off-by: Lucas Stach Tested-by: Guido Günther Reviewed-by: Christian Gmeiner Part-of: --- src/etnaviv/drm/etnaviv_bo.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/etnaviv/drm/etnaviv_bo.c b/src/etnaviv/drm/etnaviv_bo.c index 38b56953c32..5cbc088b241 100644 --- a/src/etnaviv/drm/etnaviv_bo.c +++ b/src/etnaviv/drm/etnaviv_bo.c @@ -87,7 +87,11 @@ static struct etna_bo *lookup_bo(void *tbl, uint32_t handle) bo = etna_bo_ref(entry->data); /* don't break the bucket if this bo was found in one */ - list_delinit(&bo->list); + if (list_is_linked(&bo->list)) { + VG_BO_OBTAIN(bo); + etna_device_ref(bo->dev); + list_delinit(&bo->list); + } } return bo;