[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240119141402.44262-3-paul@crapouillou.net>
Date: Fri, 19 Jan 2024 15:13:58 +0100
From: Paul Cercueil <paul@...pouillou.net>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jonathan Corbet <corbet@....net>,
Sumit Semwal <sumit.semwal@...aro.org>,
Christian König <christian.koenig@....com>
Cc: Jonathan Cameron <jic23@...nel.org>,
Nuno Sá <noname.nuno@...il.com>,
Michael Hennerich <Michael.Hennerich@...log.com>,
linux-usb@...r.kernel.org,
linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-media@...r.kernel.org,
dri-devel@...ts.freedesktop.org,
linaro-mm-sig@...ts.linaro.org,
Paul Cercueil <paul@...pouillou.net>
Subject: [PATCH v5 2/6] dma-buf: udmabuf: Implement .{begin,end}_access
Implement .begin_access() and .end_access() callbacks.
For now these functions will simply sync/flush the CPU cache when
needed.
Signed-off-by: Paul Cercueil <paul@...pouillou.net>
---
v5: New patch
---
drivers/dma-buf/udmabuf.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c
index c40645999648..a87d89b58816 100644
--- a/drivers/dma-buf/udmabuf.c
+++ b/drivers/dma-buf/udmabuf.c
@@ -179,6 +179,31 @@ static int end_cpu_udmabuf(struct dma_buf *buf,
return 0;
}
+static int begin_udmabuf(struct dma_buf_attachment *attach,
+ struct sg_table *sgt,
+ enum dma_data_direction dir)
+{
+ struct dma_buf *buf = attach->dmabuf;
+ struct udmabuf *ubuf = buf->priv;
+ struct device *dev = ubuf->device->this_device;
+
+ dma_sync_sg_for_device(dev, sgt->sgl, sg_nents(sgt->sgl), dir);
+ return 0;
+}
+
+static int end_udmabuf(struct dma_buf_attachment *attach,
+ struct sg_table *sgt,
+ enum dma_data_direction dir)
+{
+ struct dma_buf *buf = attach->dmabuf;
+ struct udmabuf *ubuf = buf->priv;
+ struct device *dev = ubuf->device->this_device;
+
+ if (dir != DMA_TO_DEVICE)
+ dma_sync_sg_for_cpu(dev, sgt->sgl, sg_nents(sgt->sgl), dir);
+ return 0;
+}
+
static const struct dma_buf_ops udmabuf_ops = {
.cache_sgt_mapping = true,
.map_dma_buf = map_udmabuf,
@@ -189,6 +214,8 @@ static const struct dma_buf_ops udmabuf_ops = {
.vunmap = vunmap_udmabuf,
.begin_cpu_access = begin_cpu_udmabuf,
.end_cpu_access = end_cpu_udmabuf,
+ .begin_access = begin_udmabuf,
+ .end_access = end_udmabuf,
};
#define SEALS_WANTED (F_SEAL_SHRINK)
--
2.43.0
Powered by blists - more mailing lists