dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Tiago Vignatti <tiago.vignatti@intel.com>
Cc: daniel.thompson@linaro.org, daniel.vetter@ffwll.ch,
	thellstrom@vmware.com, dri-devel@lists.freedesktop.org,
	jglisse@redhat.com
Subject: Re: [PATCH igt v6 4/6] lib: Add prime_sync_start and prime_sync_end helpers
Date: Thu, 17 Dec 2015 11:18:12 +0100	[thread overview]
Message-ID: <20151217101812.GY30437@phenom.ffwll.local> (raw)
In-Reply-To: <1450304743-6571-10-git-send-email-tiago.vignatti@intel.com>

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@intel.com>
> ---
>  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@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2015-12-17 10:18 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-16 22:25 Direct userspace dma-buf mmap (v6) Tiago Vignatti
2015-12-16 22:25 ` [PATCH v6 1/5] drm: prime: Honour O_RDWR during prime-handle-to-fd Tiago Vignatti
2015-12-16 22:25 ` [PATCH v6 2/5] dma-buf: Remove range-based flush Tiago Vignatti
2015-12-16 22:25 ` [PATCH v6 3/5] dma-buf: Add ioctls to allow userspace to flush Tiago Vignatti
2015-12-17 18:19   ` Alex Deucher
2015-12-18 18:46     ` Tiago Vignatti
2015-12-17 21:58   ` Thomas Hellstrom
2015-12-18 15:29     ` Daniel Vetter
2015-12-18 19:50     ` Tiago Vignatti
2015-12-21  9:38       ` Thomas Hellstrom
2015-12-16 22:25 ` [PATCH v6 4/5] drm/i915: Implement end_cpu_access Tiago Vignatti
2015-12-17  8:01   ` Chris Wilson
2015-12-18 19:02     ` Tiago Vignatti
2015-12-18 19:19       ` Tiago Vignatti
2015-12-22 20:51         ` Chris Wilson
2015-12-16 22:25 ` [PATCH v6 5/5] drm/i915: Use CPU mapping for userspace dma-buf mmap() Tiago Vignatti
2015-12-16 22:25 ` [PATCH igt v6 1/6] lib: Add gem_userptr and __gem_userptr helpers Tiago Vignatti
2015-12-16 22:25 ` [PATCH igt v6 2/6] prime_mmap: Add new test for calling mmap() on dma-buf fds Tiago Vignatti
2015-12-16 22:25 ` [PATCH igt v6 3/6] prime_mmap: Add basic tests to write in a bo using CPU Tiago Vignatti
2015-12-16 22:25 ` [PATCH igt v6 4/6] lib: Add prime_sync_start and prime_sync_end helpers Tiago Vignatti
2015-12-17 10:18   ` Daniel Vetter [this message]
2015-12-16 22:25 ` [PATCH igt v6 5/6] tests: Add kms_mmap_write_crc for cache coherency tests Tiago Vignatti
2015-12-17  7:53   ` Chris Wilson
2015-12-16 22:25 ` [PATCH igt v6 6/6] tests: Add prime_mmap_coherency " Tiago Vignatti
2015-12-17 10:15 ` Direct userspace dma-buf mmap (v6) Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151217101812.GY30437@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=daniel.thompson@linaro.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jglisse@redhat.com \
    --cc=thellstrom@vmware.com \
    --cc=tiago.vignatti@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox