dma-buf: Add struct dma-buf-map for storing struct dma_buf.vaddr_ptr
authorThomas Zimmermann <tzimmermann@suse.de>
Fri, 25 Sep 2020 11:55:58 +0000 (13:55 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Tue, 29 Sep 2020 10:40:36 +0000 (12:40 +0200)
commit01fd30da0474d5528d96a154cb50ce3b0352fd19
treee8b85a9fa2d4d338da76b6527f7adb5138ec16a3
parent79b4d4d26bd256a0c7e3ce74c13a64797d98d1ac
dma-buf: Add struct dma-buf-map for storing struct dma_buf.vaddr_ptr

The new type struct dma_buf_map represents a mapping of dma-buf memory
into kernel space. It contains a flag, is_iomem, that signals users to
access the mapped memory with I/O operations instead of regular loads
and stores.

It was assumed that DMA buffer memory can be accessed with regular load
and store operations. Some architectures, such as sparc64, require the
use of I/O operations to access dma-map buffers that are located in I/O
memory. Providing struct dma_buf_map allows drivers to implement this.
This was specifically a problem when refreshing the graphics framebuffer
on such systems. [1]

As the first step, struct dma_buf stores an instance of struct dma_buf_map
internally. Afterwards, dma-buf's vmap and vunmap interfaces are be
converted. Finally, affected drivers can be fixed.

v3:
* moved documentation into separate patch
* test for NULL pointers with !<ptr>

[1] https://lore.kernel.org/dri-devel/20200725191012.GA434957@ravnborg.org/

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200925115601.23955-2-tzimmermann@suse.de
drivers/dma-buf/dma-buf.c
include/linux/dma-buf-map.h [new file with mode: 0644]
include/linux/dma-buf.h