This is a note to let you know that I've just added the patch titled drm/shmem-helpers: vunmap: Don't put pages for dma-buf to the 5.11-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: drm-shmem-helpers-vunmap-don-t-put-pages-for-dma-buf.patch and it can be found in the queue-5.11 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 64e194e278673bceb68fb2dde7dbc3d812bfceb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= <noralf@xxxxxxxxxxx> Date: Fri, 19 Feb 2021 13:22:03 +0100 Subject: drm/shmem-helpers: vunmap: Don't put pages for dma-buf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Noralf Trønnes <noralf@xxxxxxxxxxx> commit 64e194e278673bceb68fb2dde7dbc3d812bfceb3 upstream. dma-buf importing was reworked in commit 7d2cd72a9aa3 ("drm/shmem-helpers: Simplify dma-buf importing"). Before that commit drm_gem_shmem_prime_import_sg_table() did set ->pages_use_count=1 and drm_gem_shmem_vunmap_locked() could call drm_gem_shmem_put_pages() unconditionally. Now without the use count set, put pages is called also on dma-bufs. Fix this by only putting pages if it's not imported. Signed-off-by: Noralf Trønnes <noralf@xxxxxxxxxxx> Fixes: 7d2cd72a9aa3 ("drm/shmem-helpers: Simplify dma-buf importing") Cc: Daniel Vetter <daniel.vetter@xxxxxxxx> Cc: Thomas Zimmermann <tzimmermann@xxxxxxx> Acked-by: Thomas Zimmermann <tzimmermann@xxxxxxx> Tested-by: Thomas Zimmermann <tzimmermann@xxxxxxx> Link: https://patchwork.freedesktop.org/patch/msgid/20210219122203.51130-1-noralf@xxxxxxxxxxx (cherry picked from commit cdea72518a2b38207146e92e1c9e2fac15975679) Signed-off-by: Thomas Zimmermann <tzimmermann@xxxxxxx> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/gpu/drm/drm_gem_shmem_helper.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -357,13 +357,14 @@ static void drm_gem_shmem_vunmap_locked( if (--shmem->vmap_use_count > 0) return; - if (obj->import_attach) + if (obj->import_attach) { dma_buf_vunmap(obj->import_attach->dmabuf, map); - else + } else { vunmap(shmem->vaddr); + drm_gem_shmem_put_pages(shmem); + } shmem->vaddr = NULL; - drm_gem_shmem_put_pages(shmem); } /* Patches currently in stable-queue which might be from noralf@xxxxxxxxxxx are queue-5.11/drm-use-usb-controller-s-dma-mask-when-importing-dmabufs.patch queue-5.11/drm-shmem-helpers-vunmap-don-t-put-pages-for-dma-buf.patch