• Daniel Vetter's avatar
    drm/shme-helpers: Fix dma_buf_mmap forwarding bug · f49a51bf
    Daniel Vetter authored
    When we forward an mmap to the dma_buf exporter, they get to own
    everything. Unfortunately drm_gem_mmap_obj() overwrote
    vma->vm_private_data after the driver callback, wreaking the
    exporter complete. This was noticed because vb2_common_vm_close blew
    up on mali gpu with panfrost after commit 26d3ac3c
    ("drm/shmem-helpers: Redirect mmap for imported dma-buf").
    
    Unfortunately drm_gem_mmap_obj also acquires a surplus reference that
    we need to drop in shmem helpers, which is a bit of a mislayer
    situation. Maybe the entire dma_buf_mmap forwarding should be pulled
    into core gem code.
    
    Note that the only two other drivers which forward mmap in their own
    code (etnaviv and exynos) get this somewhat right by overwriting the
    gem mmap code. But they seem to still have the leak. This might be a
    good excuse to move these drivers over to shmem helpers completely.
    Reviewed-by: default avatarBoris Brezillon <boris.brezillon@collabora.com>
    Acked-by: default avatarChristian König <christian.koenig@amd.com>
    Cc: Christian König <christian.koenig@amd.com>
    Cc: Sumit Semwal <sumit.semwal@linaro.org>
    Cc: Lucas Stach <l.stach@pengutronix.de>
    Cc: Russell King <linux+etnaviv@armlinux.org.uk>
    Cc: Christian Gmeiner <christian.gmeiner@gmail.com>
    Cc: Inki Dae <inki.dae@samsung.com>
    Cc: Joonyoung Shim <jy0922.shim@samsung.com>
    Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
    Cc: Kyungmin Park <kyungmin.park@samsung.com>
    Fixes: 26d3ac3c ("drm/shmem-helpers: Redirect mmap for imported dma-buf")
    Cc: Boris Brezillon <boris.brezillon@collabora.com>
    Cc: Thomas Zimmermann <tzimmermann@suse.de>
    Cc: Gerd Hoffmann <kraxel@redhat.com>
    Cc: Rob Herring <robh@kernel.org>
    Cc: dri-devel@lists.freedesktop.org
    Cc: linux-media@vger.kernel.org
    Cc: linaro-mm-sig@lists.linaro.org
    Cc: <stable@vger.kernel.org> # v5.9+
    Reported-and-tested-by: piotr.oniszczuk@gmail.com
    Cc: piotr.oniszczuk@gmail.com
    Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20201027214922.3566743-1-daniel.vetter@ffwll.ch
    f49a51bf
drm_gem_shmem_helper.c 19.9 KB