diff mbox

[1/3] ARM: cache-l2x0: make the reinitialization possible

Message ID 1314690017-17590-2-git-send-email-shawn.guo@linaro.org
State New
Headers show

Commit Message

Shawn Guo Aug. 30, 2011, 7:40 a.m. UTC
If ARM core gets powered off during suspend, L2 cache controller
has to be reinitialized by resume procedure.

The patch removes __init annotation from a few initialization
functions to make the reinitialization possible.  For example,
platform resume function can call l2x0_of_init() to get L2 cache
back to work.

It also adds the empty function for l2x0_init() and l2x0_of_init(),
so that we can keep '#ifdef CONFIG_CACHE_L2X0' check in header.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 arch/arm/include/asm/hardware/cache-l2x0.h |   10 +++++++++-
 arch/arm/mm/cache-l2x0.c                   |   23 +++++++++++++----------
 2 files changed, 22 insertions(+), 11 deletions(-)

Comments

Barry Song Aug. 30, 2011, 2:08 p.m. UTC | #1
2011/8/30 Shawn Guo <shawn.guo@linaro.org>:
> If ARM core gets powered off during suspend, L2 cache controller
> has to be reinitialized by resume procedure.
>
> The patch removes __init annotation from a few initialization
> functions to make the reinitialization possible.  For example,
> platform resume function can call l2x0_of_init() to get L2 cache
> back to work.

i think it is good. and i have sent a similar patch before:

http://www.spinics.net/lists/arm-kernel/msg137372.html
[PATCH v2 3/4] ARM: L2X0: move l2x0_init out of .init section

people haven't give any feedback yet.

>
> It also adds the empty function for l2x0_init() and l2x0_of_init(),
> so that we can keep '#ifdef CONFIG_CACHE_L2X0' check in header.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
-barry
Shawn Guo Aug. 30, 2011, 2:52 p.m. UTC | #2
On Tue, Aug 30, 2011 at 10:08:59PM +0800, Barry Song wrote:
> 2011/8/30 Shawn Guo <shawn.guo@linaro.org>:
> > If ARM core gets powered off during suspend, L2 cache controller
> > has to be reinitialized by resume procedure.
> >
> > The patch removes __init annotation from a few initialization
> > functions to make the reinitialization possible.  For example,
> > platform resume function can call l2x0_of_init() to get L2 cache
> > back to work.
> 
> i think it is good. and i have sent a similar patch before:
> 
> http://www.spinics.net/lists/arm-kernel/msg137372.html
> [PATCH v2 3/4] ARM: L2X0: move l2x0_init out of .init section
> 
Since prima2 supports DT, you may also want to call l2x0_of_init()
instead of l2x0_init().  l2x0_of_init() will parse configuration from
DT and sets up tag RAM control for you.
Barry Song Aug. 30, 2011, 11:11 p.m. UTC | #3
2011/8/30 Shawn Guo <shawn.guo@freescale.com>:
> On Tue, Aug 30, 2011 at 10:08:59PM +0800, Barry Song wrote:
>> 2011/8/30 Shawn Guo <shawn.guo@linaro.org>:
>> > If ARM core gets powered off during suspend, L2 cache controller
>> > has to be reinitialized by resume procedure.
>> >
>> > The patch removes __init annotation from a few initialization
>> > functions to make the reinitialization possible.  For example,
>> > platform resume function can call l2x0_of_init() to get L2 cache
>> > back to work.
>>
>> i think it is good. and i have sent a similar patch before:
>>
>> http://www.spinics.net/lists/arm-kernel/msg137372.html
>> [PATCH v2 3/4] ARM: L2X0: move l2x0_init out of .init section
>>
> Since prima2 supports DT, you may also want to call l2x0_of_init()
> instead of l2x0_init().  l2x0_of_init() will parse configuration from
> DT and sets up tag RAM control for you.

i know that. and rob's patch did some suppport to prima2 and we were
in the loop of that patch and i have acked it if you read the mail.
i sent the patch againest the Linus's tree.

>
> --
> Regards,
> Shawn
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
Barry Song Aug. 30, 2011, 11:48 p.m. UTC | #4
2011/8/31 Barry Song <21cnbao@gmail.com>:
> 2011/8/30 Shawn Guo <shawn.guo@freescale.com>:
>> On Tue, Aug 30, 2011 at 10:08:59PM +0800, Barry Song wrote:
>>> 2011/8/30 Shawn Guo <shawn.guo@linaro.org>:
>>> > If ARM core gets powered off during suspend, L2 cache controller
>>> > has to be reinitialized by resume procedure.
>>> >
>>> > The patch removes __init annotation from a few initialization
>>> > functions to make the reinitialization possible.  For example,
>>> > platform resume function can call l2x0_of_init() to get L2 cache
>>> > back to work.
>>>
>>> i think it is good. and i have sent a similar patch before:
>>>
>>> http://www.spinics.net/lists/arm-kernel/msg137372.html
>>> [PATCH v2 3/4] ARM: L2X0: move l2x0_init out of .init section
>>>
>> Since prima2 supports DT, you may also want to call l2x0_of_init()
>> instead of l2x0_init().  l2x0_of_init() will parse configuration from
>> DT and sets up tag RAM control for you.
>
> i know that. and rob's patch did some suppport to prima2 and we were
> in the loop of that patch and i have acked it if you read the mail.
> i sent the patch againest the Linus's tree.

