dma-buf: Add ioctls to allow userspace to flush 34/115834/2 accepted/tizen/mobile/20170316.101739 accepted/tizen/unified/20170316.101857 submit/tizen/20170316.045621
authorMarek Szyprowski <m.szyprowski@samsung.com>
Tue, 21 Feb 2017 11:20:25 +0000 (12:20 +0100)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 8 Mar 2017 10:06:30 +0000 (02:06 -0800)
commit200efc9a8ab2b9e9d9ddbb579df3aece2db73b17
tree3a26cfedd87e5aeed94ed6c0d79f1ed47e57daa1
parent91abd955d8535c01fd39487b1c066c3758668dee
dma-buf: Add ioctls to allow userspace to flush

The userspace might need some sort of cache coherency management e.g. when CPU
and GPU domains are being accessed through dma-buf at the same time. To
circumvent this problem there are begin/end coherency markers, that forward
directly to existing dma-buf device drivers vfunc hooks. Userspace can make use
of those markers through the DMA_BUF_IOCTL_SYNC ioctl. The sequence would be
used like following:
     - mmap dma-buf fd
     - for each drawing/upload cycle in CPU 1. SYNC_START ioctl, 2. read/write
       to mmap area 3. SYNC_END ioctl. This can be repeated as often as you
       want (with the new data being consumed by the GPU or say scanout device)
     - munmap once you don't need the buffer any more

v2 (Tiago): Fix header file type names (u64 -> __u64)
v3 (Tiago): Add documentation. Use enum dma_buf_sync_flags to the begin/end
dma-buf functions. Check for overflows in start/length.
v4 (Tiago): use 2d regions for sync.
v5 (Tiago): forget about 2d regions (v4); use _IOW in DMA_BUF_IOCTL_SYNC and
remove range information from struct dma_buf_sync.
v6 (Tiago): use __u64 structured padded flags instead enum. Adjust
documentation about the recommendation on using sync ioctls.
v7 (Tiago): Alex' nit on flags definition and being even more wording in the
doc about sync usage.
v9 (Tiago): remove useless is_dma_buf_file check. Fix sync.flags conditionals
and its mask order check. Add <linux/types.h> include in dma-buf.h.

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: David Herrmann <dh.herrmann@gmail.com>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
[mszyprow: backport of mainline commit c11e391da2a8fe973c3c2398452000bed505851e]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Change-Id: I74eabf0faafebadabce17cb91e9962a44b5af544
drivers/base/dma-buf.c
drivers/staging/android/ion/ion.c
include/linux/dma-buf.h
include/uapi/linux/dma-buf.h [new file with mode: 0644]