From patchwork Wed Apr 27 12:00:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 66782 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp2143432qge; Wed, 27 Apr 2016 05:00:50 -0700 (PDT) X-Received: by 10.66.141.42 with SMTP id rl10mr11320518pab.48.1461758450232; Wed, 27 Apr 2016 05:00:50 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e187si3934616pfe.32.2016.04.27.05.00.50; Wed, 27 Apr 2016 05:00:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752290AbcD0MAs (ORCPT + 4 others); Wed, 27 Apr 2016 08:00:48 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:18035 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750826AbcD0MAr (ORCPT ); Wed, 27 Apr 2016 08:00:47 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O6A0069CK18Y900@mailout4.w1.samsung.com>; Wed, 27 Apr 2016 13:00:44 +0100 (BST) X-AuditID: cbfec7f5-f792a6d000001302-4b-5720a9eb4308 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 74.1E.04866.BE9A0275; Wed, 27 Apr 2016 13:00:43 +0100 (BST) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O6A00AH4K13ALB0@eusync3.samsung.com>; Wed, 27 Apr 2016 13:00:43 +0100 (BST) From: Marek Szyprowski To: linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Sylwester Nawrocki , Kamil Debski , Laurent Pinchart , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH RESEND 1/2] media: vb2-dma-contig: add helper for setting dma max seg size Date: Wed, 27 Apr 2016 14:00:28 +0200 Message-id: <1461758429-12913-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGJMWRmVeSWpSXmKPExsVy+t/xq7qvVyqEG3y8I22xccZ6Vosfry+w Wbx+YWjROXEJu0XPhq2sFjPO72OyWHvkLrvF4TftrA4cHrM7ZrJ69G1ZxejxeZNcAHMUl01K ak5mWWqRvl0CV0b3q27Ggl2CFYsuf2BuYPzH18XIySEhYCJx8PFldghbTOLCvfVsXYxcHEIC SxklJl25yw7hNDFJbN3+mA2kik3AUKLrbReYLSLgJLFw1l+wImaBZUwSb+c+BxslLBAj0dX2 D6iIg4NFQFVi/fMskDCvgIfEi4dHmSG2yUn8f7mCaQIj9wJGhlWMoqmlyQXFSem5RnrFibnF pXnpesn5uZsYIaHxdQfj0mNWhxgFOBiVeHgLJBTChVgTy4orcw8xSnAwK4nwMiwDCvGmJFZW pRblxxeV5qQWH2KU5mBREueduet9iJBAemJJanZqakFqEUyWiYNTqoExOM6SJzo4Tly1Mkx4 k/DKvZbhphvfbTLbvSd4ot/Zk/q/XzNOFn+wNUj6jO3ih1Z996reWZzg/+Cym3GKYGhb2M+0 A7H7uxQ8Xll6f954MSvmeGxdmtJibi7nfw1OHOmvdi9+ZbEw6yjPrTxvJ309S0d9C5PVVRtX lay2D/T6UafqqcSy1UqJpTgj0VCLuag4EQDobeTfCQIAAA== Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org 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 --- 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(+) -- 1.9.2 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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 "); 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;