dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: l.stach@pengutronix.de, nicolas@ndufresne.ca,
	ppaalanen@gmail.com, sumit.semwal@linaro.org, daniel@ffwll.ch,
	robdclark@gmail.com, dri-devel@lists.freedesktop.org,
	linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org
Cc: "Christian König" <christian.koenig@amd.com>
Subject: [PATCH 3/3] media: videobuf2: set dma_coherent flag for DMA-buf
Date: Thu, 20 Oct 2022 14:13:16 +0200	[thread overview]
Message-ID: <20221020121316.3946-4-christian.koenig@amd.com> (raw)
In-Reply-To: <20221020121316.3946-1-christian.koenig@amd.com>

When a device is snooping the CPU cache we assume that all importers
must snoop the CPU cache as well.

Execpt for vmalloc allocations since those implement mmap() imports must
always snoop the cache or we will run into coherency problems.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/media/common/videobuf2/videobuf2-dma-contig.c | 2 ++
 drivers/media/common/videobuf2/videobuf2-dma-sg.c     | 2 ++
 drivers/media/common/videobuf2/videobuf2-vmalloc.c    | 1 +
 3 files changed, 5 insertions(+)

diff --git a/drivers/media/common/videobuf2/videobuf2-dma-contig.c b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
index 555bd40fa472..57433310c55c 100644
--- a/drivers/media/common/videobuf2/videobuf2-dma-contig.c
+++ b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
@@ -11,6 +11,7 @@
  */
 
 #include <linux/dma-buf.h>
+#include <linux/dma-map-ops.h>
 #include <linux/module.h>
 #include <linux/refcount.h>
 #include <linux/scatterlist.h>
