public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND 1/2] media: vb2-dma-contig: add helper for setting dma max seg size
@ 2016-04-27 12:00 Marek Szyprowski
  2016-04-27 12:00 ` [PATCH RESEND 2/2] media: set proper max seg size for devices on Exynos SoCs Marek Szyprowski
  2016-04-27 12:10 ` [PATCH RESEND 1/2] media: vb2-dma-contig: add helper for setting dma max seg size Hans Verkuil
  0 siblings, 2 replies; 8+ messages in thread
From: Marek Szyprowski @ 2016-04-27 12:00 UTC (permalink / raw)
  To: linux-media, linux-samsung-soc
  Cc: Marek Szyprowski, Sylwester Nawrocki, Kamil Debski,
	Laurent Pinchart, Krzysztof Kozlowski, Bartlomiej Zolnierkiewicz

Add a helper function for device drivers to set DMA's max_seg_size.
Setting it to largest possible value lets DMA-mapping API always create
contiguous mappings in DMA address space. This is essential for all
devices, which use dma-contig videobuf2 memory allocator and shared
buffers.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
This patch was posted earlier as a part of
http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/97316
thread, but applying it is really needed to get all Exynos multimedia
drivers working with IOMMU enabled.

Best regards,
Marek Szyprowski
---
 drivers/media/v4l2-core/videobuf2-dma-contig.c | 15 +++++++++++++++
 include/media/videobuf2-dma-contig.h           |  1 +
 2 files changed, 16 insertions(+)

diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c
index 5361197..f611456 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
@@ -753,6 +753,21 @@ void vb2_dma_contig_cleanup_ctx(void *alloc_ctx)
 }
 EXPORT_SYMBOL_GPL(vb2_dma_contig_cleanup_ctx);
 
+int vb2_dma_contig_set_max_seg_size(struct device *dev, unsigned int size)
+{
+	if (!dev->dma_parms) {
+		dev->dma_parms = devm_kzalloc(dev, sizeof(dev->dma_parms),
+					      GFP_KERNEL);
+		if (!dev->dma_parms)
+			return -ENOMEM;
+	}
+	if (dma_get_max_seg_size(dev) < size)
+		return dma_set_max_seg_size(dev, size);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(vb2_dma_contig_set_max_seg_size);
+
 MODULE_DESCRIPTION("DMA-contig memory handling routines for videobuf2");
 MODULE_AUTHOR("Pawel Osciak <pawel@osciak.com>");
 MODULE_LICENSE("GPL");
diff --git a/include/media/videobuf2-dma-contig.h b/include/media/videobuf2-dma-contig.h
index 2087c9a..98857b5 100644
--- a/include/media/videobuf2-dma-contig.h
+++ b/include/media/videobuf2-dma-contig.h
@@ -35,6 +35,7 @@ static inline void *vb2_dma_contig_init_ctx(struct device *dev)
 }
 
 void vb2_dma_contig_cleanup_ctx(void *alloc_ctx);
+int vb2_dma_contig_set_max_seg_size(struct device *dev, unsigned int size);
 
 extern const struct vb2_mem_ops vb2_dma_contig_memops;
 
-- 
1.9.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-04-27 13:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-27 12:00 [PATCH RESEND 1/2] media: vb2-dma-contig: add helper for setting dma max seg size Marek Szyprowski
2016-04-27 12:00 ` [PATCH RESEND 2/2] media: set proper max seg size for devices on Exynos SoCs Marek Szyprowski
2016-04-27 12:08   ` Hans Verkuil
2016-04-27 12:10 ` [PATCH RESEND 1/2] media: vb2-dma-contig: add helper for setting dma max seg size Hans Verkuil
2016-04-27 12:23   ` Marek Szyprowski
2016-04-27 12:58     ` Hans Verkuil
2016-04-27 13:14       ` Marek Szyprowski
2016-04-27 13:33         ` Hans Verkuil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox