On Wed, Dec 16, 2015 at 08:25:41PM -0200, Tiago Vignatti wrote: > This patch adds dma-buf mmap synchronization ioctls that can be used by tests > for cache coherency management e.g. when CPU and GPU domains are being accessed > through dma-buf at the same time. > > Signed-off-by: Tiago Vignatti <tiago.vignatti@xxxxxxxxx> > --- > lib/ioctl_wrappers.c | 26 ++++++++++++++++++++++++++ > lib/ioctl_wrappers.h | 15 +++++++++++++++ > 2 files changed, 41 insertions(+) > > diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c > index 86a61ba..0d84d00 100644 > --- a/lib/ioctl_wrappers.c > +++ b/lib/ioctl_wrappers.c > @@ -1400,6 +1400,32 @@ off_t prime_get_size(int dma_buf_fd) > } > > /** > + * prime_sync_start > + * @dma_buf_fd: dma-buf fd handle > + */ > +void prime_sync_start(int dma_buf_fd) > +{ > + struct local_dma_buf_sync sync_start; > + > + memset(&sync_start, 0, sizeof(sync_start)); > + sync_start.flags = LOCAL_DMA_BUF_SYNC_START | LOCAL_DMA_BUF_SYNC_RW; > + do_ioctl(dma_buf_fd, LOCAL_DMA_BUF_IOCTL_SYNC, &sync_start); > +} > + > +/** > + * prime_sync_end > + * @dma_buf_fd: dma-buf fd handle > + */ > +void prime_sync_end(int dma_buf_fd) > +{ > + struct local_dma_buf_sync sync_end; > + > + memset(&sync_end, 0, sizeof(sync_end)); > + sync_end.flags = LOCAL_DMA_BUF_SYNC_END | LOCAL_DMA_BUF_SYNC_RW; > + do_ioctl(dma_buf_fd, LOCAL_DMA_BUF_IOCTL_SYNC, &sync_end); > +} > + > +/** > * igt_require_fb_modifiers: > * @fd: Open DRM file descriptor. > * > diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h > index d3ffba2..cbd7a73 100644 > --- a/lib/ioctl_wrappers.h > +++ b/lib/ioctl_wrappers.h > @@ -148,6 +148,19 @@ void gem_require_caching(int fd); > void gem_require_ring(int fd, int ring_id); > > /* prime */ > +struct local_dma_buf_sync { > + uint64_t flags; > +}; > + > +#define LOCAL_DMA_BUF_SYNC_RW (3 << 0) > +#define LOCAL_DMA_BUF_SYNC_START (0 << 2) > +#define LOCAL_DMA_BUF_SYNC_END (1 << 2) > +#define DMA_BUF_SYNC_VALID_FLAGS_MASK \ > + (DMA_BUF_SYNC_RW | DMA_BUF_SYNC_END) What seems to be missing is negative ioclt tests, i.e. making sure invalid flags and stuff gets properly rejected. -Daniel > + > +#define LOCAL_DMA_BUF_BASE 'b' > +#define LOCAL_DMA_BUF_IOCTL_SYNC _IOW(LOCAL_DMA_BUF_BASE, 0, struct local_dma_buf_sync) > + > int prime_handle_to_fd(int fd, uint32_t handle); > #ifndef DRM_RDWR > #define DRM_RDWR O_RDWR > @@ -155,6 +168,8 @@ int prime_handle_to_fd(int fd, uint32_t handle); > int prime_handle_to_fd_for_mmap(int fd, uint32_t handle); > uint32_t prime_fd_to_handle(int fd, int dma_buf_fd); > off_t prime_get_size(int dma_buf_fd); > +void prime_sync_start(int dma_buf_fd); > +void prime_sync_end(int dma_buf_fd); > > /* addfb2 fb modifiers */ > struct local_drm_mode_fb_cmd2 { > -- > 2.1.4 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/dri-devel