From 39156b6cd4dbdfaf158220ae6f81749206031820 Mon Sep 17 00:00:00 2001 From: Thomas Wagner Date: Tue, 9 Jul 2024 16:56:05 +0200 Subject: [PATCH] llvmpipe: Unmap DMA buffer to release all resources If the buffer is not unmapped then a reference to the DMA buffer is still kept. The DRM device is then not properly cleaned up. This can cause the application to keep a DRM device open which is still DRM master without any visible open file descriptors. Fixes: d74ea2c117f ("llvmpipe: Implement dmabuf handling") Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/llvmpipe/lp_texture.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index db155d9a60b..5cd7be1d4ef 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -557,6 +557,8 @@ llvmpipe_resource_destroy(struct pipe_screen *pscreen, if (lpr->dt) { /* display target */ struct sw_winsys *winsys = screen->winsys; + if (lpr->dmabuf) + winsys->displaytarget_unmap(winsys, lpr->dt); winsys->displaytarget_destroy(winsys, lpr->dt); } else if (llvmpipe_resource_is_texture(pt)) { /* free linear image data */ @@ -1611,7 +1613,10 @@ llvmpipe_resource_bind_backing(struct pipe_screen *pscreen, if (lpr->dmabuf) { if (lpr->dt) + { + winsys->displaytarget_unmap(winsys, lpr->dt); winsys->displaytarget_destroy(winsys, lpr->dt); + } if (pmem) { /* Round up the surface size to a multiple of the tile size to * avoid tile clipping.