All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nishanth Menon <nm@ti.com>
To: linux-omap <linux-omap@vger.kernel.org>
Cc: Kevin <khilman@deeprootsystems.com>,
	Jean Pihet <jean.pihet@newoldbits.com>,
	Vishwanath Sripathy <vishwanath.bs@ti.com>,
	Tony <tony@atomide.com>
Subject: [PATCH 07/13] OMAP3: PM: allocate secure RAM context memory from low-mem
Date: Thu, 18 Nov 2010 19:54:52 -0600	[thread overview]
Message-ID: <1290131698-6194-8-git-send-email-nm@ti.com> (raw)
In-Reply-To: <1290131698-6194-1-git-send-email-nm@ti.com>

From: Tero Kristo <tero.kristo@nokia.com>

Currently memory is allocated from kernel heap, which is located at high-mem.
Low-mem allocation is needed due to limitation in ROMCode which mirrors
memory every 256MB of memory blocks back to the first block

Allocation needs to be done later in the process compared to the traditional
reserve as the size required to be allocated depends on the cpu type we are
booting on, and is done as part of the map_io path instead of the reserve
path

[nm@ti.com: modified to use memblock and rebased to 2.6.37-rc2]
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Tero Kristo <tero.kristo@nokia.com>
---
 arch/arm/mach-omap2/io.c     |   11 +++++++++++
 arch/arm/mach-omap2/pm.h     |    2 ++
 arch/arm/mach-omap2/pm34xx.c |   39 ++++++++++++++++++++++++++++++---------
 3 files changed, 43 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 40562dd..6098f81 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -41,6 +41,7 @@
 #include <plat/omap-pm.h>
 #include <plat/powerdomain.h>
 #include "powerdomains.h"
+#include "pm.h"
 
 #include <plat/clockdomain.h>
 #include "clockdomains.h"
@@ -230,6 +231,13 @@ static struct map_desc omap44xx_io_desc[] __initdata = {
 };
 #endif
 
+static void __init _omap_pm_reserve_sdram_memblock(void)
+{
+	if (cpu_is_omap34xx())
+		omap3_pm_reserve_sdram_memblock();
+
+}
+
 static void __init _omap2_map_common_io(void)
 {
 	/* Normally devicemaps_init() would flush caches and tlb after
@@ -241,6 +249,9 @@ static void __init _omap2_map_common_io(void)
 
 	omap2_check_revision();
 	omap_sram_init();
+
+	/* Allocate the secure SRAM storage after sram init and cpu detect */
+	_omap_pm_reserve_sdram_memblock();
 }
 
 #ifdef CONFIG_ARCH_OMAP2420
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 39934ec..fcca056 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -114,11 +114,13 @@ struct omap3_secure_copy_data {
 
 #if defined(CONFIG_PM)
 extern int __init omap3_secure_copy_data_set(struct omap3_secure_copy_data *d);
+extern void __init omap3_pm_reserve_sdram_memblock(void);
 #else
 static inline int omap3_secure_copy_data_set(struct omap3_secure_copy_data *d)
 {
 	return -EINVAL;
 }
+static inline void omap3_pm_reserve_sdram_memblock(void) { }
 #endif
 
 #endif
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index bbb1a40..7877f74 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -28,6 +28,7 @@
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
+#include <linux/memblock.h>
 
 #include <plat/sram.h>
 #include <plat/clockdomain.h>
@@ -60,6 +61,8 @@ static struct omap3_secure_copy_data secure_copy_data = {
 	.save_every_cycle = false,	/* explicit for readability */
 };
 
+#define OMAP3_SECURE_MAX_ALLOCATE_ADDRESS 0x8fffffff
+
 struct power_state {
 	struct powerdomain *pwrdm;
 	u32 next_state;
@@ -198,7 +201,7 @@ static void omap3_save_secure_ram_context(u32 target_mpu_state)
 		 */
 		pwrdm_set_next_pwrst(mpu_pwrdm, PWRDM_POWER_ON);
 		secure_ram_save_status = _omap_save_secure_sram((u32 *)
-				__pa(omap3_secure_ram_storage));
+				(omap3_secure_ram_storage));
 		pwrdm_set_next_pwrst(mpu_pwrdm, target_mpu_state);
 		if (!secure_copy_data.save_every_cycle)
 			secure_ram_saved = 1;
@@ -1065,14 +1068,6 @@ static int __init omap3_pm_init(void)
 	omap3_idle_init();
 
 	clkdm_add_wkdep(neon_clkdm, mpu_clkdm);
-	if (omap_type() != OMAP2_DEVICE_TYPE_GP) {
-		omap3_secure_ram_storage =
-			kmalloc(secure_copy_data.size, GFP_KERNEL);
-		if (!omap3_secure_ram_storage)
-			printk(KERN_ERR "Memory allocation failed when"
-					"allocating for secure sram context\n");
-
-	}
 
 	omap3_save_scratchpad_contents();
 err1:
@@ -1087,3 +1082,29 @@ err2:
 }
 
 late_initcall(omap3_pm_init);
+
+void __init omap3_pm_reserve_sdram_memblock(void)
+{
+	phys_addr_t size = secure_copy_data.size;
+	phys_addr_t paddr;
+	phys_addr_t max_addr = OMAP3_SECURE_MAX_ALLOCATE_ADDRESS;
+
+	if (!size || !cpu_is_omap34xx() || omap_type() == OMAP2_DEVICE_TYPE_GP)
+		return;
+
+	/*
+	 * On OMAP3 Silicon, due to ROM Code limitation, we should
+	 * not have the allocation beyond the first 256MB area.
+	 * This limitation is true for both OMAP3430 and 3630 and
+	 * all versions of the same.
+	 */
+	paddr = memblock_alloc_base(size, SZ_1M, max_addr);
+
+	if (!paddr) {
+		pr_err("%s: failed to reserve %x bytes\n",
+				__func__, size);
+		return;
+	}
+
+	omap3_secure_ram_storage = (void *)paddr;
+}
-- 
1.6.3.3


  parent reply	other threads:[~2010-11-19  1:55 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-19  1:54 [PATCH 00/13] OMAP3: OFF mode fixes Nishanth Menon
2010-11-19  1:54 ` [PATCH 01/13] OMAP3: PM: Update clean_l2 to use v7_flush_dcache_all Nishanth Menon
2010-11-19  9:46   ` Jean Pihet
2010-11-19  9:57     ` Peter 'p2' De Schrijver
2010-11-19 10:15       ` Jean Pihet
2010-11-19  1:54 ` [PATCH 02/13] OMAP3: PM: Errata i581 suppport: dll kick strategy Nishanth Menon
2010-11-24 16:51   ` Sripathy, Vishwanath
2010-11-24 17:24     ` Nishanth Menon
2010-11-25  6:39       ` Sripathy, Vishwanath
2010-11-25 12:22     ` Peter 'p2' De Schrijver
2010-11-19  1:54 ` [PATCH 03/13] OMAP3: PM: make secure ram save size configurable Nishanth Menon
2010-11-19  1:54 ` [PATCH 04/13] OMAP3: PM: Save secure RAM context before entering WFI Nishanth Menon
2010-11-19  1:54 ` [PATCH 05/13] OMAP3: PM: optional save secure RAM context every core off cycle Nishanth Menon
2010-11-19  1:54 ` [PATCH 06/13] OMAP3: PM: Fix secure save size for OMAP3 Nishanth Menon
2010-11-19  1:54 ` Nishanth Menon [this message]
2010-11-19  1:54 ` [PATCH 08/13] OMAP3: PM: Deny MPU idle while saving secure RAM Nishanth Menon
2010-11-19 17:08   ` Kevin Hilman
2010-11-19 17:16     ` Nishanth Menon
2010-11-19 17:18     ` Santosh Shilimkar
2010-11-19 17:24       ` Nishanth Menon
2010-11-19 17:28         ` Santosh Shilimkar
2010-11-19 18:51           ` Nishanth Menon
2010-11-19 20:39             ` Kevin Hilman
2010-11-19 20:54               ` Nishanth Menon
2010-11-19 21:06                 ` Kevin Hilman
2010-11-19 21:15                   ` Nishanth Menon
2010-11-20 10:04                     ` Santosh Shilimkar
2010-11-19 19:41           ` Kevin Hilman
2010-11-19 20:18             ` Nishanth Menon
2010-11-19 20:55               ` Kevin Hilman
2010-11-19 21:02                 ` Nishanth Menon
2010-11-19 21:09                   ` Kevin Hilman
2010-11-20 10:02                     ` Santosh Shilimkar
2010-11-19  1:54 ` [PATCH 09/13] OMAP3: PM: Apply errata i540 before save secure ram Nishanth Menon
2010-11-19 10:09   ` Jean Pihet
2010-11-19 12:12     ` Nishanth Menon
2010-11-19 12:54       ` Jean Pihet
2010-11-19 17:15   ` Kevin Hilman
2010-11-19 17:18     ` Nishanth Menon
2010-11-19 19:47       ` Kevin Hilman
2010-11-19 20:08         ` Nishanth Menon
2010-11-19  1:54 ` [PATCH 10/13] OMAP3: PM: Errata i582: per domain reset issue: uart Nishanth Menon
2010-11-22 18:59   ` Kevin Hilman
2010-11-19  1:54 ` [PATCH 11/13] OMAP3630: PM: Errata i608: disable RTA Nishanth Menon
2010-11-19  9:57   ` Jean Pihet
2010-11-19 12:09     ` Nishanth Menon
2010-11-19  1:54 ` [PATCH 12/13] OMAP3630: PM: Disable L2 cache while invalidating L2 cache Nishanth Menon
2010-11-19  1:54 ` [PATCH 13/13] OMAP3630: PM: Errata i583: disable coreoff if < ES1.2 Nishanth Menon
2010-11-19 10:07   ` Jean Pihet
2010-11-19 12:14     ` Nishanth Menon
2010-11-19 10:18 ` [PATCH 00/13] OMAP3: OFF mode fixes Jean Pihet
2010-11-19 12:03   ` Nishanth Menon
2010-11-19 21:20 ` Kevin Hilman
2010-11-19 21:37   ` Nishanth Menon
2010-11-20  9:56     ` Santosh Shilimkar
2010-11-22 16:08     ` Kevin Hilman
2010-11-22 19:16 ` Kevin Hilman
2010-11-23  9:02   ` Santosh Shilimkar
2010-11-23 20:35     ` Kevin Hilman
2010-11-24  5:34       ` Santosh Shilimkar
2010-11-24  9:22       ` Santosh Shilimkar
2010-11-24 17:11         ` Jean Pihet
2010-11-24 17:21           ` Nishanth Menon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1290131698-6194-8-git-send-email-nm@ti.com \
    --to=nm@ti.com \
    --cc=jean.pihet@newoldbits.com \
    --cc=khilman@deeprootsystems.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=tony@atomide.com \
    --cc=vishwanath.bs@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.