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: 8956121 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BEBC5BF29F for ; Wed, 27 Apr 2016 12:00:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BD27720259 for ; Wed, 27 Apr 2016 12:00:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C9AF1200DB for ; Wed, 27 Apr 2016 12:00:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752290AbcD0MAs (ORCPT ); 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 X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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;