From patchwork Mon Dec 7 12:08:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 7783101 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 9C8339F350 for ; Mon, 7 Dec 2015 12:10:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D00C42040F for ; Mon, 7 Dec 2015 12:10:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DBF5520453 for ; Mon, 7 Dec 2015 12:10:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755415AbbLGMKC (ORCPT ); Mon, 7 Dec 2015 07:10:02 -0500 Received: from mailout3.w1.samsung.com ([210.118.77.13]:21732 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755220AbbLGMJl (ORCPT ); Mon, 7 Dec 2015 07:09: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 <0NYZ00MKGLS1A5A0@mailout3.w1.samsung.com>; Mon, 07 Dec 2015 12:09:38 +0000 (GMT) X-AuditID: cbfec7f5-f79b16d000005389-8c-56657701a5cb Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 8D.E3.21385.10775665; Mon, 7 Dec 2015 12:09:37 +0000 (GMT) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NYZ00FEQLRTAS00@eusync1.samsung.com>; Mon, 07 Dec 2015 12:09:37 +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 4/7] media: vb2-dma-contig: add helper for setting dma max seg size Date: Mon, 07 Dec 2015 13:08:59 +0100 Message-id: <1449490142-27502-5-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1449490142-27502-1-git-send-email-m.szyprowski@samsung.com> References: <1449490142-27502-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrELMWRmVeSWpSXmKPExsVy+t/xy7qM5alhBuv7LS1urTvHarFxxnpW i/lHgKwfry+wWbx+YWjR//g1s0XnxCXsFj0btrJazDi/j8li7ZG77BaH37SzOnB7zO6Yyeqx aVUnm0ffllWMHp83yQWwRHHZpKTmZJalFunbJXBldE1/y1TwX7Bixuv77A2MW/m7GDk5JARM JDr7OpkhbDGJC/fWs3UxcnEICSxllJh0Yhc7hNPEJLH/yhImkCo2AUOJrrddbCC2iICTxMJZ f8GKmAU6mCUezFzICpIQFgiV2PHsD9hYFgFViaufHrCA2LwCHhJb1rVArZOT+P9yBdhQTgFP iYc/vzN2MXIAbfOQeLwlYwIj7wJGhlWMoqmlyQXFSem5RnrFibnFpXnpesn5uZsYISH3dQfj 0mNWhxgFOBiVeHgnZKaECbEmlhVX5h5ilOBgVhLhlc1MDRPiTUmsrEotyo8vKs1JLT7EKM3B oiTOO3PX+xAhgfTEktTs1NSC1CKYLBMHp1QDo/nXBOOP+2ZZdwlMkuM31/6+tiT4YdURrtx/ E25Nkg7i+SX++lj4hKK+lek+uQlCutxZh5ULXuUqxFZnSFRdyHldI8Q5f1fqI7b9780nLzr+ 2ufyqjUng9yyNd7HaTW2LdpjmJLXwSPeuaV1+0kHU/nKLQdPciRJyb3wMr6tJM98jC+Hv36a EktxRqKhFnNRcSIAFw+v0DUCAAA= 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 --- Changelog: v3: - make this code a helper function instead of chaning max_seg_size unconditionally on vb2_dma_contig_init_ctx v2: - set max segment size only if a new dma params structure has been allocated, as suggested by Laurent Pinchart --- 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 c33127284cfe..628518dc3aad 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 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;