From patchwork Fri Feb 21 12:25:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 3696411 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 0E289BF13A for ; Fri, 21 Feb 2014 13:04:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 264DF20149 for ; Fri, 21 Feb 2014 13:04:51 +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 024562017D for ; Fri, 21 Feb 2014 13:04:50 +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 1WGpEo-0007U2-G5; Fri, 21 Feb 2014 12:29:56 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WGpDs-0000tG-W4; Fri, 21 Feb 2014 12:28:57 +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 1WGpBq-0000Yt-38 for linux-arm-kernel@lists.infradead.org; Fri, 21 Feb 2014 12:26:51 +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 <0N1C00LC5IJSWR90@mailout1.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Fri, 21 Feb 2014 12:26:16 +0000 (GMT) X-AuditID: cbfec7f4-b7f796d000005a13-ab-530745e7c978 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 07.31.23059.7E547035; Fri, 21 Feb 2014 12:26:15 +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 <0N1C001ZAIJD5M60@eusync3.samsung.com>; Fri, 21 Feb 2014 12:26:15 +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 v5 07/11] drivers: dma-coherent: add initialization from device tree Date: Fri, 21 Feb 2014 13:25:23 +0100 Message-id: <1392985527-6260-8-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1392985527-6260-1-git-send-email-m.szyprowski@samsung.com> References: <1392985527-6260-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAyWRX0hTcRTH/d3d3XudTm5L5YeE2KAXQ6cQ+StMyqh+0EOC0EMItnQ5y+nY UlyBTdM159S5KG34FzVo6dQZqaPIyXCyTDQ3DUojLUydlk17qE1y+vY53/M55zwchiMwkjFM fuEdiaJQXCCkeOS7XacnYeUCnZk07Y1HAeM4jX5VVHHQz2d6gNocU1xU7+3golH/MEDeWi2J RiybAL2v8NJoqLqJRtvurwSyLs9xUYemi0SztmYK9ToWaNS/aidQ9/wMgdqdlVzkb4xFrnkf hXocnTQyNPaSqOqNg0aBISuJ1uwaEvU1rZPIbPMDtLo1QZ49gntaewD+99cI8PojA8CzdbUE HjEt0FjvreRiq7mawp/nXlN4sOs+/rS7zMHuiQoutvjXCFwfSMIttjqA616aAfZZYzMOXeOl 5koK8kskClHadZ7UuLEC5B8jSisHNRw1GA7XgVAGsifgwE4tfcDRcHqxj9IBHiNguwH8oPXR B0UNAacadWTQothkqNvQUUGOZDsA9LWSQYnDfqGgdkZPBBuH2atQ1/YKBJlkj8HB56v7A3z2 Enxs+rO3ldk7FwebjanBOJTFcHJ0ZT8W7CkW7S0D4LeDEDOIkhTnyJU38mTJiUqxTFlcmJeY UySzgoM/bg+DzvHTY4BlgDCcL4dUpoArLlGqZGMAMhxhJN8uojMF/Fyx6q5EUZStKC6QKMcA wYTGqIFU1FDjXJKjc+Bt3EJzlCWMSngQYcpRnwxJkaY+XfLkm6wtNzUZ6uwf+WGnftuiB1yG tOMXM4o8lvKspYSs71uqEvUVVycjLdvpL0+ZDCyqxJvZDZMPtU/KROlUq9tu6WNyb3tfbDqP Spbj9XHnL3/znnH5eKXp97QevjtJSCql4uR4jkIp/g8wMGKzpQIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140221_072650_268299_4C78F394 X-CRM114-Status: GOOD ( 10.15 ) X-Spam-Score: -6.9 (------) 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=-4.2 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED, 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 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 | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c index bc256b641027..2343ba5d6d43 100644 --- a/drivers/base/dma-coherent.c +++ b/drivers/base/dma-coherent.c @@ -218,3 +218,44 @@ 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, struct of_phandle_args *args) +{ + 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