asahi: Do not leak staging resources for PIPE_MAP_READ

We were only dereferencing the resource in the PIPE_MAP_WRITE path of
agx_transfer_unmap, which means that read-only transfers leaked the
staging resource/BO. Always free the staging resource unconditionally.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>
This commit is contained in:
Asahi Lina
2022-12-07 18:33:46 +09:00
committed by Marge Bot
parent eba2b182c8
commit 331c2f4b7e
+1 -1
View File
@@ -845,7 +845,6 @@ agx_transfer_unmap(struct pipe_context *pctx,
agx_blit_from_staging(pctx, trans);
agx_flush_readers(agx_context(pctx), agx_resource(trans->staging.rsrc),
"GPU write staging blit");
pipe_resource_reference(&trans->staging.rsrc, NULL);
} else if (trans->map && (transfer->usage & PIPE_MAP_WRITE)) {
assert(rsrc->modifier == DRM_FORMAT_MOD_APPLE_TWIDDLED);
@@ -869,6 +868,7 @@ agx_transfer_unmap(struct pipe_context *pctx,
/* Free the transfer */
free(trans->map);
pipe_resource_reference(&trans->staging.rsrc, NULL);
pipe_resource_reference(&transfer->resource, NULL);
FREE(transfer);
}