Skip to contentSkip to conversation

ARM: cache-l2x0: add resume entry for l2 in secure mode

PATCH Superseded Barry Song 4 participants 8 messages Sep 21, 2011 Arm (32-bit)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Barry Song

author
#0 lore raw

PATCH 1/1 ARM: cache-l2x0: add resume entry for l2 in secure mode

we save the l2x0 registers at the first initialization, and restore them after resuming every time.

---
 arch/arm/include/asm/outercache.h |    7 +++
 arch/arm/mm/cache-l2x0.c          |   81 ++++++++++++++++++++++++++++++++----
 2 files changed, 79 insertions(+), 9 deletions(-)
arch/arm/include/asm/outercache.h +7 -0
index d838743..53426c6 100644
@@ -34,6 +34,7 @@ struct outer_cache_fns {
 	void (*sync)(void);
 #endif
 	void (*set_debug)(unsigned long);
+	void (*resume)(void);
 };
 
 #ifdef CONFIG_OUTER_CACHE
@@ -74,6 +75,12 @@ static inline void outer_disable(void)
 		outer_cache.disable();
 }
 
+static inline void outer_resume(void)
+{
+	if (outer_cache.resume)
+		outer_cache.resume();
+}
+
 #else
 
 static inline void outer_inv_range(phys_addr_t start, phys_addr_t end)
arch/arm/mm/cache-l2x0.c +72 -9

122 lines not on this page · raw message

Signature · 6 lines
1.7.1



Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
#1 lore raw

PATCH 1/1 ARM: cache-l2x0: add resume entry for l2 in secure mode

Hi Barry,

Quoted 3 lines · Barry Song

we save the l2x0 registers at the first initialization, and restore them after resuming every time.

I'm unsure that it will work for cases like imx6q, where L2 cache is retained and the controller needs to be restored at the very beginning of the resume entry (running on physical space).

Regards,
Shawn

Quoted 5 lines
---
 arch/arm/include/asm/outercache.h |    7 +++
 arch/arm/mm/cache-l2x0.c          |   81 ++++++++++++++++++++++++++++++++----
 2 files changed, 79 insertions(+), 9 deletions(-)
#2 lore raw

PATCH 1/1 ARM: cache-l2x0: add resume entry for l2 in secure mode

2011/9/21 Shawn Guo <[email protected]>:

Quoted 9 lines

Hi Barry,

Quoted 3 lines · Barry Song

we save the l2x0 registers at the first initialization, and restore them after resuming every time.

I'm unsure that it will work for cases like imx6q, where L2 cache is retained and the controller needs to be restored at the very beginning of the resume entry (running on physical space).

yes. imx6q actually needs to enable l2 earlier than cpu_resume(and mmu resume). so how about letting outer_resume support both phy and virt address restore?
for example, add early resume: outer_early_resume()

Then for your case, you use asm to "bl out_resume", then "b cpu_resume". For those chips which lose l2 in suspend cycle, people can call it in C function after cpu_resume.

Quoted 3 lines

Regards,
Shawn

-barry

#3 lore raw

PATCH 1/1 ARM: cache-l2x0: add resume entry for l2 in secure mode

Quoted 11 lines · Barry Song

2011/9/21 Shawn Guo <[email protected]>:

Quoted 9 lines

Hi Barry,

Quoted 3 lines · Barry Song

we save the l2x0 registers at the first initialization, and restore them after resuming every time.

I'm unsure that it will work for cases like imx6q, where L2 cache is retained and the controller needs to be restored at the very beginning of the resume entry (running on physical space).

Quoted 9 lines

yes. imx6q actually needs to enable l2 earlier than cpu_resume(and mmu resume). so how about letting outer_resume support both phy and virt address restore?
for example, add early resume: outer_early_resume()

Then for your case, you use asm to "bl out_resume", then "b cpu_resume". For those chips which lose l2 in suspend cycle, people can call it in C function after cpu_resume.

It's worth a try. Except that, I have another two comments on the patch.

* To be safe, all the variables used to save L2 registers need to be ensured being written external memory.

* What registers to save seems to be a platform decision. For example, you patch save 5 registers for pl310 while I only need one aux_ctrl on imx6q.

It seems that Lorenzo also has a plan working on this, so I Cc-ed him for comments.

Signature · 2 lines
Regards,
Shawn
#4 lore raw

PATCH 1/1 ARM: cache-l2x0: add resume entry for l2 in secure mode

In reply to Barry Song
Quoted 3 lines · Barry Song

yes. imx6q actually needs to enable l2 earlier than cpu_resume(and mmu resume). so how about letting outer_resume support both phy and virt address restore?

You can't call C functions in the kernel before the MMU is enabled.

#5 lore raw

PATCH 1/1 ARM: cache-l2x0: add resume entry for l2 in secure mode

2011/9/21 Russell King - ARM Linux <[email protected]>:

Quoted 6 lines · Barry Song
Quoted 3 lines

yes. imx6q actually needs to enable l2 earlier than cpu_resume(and mmu resume). so how about letting outer_resume support both phy and virt address restore?

You can't call C functions in the kernel before the MMU is enabled.

well. a direct call will fall into virtual address. then we need to transfer it to a phy address before calling it.

Quoted 1 line
#6 lore raw

PATCH 1/1 ARM: cache-l2x0: add resume entry for l2 in secure mode

Quoted 10 lines · Barry Song

2011/9/21 Russell King - ARM Linux <[email protected]>:

Quoted 6 lines · Barry Song
Quoted 3 lines

yes. imx6q actually needs to enable l2 earlier than cpu_resume(and mmu resume). so how about letting outer_resume support both phy and virt address restore?

You can't call C functions in the kernel before the MMU is enabled.

well. a direct call will fall into virtual address. then we need to transfer it to a phy address before calling it.

No. I say again, you can't call C functions in the kernel before the MMU is enabled.

C functions have literal tables that contain absolute virtual addresses of variables and such like. Without the MMU enabled, those addresses are meaningless and won't point at the right place.

#7 lore raw

PATCH 1/1 ARM: cache-l2x0: add resume entry for l2 in secure mode

In reply to Barry Song

2011/9/21 Barry Song <[email protected]>:

Quoted 10 lines

2011/9/21 Russell King - ARM Linux <[email protected]>:

Quoted 6 lines · Barry Song
Quoted 3 lines

yes. imx6q actually needs to enable l2 earlier than cpu_resume(and mmu resume). so how about letting outer_resume support both phy and virt address restore?

You can't call C functions in the kernel before the MMU is enabled.

well. a direct call will fall into virtual address. then we need to transfer it to a phy address before calling it.

stack and global variant is still a problem. then if we want a generic function for resuming before mmu on, it seems it is best to be asm codes.

Quoted 3 lines
Quoted 2 lines

-barry