From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Tomasz Figa <tfiga@chromium.org>,
Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Christoph Hellwig <hch@lst.de>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: [PATCH 4/8] videobuf2: move cache_hints handling to allocators
Date: Tue, 2 Mar 2021 09:46:20 +0900 [thread overview]
Message-ID: <20210302004624.31294-5-senozhatsky@chromium.org> (raw)
In-Reply-To: <20210302004624.31294-1-senozhatsky@chromium.org>
This moves cache hints handling from videobuf2 core down
to allocators level, because allocators do the sync/flush
caches eventually and may take better decisions. Besides,
allocators already decide whether cache sync/flush should
be done or can be skipped. This patch moves the scattered
buffer cache sync logic to one common place.
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
drivers/media/common/videobuf2/videobuf2-core.c | 6 ------
drivers/media/common/videobuf2/videobuf2-dma-contig.c | 6 ++++++
drivers/media/common/videobuf2/videobuf2-dma-sg.c | 6 ++++++
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
index 76210c006958..55af63d54f23 100644
--- a/drivers/media/common/videobuf2/videobuf2-core.c
+++ b/drivers/media/common/videobuf2/videobuf2-core.c
@@ -328,9 +328,6 @@ static void __vb2_buf_mem_prepare(struct vb2_buffer *vb)
return;
vb->synced = 1;
- if (vb->skip_cache_sync_on_prepare)
- return;
-
for (plane = 0; plane < vb->num_planes; ++plane)
call_void_memop(vb, prepare, vb->planes[plane].mem_priv);
}
@@ -347,9 +344,6 @@ static void __vb2_buf_mem_finish(struct vb2_buffer *vb)
return;
vb->synced = 0;
- if (vb->skip_cache_sync_on_finish)
- return;
-
for (plane = 0; plane < vb->num_planes; ++plane)
call_void_memop(vb, finish, vb->planes[plane].mem_priv);
}
diff --git a/drivers/media/common/videobuf2/videobuf2-dma-contig.c b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
index 019c3843dc6d..1e218bc440c6 100644
--- a/drivers/media/common/videobuf2/videobuf2-dma-contig.c
+++ b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
@@ -101,6 +101,9 @@ static void vb2_dc_prepare(void *buf_priv)
struct vb2_dc_buf *buf = buf_priv;
struct sg_table *sgt = buf->dma_sgt;
+ if (buf->vb->skip_cache_sync_on_prepare)
+ return;
+
if (!sgt)
return;
@@ -112,6 +115,9 @@ static void vb2_dc_finish(void *buf_priv)
struct vb2_dc_buf *buf = buf_priv;
struct sg_table *sgt = buf->dma_sgt;
+ if (buf->vb->skip_cache_sync_on_finish)
+ return;
+
if (!sgt)
return;
diff --git a/drivers/media/common/videobuf2/videobuf2-dma-sg.c b/drivers/media/common/videobuf2/videobuf2-dma-sg.c
index 71094cb5c5d7..cb587c5a345b 100644
--- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c
+++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c
@@ -204,6 +204,9 @@ static void vb2_dma_sg_prepare(void *buf_priv)
struct vb2_dma_sg_buf *buf = buf_priv;
struct sg_table *sgt = buf->dma_sgt;
+ if (buf->vb->skip_cache_sync_on_prepare)
+ return;
+
dma_sync_sgtable_for_device(buf->dev, sgt, buf->dma_dir);
}
@@ -212,6 +215,9 @@ static void vb2_dma_sg_finish(void *buf_priv)
struct vb2_dma_sg_buf *buf = buf_priv;
struct sg_table *sgt = buf->dma_sgt;
+ if (buf->vb->skip_cache_sync_on_finish)
+ return;
+
dma_sync_sgtable_for_cpu(buf->dev, sgt, buf->dma_dir);
}
--
2.30.1.766.gb4fecdf3b7-goog
next prev parent reply other threads:[~2021-03-02 7:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-02 0:46 [PATCH 0/8] videobuf2: support new noncontiguous DMA API Sergey Senozhatsky
2021-03-02 0:46 ` [PATCH 1/8] videobuf2: rework vb2_mem_ops API Sergey Senozhatsky
2021-03-02 0:46 ` [PATCH 2/8] videobuf2: inverse buffer cache_hints flags Sergey Senozhatsky
2021-03-02 0:46 ` [PATCH 3/8] videobuf2: split buffer cache_hints initialisation Sergey Senozhatsky
2021-03-02 0:46 ` Sergey Senozhatsky [this message]
2021-03-02 0:46 ` [PATCH 5/8] videobuf2: add V4L2_FLAG_MEMORY_NON_COHERENT flag Sergey Senozhatsky
2021-03-22 7:02 ` Hans Verkuil
2021-03-02 0:46 ` [PATCH 6/8] videobuf2: add queue memory coherency parameter Sergey Senozhatsky
2021-03-02 0:46 ` [PATCH 7/8] videobuf2: handle V4L2_FLAG_MEMORY_NON_COHERENT flag Sergey Senozhatsky
2021-03-22 7:16 ` Hans Verkuil
2021-03-22 7:18 ` Hans Verkuil
2021-03-02 0:46 ` [PATCH 8/8] videobuf2: handle non-contiguous DMA allocations Sergey Senozhatsky
2021-03-22 7:40 ` Hans Verkuil
2021-03-24 12:07 ` Tomasz Figa
2023-07-04 10:50 ` Hsia-Jun Li
2023-07-05 10:45 ` Tomasz Figa
2023-07-17 9:21 ` Hsia-Jun Li
2023-07-28 8:19 ` Tomasz Figa
2021-03-02 0:49 ` [PATCH] v4l-compliance: re-introduce NON_COHERENT and cache hints tests Sergey Senozhatsky
2021-03-02 0:50 ` Sergey Senozhatsky
2021-03-24 12:09 ` [PATCH 0/8] videobuf2: support new noncontiguous DMA API Tomasz Figa
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=20210302004624.31294-5-senozhatsky@chromium.org \
--to=senozhatsky@chromium.org \
--cc=hch@lst.de \
--cc=hverkuil-cisco@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--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).