From patchwork Wed Dec 16 15:37:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 7863231 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7E0E29F387 for ; Wed, 16 Dec 2015 15:38:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AA9952038E for ; Wed, 16 Dec 2015 15:38:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C6DE920382 for ; Wed, 16 Dec 2015 15:38:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933781AbbLPPhl (ORCPT ); Wed, 16 Dec 2015 10:37:41 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:24664 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965528AbbLPPhk (ORCPT ); Wed, 16 Dec 2015 10:37:40 -0500 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NZG0087HJEO6810@mailout1.w1.samsung.com>; Wed, 16 Dec 2015 15:37:36 +0000 (GMT) X-AuditID: cbfec7f5-f79b16d000005389-0e-567185405ec9 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 9E.0F.21385.04581765; Wed, 16 Dec 2015 15:37:36 +0000 (GMT) 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 <0NZG0019WJEJLV00@eusync3.samsung.com>; Wed, 16 Dec 2015 15:37: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 v3 4/7] media: vb2-dma-contig: add helper for setting dma max seg size Date: Wed, 16 Dec 2015 16:37:26 +0100 Message-id: <1450280249-24681-5-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1450280249-24681-1-git-send-email-m.szyprowski@samsung.com> References: <1450280249-24681-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrELMWRmVeSWpSXmKPExsVy+t/xq7oOrYVhBqs/mFrcWneO1WLjjPWs FvOPAFk/Xl9gs3j9wtCi//FrZovOiUvYLXo2bGW1mHF+H5PF2iN32S0Ov2lndeD2mN0xk9Vj 06pONo++LasYPT5vkgtgieKySUnNySxLLdK3S+DK2NDxla3gKX/F9ZeL2RoY7/B2MXJySAiY SJzrOcoCYYtJXLi3nq2LkYtDSGApo8SSc5OZIJwmJonlR3eBVbEJGEp0ve1iA7FFBJwkFs76 yw5SxCzQwSzxYOZCVpCEsECExN09xxlBbBYBVYnP0zeBNfMKeEj8mTmTEWKdnMT/lyuYQGxO AU+Jb/snAdVwAG3zkHjcUjaBkXcBI8MqRtHU0uSC4qT0XCO94sTc4tK8dL3k/NxNjJCQ+7qD cekxq0OMAhyMSjy8GjEFYUKsiWXFlbmHGCU4mJVEeB/KFYYJ8aYkVlalFuXHF5XmpBYfYpTm YFES5525632IkEB6YklqdmpqQWoRTJaJg1OqgXHV5ItyGQ232BV3PmbeNEekhu2gn47szdp7 HuKaeYHfOteFd91VLP8W5BR1Y6q56RYGl2cZDJ1d5x4KzHuVttIwfI3s3I8VPxVPdLsuZGvv 6g8y3uXAfUlo19sVC409Gh88y7mzbnr1rv+TJ76e8iN86qvwhOwwhlt7z7kfd12Yeevkxsdr fv5QYinOSDTUYi4qTgQAnoDoUTUCAAA= 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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 --- drivers/media/v4l2-core/videobuf2-dma-contig.c | 14 ++++++++++++++ include/media/videobuf2-dma-contig.h | 1 + 2 files changed, 15 insertions(+) diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c index c33127284cfe..bd893788d1ae 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-contig.c +++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c @@ -742,6 +742,20 @@ 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 = kzalloc(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 c33dfa69d7ab..0e6ba644939e 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;