From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>,
ezequiel@vanguardiasur.com.ar, linux-media@vger.kernel.org,
laurent.pinchart@ideasonboard.com, hverkuil@xs4all.nl,
ribalda@chromium.org, tfiga@chromium.org, senozhatsky@google.com,
kernel@collabora.com
Subject: Re: [PATCH 3/3] media: stk1160: use dma_alloc_noncontiguous API
Date: Wed, 12 Jan 2022 18:25:17 +0900 [thread overview]
Message-ID: <Yd6efUeghxZckeoT@google.com> (raw)
In-Reply-To: <20220111085958.GA22795@lst.de>
On (22/01/11 09:59), Christoph Hellwig wrote:
[..]
> >>> You mean you would call "invalidate_kernel_vmap_range" before "dma_sync_sgtable_for_cpu" ?
> >>
> >> Yes.
> >
> > Could you explain why?
>
> the vmap range is the one actually use for cpu access and thus most
> prone for speculation, so I'd invalidate it first. It probably does
> not matter to much, but that order looks more sensible.
Shall we do the same in videobuf2?
----
diff --git a/drivers/media/common/videobuf2/videobuf2-dma-contig.c b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
index 7c4096e62173..0e3f264122af 100644
--- a/drivers/media/common/videobuf2/videobuf2-dma-contig.c
+++ b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
@@ -132,12 +132,12 @@ static void vb2_dc_prepare(void *buf_priv)
if (!buf->non_coherent_mem)
return;
- /* For both USERPTR and non-coherent MMAP */
- dma_sync_sgtable_for_device(buf->dev, sgt, buf->dma_dir);
-
/* Non-coherent MMAP only */
if (buf->vaddr)
flush_kernel_vmap_range(buf->vaddr, buf->size);
+
+ /* For both USERPTR and non-coherent MMAP */
+ dma_sync_sgtable_for_device(buf->dev, sgt, buf->dma_dir);
}
static void vb2_dc_finish(void *buf_priv)
@@ -152,12 +152,12 @@ static void vb2_dc_finish(void *buf_priv)
if (!buf->non_coherent_mem)
return;
- /* For both USERPTR and non-coherent MMAP */
- dma_sync_sgtable_for_cpu(buf->dev, sgt, buf->dma_dir);
-
/* Non-coherent MMAP only */
if (buf->vaddr)
invalidate_kernel_vmap_range(buf->vaddr, buf->size);
+
+ /* For both USERPTR and non-coherent MMAP */
+ dma_sync_sgtable_for_cpu(buf->dev, sgt, buf->dma_dir);
}
/*********************************************/
next prev parent reply other threads:[~2022-01-12 9:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-11 6:55 [PATCH 0/3] media: stk1160: allocate urb buffs with the DMA noncontiguous API Dafna Hirschfeld
2022-01-11 6:55 ` [PATCH 1/3] media: stk1160: fix number of buffers in case not all buffers are created Dafna Hirschfeld
2022-01-11 12:21 ` Ezequiel Garcia
2022-01-11 6:55 ` [PATCH 2/3] media: stk1160: move transfer_buffer and urb to same struct 'stk1160_urb' Dafna Hirschfeld
2022-01-11 8:10 ` Christoph Hellwig
2022-01-11 12:29 ` Ezequiel Garcia
2022-01-11 6:55 ` [PATCH 3/3] media: stk1160: use dma_alloc_noncontiguous API Dafna Hirschfeld
2022-01-11 8:13 ` Christoph Hellwig
2022-01-11 8:50 ` Dafna Hirschfeld
2022-01-11 8:52 ` Christoph Hellwig
2022-01-11 8:55 ` Dafna Hirschfeld
2022-01-11 8:59 ` Christoph Hellwig
2022-01-12 9:25 ` Sergey Senozhatsky [this message]
2022-01-11 12:38 ` Ezequiel Garcia
2022-01-24 14:43 ` Dafna Hirschfeld
2022-01-24 16:02 ` Dafna Hirschfeld
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=Yd6efUeghxZckeoT@google.com \
--to=senozhatsky@chromium.org \
--cc=dafna.hirschfeld@collabora.com \
--cc=ezequiel@vanguardiasur.com.ar \
--cc=hch@lst.de \
--cc=hverkuil@xs4all.nl \
--cc=kernel@collabora.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=ribalda@chromium.org \
--cc=senozhatsky@google.com \
--cc=tfiga@chromium.org \
/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;
as well as URLs for NNTP newsgroup(s).