drm: vc4: Block swiotlb bounce buffers being imported as dmabuf
authorDave Stevenson <dave.stevenson@raspberrypi.com>
Wed, 22 Nov 2023 19:17:44 +0000 (19:17 +0000)
committerDom Cobley <popcornmix@gmail.com>
Mon, 19 Feb 2024 11:35:16 +0000 (11:35 +0000)
commit40cbb9d543847790b82df811523389a0e4857006
treee4aa707ff0e792e3e240ee5e60a7175eadc45bd2
parentcd927c467ac012f492357fcb9a85ca2f5dd06ad4
drm: vc4: Block swiotlb bounce buffers being imported as dmabuf

The dmabuf import already checks that the backing buffer is contiguous
and rejects it if it isn't. vc4 also requires that the buffer is
in the bottom 1GB of RAM, and this is all correctly defined via
dma-ranges.

However the kernel silently uses swiotlb to bounce dma buffers
around if they are in the wrong region. This relies on dma sync
functions to be called in order to copy the data to/from the
bounce buffer.

DRM is based on all memory allocations being coherent with the
GPU so that any updates to a framebuffer will be acted on without
the need for any additional update. This is fairly fundamentally
incompatible with needing to call dma_sync_ to handle the bounce
buffer copies, and therefore we have to detect and reject mappings
that use bounce buffers.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
drivers/gpu/drm/vc4/vc4_drv.c