Linux Media Controller development
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org, pawel@osciak.com,
	m.szyprowski@samsung.com, Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [REVIEWv7 PATCH 03/12] vb2: add dma_dir to the alloc memop.
Date: Wed, 26 Nov 2014 21:53:51 +0200	[thread overview]
Message-ID: <1647835.UEKlNAWcZz@avalon> (raw)
In-Reply-To: <1416315068-22936-4-git-send-email-hverkuil@xs4all.nl>

Hi Hans,

Thank you for the patch.

On Tuesday 18 November 2014 13:50:59 Hans Verkuil wrote:
> From: Hans Verkuil <hans.verkuil@cisco.com>
> 
> This is needed for the next patch where the dma-sg alloc memop needs
> to know the dma_dir.
> 
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> Acked-by: Pawel Osciak <pawel@osciak.com>

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/media/v4l2-core/videobuf2-core.c       | 4 +++-
>  drivers/media/v4l2-core/videobuf2-dma-contig.c | 4 +++-
>  drivers/media/v4l2-core/videobuf2-dma-sg.c     | 5 +++--
>  drivers/media/v4l2-core/videobuf2-vmalloc.c    | 4 +++-
>  include/media/videobuf2-core.h                 | 4 +++-
>  5 files changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c
> b/drivers/media/v4l2-core/videobuf2-core.c index 573f6fb..7aed8f2 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -189,6 +189,8 @@ static void __vb2_queue_cancel(struct vb2_queue *q);
>  static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
>  {
>  	struct vb2_queue *q = vb->vb2_queue;
> +	enum dma_data_direction dma_dir =
> +		V4L2_TYPE_IS_OUTPUT(q->type) ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
>  	void *mem_priv;
>  	int plane;
> 
> @@ -200,7 +202,7 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
>  		unsigned long size = PAGE_ALIGN(q->plane_sizes[plane]);
> 
>  		mem_priv = call_ptr_memop(vb, alloc, q->alloc_ctx[plane],
> -				      size, q->gfp_flags);
> +				      size, dma_dir, q->gfp_flags);
>  		if (IS_ERR_OR_NULL(mem_priv))
>  			goto free;
> 
> diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c
> b/drivers/media/v4l2-core/videobuf2-dma-contig.c index 2bdffd3..c4305bf
> 100644
> --- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
> +++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
> @@ -155,7 +155,8 @@ static void vb2_dc_put(void *buf_priv)
>  	kfree(buf);
>  }
> 
> -static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size, gfp_t
> gfp_flags) +static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size,
> +			  enum dma_data_direction dma_dir, gfp_t gfp_flags)
>  {
>  	struct vb2_dc_conf *conf = alloc_ctx;
>  	struct device *dev = conf->dev;
> @@ -176,6 +177,7 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned long
> size, gfp_t gfp_flags) /* Prevent the device from being released while the
> buffer is used */ buf->dev = get_device(dev);
>  	buf->size = size;
> +	buf->dma_dir = dma_dir;
> 
>  	buf->handler.refcount = &buf->refcount;
>  	buf->handler.put = vb2_dc_put;
> diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c
> b/drivers/media/v4l2-core/videobuf2-dma-sg.c index 6b54a14..2529b83 100644
> --- a/drivers/media/v4l2-core/videobuf2-dma-sg.c
> +++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c
> @@ -86,7 +86,8 @@ static int vb2_dma_sg_alloc_compacted(struct
> vb2_dma_sg_buf *buf, return 0;
>  }
> 
> -static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size, gfp_t
> gfp_flags) +static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long
> size, +			      enum dma_data_direction dma_dir, gfp_t gfp_flags)
>  {
>  	struct vb2_dma_sg_buf *buf;
>  	int ret;
> @@ -97,7 +98,7 @@ static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned
> long size, gfp_t gfp_fla return NULL;
> 
>  	buf->vaddr = NULL;
> -	buf->dma_dir = DMA_NONE;
> +	buf->dma_dir = dma_dir;
>  	buf->offset = 0;
>  	buf->size = size;
>  	/* size is already page aligned */
> diff --git a/drivers/media/v4l2-core/videobuf2-vmalloc.c
> b/drivers/media/v4l2-core/videobuf2-vmalloc.c index fc1eb45..bba2460 100644
> --- a/drivers/media/v4l2-core/videobuf2-vmalloc.c
> +++ b/drivers/media/v4l2-core/videobuf2-vmalloc.c
> @@ -35,7 +35,8 @@ struct vb2_vmalloc_buf {
> 
>  static void vb2_vmalloc_put(void *buf_priv);
> 
> -static void *vb2_vmalloc_alloc(void *alloc_ctx, unsigned long size, gfp_t
> gfp_flags) +static void *vb2_vmalloc_alloc(void *alloc_ctx, unsigned long
> size, +			       enum dma_data_direction dma_dir, gfp_t gfp_flags)
>  {
>  	struct vb2_vmalloc_buf *buf;
> 
> @@ -45,6 +46,7 @@ static void *vb2_vmalloc_alloc(void *alloc_ctx, unsigned
> long size, gfp_t gfp_fl
> 
>  	buf->size = size;
>  	buf->vaddr = vmalloc_user(buf->size);
> +	buf->dma_dir = dma_dir;
>  	buf->handler.refcount = &buf->refcount;
>  	buf->handler.put = vb2_vmalloc_put;
>  	buf->handler.arg = buf;
> diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
> index d607871..bd2cec2 100644
> --- a/include/media/videobuf2-core.h
> +++ b/include/media/videobuf2-core.h
> @@ -82,7 +82,9 @@ struct vb2_threadio_data;
>   *				  unmap_dmabuf.
>   */
>  struct vb2_mem_ops {
> -	void		*(*alloc)(void *alloc_ctx, unsigned long size, gfp_t gfp_flags);
> +	void		*(*alloc)(void *alloc_ctx, unsigned long size,
> +				  enum dma_data_direction dma_dir,
> +				  gfp_t gfp_flags);
>  	void		(*put)(void *buf_priv);
>  	struct dma_buf *(*get_dmabuf)(void *buf_priv, unsigned long flags);

-- 
Regards,

Laurent Pinchart


  reply	other threads:[~2014-11-26 19:53 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-18 12:50 [REVIEWv7 PATCH 00/12] vb2: improve dma-sg, expbuf Hans Verkuil
2014-11-18 12:50 ` [REVIEWv7 PATCH 01/12] videobuf2-core.h: improve documentation Hans Verkuil
2014-11-23 11:01   ` Pawel Osciak
2014-11-26 19:48     ` Laurent Pinchart
2014-11-18 12:50 ` [REVIEWv7 PATCH 02/12] vb2: replace 'write' by 'dma_dir' Hans Verkuil
2014-11-26 19:50   ` Laurent Pinchart
2014-11-18 12:50 ` [REVIEWv7 PATCH 03/12] vb2: add dma_dir to the alloc memop Hans Verkuil
2014-11-26 19:53   ` Laurent Pinchart [this message]
2014-11-18 12:51 ` [REVIEWv7 PATCH 04/12] vb2: don't free alloc context if it is ERR_PTR Hans Verkuil
2014-11-23 10:19   ` Pawel Osciak
2014-11-26 19:57   ` Laurent Pinchart
2014-11-18 12:51 ` [REVIEWv7 PATCH 05/12] vb2-dma-sg: add allocation context to dma-sg Hans Verkuil
2014-11-23 10:36   ` Pawel Osciak
2014-11-26 20:01   ` Laurent Pinchart
2014-11-27  8:38     ` Hans Verkuil
2014-11-18 12:51 ` [REVIEWv7 PATCH 06/12] vb2-dma-sg: move dma_(un)map_sg here Hans Verkuil
2014-11-26 20:43   ` Laurent Pinchart
2014-11-27  8:48     ` Hans Verkuil
2014-11-18 12:51 ` [REVIEWv7 PATCH 07/12] vb2-dma-sg: add dmabuf import support Hans Verkuil
2014-11-26 21:00   ` Laurent Pinchart
2014-11-27  9:02     ` Hans Verkuil
2014-12-01 22:46       ` Laurent Pinchart
2014-12-02  7:35         ` Hans Verkuil
2014-11-18 12:51 ` [REVIEWv7 PATCH 08/12] vb2-dma-sg: add support for dmabuf exports Hans Verkuil
2014-11-18 12:51 ` [REVIEWv7 PATCH 09/12] vb2-vmalloc: " Hans Verkuil
2014-11-23 10:52   ` Pawel Osciak
2014-11-18 12:51 ` [REVIEWv7 PATCH 10/12] vivid: enable vb2_expbuf support Hans Verkuil
2014-11-26 20:46   ` Laurent Pinchart
2014-11-18 12:51 ` [REVIEWv7 PATCH 11/12] vim2m: support expbuf Hans Verkuil
2014-11-26 20:46   ` Laurent Pinchart
2014-11-18 12:51 ` [REVIEWv7 PATCH 12/12] vb2: use dma_map_sg_attrs to prevent unnecessary sync Hans Verkuil
2014-11-23 10:55   ` Pawel Osciak

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=1647835.UEKlNAWcZz@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=hans.verkuil@cisco.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=pawel@osciak.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