drm: Fix for GEM buffers with write-combine memory
authorPaul Cercueil <paul@crapouillou.net>
Thu, 27 May 2021 23:03:34 +0000 (00:03 +0100)
committerPaul Cercueil <paul@crapouillou.net>
Fri, 28 May 2021 08:47:53 +0000 (09:47 +0100)
commit162ba3bd9dce61889eb739adf2923811dcbeff94
tree51042243cb6553794e3632d6f6af6ecb1b5bb07c
parent71b970c8680732b3dec1f9506087ef56bd6a123d
drm: Fix for GEM buffers with write-combine memory

The previous commit wrongly assumed that dma_mmap_wc() could be replaced
by pgprot_writecombine() + dma_mmap_pages(). It did work on my setup,
but did not work everywhere.

Use dma_mmap_wc() when the buffer has the write-combine cache attribute,
and dma_mmap_pages() when it has the non-coherent cache attribute.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Reported-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Fixes: cf8ccbc72d61 ("drm: Add support for GEM buffers backed by non-coherent memory")
Link: https://patchwork.freedesktop.org/patch/msgid/20210527230334.151947-1-paul@crapouillou.net
drivers/gpu/drm/drm_gem_cma_helper.c