From patchwork Tue Feb 18 13:37:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 24842 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 52A8A202B2 for ; Tue, 18 Feb 2014 13:41:04 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id rl12sf8573009iec.2 for ; Tue, 18 Feb 2014 05:41:03 -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=RXv/Fnt4i88zEM6C9PMjdCcQgvCrFZkfLsIVVLKauYg=; b=gFT9ytpLx/fJdbbbhyHErz/O1AWXtnfLJGcBfKTWm3x7ZfDf/I5xZgM+oKFrf+36yc J32edE+7cMIH/MLSL0G/nIabpuAn/ggq1jtMF+w0rBc9VKF9PPT6dKzQCXD4Wn0TVknv p7r/8PC3HT3vb9amSg5isCo38dA7FJ2C2NFajMdZ7SgmR4H1nQXvX7cp4bnBx7NxfNTG Y5U4x7MINSYY9LdPMxpOf2yDv3waB4WJoO4UGgdCYXpL3wW+thx9Fd72LGUn1AuzJkn2 xUpIDbcAkStCq3qUHEirtXEEMcbavqrsN53kagjn0giVeBsgDCp8P0qQrhnzzrLlsYhH MFrw== X-Gm-Message-State: ALoCoQnLR6kVlvGW78evLoOzS1VFopVzp/WufHNH0aHqQyxGSd5PYl1vzYH56j3Hu2Pf6XhmvPe+ X-Received: by 10.42.119.209 with SMTP id c17mr11662046icr.17.1392730863410; Tue, 18 Feb 2014 05:41:03 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.94.129 with SMTP id g1ls1249833qge.69.gmail; Tue, 18 Feb 2014 05:41:03 -0800 (PST) X-Received: by 10.220.11.141 with SMTP id t13mr9266955vct.30.1392730863319; Tue, 18 Feb 2014 05:41:03 -0800 (PST) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id tr5si5493752vdc.65.2014.02.18.05.41.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 05:41:03 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.173 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.173; Received: by mail-ve0-f173.google.com with SMTP id jw12so6102632veb.4 for ; Tue, 18 Feb 2014 05:41:03 -0800 (PST) X-Received: by 10.220.191.134 with SMTP id dm6mr21485471vcb.16.1392730863172; Tue, 18 Feb 2014 05:41:03 -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 u4csp217179vcz; Tue, 18 Feb 2014 05:41:02 -0800 (PST) X-Received: by 10.194.61.114 with SMTP id o18mr18296848wjr.6.1392730862206; Tue, 18 Feb 2014 05:41:02 -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 je10si12044655wic.13.2014.02.18.05.41.01 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 18 Feb 2014 05:41:02 -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 1WFktl-0001Je-Al; Tue, 18 Feb 2014 13:39:45 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1WFktf-0001JT-C1 for linaro-mm-sig@lists.linaro.org; Tue, 18 Feb 2014 13:39:39 +0000 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N1700JZC1ZYORB0@mailout1.samsung.com> for linaro-mm-sig@lists.linaro.org; Tue, 18 Feb 2014 22:40:46 +0900 (KST) X-AuditID: cbfee61b-b7f456d000006dfd-97-530362de2f2c Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id A8.D3.28157.ED263035; Tue, 18 Feb 2014 22:40:46 +0900 (KST) Received: from amdc1339.mshome.net ([106.116.147.30]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N17001N61VOJ880@mmp1.samsung.com>; Tue, 18 Feb 2014 22:40:46 +0900 (KST) 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: Tue, 18 Feb 2014 14:37:58 +0100 Message-id: <1392730681-14695-4-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1392730681-14695-1-git-send-email-m.szyprowski@samsung.com> References: <1392730681-14695-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWRa0hTYQCG+845OzsbLk7L6uhQamG1UHPajw+0sB/F168KiUDoMvWgK6dz U9EIGrZpW3lhJl6wualBDC+5aVOxcHPZzSQvKZQaMirUVeKkxDbNGf17Xt4H3h8vhQvNRDgl z8lnVTmybDHJJ95ueOiYuTQ8JW7t3mEYMA5z4XKJDodN7lEOrPRaOHDQ3wugt/wuAfs6fgD4 rsTLhQ59HReuTs5j0OaZ4kBLaSsBJ/obSdjunuXCJwtODD6aHsOg+aWWA/21kfDNtI+EVbXt BNQ9c3NhwGEj4KKzlICddUsEtPb7QXIYajO1AfRn3QjQUnUVQBMV5Rjqa5jlovteLQfZrHoS zUwNkMjeeht92vDgaPJVCQd1+BcxVBmIQxXdVoB8tkjU9fDieTqVn5TBZssLWdWxk9f4Wa/n A6SyLqLow0gNpgEWxgB4FEMfZ3w14+Af72Xez3WSBsCnhHQzYLrMQ/i/oMOYO8PNeNAiaSlj +G4ggxxKWwDjMxFBCadrSaal5+d2sZs+x3Tr27hBJugoZnZ8BQuygEaM9vcUxwCorbn9TKMx KYg8+iyzOh0dNIRbRs9nD14FBGawwwr2sMp0pTotUxEfq5Yp1AU5mbHpuQob2P7tq6gXWDXQ BWgKiEMEywexFCFHVqguVrgAQ+HiUIEkFU8RCjJkxTdZVe5VVUE2q3YBEUWI9wmcusQLQjpT ls/eYFklq/rfYhQvXAMa8s7YE+z1Ubd6/KKyvBh/9QBbFv8ibMKh2ilMOfCLJ5EnPq0fOcSN cC7bo3axYfmW5oV1icJkON1EmcbpsZlk5eCmXPtYuhaSJxkdcogScskHK7aELlh0qkZvvOyK 1LqjKxtaoKYPPzJ0qUn6zXHl4/Pr1Sbe5gmdl/4iJtRZMulRXKWW/QXgox3lswIAAA== Cc: Mark Rutland , Pawel Moll , Arnd Bergmann , Stephen Warren , Josh Cartwright , Benjamin Herrenschmidt , Tomasz Figa , Tomasz Figa , Michal Nazarewicz , Olof Johansson , Kyungmin Park , Rob Herring , Kumar Gala , Grant Likely , Ian Campbell , Sascha Hauer Subject: [Linaro-mm-sig] [PATCH v3 3/6] drivers: of: implement reserved-memory handling for dma 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.173 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 From: Josh Cartwright Add support for handling 'shared-dma-pool' reserved-memory nodes using dma exclusive driver (dma_alloc_coherent()). Signed-off-by: Josh Cartwright Signed-off-by: Marek Szyprowski --- drivers/of/Kconfig | 7 ++++ drivers/of/Makefile | 1 + drivers/of/of_reserved_mem_dma.c | 65 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 drivers/of/of_reserved_mem_dma.c diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index f25931dfc6db..7f00b801bcd2 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -80,4 +80,11 @@ config OF_RESERVED_MEM help Helpers to allow for reservation of memory regions +config OF_RESERVED_MEM_DMA + depends on OF_RESERVED_MEM + depends on HAVE_GENERIC_DMA_COHERENT + def_bool y + help + Helpers for reserving memory regions for DMA use + endmenu # OF diff --git a/drivers/of/Makefile b/drivers/of/Makefile index ed9660adad77..6142227ca854 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile @@ -10,3 +10,4 @@ obj-$(CONFIG_OF_PCI) += of_pci.o obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o obj-$(CONFIG_OF_MTD) += of_mtd.o obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o +obj-$(CONFIG_OF_RESERVED_MEM_DMA) += of_reserved_mem_dma.o diff --git a/drivers/of/of_reserved_mem_dma.c b/drivers/of/of_reserved_mem_dma.c new file mode 100644 index 000000000000..a3e596d1091d --- /dev/null +++ b/drivers/of/of_reserved_mem_dma.c @@ -0,0 +1,65 @@ +/* + * Device tree based initialization code for DMA reserved regions. + * + * Copyright (c) 2013, The Linux Foundation. All Rights Reserved. + * Copyright (c) 2013,2014 Samsung Electronics Co., Ltd. + * http://www.samsung.com + * Author: Marek Szyprowski + * Author: Josh Cartwright + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License or (at your optional) any later version of the license. + */ +#include +#include +#include +#include +#include +#include +#include +#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) +{ + int err; + + if (of_get_flat_dt_prop(node, "reusable", NULL)) + return -EINVAL; + + err = memblock_remove(rmem->base, rmem->size); + if (err == 0) { + 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); + } else { + pr_err("Reserved memory: unable to setup '%s' memory region for DMA.\n", + uname); + } + return err; +} +RESERVEDMEM_OF_DECLARE(dma, "shared-dma-pool", rmem_dma_setup);