From patchwork Fri Feb 28 13:42:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 3741621 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B6D9DBF13A for ; Fri, 28 Feb 2014 14:05:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DB862202B4 for ; Fri, 28 Feb 2014 14:05:02 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B69D92013D for ; Fri, 28 Feb 2014 14:05:00 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WJNld-0003hu-Sy; Fri, 28 Feb 2014 13:46:23 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WJNkv-0004TU-1W; Fri, 28 Feb 2014 13:45:37 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WJNjD-00048m-2a for linux-arm-kernel@lists.infradead.org; Fri, 28 Feb 2014 13:43:56 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N1P00FEAKS5S080@mailout1.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Fri, 28 Feb 2014 13:43:17 +0000 (GMT) X-AuditID: cbfec7f4-b7f796d000005a13-22-53109274c7c4 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 88.55.23059.47290135; Fri, 28 Feb 2014 13:43:16 +0000 (GMT) Received: from amdc1339.mshome.net ([106.116.147.30]) by eusync3.samsung.com (Oracle Communications Messaging Server 7u4-23.01 (7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0N1P002ZJKROU750@eusync3.samsung.com>; Fri, 28 Feb 2014 13:43:16 +0000 (GMT) From: Marek Szyprowski To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-mm-sig@lists.linaro.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v6 07/11] drivers: dma-coherent: add initialization from device tree Date: Fri, 28 Feb 2014 14:42:52 +0100 Message-id: <1393594976-16728-8-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1393594976-16728-1-git-send-email-m.szyprowski@samsung.com> References: <1393594976-16728-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAyWRa0hTYRzGe8/OzjlOl6e17CChsYjA0LT68FJm0adXiSgEBbvY0uEkN2Xz klI5hopO5+YUNHW2eYOGOpuSFwxyzEtauTXdimVSBjFdligVNSWn334P/9/zfPlTLF4dHk5l S/NFMqkwR0Bw8NntqYXofB2dHKuYOwy3dJMk/KksZ8Ef3TUAPrG9ZUONz8iGL/3DAPrUlTgc 6VsD8I3SR8KhqiYSbs5/xqBl2cWGxopOHDpHWwnYa1skYb93HINdbgcGDVNlbOhvjIAz7g0C 9tg6SKht7MVh+QsbCbeGLDhcGa/AoblpFYemUT+A3vVp/NIR1NPWA9C/vzqAVuu1ADlr1Rga aV4kUY2vjI0spioCfXSNEWigsxR5tpdZaH5ayUZ9/hUMabZikX60FqDaQRNAG5aIawfSOPGZ opzsQpHsVMIdjthZGZw3uP+++v0sSwFaQlQgiGLos4zj+Ttyj8MY+yczoQIcikd3AUZhnsD2 QjXG2N16ImARdByj+q7aZT5tBMxGGx6QWPQSwVQ6arDA4SCdwixo9LuzOH2cWVOu7xQoiksj ZsAjDCBDH2VadfEBI4hOZBSNS+wA83YMzx830AKuAewzgUOigow8+d0sSVyMXCiRF0izYjJy JRaw98bNYdAxec4KaAoIQrjaxNBkHltYKC+WWAFDsQR87lclnczjZgqLS0Sy3HRZQY5IbgUY FRSuAFhqSvR5Q9k387F2sXHu+pg305qmiz1pSX2myW2fKSdkYn6kp+HK1awhWtBtn2oWO2/U q1eyb9u40pYPkbeCTY9CS+ZeraZ3vC7Sz7rW7EmP7+X/OjH221H61Js00dB/GY/ZNjTU6S+0 Vp/2bhZdhA9unqkodIUxugT+wyjbFwEuFwvjolgyufA/3h44QqQCAAA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140228_084351_284590_FA98217F X-CRM114-Status: UNSURE ( 9.75 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -3.8 (---) Cc: Mark Rutland , Benjamin Herrenschmidt , Tomasz Figa , Will Deacon , Tomasz Figa , Paul Mackerras , Marek Szyprowski , Arnd Bergmann , Josh Cartwright , Catalin Marinas , Grant Likely , Laura Abbott , Ian Campbell , Pawel Moll , Stephen Warren , Sascha Hauer , Michal Nazarewicz , Marc , Nishanth Peethambaran , Rob Herring , Kumar Gala , Olof Johansson X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=no 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 support for handling 'shared-dma-pool' reserved-memory device tree nodes. Based on previous code provided by Josh Cartwright Signed-off-by: Marek Szyprowski --- drivers/base/dma-coherent.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c index bc256b641027..0a5fc7f3d03e 100644 --- a/drivers/base/dma-coherent.c +++ b/drivers/base/dma-coherent.c @@ -218,3 +218,43 @@ int dma_mmap_from_coherent(struct device *dev, struct vm_area_struct *vma, return 0; } EXPORT_SYMBOL(dma_mmap_from_coherent); + +/* + * Support for reserved memory regions defined in device tree + */ +#ifdef CONFIG_OF_RESERVED_MEM +#include +#include +#include + +static void rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev) +{ + dma_declare_coherent_memory(dev, rmem->base, rmem->base, + rmem->size, DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); +} + +static void rmem_dma_device_release(struct reserved_mem *rmem, + struct device *dev) +{ + dma_release_declared_memory(dev); +} + +static const struct reserved_mem_ops rmem_dma_ops = { + .device_init = rmem_dma_device_init, + .device_release = rmem_dma_device_release, +}; + +static int __init rmem_dma_setup(struct reserved_mem *rmem, + unsigned long node, + const char *uname) +{ + if (of_get_flat_dt_prop(node, "reusable", NULL)) + return -EINVAL; + + rmem->ops = &rmem_dma_ops; + pr_info("Reserved memory: created DMA memory pool at %pa, size %ld MiB\n", + &rmem->base, (unsigned long)rmem->size / SZ_1M); + return 0; +} +RESERVEDMEM_OF_DECLARE(dma, "shared-dma-pool", rmem_dma_setup); +#endif