you might find two earlier threads about l2x0 re-init as well:

Colin Cross:
[PATCH] ARM: mm: cache-l2x0: Add support for re-enabling l2x0

Barry Song:
[RFC] ARM: l2x0: suspend/resume entries

let's wait for some feedback from Russell.

>
>>
>> --
>> Regards,
>> Shawn
-barry
diff mbox

Patch

diff --git a/arch/arm/include/asm/hardware/cache-l2x0.h b/arch/arm/include/asm/hardware/cache-l2x0.h
index 4a6004a..ed946c5 100644
--- a/arch/arm/include/asm/hardware/cache-l2x0.h
+++ b/arch/arm/include/asm/hardware/cache-l2x0.h
@@ -89,8 +89,16 @@ 
 #define L2X0_ADDR_FILTER_EN		1
 
 #ifndef __ASSEMBLY__
-extern void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask);
+#ifdef CONFIG_CACHE_L2X0
+extern void l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask);
 extern int l2x0_of_init(__u32 aux_val, __u32 aux_mask);
+#else
+static void l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask) {}
+static inline int l2x0_of_init(__u32 aux_val, __u32 aux_mask)
+{
+	return -ENOSYS;
+}
+#endif
 #endif
 
 #endif
diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
index c035b9a..3eeb025 100644
--- a/arch/arm/mm/cache-l2x0.c
+++ b/arch/arm/mm/cache-l2x0.c
@@ -280,7 +280,7 @@  static void l2x0_disable(void)
 	spin_unlock_irqrestore(&l2x0_lock, flags);
 }
 
-void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask)
+void l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask)
 {
 	__u32 aux;
 	__u32 cache_id;
@@ -350,13 +350,13 @@  void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask)
 	outer_cache.disable = l2x0_disable;
 	outer_cache.set_debug = l2x0_set_debug;
 
-	printk(KERN_INFO "%s cache controller enabled\n", type);
-	printk(KERN_INFO "l2x0: %d ways, CACHE_ID 0x%08x, AUX_CTRL 0x%08x, Cache size: %d B\n",
+	pr_info_once("%s cache controller enabled\n", type);
+	pr_info_once("l2x0: %d ways, CACHE_ID 0x%08x, AUX_CTRL 0x%08x, Cache size: %d B\n",
 			ways, cache_id, aux, l2x0_size);
 }
 
 #ifdef CONFIG_OF
-static void __init l2x0_of_setup(const struct device_node *np,
+static void l2x0_of_setup(const struct device_node *np,
 				 __u32 *aux_val, __u32 *aux_mask)
 {
 	u32 data[2] = { 0, 0 };
@@ -390,7 +390,7 @@  static void __init l2x0_of_setup(const struct device_node *np,
 	*aux_mask &= ~mask;
 }
 
-static void __init pl310_of_setup(const struct device_node *np,
+static void pl310_of_setup(const struct device_node *np,
 				  __u32 *aux_val, __u32 *aux_mask)
 {
 	u32 data[3] = { 0, 0, 0 };
@@ -424,14 +424,14 @@  static void __init pl310_of_setup(const struct device_node *np,
 	}
 }
 
-static const struct of_device_id l2x0_ids[] __initconst = {
+static const struct of_device_id l2x0_ids[] = {
 	{ .compatible = "arm,pl310-cache", .data = pl310_of_setup },
 	{ .compatible = "arm,l220-cache", .data = l2x0_of_setup },
 	{ .compatible = "arm,l210-cache", .data = l2x0_of_setup },
 	{}
 };
 
-int __init l2x0_of_init(__u32 aux_val, __u32 aux_mask)
+int l2x0_of_init(__u32 aux_val, __u32 aux_mask)
 {
 	struct device_node *np;
 	void (*l2_setup)(const struct device_node *np,
@@ -440,9 +440,12 @@  int __init l2x0_of_init(__u32 aux_val, __u32 aux_mask)
 	np = of_find_matching_node(NULL, l2x0_ids);
 	if (!np)
 		return -ENODEV;
-	l2x0_base = of_iomap(np, 0);
-	if (!l2x0_base)
-		return -ENOMEM;
+
+	if (!l2x0_base) {
+		l2x0_base = of_iomap(np, 0);
+		if (!l2x0_base)
+			return -ENOMEM;
+	}
 
 	/* L2 configuration can only be changed if the cache is disabled */
 	if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & 1)) {