From patchwork Mon Jul 14 07:12:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 4543131 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2B1049F1D6 for ; Mon, 14 Jul 2014 07:36:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5190C2012F for ; Mon, 14 Jul 2014 07:36:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (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 7711C2013A for ; Mon, 14 Jul 2014 07:36:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X6amJ-00022I-RB; Mon, 14 Jul 2014 07:34:27 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X6alr-0001Gf-08 for linux-arm-kernel@lists.infradead.org; Mon, 14 Jul 2014 07:33:59 +0000 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) 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 <0N8O00H17YBPM700@mailout1.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Mon, 14 Jul 2014 08:33:25 +0100 (BST) X-AuditID: cbfec7f5-b7f626d000004b39-6d-53c387c825e3 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id DC.F3.19257.8C783C35; Mon, 14 Jul 2014 08:33:28 +0100 (BST) Received: from amdc1339.digital.local ([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 <0N8O00FFGYBLTX50@eusync3.samsung.com>; Mon, 14 Jul 2014 08:33:28 +0100 (BST) From: Marek Szyprowski To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 3/4] drivers: dma-coherent: add initialization from device tree Date: Mon, 14 Jul 2014 09:12:45 +0200 Message-id: <1405321966-28184-4-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1405321966-28184-1-git-send-email-m.szyprowski@samsung.com> References: <1405321966-28184-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRmVeSWpSXmKPExsVy+t/xq7on2g8HGxy6r2UxZ/0aNovHr+ex WPyddIzd4kNTK7PF+2U9jBbzj5xjtTjwZwejxcruZjaLneveMVqcbXrDbrG9cwa7xZcrD5ks Nj2+xmpxedccNou1R+6yW2x4eZDJYsHxFlaLP9PlLNYcWcxu8Xf7JhaL9TNes1gsnH+f3eLl xxMsDuIea+atYfT4/WsSo8flvl4mj52z7rJ79LxpYfXoenuFyePOtT1sHidm/GbxeHBoM4vH 5iX1Hrf/PWb2WPfnFZNH/18Dj7m7+hg9+rasYvT4vEkuQCCKyyYlNSezLLVI3y6BK+PQnG7G gmV8FZu3L2NrYJzB08XIySEhYCKxo3EfG4QtJnHh3nogm4tDSGApo8TOjiVQTh+TxPSTy1lA qtgEDCW63naBdYgIuEn8W3cIrIhZYAGbxNH/PxhBEsICIRJT9n8CK2IRUJVY9fgcUxcjBwev gIfEgkv2ENvkJP6/XMEEYnMKeEpsnPyNFcQWAio5vG8P4wRG3gWMDKsYRVNLkwuKk9JzjfSK E3OLS/PS9ZLzczcxQuLr6w7GpcesDjEKcDAq8fAW8B8OFmJNLCuuzD3EKMHBrCTCG+4GFOJN SaysSi3Kjy8qzUktPsTIxMEp1cDoOO2+77zl/vNlPdq0WD/meK67y6T1a4+S+Z2ZRi9rDlo4 Pfbo0JWs2uop2n3vdZnNqTAlRs8wWY2OzSnRb++v+vFEL0q4Kina2nrJrmPHV/67IpI/tbH6 yDKV0HVMLjsyV2uL7vW7vetqw2vDuN3798y/oXjJaaV89QqlOX+a/UQ0GioL8jmUWIozEg21 mIuKEwGDqAOxjQIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140714_003359_194993_7F369FEE X-CRM114-Status: GOOD ( 11.55 ) X-Spam-Score: -5.0 (-----) Cc: Jon Medhurst , devicetree@vger.kernel.org, Laura Abbott , Andrew Morton , Arnd Bergmann , Josh Cartwright , Benjamin Herrenschmidt , Tomasz Figa , Will Deacon , Michal Nazarewicz , linaro-mm-sig@lists.linaro.org, Marc , Nishanth Peethambaran , Paul Mackerras , "Aneesh Kumar K.V." , Catalin Marinas , Grant Likely , Joonsoo Kim , Sascha Hauer , Marek Szyprowski X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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.9 required=5.0 tests=BAYES_00,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 | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c index 7d6e84a51424..b20cbe095d86 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 = rmem->fdt_node; + + 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