Add support for Aurora L2 Cache Controller
Subsystems (4)
PATCH v3 1/1 Add support for Aurora L2 Cache Controller
Hello,
This a the 3rd version of the patch set (the forth if we include the RFC). See the end of this email for the changelog.
The purpose of this patch set is to add support for Aurora L2 Cache Controller used by Armada 370 and Armada XP SoCs. As it was initially designed by Marvell engineer to be compatible with the ARM L2 Cache Controller, we chose to reuse the existing code and to just extend it to support the differences and improvements brought by the Aurora controller.The diffstat looks like:
Documentation/devicetree/bindings/arm/l2cc.txt | 9 + arch/arm/boot/dts/armada-370.dtsi | 6 + arch/arm/boot/dts/armada-xp.dtsi | 7 + arch/arm/include/asm/hardware/cache-aurora-l2.h | 55 +++++ arch/arm/include/asm/hardware/cache-l2x0.h | 5 + arch/arm/mach-mvebu/Kconfig | 1 + arch/arm/mach-mvebu/irq-armada-370-xp.c | 4 + arch/arm/mm/cache-l2x0.c | 275 +++++++++++++++++++++-- 8 files changed, 341 insertions(+), 21 deletions(-)
The main differences and improvements are:
- no cache id part number available through hardware (need to get it by the DT).
- always write through mode available.
- two flavors of the controller 'outer cache' and 'system cache' (the last one meaning maintenance operations on L1 are broadcasted to the L2 and L2 performs the same operation).
- in outer cache mode, the cache maintenance operations are improved and can be done on a range inside a page and are not limited to a cache line.
- during resume the controller need to restore the ctrl register.
The first patch adds some modifications in the driver infrastructure. As most of the outer cache functions can use the Aurora improvements, we had to introduce new functions. So we thought it was better to use a outer_cache_fns field inside l2x0_of_data and just memcopy it into outer_cache depending of the type of the l2x0 cache.
Changelog:
V2 -> V3:
- Use define instead of literal value for AURORA_CTRL_FW, AURORA_WAY_SIZE_SHIFT, L2X0_WAY_SIZE_SHIFT and L2X0_CTRL_EN.
- Used ALIGN, IS_ALUGNED and PAGE_ALIGN macro instead of bitwise operation.
- Calculate the number of way for Aurora instead of using a switch case.
- removed inaccurate BUG() call and replaced them by a pr_warn if needed.
- In aurora_inv_range round the start and end addresses to cache line size. The initial code was supposed to invalidate partial line cache but actually invalidate the full line, so there was no point to do it outside the aurora_pa_range call.
- Removed the dsb call in the aurora_*_range function: the cache_sync() call inside aurora_pa_range() is enough.
- And as usual tested on Armada 370 and Armada XP boards and ran benchmark without seeing any regression. Results are updated on the wiki page.
V1 -> V2:
- Rebased L2 pach set onto v3.6-rc4.
- Changed the compatible names to be more explicit, from aurora-cache-with-outer to aurora-outer-cache , and from aurora-cache-without-outer to aurora-system-cache.
- Add an isb() after the call to mcr in aurora_broadcast_l2_commands().
- Added the tested and reviewed-by from Lior Amsalem and Yehuda Yitschak.
- Tested on Armada 370 and Armada XP boards and ran benchmark without seeing any regression.
RFC -> V1:
- Rebased the series on to V3.6-rc3
- Added missing Signed-off-by
- Corrected a compilation warning that I have missed
- Ran benchmarks without seeing any regression
Benchmarks results are visible here:
https://github.com/MISL-EBU-System-SW/mainline-public/wiki/Non-official-cache-bench-results-on-the-mainline-Linux-port-%28-kernels-3.6-rcX%29-of-Armada-XP-and-Armada-370
The git branch aurora-L2-cache-ctrl is visible at
https://github.com/MISL-EBU-System-SW/mainline-public.git
Regards,
Gregory
PATCH v3 1/6 arm: cache-l2x0: make outer_cache_fns a field of l2x0_of_data
Instead of having multiple functions belonging to outer_cache and filling this structure on the fly, use a outer_cache_fns field inside l2x0_of_data and just memcopy it into outer_cache depending of the type of the l2x0 cache. For non DT case, the former code was kept.
--- arch/arm/mm/cache-l2x0.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-)
arch/arm/mm/cache-l2x0.c +30 -8
@@ -39,7 +39,7 @@ struct l2x0_regs l2x0_saved_regs;struct l2x0_of_data {void (*setup)(const struct device_node *,u32 *,u32 *);void (*save)(void ); -void (*resume)(void ); +struct outer_cache_fns outer_cache; };static inline void cache_wait_way (void __iomem *reg,unsigned long mask)
@@ -376,6 +376,7 @@ void __init l2x0_init(void __iomem *base, u32 aux_val, u32 aux_mask)writel_relaxed (1 , l2x0_base +L2X0_CTRL ); } +#ifndef CONFIG_OF outer_cache.inv_range = l2x0_inv_range; outer_cache.clean_range = l2x0_clean_range; outer_cache.flush_range = l2x0_flush_range;
@@ -383,6 +384,7 @@ void __init l2x0_init(void __iomem *base, u32 aux_val, u32 aux_mask) outer_cache.flush_all = l2x0_flush_all; outer_cache.inv_all = l2x0_inv_all; outer_cache.disable = l2x0_disable; +#endif 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",
@@ -533,15 +535,34 @@ static void pl310_resume(void) }static const struct l2x0_of_data pl310_data = { - pl310_of_setup, - pl310_save, - pl310_resume, + .setup = pl310_of_setup, + .save = pl310_save, + .outer_cache = { + .resume = pl310_resume, + .inv_range = l2x0_inv_range, + .clean_range = l2x0_clean_range, + .flush_range = l2x0_flush_range, + .sync = l2x0_cache_sync, + .flush_all = l2x0_flush_all, + .inv_all = l2x0_inv_all, + .disable = l2x0_disable, + .set_debug = pl310_set_debug, + }, };static const struct l2x0_of_data l2x0_data = { - l2x0_of_setup, -NULL , - l2x0_resume, + .setup = l2x0_of_setup, + .save =NULL , + .outer_cache = { + .resume = l2x0_resume, + .inv_range = l2x0_inv_range, + .clean_range = l2x0_clean_range, + .flush_range = l2x0_flush_range, + .sync = l2x0_cache_sync, + .flush_all = l2x0_flush_all, + .inv_all = l2x0_inv_all, + .disable = l2x0_disable, + }, };static const struct of_device_id l2x0_ids[]__initconst = {
@@ -583,7 +604,8 @@ int __init l2x0_of_init(u32 aux_val, u32 aux_mask)l2x0_init (l2x0_base, aux_val, aux_mask); - outer_cache.resume = data->resume; +memcpy (&outer_cache, &data->outer_cache,sizeof (outer_cache)); + return 0; }#endif
Signature · 1 line
1.7.9.5
PATCH v3 1/6 arm: cache-l2x0: make outer_cache_fns a field of l2x0_of_data
Quoted 9 lines · Gregory CLEMENT
Instead of having multiple functions belonging to
outer_cacheand filling this structure on the fly, use aouter_cache_fnsfield insidel2x0_of_dataand just memcopy it intoouter_cachedepending of the type of the l2x0 cache. For non DT case, the former code was kept.Signed-off-by Gregory CLEMENT <[email protected]>Tested-and-reviewed-by Yehuda Yitschak <[email protected]>Tested-and-reviewed-by Lior Amsalem <[email protected]>
Quoted 6 lines
Cc Barry Song <[email protected]>Cc Will Deacon <[email protected]>Cc Santosh Shilimkar <[email protected]>Cc Rob Herring <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Olof Johansson <[email protected]>
Applied to:
git://git.infradead.org/users/jcooper/linux.git arm/cache-l2x0
On the advise of Will Deacon, sending through rmk's tree.
thx,
Jason.
PATCH v3 1/6 arm: cache-l2x0: make outer_cache_fns a field of l2x0_of_data
In reply to Gregory CLEMENTQuoted 8 lines · Gregory CLEMENT
Instead of having multiple functions belonging to
outer_cacheand filling this structure on the fly, use aouter_cache_fnsfield insidel2x0_of_dataand just memcopy it intoouter_cachedepending of the type of the l2x0 cache. For non DT case, the former code was kept.Signed-off-by Gregory CLEMENT <[email protected]>Tested-and-reviewed-by Yehuda Yitschak <[email protected]>Tested-and-reviewed-by Lior Amsalem <[email protected]>
Just tried pulling this and got conflicts, so I looked a little deeper at this. This patch advertises itself as merely changing the way outer_cache is initialized:
arch/arm/mm/cache-l2x0.c void __init l2x0_init(void __iomem *base, u32 aux_val, u32 aux_mask) · line 387
Quoted 9 lines
arch/arm/mm/cache-l2x0.c +2
-0+#ifndef CONFIG_OF outer_cache.inv_range = l2x0_inv_range; outer_cache.clean_range = l2x0_clean_range; outer_cache.flush_range = l2x0_flush_range;@@ -383,6 +384,7 @@ void __init l2x0_init(void __iomem *base, u32 aux_val, u32 aux_mask) outer_cache.flush_all = l2x0_flush_all; outer_cache.inv_all = l2x0_inv_all; outer_cache.disable = l2x0_disable; +#endif
It disables this assignment...
Quoted 1 line
arch/arm/mm/cache-l2x0.c +0
-0static const struct l2x0_of_data pl310_data = {
...
arch/arm/mm/cache-l2x0.c static void pl310_resume(void) · line 541
Quoted 2 lines
arch/arm/mm/cache-l2x0.c +2
-0+ .outer_cache = { + .resume = pl310_resume,
moves the resume here...
arch/arm/mm/cache-l2x0.c static void pl310_resume(void) · line 548
Quoted 7 lines
arch/arm/mm/cache-l2x0.c +7
-0+ .inv_range = l2x0_inv_range, + .clean_range = l2x0_clean_range, + .flush_range = l2x0_flush_range, + .sync = l2x0_cache_sync, + .flush_all = l2x0_flush_all, + .inv_all = l2x0_inv_all, + .disable = l2x0_disable,
initializes all these values that were previously set...
arch/arm/mm/cache-l2x0.c static void pl310_resume(void) · line 549
Quoted 1 line
arch/arm/mm/cache-l2x0.c +1
-0+ .set_debug = pl310_set_debug,
and adds one extra, which gets added because we blat over the assignment of it in l2x0_init() after we read the ID from the device.
Plus, doesn't this patch break systems which may enable CONFIG_OF, but don't supply a DT file, relying on the old way to initialize the L2 cache operations functions?
This patch just looks buggy to me.
PATCH v3 1/6 arm: cache-l2x0: make outer_cache_fns a field of l2x0_of_data
Quoted 25 lines · Gregory CLEMENT
Quoted 8 lines
Instead of having multiple functions belonging to
outer_cacheand filling this structure on the fly, use aouter_cache_fnsfield insidel2x0_of_dataand just memcopy it intoouter_cachedepending of the type of the l2x0 cache. For non DT case, the former code was kept.Signed-off-by Gregory CLEMENT <[email protected]>Tested-and-reviewed-by Yehuda Yitschak <[email protected]>Tested-and-reviewed-by Lior Amsalem <[email protected]>Just tried pulling this and got conflicts, so I looked a little deeper at this. This patch advertises itself as merely changing the way
outer_cacheis initialized:Review void __init l2x0_init(void __iomem *base, u32 aux_val, u32 aux_mask) · line 387
Quoted 9 lines
(quoted diff) +2
-0+#ifndef CONFIG_OF outer_cache.inv_range = l2x0_inv_range; outer_cache.clean_range = l2x0_clean_range; outer_cache.flush_range = l2x0_flush_range;@@ -383,6 +384,7 @@ void __init l2x0_init(void __iomem *base, u32 aux_val, u32 aux_mask) outer_cache.flush_all = l2x0_flush_all; outer_cache.inv_all = l2x0_inv_all; outer_cache.disable = l2x0_disable; +#endifIt disables this assignment...
Quoted 6 lines
Quoted 1 line
(quoted diff) +0
-0static const struct l2x0_of_data pl310_data = {...
Review
Quoted 2 lines
(quoted diff) +2
-0+ .outer_cache = { + .resume = pl310_resume,moves the resume here...
At the end of l2x0_of_init(), resume were assigned in the outer_cache. It is the only place where this field is used.This patch introduces an outer_cache_fn field. It seemed logical to use it. I don't see where is the problem here.
Quoted 10 lines
Review
Quoted 8 lines
(quoted diff) +7
-0+ .inv_range = l2x0_inv_range, + .clean_range = l2x0_clean_range, + .flush_range = l2x0_flush_range, + .sync = l2x0_cache_sync, + .flush_all = l2x0_flush_all, + .inv_all = l2x0_inv_all, + .disable = l2x0_disable,initializes all these values that were previously set...
Well if CONFIG_OF is not set then these part of the code is not compiled. The values arr not initialized here. If CONFIG_OF is set then these values are not assigned before (due to the #ifndef CONFIG_OF).
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +1
-0+ .set_debug = pl310_set_debug,and adds one extra, which gets added because we blat over the assignment of it in
l2x0_init()after we read the ID from the device.
As set_debug is also a field of outer_cache_fn field, it seemed logical to assign it here.
Quoted 4 lines
Plus, doesn't this patch break systems which may enable
CONFIG_OF, but don't supply a DT file, relying on the old way to initialize the L2 cache operations functions?
Right I didn't think that we would want enable CONFIG_OF without using a DT file. But indeed it is still possible. I can replace the ifndef CONFIG_OF by a flag set in l2x0_of_init.
What do you think about this, then:
Quoted 1 line
From
76ab86c053edd47459332665ba032ca93826f23cMon Sep 17 00:00:00 2001
From: Gregory CLEMENT <[email protected]>
Date: Tue, 7 Aug 2012 10:39:41 +0200
Subject: [PATCH] arm: cache-l2x0: make outer_cache_fns a field of
l2x0_of_data
Instead of having multiple functions belonging to outer_cache and filling this structure on the fly, use a outer_cache_fns field inside l2x0_of_data and just memcopy it into outer_cache depending of the type of the l2x0 cache. For non DT case, the former code was kept.
--- arch/arm/mm/cache-l2x0.c | 55 +++++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 15 deletions(-)
arch/arm/mm/cache-l2x0.c +40 -15
@@ -39,8 +39,9 @@ struct l2x0_regs l2x0_saved_regs;struct l2x0_of_data {void (*setup)(const struct device_node *,u32 *,u32 *);void (*save)(void ); -void (*resume)(void ); +struct outer_cache_fns outer_cache; }; +static bool of_init = false;static inline void cache_wait_way (void __iomem *reg,unsigned long mask) {
@@ -376,13 +377,15 @@ void __init l2x0_init(void __iomem *base, u32 aux_val, u32 aux_mask)writel_relaxed (1 , l2x0_base +L2X0_CTRL ); } - outer_cache.inv_range = l2x0_inv_range; - outer_cache.clean_range = l2x0_clean_range; - outer_cache.flush_range = l2x0_flush_range; - outer_cache.sync = l2x0_cache_sync; - outer_cache.flush_all = l2x0_flush_all; - outer_cache.inv_all = l2x0_inv_all; - outer_cache.disable = l2x0_disable; +if (!of_init) { + outer_cache.inv_range = l2x0_inv_range; + outer_cache.clean_range = l2x0_clean_range; + outer_cache.flush_range = l2x0_flush_range; + outer_cache.sync = l2x0_cache_sync; + outer_cache.flush_all = l2x0_flush_all; + outer_cache.inv_all = l2x0_inv_all; + outer_cache.disable = l2x0_disable; + }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",
@@ -533,15 +536,34 @@ static void pl310_resume(void) }static const struct l2x0_of_data pl310_data = { - pl310_of_setup, - pl310_save, - pl310_resume, + .setup = pl310_of_setup, + .save = pl310_save, + .outer_cache = { + .resume = pl310_resume, + .inv_range = l2x0_inv_range, + .clean_range = l2x0_clean_range, + .flush_range = l2x0_flush_range, + .sync = l2x0_cache_sync, + .flush_all = l2x0_flush_all, + .inv_all = l2x0_inv_all, + .disable = l2x0_disable, + .set_debug = pl310_set_debug, + }, };static const struct l2x0_of_data l2x0_data = { - l2x0_of_setup, -NULL , - l2x0_resume, + .setup = l2x0_of_setup, + .save =NULL , + .outer_cache = { + .resume = l2x0_resume, + .inv_range = l2x0_inv_range, + .clean_range = l2x0_clean_range, + .flush_range = l2x0_flush_range, + .sync = l2x0_cache_sync, + .flush_all = l2x0_flush_all, + .inv_all = l2x0_inv_all, + .disable = l2x0_disable, + }, };static const struct of_device_id l2x0_ids[]__initconst = {
@@ -581,9 +603,12 @@ int __init l2x0_of_init(u32 aux_val, u32 aux_mask)if (data->save) data->save (); +/* */ + of_init = true;l2x0_init (l2x0_base, aux_val, aux_mask); - outer_cache.resume = data->resume; +memcpy (&outer_cache, &data->outer_cache,sizeof (outer_cache)); + return 0; }#endif
Signature · 1 line
1.7.9.5
PATCH v3 2/6 arm: cache-l2x0: add an optional register to save/restore
In reply to Gregory CLEMENT--- arch/arm/include/asm/hardware/cache-l2x0.h | 1 + 1 file changed, 1 insertion(+)
arch/arm/include/asm/hardware/cache-l2x0.h +1 -0
@@ -126,6 +126,7 @@ struct l2x0_regs {unsigned long filter_end;unsigned long prefetch_ctrl;unsigned long pwr_ctrl; +unsigned long ctrl; };extern struct l2x0_regs l2x0_saved_regs;
Signature · 1 line
1.7.9.5
PATCH v3 2/6 arm: cache-l2x0: add an optional register to save/restore
Quoted 9 lines · Gregory CLEMENT
Signed-off-by Gregory CLEMENT <[email protected]>Tested-and-reviewed-by Yehuda Yitschak <[email protected]>Tested-and-reviewed-by Lior Amsalem <[email protected]>Cc Barry Song <[email protected]>Cc Rob Herring <[email protected]>Cc Santosh Shilimkar <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Olof Johansson <[email protected]>
Applied to:
git://git.infradead.org/users/jcooper/linux.git arm/cache-l2x0
also going through rmk's tree.
thx,
Jason.
PATCH v3 3/6 arm: cache-l2x0: add support for Aurora L2 cache ctrl
In reply to Gregory CLEMENTAurora Cache Controller was designed to be compatible with the ARM L2 Cache Controller. It comes with some difference or improvement such as:
- no cache id part number available through hardware (need to get it by the DT).
- always write through mode available.
- two flavors of the controller outer cache and system cache (meaning maintenance operations on L1 are broadcasted to the L2 and L2 performs the same operation).
- in outer cache mode, the cache maintenance operations are improved and can be done on a range inside a page and are not limited to a cache line.
--- arch/arm/include/asm/hardware/cache-aurora-l2.h | 55 ++++++ arch/arm/include/asm/hardware/cache-l2x0.h | 4 + arch/arm/mm/cache-l2x0.c | 237 +++++++++++++++++++++-- 3 files changed, 283 insertions(+), 13 deletions(-) create mode 100644 arch/arm/include/asm/hardware/cache-aurora-l2.h
arch/arm/include/asm/hardware/cache-aurora-l2.h new file +55 -0
@@ -0,0 +1,55 @@ +/* +* AURORA shared L2 cache controller support +* +* Copyright (C) 2012 Marvell +* +* Yehuda Yitschak <[email protected]> +* Gregory CLEMENT <[email protected]> +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ + +#ifndef __ASM_ARM_HARDWARE_AURORA_L2_H +#define __ASM_ARM_HARDWARE_AURORA_L2_H + +#define AURORA_SYNC_REG 0x700 +#define AURORA_RANGE_BASE_ADDR_REG 0x720 +#define AURORA_FLUSH_PHY_ADDR_REG 0x7f0 +#define AURORA_INVAL_RANGE_REG 0x774 +#define AURORA_CLEAN_RANGE_REG 0x7b4 +#define AURORA_FLUSH_RANGE_REG 0x7f4 + +#define AURORA_ACR_REPLACEMENT_OFFSET 27 +#define AURORA_ACR_REPLACEMENT_MASK \ + (0x3 << AURORA_ACR_REPLACEMENT_OFFSET) +#define AURORA_ACR_REPLACEMENT_TYPE_WAYRR \ + (0 << AURORA_ACR_REPLACEMENT_OFFSET) +#define AURORA_ACR_REPLACEMENT_TYPE_LFSR \ + (1 << AURORA_ACR_REPLACEMENT_OFFSET) +#define AURORA_ACR_REPLACEMENT_TYPE_SEMIPLRU \ + (3 << AURORA_ACR_REPLACEMENT_OFFSET) + +#define AURORA_ACR_FORCE_WRITE_POLICY_OFFSET 0 +#define AURORA_ACR_FORCE_WRITE_POLICY_MASK \ + (0x3 << AURORA_ACR_FORCE_WRITE_POLICY_OFFSET) +#define AURORA_ACR_FORCE_WRITE_POLICY_DIS \ + (0 << AURORA_ACR_FORCE_WRITE_POLICY_OFFSET) +#define AURORA_ACR_FORCE_WRITE_BACK_POLICY \ + (1 << AURORA_ACR_FORCE_WRITE_POLICY_OFFSET) +#define AURORA_ACR_FORCE_WRITE_THRO_POLICY \ + (2 << AURORA_ACR_FORCE_WRITE_POLICY_OFFSET) + +#define MAX_RANGE_SIZE 1024 + +#define AURORA_WAY_SIZE_SHIFT 2 + +#define AURORA_CTRL_FW 0x100 + +/* chose a number outside L2X0_CACHE_ID_PART_MASK to be sure to make +* the distinction between a number coming from hardware and a number +* coming from the device tree */ +#define AURORA_CACHE_ID 0x100 + +#endif /* __ASM_ARM_HARDWARE_AURORA_L2_H */
arch/arm/include/asm/hardware/cache-l2x0.h +4 -0
@@ -102,6 +102,10 @@#define L2X0_ADDR_FILTER_EN 1 +#define L2X0_CTRL_EN 1 + +#define L2X0_WAY_SIZE_SHIFT 3 +#ifndef __ASSEMBLY__extern void __init l2x0_init (void __iomem *base,u32 aux_val,u32 aux_mask);#if defined(CONFIG_CACHE_L2X0 ) && defined(CONFIG_OF )
arch/arm/mm/cache-l2x0.c +224 -13
353 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v3 3/6 arm: cache-l2x0: add support for Aurora L2 cache ctrl
Quoted 23 lines · Gregory CLEMENT
Aurora Cache Controller was designed to be compatible with the ARM L2 Cache Controller. It comes with some difference or improvement such as:
- no cache id part number available through hardware (need to get it by the DT).
- always write through mode available.
- two flavors of the controller outer cache and system cache (meaning maintenance operations on L1 are broadcasted to the L2 and L2 performs the same operation).
- in outer cache mode, the cache maintenance operations are improved and can be done on a range inside a page and are not limited to a cache line.Signed-off-by Gregory CLEMENT <[email protected]>Signed-off-by Yehuda Yitschak <[email protected]>Tested-and-reviewed-by Lior Amsalem <[email protected]>Cc Barry Song <[email protected]>Cc Will Deacon <[email protected]>Cc Santosh Shilimkar <[email protected]>Cc Rob Herring <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Olof Johansson <[email protected]>
Quoted 6 lines
--- arch/arm/include/asm/hardware/cache-aurora-l2.h | 55 ++++++ arch/arm/include/asm/hardware/cache-l2x0.h | 4 + arch/arm/mm/cache-l2x0.c | 237 +++++++++++++++++++++-- 3 files changed, 283 insertions(+), 13 deletions(-) create mode 100644 arch/arm/include/asm/hardware/cache-aurora-l2.h
This is looking pretty good now:
Cheers,
Will
PATCH v3 3/6 arm: cache-l2x0: add support for Aurora L2 cache ctrl
Quoted 31 lines · Will Deacon
Quoted 23 lines · Gregory CLEMENT
Aurora Cache Controller was designed to be compatible with the ARM L2 Cache Controller. It comes with some difference or improvement such as:
- no cache id part number available through hardware (need to get it by the DT).
- always write through mode available.
- two flavors of the controller outer cache and system cache (meaning maintenance operations on L1 are broadcasted to the L2 and L2 performs the same operation).
- in outer cache mode, the cache maintenance operations are improved and can be done on a range inside a page and are not limited to a cache line.Signed-off-by Gregory CLEMENT <[email protected]>Signed-off-by Yehuda Yitschak <[email protected]>Tested-and-reviewed-by Lior Amsalem <[email protected]>Cc Barry Song <[email protected]>Cc Will Deacon <[email protected]>Cc Santosh Shilimkar <[email protected]>Cc Rob Herring <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Olof Johansson <[email protected]>Quoted 6 lines
--- arch/arm/include/asm/hardware/cache-aurora-l2.h | 55 ++++++ arch/arm/include/asm/hardware/cache-l2x0.h | 4 + arch/arm/mm/cache-l2x0.c | 237 +++++++++++++++++++++-- 3 files changed, 283 insertions(+), 13 deletions(-) create mode 100644 arch/arm/include/asm/hardware/cache-aurora-l2.h
Quoted 4 lines
This is looking pretty good now:
Reviewed-by Will Deacon <[email protected]>
Thanks. I guess you also reviewed patches 1 and 2, don't you?
And then where should I push my series?
Patches 1,2 and 3 depend of ARM subsystem so they should be submitted using Russell King's patch state system. Patches 4 and 5 are more soc specific and should go to marvell tree and then arm-soc. But patches 4 and 5 are meaningless if the first patches are not applied. What is the good practice?
Quoted 9 lines
Cheers,
Will
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 4 lines
Gregory Clement, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH v3 3/6 arm: cache-l2x0: add support for Aurora L2 cache ctrl
Quoted 14 lines · Gregory CLEMENT
Quoted 13 lines · Will Deacon
Quoted 12 lines · Gregory CLEMENT
Aurora Cache Controller was designed to be compatible with the ARM L2 Cache Controller. It comes with some difference or improvement such as:
- no cache id part number available through hardware (need to get it by the DT).
- always write through mode available.
- two flavors of the controller outer cache and system cache (meaning maintenance operations on L1 are broadcasted to the L2 and L2 performs the same operation).
- in outer cache mode, the cache maintenance operations are improved and can be done on a range inside a page and are not limited to a cache line.
[...]
Quoted 4 lines
Quoted 2 lines
Reviewed-by Will Deacon <[email protected]>Thanks. I guess you also reviewed patches 1 and 2, don't you?
Well I didn't really read those because they looked fairly boring :) Boring is good though, so I doubt they're problematic.
Quoted 7 lines
And then where should I push my series?
Patches 1,2 and 3 depend of ARM subsystem so they should be submitted using Russell King's patch state system. Patches 4 and 5 are more soc specific and should go to marvell tree and then arm-soc. But patches 4 and 5 are meaningless if the first patches are not applied. What is the good practice?
When I end up in situations like this, I usually prepare a branch for Russell containing the patches that should go via his tree. Then, send him a pull request and once he has pulled it, Arnd and Olof can pull the same branch into arm-soc as a baseline branch. You can then base your other patches on top of that.
Make sense?
Will
PATCH v3 3/6 arm: cache-l2x0: add support for Aurora L2 cache ctrl
In reply to Gregory CLEMENTQuoted 17 lines · Gregory CLEMENT
Aurora Cache Controller was designed to be compatible with the ARM L2 Cache Controller. It comes with some difference or improvement such as:
- no cache id part number available through hardware (need to get it by the DT).
- always write through mode available.
- two flavors of the controller outer cache and system cache (meaning maintenance operations on L1 are broadcasted to the L2 and L2 performs the same operation).
- in outer cache mode, the cache maintenance operations are improved and can be done on a range inside a page and are not limited to a cache line.Signed-off-by Gregory CLEMENT <[email protected]>Signed-off-by Yehuda Yitschak <[email protected]>Tested-and-reviewed-by Lior Amsalem <[email protected]>
Quoted 6 lines
Cc Barry Song <[email protected]>Cc Will Deacon <[email protected]>Cc Santosh Shilimkar <[email protected]>Cc Rob Herring <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Olof Johansson <[email protected]>
Applied to:
git://git.infradead.org/users/jcooper/linux.git kirkwood/dt
thx,
Jason.
PATCH v3 3/6 arm: cache-l2x0: add support for Aurora L2 cache ctrl
In reply to Gregory CLEMENTarch/arm/mm/cache-l2x0.c static void l2x0_flush_range(unsigned long start, unsigned long end) · line 284
Quoted 5 lines · Gregory CLEMENT
arch/arm/mm/cache-l2x0.c +1
-0@@ -275,6 +281,112 @@ static void l2x0_flush_range(unsigned long start, unsigned long end)cache_sync ();raw_spin_unlock_irqrestore (&l2x0_lock, flags); } +/*
Where's the blank line?
arch/arm/mm/cache-l2x0.c static void l2x0_flush_range(unsigned long start, unsigned long end) · line 295
Quoted 11 lines
arch/arm/mm/cache-l2x0.c +11
-0+* Note that the end addresses passed to Linux primitives are +* noninclusive, while the hardware cache range operations use +* inclusive start and end addresses. +*/ +static unsigned long calc_range_end (unsigned long start,unsigned long end) +{ +if (!IS_ALIGNED (start,CACHE_LINE_SIZE )) { +pr_warn ("%s: start address not align on a cache line size\n" , + __func__); + start &= ~(CACHE_LINE_SIZE -1 ); + };
No semicolon here. But why is this check even here?
arch/arm/mm/cache-l2x0.c static void l2x0_flush_range(unsigned long start, unsigned long end) · line 301
Quoted 6 lines
arch/arm/mm/cache-l2x0.c +6
-0+ +if (!IS_ALIGNED (end,CACHE_LINE_SIZE )) { +pr_warn ("%s: end address not align on a cache line size\n" , + __func__); + end = (PAGE_ALIGN (end)); + }
And this one - and why when it fails do you align to a page not a cache line?
arch/arm/mm/cache-l2x0.c static void l2x0_flush_range(unsigned long start, unsigned long end) · line 350
Quoted 13 lines
arch/arm/mm/cache-l2x0.c +13
-0+static void aurora_inv_range (unsigned long start,unsigned long end) +{ +/* +* round start and end adresses up to cache line size +*/ + start &= ~(CACHE_LINE_SIZE -1 ); + end =ALIGN (end,CACHE_LINE_SIZE ); + +/* +* Invalidate all full cache lines between 'start' and 'end'. +*/ +while (start < end) { +unsigned long range_end =calc_range_end (start, end);
And note that you (above) guarantee that the start/end addresses are cache line aligned. It only goes wrong if your calc_range_end() fails - but isn't that a matter of internal proving that your code is correct, rather than lumbering all kernels with such checking?
PATCH v3 3/6 arm: cache-l2x0: add support for Aurora L2 cache ctrl
Quoted 7 lines · Gregory CLEMENT
arch/arm/mm/cache-l2x0.c static void l2x0_flush_range(unsigned long start, unsigned long end) · line 284
Quoted 5 lines
arch/arm/mm/cache-l2x0.c +1
-0@@ -275,6 +281,112 @@ static void l2x0_flush_range(unsigned long start, unsigned long end)cache_sync ();raw_spin_unlock_irqrestore (&l2x0_lock, flags); } +/* Where's the blank line?
I will fix it
Quoted 15 lines
arch/arm/mm/cache-l2x0.c static void l2x0_flush_range(unsigned long start, unsigned long end) · line 295
Quoted 12 lines
arch/arm/mm/cache-l2x0.c +11
-0+* Note that the end addresses passed to Linux primitives are +* noninclusive, while the hardware cache range operations use +* inclusive start and end addresses. +*/ +static unsigned long calc_range_end (unsigned long start,unsigned long end) +{ +if (!IS_ALIGNED (start,CACHE_LINE_SIZE )) { +pr_warn ("%s: start address not align on a cache line size\n" , + __func__); + start &= ~(CACHE_LINE_SIZE -1 ); + };No semicolon here. But why is this check even here?
I will remove it, see below.
Quoted 9 lines
arch/arm/mm/cache-l2x0.c static void l2x0_flush_range(unsigned long start, unsigned long end) · line 301
Quoted 6 lines
arch/arm/mm/cache-l2x0.c +6
-0+ +if (!IS_ALIGNED (end,CACHE_LINE_SIZE )) { +pr_warn ("%s: end address not align on a cache line size\n" , + __func__); + end = (PAGE_ALIGN (end)); + }And this one - and why when it fails do you align to a page not a cache line?
I guess it was a bad copy/paste. it should be
end = ALIGN(end, CACHE_LINE_SIZE);
But I will remove it too.
Quoted 11 lines
Quoted 11 lines
arch/arm/mm/cache-l2x0.c +10
-0+static void aurora_inv_range (unsigned long start,unsigned long end) +{ +/* +* round start and end adresses up to cache line size +*/ + start &= ~(CACHE_LINE_SIZE -1 ); + end =ALIGN (end,CACHE_LINE_SIZE ); + +/* +* Invalidate all full cache lines between 'start' and 'end'.
Quoted 9 lines
arch/arm/mm/cache-l2x0.c static void l2x0_flush_range(unsigned long start, unsigned long end) · line 350
Quoted 3 lines
arch/arm/mm/cache-l2x0.c +3
-0+*/ +while (start < end) { +unsigned long range_end =calc_range_end (start, end);And note that you (above) guarantee that the start/end addresses are cache line aligned. It only goes wrong if your
calc_range_end()fails - but isn't that a matter of internal proving that your code is correct, rather than lumbering all kernels with such checking?
This part of the code was almost the same than the one in cache-feroceon-l2.c. In first the versions there was BUG_ON() to test if start and end were aligned on a cache line. Will Deacon proposed to fix the addresses instead of rising an oops. But in the end, we can just remove it, right.
I am going to submit an updated series which I hope will meet your expectation.
Signature · 4 lines
Gregory Clement, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH v3 4/6 arm: mvebu: add L2 cache support
In reply to Gregory CLEMENT--- arch/arm/mach-mvebu/Kconfig | 1 + arch/arm/mach-mvebu/irq-armada-370-xp.c | 4 ++++ 2 files changed, 5 insertions(+)
arch/arm/mach-mvebu/Kconfig +1 -0
@@ -6,6 +6,7 @@ config MACH_ARMADA_370_XP bool "Marvell Armada 370 and Aramada XP boards" select ARMADA_370_XP_TIMER select CPU_V7 + select CACHE_L2X0 help Say 'Y' here if you want your kernel to support boards based on
arch/arm/mach-mvebu/irq-armada-370-xp.c +4 -0
@@ -24,6 +24,7 @@#include <linux/irqdomain.h> #include <asm/mach/arch.h> #include <asm/exception.h> +#include <asm/hardware/cache-l2x0.h> /* Interrupt Controller Registers Map */ #define ARMADA_370_XP_INT_SET_MASK_OFFS (0x48)
@@ -130,4 +131,7 @@ static const struct of_device_id mpic_of_match[] __initconst = {void __init armada_370_xp_init_irq (void ) {of_irq_init (mpic_of_match); +#ifdef CONFIG_CACHE_L2X0 +l2x0_of_init (0 , ~0UL ); +#endif }
Signature · 1 line
1.7.9.5
PATCH v3 4/6 arm: mvebu: add L2 cache support
Quoted 8 lines · Gregory CLEMENT
Signed-off-by Gregory CLEMENT <[email protected]>Tested-and-reviewed-by Yehuda Yitschak <[email protected]>Tested-and-reviewed-by Lior Amsalem <[email protected]>Cc Jason Cooper <[email protected]>Cc Andrew Lunn <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Olof Johansson <[email protected]>
Applied to:
git://git.infradead.org/users/jcooper/linux.git kirkwood/dt
thx,
Jason.
PATCH v3 5/6 arm: mvebu: add Aurora L2 Cache Controller to the DT
In reply to Gregory CLEMENT--- arch/arm/boot/dts/armada-370.dtsi | 6 ++++++ arch/arm/boot/dts/armada-xp.dtsi | 7 +++++++ 2 files changed, 13 insertions(+)
arch/arm/boot/dts/armada-370.dtsi +6 -0
@@ -20,6 +20,12 @@ / { model = "Marvell Armada 370 family SoC"; compatible = "marvell,armada370", "marvell,armada-370-xp"; + L2: l2-cache { + compatible = "marvell,aurora-outer-cache"; + reg = <0xd0008000 0x1000>; + cache-id-part = <0x100>; + wt-override; + }; mpic: interrupt-controller at d0020000 { reg = <0xd0020a00 0x1d0>,
arch/arm/boot/dts/armada-xp.dtsi +7 -0
@@ -22,6 +22,13 @@ model = "Marvell Armada XP family SoC"; compatible = "marvell,armadaxp", "marvell,armada-370-xp"; + L2: l2-cache { + compatible = "marvell,aurora-system-cache"; + reg = <0xd0008000 0x1000>; + cache-id-part = <0x100>; + wt-override; + }; + mpic: interrupt-controller at d0020000 { reg = <0xd0020a00 0x1d0>, <0xd0021870 0x58>;
Signature · 1 line
1.7.9.5
PATCH v3 5/6 arm: mvebu: add Aurora L2 Cache Controller to the DT
Quoted 9 lines · Gregory CLEMENT
Signed-off-by Gregory CLEMENT <[email protected]>Signed-off-by Yehuda Yitschak <[email protected]>Tested-and-reviewed-by Yehuda Yitschak <[email protected]>Tested-and-reviewed-by Lior Amsalem <[email protected]>Cc Jason Cooper <[email protected]>Cc Andrew Lunn <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Olof Johansson <[email protected]>
Applied to:
git://git.infradead.org/users/jcooper/linux.git kirkwood/dt
thx,
Jason.
PATCH v3 6/6 arm: l2x0: add aurora related properties to OF binding
In reply to Gregory CLEMENTAurora is a L2 Cache Controller designed to be compatible with the L2x0 Cache Controller. L2X0 OF bindings are extended to support some specificity of Aurora (no cache id part number available through hardware, always write through mode, choice between outer cache and system cache).
--- Documentation/devicetree/bindings/arm/l2cc.txt | 9 +++++++++ 1 file changed, 9 insertions(+)
Documentation/devicetree/bindings/arm/l2cc.txt +9 -0
@@ -10,6 +10,12 @@ Required properties: "arm,pl310-cache" "arm,l220-cache" "arm,l210-cache" + "marvell,aurora-system-cache": Marvell Controller designed to be + compatible with the ARM one, with system cache mode (meaning + maintenance operations on L1 are broadcasted to the L2 and L2 + performs the same operation). + "marvell,"aurora-outer-cache: Marvell Controller designed to be + compatible with the ARM one with outer cache mode. - cache-unified : Specifies the cache is a unified cache. - cache-level : Should be set to 2 for a level 2 cache. - reg : Physical base address and size of cache controller's memory mapped
@@ -29,6 +35,9 @@ Optional properties: filter. Addresses in the filter window are directed to the M1 port. Other addresses will go to the M0 port. - interrupts : 1 combined interrupt. +- cache-id-part: cache id part number to be used if it is not present + on hardware +- wt-override: If present then L2 is forced to Write through mode Example:
Signature · 1 line
1.7.9.5
PATCH v3 6/6 arm: l2x0: add aurora related properties to OF binding
Quoted 10 lines · Gregory CLEMENT
Aurora is a L2 Cache Controller designed to be compatible with the L2x0 Cache Controller. L2X0 OF bindings are extended to support some specificity of Aurora (no cache id part number available through hardware, always write through mode, choice between outer cache and system cache).
Signed-off-by Gregory CLEMENT <[email protected]>Signed-off-by Yehuda Yitschak <[email protected]>Tested-and-reviewed-by Lior Amsalem <[email protected]>
Quoted 7 lines
Cc Grant Likely <[email protected]>Cc Rob Herring <[email protected]>Cc Russell King <[email protected]>Cc Barry Song <[email protected]>Cc Will Deacon <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Olof Johansson <[email protected]>
Applied to:
git://git.infradead.org/users/jcooper/linux.git kirkwood/dt
thx,
Jason.