From patchwork Wed Nov 26 21:22:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Gerlach X-Patchwork-Id: 5388131 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 986C0C11AD for ; Wed, 26 Nov 2014 21:25:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AD552201B9 for ; Wed, 26 Nov 2014 21:25:07 +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 CD0AF201C7 for ; Wed, 26 Nov 2014 21:25:06 +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 1Xtk3G-0002Bp-4b; Wed, 26 Nov 2014 21:23:06 +0000 Received: from bear.ext.ti.com ([192.94.94.41]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xtk32-00027Y-Kl for linux-arm-kernel@lists.infradead.org; Wed, 26 Nov 2014 21:22:53 +0000 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id sAQLMOXO031475; Wed, 26 Nov 2014 15:22:24 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id sAQLMO3V021689; Wed, 26 Nov 2014 15:22:24 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Wed, 26 Nov 2014 15:22:24 -0600 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id sAQLMOBl010941; Wed, 26 Nov 2014 15:22:24 -0600 Received: from localhost (j-172-22-146-2.vpn.ti.com [172.22.146.2]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id sAQLMNt14176; Wed, 26 Nov 2014 15:22:23 -0600 (CST) From: Dave Gerlach To: , , , Subject: [RFC PATCH] misc: SRAM: Add option to map SRAM to allow code execution Date: Wed, 26 Nov 2014 15:22:18 -0600 Message-ID: <5cca5199a7e675d2ac35b4e7f2901b10bbd5f4be.1417029919.git.d-gerlach@ti.com> X-Mailer: git-send-email 2.1.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141126_132252_834017_E6A7B918 X-CRM114-Status: GOOD ( 14.85 ) X-Spam-Score: -5.0 (-----) Cc: Arnd Bergmann , Dave Gerlach , Tony Lindgren , Greg Kroah-Hartman , Anson.Huang@freescale.com, Russ Dill , Philipp Zabel , Shawn Guo 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_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 From: Russ Dill Allow option for mapping SRAM as executable. This is useful for platforms using the sram driver that need to run PM code from sram like several ARM platforms. Signed-off-by: Russ Dill Signed-off-by: Dave Gerlach --- This patch depends on the series here [1] and can be seen in context as a dependency for am335x suspend in this branch based on v3.18-rc6 here [2]. [1] http://lkml.iu.edu/hypermail/linux/kernel/1411.3/02782.html [2] https://github.com/dgerlach/linux-pm/tree/rfc-pm-am335x-v3.18-rc6 Documentation/devicetree/bindings/misc/sram.txt | 1 + drivers/misc/sram.c | 13 ++++++++++++- include/linux/platform_data/sram.h | 8 ++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 include/linux/platform_data/sram.h diff --git a/Documentation/devicetree/bindings/misc/sram.txt b/Documentation/devicetree/bindings/misc/sram.txt index 36cbe5a..c5ecde4 100644 --- a/Documentation/devicetree/bindings/misc/sram.txt +++ b/Documentation/devicetree/bindings/misc/sram.txt @@ -33,6 +33,7 @@ Optional properties in the area nodes: - compatible : standard definition, should contain a vendor specific string in the form ,[-] +- map-exec : Map range to allow code execution Example: diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c index 21181fa..f5822de 100644 --- a/drivers/misc/sram.c +++ b/drivers/misc/sram.c @@ -31,6 +31,7 @@ #include #include #include +#include #define SRAM_GRANULARITY 32 @@ -56,6 +57,7 @@ static int sram_reserve_cmp(void *priv, struct list_head *a, static int sram_probe(struct platform_device *pdev) { + struct sram_platform_data *pdata = pdev->dev.platform_data; void __iomem *virt_base; struct sram_dev *sram; struct resource *res; @@ -64,12 +66,21 @@ static int sram_probe(struct platform_device *pdev) struct sram_reserve *rblocks, *block; struct list_head reserve_list; unsigned int nblocks; + bool map_exec = false; int ret; INIT_LIST_HEAD(&reserve_list); + if (of_get_property(pdev->dev.of_node, "map-exec", NULL)) + map_exec = true; + if (pdata && pdata->map_exec) + map_exec |= true; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - virt_base = devm_ioremap_resource(&pdev->dev, res); + if (map_exec) + virt_base = devm_ioremap_exec_resource(&pdev->dev, res); + else + virt_base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(virt_base)) return PTR_ERR(virt_base); diff --git a/include/linux/platform_data/sram.h b/include/linux/platform_data/sram.h new file mode 100644 index 0000000..8f5c4ba --- /dev/null +++ b/include/linux/platform_data/sram.h @@ -0,0 +1,8 @@ +#ifndef _LINUX_SRAM_H +#define _LINUX_SRAM_H + +struct sram_platform_data { + bool map_exec; +}; + +#endif