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: 25104 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f199.google.com (mail-ve0-f199.google.com [209.85.128.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2CFAC20143 for ; Fri, 21 Feb 2014 12:26:42 +0000 (UTC) Received: by mail-ve0-f199.google.com with SMTP id oy12sf6474855veb.6 for ; Fri, 21 Feb 2014 04:26:41 -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=M+nseSASXR7fP3UZEaL8YaJHUvDXlXeM63wpBk7mT7k=; b=CPNAPNdIp+Wm+IaKaD39sVhl18K/GYeMySEj0nXQa/bpR7W4CSVBUydKdgugIeqKPJ eH6T+MbsutnDCFI8x1d5uiw+wrGPtj6geG+maZvY/nSZm+ACCsb/THnwwSHq1VUOajGh 31FnfzKhfb5avyY0Td83BPHx9HSCaO2YNTDTJFvdFayblcYLmrs1DqNsVyDC8Jr3Qe0d sK6b7ih3zGBxiQy6awC+6UTMffokcW3lQjsetrqu85qgW2FVGKWZ57+dwp0zqCvmBtCP P3RGvOS4dpOsBt2cWwrXwQWgedpUcqpkEHiXQOCtbTuZzdRl/7OS0Gxgw+GBu4FdOtLg j9gQ== X-Gm-Message-State: ALoCoQkRMGHO8CsZ+C+2nAjo5y3Q06jC9Cq8ApLoBsd+t8lpQM/sHyhNZitq0dUpi4XlrkrK/lLY X-Received: by 10.236.90.200 with SMTP id e48mr3162203yhf.28.1392985601938; Fri, 21 Feb 2014 04:26:41 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.31.72 with SMTP id e66ls977277qge.67.gmail; Fri, 21 Feb 2014 04:26:41 -0800 (PST) X-Received: by 10.220.103.141 with SMTP id k13mr4582933vco.25.1392985601835; Fri, 21 Feb 2014 04:26:41 -0800 (PST) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id xt2si2911952vcb.108.2014.02.21.04.26.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 21 Feb 2014 04:26:41 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id pa12so3166834veb.16 for ; Fri, 21 Feb 2014 04:26:41 -0800 (PST) X-Received: by 10.220.81.71 with SMTP id w7mr4482312vck.71.1392985601669; Fri, 21 Feb 2014 04:26:41 -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.174.196 with SMTP id u4csp30041vcz; Fri, 21 Feb 2014 04:26:40 -0800 (PST) X-Received: by 10.14.1.68 with SMTP id 44mr8312969eec.0.1392985600323; Fri, 21 Feb 2014 04:26:40 -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 v5si15794529eel.223.2014.02.21.04.26.39 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 21 Feb 2014 04:26:40 -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 1WGpAN-0004FZ-RP; Fri, 21 Feb 2014 12:25:19 +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 1WGpA3-0004D6-1i for linaro-mm-sig@lists.linaro.org; Fri, 21 Feb 2014 12:24:59 +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 linaro-mm-sig@lists.linaro.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 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== 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 v5 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.128.171 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 | 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