@@ -507,6 +508,7 @@ static struct dma_buf *vb2_dc_get_dmabuf(struct vb2_buffer *vb,
 	exp_info.size = buf->size;
 	exp_info.flags = flags;
 	exp_info.priv = buf;
+	exp_info.coherent = dev_is_dma_coherent(vb->vb2_queue->dev);
 
 	if (!buf->sgt_base)
 		buf->sgt_base = vb2_dc_get_base_sgt(buf);
diff --git a/drivers/media/common/videobuf2/videobuf2-dma-sg.c b/drivers/media/common/videobuf2/videobuf2-dma-sg.c
index 36981a5b5c53..dbdd753e4a39 100644
--- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c
+++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c
@@ -10,6 +10,7 @@
  * the Free Software Foundation.
  */
 
+#include <linux/dma-map-ops.h>
 #include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/refcount.h>
@@ -522,6 +523,7 @@ static struct dma_buf *vb2_dma_sg_get_dmabuf(struct vb2_buffer *vb,
 	exp_info.size = buf->size;
 	exp_info.flags = flags;
 	exp_info.priv = buf;
+	exp_info.coherent = dev_is_dma_coherent(vb->vb2_queue->dev);
 
 	if (WARN_ON(!buf->dma_sgt))
 		return NULL;
diff --git a/drivers/media/common/videobuf2/videobuf2-vmalloc.c b/drivers/media/common/videobuf2/videobuf2-vmalloc.c
index 41db707e43a4..0b6874733e86 100644
--- a/drivers/media/common/videobuf2/videobuf2-vmalloc.c
+++ b/drivers/media/common/videobuf2/videobuf2-vmalloc.c
@@ -341,6 +341,7 @@ static struct dma_buf *vb2_vmalloc_get_dmabuf(struct vb2_buffer *vb,
 	exp_info.size = buf->size;
 	exp_info.flags = flags;
 	exp_info.priv = buf;
+	exp_info.coherent = true;
 
 	if (WARN_ON(!buf->vaddr))
 		return NULL;
-- 
2.25.1


  parent reply	other threads:[~2022-10-20 12:14 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20 12:13 Try to address the DMA-buf coherency problem Christian König
2022-10-20 12:13 ` [PATCH 1/3] dma-buf: add dma_coherent flag Christian König
2022-10-20 12:13 ` [PATCH 2/3] drm/prime: set the dma_coherent flag for export Christian König
2022-10-20 14:43   ` Rob Clark
2022-10-20 14:56     ` Christian König
2022-10-28  1:11       ` Rob Clark
2022-10-20 12:13 ` Christian König [this message]
2022-11-04 10:42   ` [PATCH 3/3] media: videobuf2: set dma_coherent flag for DMA-buf Hans Verkuil
2022-10-27 12:14 ` Try to address the DMA-buf coherency problem Christian König
2022-10-28  8:09 ` Lucas Stach
2022-10-28  8:40   ` Christian König
2022-10-28 11:42     ` Lucas Stach
2022-10-28 14:26       ` Christian König
2022-10-28 15:46         ` Nicolas Dufresne
2022-10-28 17:50           ` Christian König
2022-10-28 18:47             ` Daniel Stone
2022-11-01 17:40               ` Christian König
2022-11-01 21:09                 ` Nicolas Dufresne
2022-11-02 11:18                   ` Christian König
2022-11-02 11:39                     ` Lucas Stach
2022-11-02 12:21                       ` Christian König
2022-11-02 17:10                         ` Lucas Stach
2022-11-02 19:13                           ` Christian König
2022-11-02 19:48                             ` Lucas Stach
2022-11-17  9:35                             ` Tomasz Figa
2022-11-17 12:10                               ` Christian König
2022-11-17 15:38                                 ` Nicolas Dufresne
2022-11-18 19:32                                   ` Rob Clark
2022-11-19 20:35                                     ` Nicolas Dufresne
2022-11-22 14:36                                     ` Daniel Vetter
2022-11-22 17:33                                       ` Christian König
2022-11-22 18:26                                         ` Daniel Vetter
2022-11-23  8:33                                         ` Pekka Paalanen
2022-11-23 16:33                                           ` Daniel Vetter
2022-11-25 16:40                                             ` Nicolas Dufresne
2022-11-30 10:30                                               ` Daniel Vetter
2022-12-02 15:27                                                 ` Christian König
2023-01-05 11:46                                                   ` Daniel Vetter
2022-12-05  6:41                                 ` Tomasz Figa
2022-12-05  8:28                                   ` Christian König
2022-12-06 18:26                                     ` Nicolas Dufresne
2022-12-06 18:37                                       ` Christian König
2022-12-09  8:26                                     ` Tomasz Figa
2022-12-09  9:32                                       ` Pekka Paalanen
2022-12-09 17:07                                         ` Alex Deucher
2023-01-05 11:50                                           ` [Linaro-mm-sig] " Daniel Vetter
2022-12-12  3:13                                         ` Tomasz Figa
2022-12-09 10:27                                       ` Christian König
2022-12-12  3:00                                         ` Tomasz Figa
2022-12-12 11:15                                           ` Christian König
2023-01-05 20:39                                         ` Sebastian Wick
2022-11-04 14:58                         ` Rob Clark
2022-11-04 15:00                           ` Christian König
2022-11-02 12:19                     ` Pekka Paalanen
2022-11-02 12:27                       ` Christian König
2022-11-02 12:50                         ` Pekka Paalanen
2022-11-02 12:56                           ` Christian König
2022-11-03 22:16                     ` Nicolas Dufresne
2022-11-04  9:03                       ` Christian König
2022-11-04 13:38                         ` Nicolas Dufresne
2022-11-04 14:51                           ` Christian König

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=20221020121316.3946-4-christian.koenig@amd.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=l.stach@pengutronix.de \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-media@vger.kernel.org \
    --cc=nicolas@ndufresne.ca \
    --cc=ppaalanen@gmail.com \
    --cc=robdclark@gmail.com \
    --cc=sumit.semwal@linaro.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