From patchwork Wed Dec 9 13:58:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 58145 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp685696lbb; Wed, 9 Dec 2015 05:59:29 -0800 (PST) X-Received: by 10.66.155.197 with SMTP id vy5mr8053601pab.109.1449669544576; Wed, 09 Dec 2015 05:59:04 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9si12902681pfi.234.2015.12.09.05.59.04; Wed, 09 Dec 2015 05:59:04 -0800 (PST) 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 S1754891AbbLIN7D (ORCPT + 4 others); Wed, 9 Dec 2015 08:59:03 -0500 Received: from mailout3.w1.samsung.com ([210.118.77.13]:59811 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751239AbbLIN6l (ORCPT ); Wed, 9 Dec 2015 08:58:41 -0500 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NZ3003JNG5OEQ80@mailout3.w1.samsung.com>; Wed, 09 Dec 2015 13:58:36 +0000 (GMT) X-AuditID: cbfec7f5-f79b16d000005389-bd-5668338c2020 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id AE.1F.21385.C8338665; Wed, 9 Dec 2015 13:58:36 +0000 (GMT) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NZ300CXZG5IXP20@eusync2.samsung.com>; Wed, 09 Dec 2015 13:58:36 +0000 (GMT) From: Marek Szyprowski To: linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , devicetree@vger.kernel.org, Sylwester Nawrocki , Kamil Debski , Laurent Pinchart , Andrzej Hajda , Kukjin Kim , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH v2 4/7] media: vb2-dma-contig: add helper for setting dma max seg size Date: Wed, 09 Dec 2015 14:58:19 +0100 Message-id: <1449669502-24601-5-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1449669502-24601-1-git-send-email-m.szyprowski@samsung.com> References: <1449669502-24601-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrELMWRmVeSWpSXmKPExsVy+t/xK7o9xhlhBp8+sFvcWneO1WLjjPWs FvOPAFk/Xl9gs3j9wtCi//FrZovOiUvYLXo2bGW1mHF+H5PF2iN32S0Ov2lndeD2mN0xk9Vj 06pONo++LasYPT5vkgtgieKySUnNySxLLdK3S+DKuPVgMlvBS/6KiVfeszQwXubtYuTkkBAw kei5/JUVwhaTuHBvPVsXIxeHkMBSRomHG3dCOU1MEk//z2ECqWITMJToetvFBmKLCDhJLJz1 lx2kiFmgg1niwcyFYKOEBSIkzh+5ygxiswioSpxb2MYIYvMKeEj833aICWKdnMT/lyuAbA4O TgFPiVeHwcqFgEre/57MPIGRdwEjwypG0dTS5ILipPRcI73ixNzi0rx0veT83E2MkJD7uoNx 6TGrQ4wCHIxKPLwVTulhQqyJZcWVuYcYJTiYlUR4T+hnhAnxpiRWVqUW5ccXleakFh9ilOZg URLnnbnrfYiQQHpiSWp2ampBahFMlomDU6qBUaN+a9qll1fuOApr3V/wUndbWw6Xjrims11H iHK63+TZZvK3z7GVr755TujExw+3Q1JbrlgznjnQHzWnWe+XWnDnZb0PJzWjnxY7T9SoZ12x 4kA+9wVun6rrUz1OtnEc+dwitpbdR3H/4l3ucyt62p/WCjQ/nPPwJ9//u8UFn6ffsMtmrhLb osRSnJFoqMVcVJwIAMkgYB01AgAA 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 --- 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 c331272..628518d 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-contig.c +++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c @@ -742,6 +742,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 c33dfa6..0e6ba64 100644 --- a/include/media/videobuf2-dma-contig.h +++ b/include/media/videobuf2-dma-contig.h @@ -26,6 +26,7 @@ vb2_dma_contig_plane_dma_addr(struct vb2_buffer *vb, unsigned int plane_no) 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;