From patchwork Thu Feb 20 10:52:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 3686001 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 6B633BF13A for ; Thu, 20 Feb 2014 10:56:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 91BC6201B6 for ; Thu, 20 Feb 2014 10:56:55 +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 979132012E for ; Thu, 20 Feb 2014 10:56:54 +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 1WGRHK-0004TC-UH; Thu, 20 Feb 2014 10:54:55 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WGRGn-000122-3g; Thu, 20 Feb 2014 10:54:21 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WGRG0-0000ru-43 for linux-arm-kernel@lists.infradead.org; Thu, 20 Feb 2014 10:53:33 +0000 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N1A0058OJK4CX00@mailout2.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 20 Feb 2014 10:52:52 +0000 (GMT) X-AuditID: cbfec7f5-b7fc96d000004885-1c-5305de884c59 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 77.C1.18565.88ED5035; Thu, 20 Feb 2014 10:52:56 +0000 (GMT) Received: from amdc1339.mshome.net ([106.116.147.30]) by eusync2.samsung.com (Oracle Communications Messaging Server 7u4-23.01 (7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0N1A005WSJK1HXB0@eusync2.samsung.com>; Thu, 20 Feb 2014 10:52:56 +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 v4 2/7] drivers: dma-coherent: add initialization from device tree Date: Thu, 20 Feb 2014 11:52:42 +0100 Message-id: <1392893567-31623-3-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1392893567-31623-1-git-send-email-m.szyprowski@samsung.com> References: <1392893567-31623-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAy3RXUhTYRzH8Z6dl50NJ8e16iRhsvLG0DS6eArRsIgnukhckHSRTh0qbL5s TVICh82h0821Ik3MNnJhy2lN0zkqdA4nmqFMnFIaMaHU2RI1KjepZXff35/P3Z/C+HfxWKqk 9KZEXiqWCkkuPrnrmU2qXyJEKaP9CTBsHGPD77V1GAw+bQLwsfs9AZsDZgIOhxwABnT1OBzq +QbgVG2ADQcbWtlwa/YzC9r9cwQ0azpx6HW2k9DmXmTDFysjLGjxzbCgyaMmYKglDk74NknY 7X7ChoYWGw7r3rjZMDxox+HqiAaHva1rOLQ6QwCubIzj546g7o5ugHZ+GwFau2cAyKvXsdBQ 2yIbNQXUBLJbG0j0ce41ifo6a9CHXT+GZsdrCdQTWmWh5nAKeuTUA6TvtwK0aY/LirnOTSuU SEsqJfKT6XncYuP6F1A+H31L3afBVMARpQUciqFPMxvzX7G9PshML/WSWsCl+LQFMO6B0f+j kcUsmO6TEUXSqYx2XfuvBbQZMJsdeARh9CeSqZ9pYmkBRe2nrzLW0LWIwekExhYMsCNnHo0Y vyUmkgwdz7Qb0yKCQ19i7iwtEpHm/xXONi9hADwT2GcFByTKgnJFfpHsVLJCLFMoS4uSC8pk drD3xm0HsIyddQGaAsIoXo4PF/EJcaWiSuYCDIUJBbyBBULE5xWKq6ol8rJcuVIqUbgAi+LE qkDU9C8HdL2N3gof7YkX1RQmL+s8Stu2KT/9xkiGr1pn64rN8eRZM0wvJ39IK1Wt0kO3T0zt kKbLY+rhoPDiwx29+/hw6s9Yczj7mY+PybMzg2JBhRQ/87wtRZXb5Tv8SoddeXdMFKOY5lzw VjQmZWYtJxoEXr/mgaxoQnNeiCuKxamJmFwh/gMiu5cgpAIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140220_055332_295354_31199B3E X-CRM114-Status: UNSURE ( 9.85 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -4.5 (----) 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.8 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 | 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