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: 25554 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f197.google.com (mail-yk0-f197.google.com [209.85.160.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9637320543 for ; Fri, 28 Feb 2014 13:43:51 +0000 (UTC) Received: by mail-yk0-f197.google.com with SMTP id 142sf3723086ykq.0 for ; Fri, 28 Feb 2014 05:43:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=YcPAaupUYxn+CBAD2hOZfVy2Sik6t/j9A/0Z7IFNIIs=; b=Y/J72rrxqrNVbnB00mEVBKsyavLc1MdJY8WVB1lbi1Pb7Em1HYdC4W3DTyOibDy2ny DucfgobvT/YVjOzZ472c8h+0x3KLuNAoECT0alc3JGt5zMrS/iWVTSanJZyN4S3xxFwM XdCA9UPr7UMSpGdltJSZP1hrB0R/vuDwnMmYIB9cIkXeY5NoupHLY7b4uYNSPpdoSBPP /+CP0RMii1hDefwLxMCGy+ci5tXRofmfMr5gfqIdVS+NT8Gu1qqAEXXh5LSpBFKrYu05 rjHMOOcou67mkto+1iR3FJqMUkJl1oxTPei0wcmWVrcYqNBtkcQimdtSIwNsh5ZtsreE pPew== X-Gm-Message-State: ALoCoQl6J+0elTDgw3vFYyGiAK5DnIn7jug11Yr7iLEmnAvzZN8xRLEU3Wb2sUDzBak1vWVxLXyV X-Received: by 10.224.4.202 with SMTP id 10mr1196017qas.7.1393595031330; Fri, 28 Feb 2014 05:43:51 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.19.69 with SMTP id 63ls1068008qgg.75.gmail; Fri, 28 Feb 2014 05:43:51 -0800 (PST) X-Received: by 10.221.26.10 with SMTP id rk10mr2719989vcb.0.1393595031213; Fri, 28 Feb 2014 05:43:51 -0800 (PST) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id x7si266689vel.38.2014.02.28.05.43.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Feb 2014 05:43:51 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id la4so714197vcb.21 for ; Fri, 28 Feb 2014 05:43:51 -0800 (PST) X-Received: by 10.220.67.18 with SMTP id p18mr2680247vci.14.1393595031125; Fri, 28 Feb 2014 05:43:51 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.130.193 with SMTP id u1csp54603vcs; Fri, 28 Feb 2014 05:43:50 -0800 (PST) X-Received: by 10.14.106.193 with SMTP id m41mr21520435eeg.62.1393595030124; Fri, 28 Feb 2014 05:43:50 -0800 (PST) Received: from ip-10-141-164-156.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id n7si2764424eeu.208.2014.02.28.05.43.48 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 28 Feb 2014 05:43:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-141-164-156.ec2.internal) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1WJNhi-0008KI-Rx; Fri, 28 Feb 2014 13:42:18 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1WJNhF-0008HG-LE for linaro-mm-sig@lists.linaro.org; Fri, 28 Feb 2014 13:41:49 +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 linaro-mm-sig@lists.linaro.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 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= Cc: Mark Rutland , Benjamin Herrenschmidt , Tomasz Figa , Will Deacon , Tomasz Figa , Paul Mackerras , Arnd Bergmann , Josh Cartwright , Catalin Marinas , Grant Likely , Ian Campbell , Pawel Moll , Stephen Warren , Sascha Hauer , Michal Nazarewicz , Rob Herring , Kumar Gala , Olof Johansson Subject: [Linaro-mm-sig] [PATCH v6 07/11] drivers: dma-coherent: add initialization from device tree X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: linaro-mm-sig-bounces@lists.linaro.org Sender: linaro-mm-sig-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: m.szyprowski@samsung.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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