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: 57791 Delivered-To: patch@linaro.org Received: by 10.202.179.86 with SMTP id c83csp949596oif; Mon, 7 Dec 2015 04:10:35 -0800 (PST) X-Received: by 10.98.13.156 with SMTP id 28mr42218157pfn.106.1449490213617; Mon, 07 Dec 2015 04:10:13 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 71si20352050pfi.149.2015.12.07.04.10.13; Mon, 07 Dec 2015 04:10:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-media-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-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755433AbbLGMKD (ORCPT + 4 others); Mon, 7 Dec 2015 07:10:03 -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-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@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 --- 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(+) -- 1.9.2 -- To unsubscribe from this list: send the line "unsubscribe linux-media" 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 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;