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: 25002 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4B0172066E for ; Thu, 20 Feb 2014 10:53:22 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id to1sf6595572ieb.3 for ; Thu, 20 Feb 2014 02:53:22 -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=NgGbhp0UKiDlkx42RE1rRJ6/gzmj2KcuiSLHvSwF0S6iGk52evD6I1pDn7qm+JBLUR ytYsDR4tr0VitZ+/t73RlRDB0W9Y+Gi3d7ghWEaq59bElF7tYUWlTmVkAzSe3XRzn8Hm tg9n8JYB57R2AeS9qaiW/q42ZEPo72s/4Ui55GexElT8YsdkuVe8jiuPuN5rx+OQhmu2 jpMUUHQTe5F7JmZXbqiofO4FLxvCZypjxH87jbjdXmfXD1wEVyGVx+qIENZoBz3q6NmY 3ky2qI/XFlFQX0NxBM5EK/XRbBfAFCnf2A8g0Bx3v85vm0sRhpyQnAl97TS1myZg5C7a piEQ== X-Gm-Message-State: ALoCoQlVa+z1QSr9rcvvfoUzQtn/bTyheFd22YxkM8ValrThtOimoJnsDmQtxamzQ+3yViycx5hD X-Received: by 10.50.78.231 with SMTP id e7mr2924695igx.5.1392893602234; Thu, 20 Feb 2014 02:53:22 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.101.134 with SMTP id u6ls449361qge.79.gmail; Thu, 20 Feb 2014 02:53:22 -0800 (PST) X-Received: by 10.52.95.233 with SMTP id dn9mr510163vdb.3.1392893602134; Thu, 20 Feb 2014 02:53:22 -0800 (PST) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id eo4si1298622vdb.121.2014.02.20.02.53.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Feb 2014 02:53:22 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.178 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.178; Received: by mail-vc0-f178.google.com with SMTP id ik5so1666348vcb.23 for ; Thu, 20 Feb 2014 02:53:22 -0800 (PST) X-Received: by 10.52.107.35 with SMTP id gz3mr544741vdb.8.1392893602062; Thu, 20 Feb 2014 02:53:22 -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 u4csp48364vcz; Thu, 20 Feb 2014 02:53:21 -0800 (PST) X-Received: by 10.194.61.210 with SMTP id s18mr1375611wjr.10.1392893601048; Thu, 20 Feb 2014 02:53:21 -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 fw4si4200266wjb.97.2014.02.20.02.53.20 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 20 Feb 2014 02:53:21 -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 1WGREY-0007US-CW; Thu, 20 Feb 2014 10:52:02 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1WGREH-0007TO-Ux for linaro-mm-sig@lists.linaro.org; Thu, 20 Feb 2014 10:51:46 +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 linaro-mm-sig@lists.linaro.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 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== 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 v4 2/7] 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.178 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