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: [RFCv2 PATCH 03/14] vb2-dma-sg: add prepare/finish memops
Date: Sat, 13 Sep 2014 00:54:37 +0300 [thread overview]
Message-ID: <13309231.cvmkYBHmIS@avalon> (raw)
In-Reply-To: <1410526803-25887-4-git-send-email-hverkuil@xs4all.nl>
Hi Hans,
Thank you for the patch.
On Friday 12 September 2014 14:59:52 Hans Verkuil wrote:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> This moves dma_(un)map_sg to the prepare/finish memops of
> videobuf2-dma-sg.c.
>
> Now that vb2-dma-sg will sync the buffers for you in the prepare/finish
> memops we can drop that from the drivers that use dma-sg.
>
> For the solo6x10 driver that was a bit more involved because it needs to
> copy JPEG or MPEG headers to the buffer before returning it to userspace,
> and that cannot be done in the old place since the buffer there is still
> setup for DMA access, not for CPU access. However, the buf_finish_for_cpu
> op is the ideal place to do this. By the time buf_finish_for_cpu is called
> the buffer is available for CPU access, so copying to the buffer is fine.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
> drivers/media/pci/cx23885/cx23885-417.c | 7 +---
> drivers/media/pci/cx23885/cx23885-core.c | 5 ---
> drivers/media/pci/cx23885/cx23885-dvb.c | 7 +---
> drivers/media/pci/cx23885/cx23885-vbi.c | 13 +------
> drivers/media/pci/cx23885/cx23885-video.c | 13 +------
> drivers/media/pci/saa7134/saa7134-empress.c | 1 -
> drivers/media/pci/saa7134/saa7134-ts.c | 16 --------
> drivers/media/pci/saa7134/saa7134-vbi.c | 15 --------
> drivers/media/pci/saa7134/saa7134-video.c | 15 --------
> drivers/media/pci/saa7134/saa7134.h | 1 -
> drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c | 50 ++++++++++------------
> drivers/media/pci/tw68/tw68-video.c | 12 +-----
> drivers/media/platform/marvell-ccic/mcam-core.c | 18 +--------
> drivers/media/v4l2-core/videobuf2-dma-sg.c | 18 +++++++++
> 14 files changed, 51 insertions(+), 140 deletions(-)
[snip]
> diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c
> b/drivers/media/v4l2-core/videobuf2-dma-sg.c index 9b7a041..f3bc01b 100644
> --- a/drivers/media/v4l2-core/videobuf2-dma-sg.c
> +++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c
> @@ -170,6 +170,22 @@ static void vb2_dma_sg_put(void *buf_priv)
> }
> }
>
> +static void vb2_dma_sg_prepare(void *buf_priv)
> +{
> + struct vb2_dma_sg_buf *buf = buf_priv;
> + struct sg_table *sgt = &buf->sg_table;
> +
> + dma_map_sg(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir);
Shouldn't you use dma_sync_sg_for_device (and dma_sync_sg_for_cpu below)
instead ? Mapping/unmapping the buffer can be costly when an IOMMU is
involved.
> +}
> +
> +static void vb2_dma_sg_finish(void *buf_priv)
> +{
> + struct vb2_dma_sg_buf *buf = buf_priv;
> + struct sg_table *sgt = &buf->sg_table;
> +
> + dma_unmap_sg(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir);
> +}
> +
> static inline int vma_is_io(struct vm_area_struct *vma)
> {
> return !!(vma->vm_flags & (VM_IO | VM_PFNMAP));
> @@ -366,6 +382,8 @@ const struct vb2_mem_ops vb2_dma_sg_memops = {
> .put = vb2_dma_sg_put,
> .get_userptr = vb2_dma_sg_get_userptr,
> .put_userptr = vb2_dma_sg_put_userptr,
> + .prepare = vb2_dma_sg_prepare,
> + .finish = vb2_dma_sg_finish,
> .vaddr = vb2_dma_sg_vaddr,
> .mmap = vb2_dma_sg_mmap,
> .num_users = vb2_dma_sg_num_users,
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2014-09-12 21:54 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-12 12:59 [RFCv2 PATCH 00/14] vb2: improve dma-sg, expbuf Hans Verkuil
2014-09-12 12:59 ` [RFCv2 PATCH 01/14] vb2: introduce buf_prepare/finish_for_cpu Hans Verkuil
2014-09-12 21:25 ` Laurent Pinchart
2014-09-12 12:59 ` [RFCv2 PATCH 02/14] vb2-dma-sg: add allocation context to dma-sg Hans Verkuil
2014-09-12 21:49 ` Laurent Pinchart
2014-09-14 3:29 ` Pawel Osciak
2014-09-12 12:59 ` [RFCv2 PATCH 03/14] vb2-dma-sg: add prepare/finish memops Hans Verkuil
2014-09-12 21:54 ` Laurent Pinchart [this message]
2014-09-14 3:40 ` Pawel Osciak
2014-09-12 12:59 ` [RFCv2 PATCH 04/14] vb2: memop prepare: return errors Hans Verkuil
2014-09-12 12:59 ` [RFCv2 PATCH 05/14] vb2: call memop prepare before the buf_prepare op is called Hans Verkuil
2014-09-12 12:59 ` [RFCv2 PATCH 06/14] vb2-dma-sg: add dmabuf import support Hans Verkuil
2014-09-14 8:11 ` Laurent Pinchart
2014-09-12 12:59 ` [RFCv2 PATCH 07/14] vb2-dma-sg: add get_dmabuf Hans Verkuil
2014-09-12 12:59 ` [RFCv2 PATCH 08/14] vb2-vmalloc: add get_dmabuf support Hans Verkuil
2014-09-12 12:59 ` [RFCv2 PATCH 09/14] vb2: replace 'write' by 'dma_dir' Hans Verkuil
2014-09-12 22:02 ` Laurent Pinchart
2014-09-12 12:59 ` [RFCv2 PATCH 10/14] vb2: add 'new_cookies' flag Hans Verkuil
2014-09-14 7:02 ` Pawel Osciak
2014-09-12 13:00 ` [RFCv2 PATCH 11/14] tw68: only reprogram DMA engine when necessary Hans Verkuil
2014-09-12 13:00 ` [RFCv2 PATCH 12/14] cx23885: " Hans Verkuil
2014-09-12 13:00 ` [RFCv2 PATCH 13/14] saa7134: don't rebuild the page table unless new_cookies is set Hans Verkuil
2014-09-12 13:00 ` [RFCv2 PATCH 14/14] vivid: enable vb2_expbuf support Hans Verkuil
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=13309231.cvmkYBHmIS@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.