--- zzzz-none-000/linux-4.19.183/arch/arm/mm/cache-l2x0.c 2021-03-24 10:07:39.000000000 +0000 +++ bcm63-7530ax-756/linux-4.19.183/arch/arm/mm/cache-l2x0.c 2023-06-28 08:54:18.000000000 +0000 @@ -16,6 +16,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#if defined(CONFIG_AVM_FASTIRQ) +#include +#define CLIENT_FIQ_PRIO FIQ_PRIO_WATCHDOG +#endif + #include #include #include @@ -46,6 +52,17 @@ struct outer_cache_fns outer_cache; }; +#if defined(CONFIG_AVM_FASTIRQ) + +#include +#define __BUILD_AVM_CONTEXT_FUNC(func) firq_##func + +#else + +#define __BUILD_AVM_CONTEXT_FUNC(func) func + +#endif + #define CACHE_LINE_SIZE 32 static void __iomem *l2x0_base; @@ -167,6 +184,19 @@ l2x0_pmu_resume(); } +#if defined(CONFIG_BCM_KF_L2CACHE_OPTIMIZATION) +static unsigned long l2c_spin_lock_irqsave(void) +{ + unsigned long gb_flags; + __BUILD_AVM_CONTEXT_FUNC(raw_spin_lock_irqsave)(&l2x0_lock, gb_flags); + return gb_flags; +} + +static void l2c_spin_unlock_irqrestore(unsigned long gb_flags) +{ + __BUILD_AVM_CONTEXT_FUNC(raw_spin_unlock_irqrestore)(&l2x0_lock, gb_flags); +} +#endif /* * L2C-210 specific code. @@ -248,6 +278,22 @@ __l2c210_cache_sync(l2x0_base); } +#if defined(CONFIG_BCM_KF_L2CACHE_OPTIMIZATION) +/* no debug write workaround is needed for these function because lc310 controller in + 63138 is r3p3 and does not have these erratum */ +static void l2c210_flush_line_no_lock(unsigned long addr) +{ + void __iomem *base = l2x0_base; + writel_relaxed(addr, base + L2X0_CLEAN_INV_LINE_PA); +} + +static void l2c210_inv_line_no_lock(unsigned long addr) +{ + void __iomem *base = l2x0_base; + writel_relaxed(addr, base + L2X0_INV_LINE_PA); +} +#endif + static const struct l2c_init_data l2c210_data __initconst = { .type = "L2C-210", .way_size_0 = SZ_8K, @@ -287,10 +333,10 @@ { unsigned long flags; - raw_spin_lock_irqsave(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_lock_irqsave)(&l2x0_lock, flags); __l2c_op_way(base + reg); __l2c220_cache_sync(base); - raw_spin_unlock_irqrestore(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_unlock_irqrestore)(&l2x0_lock, flags); } static unsigned long l2c220_op_pa_range(void __iomem *reg, unsigned long start, @@ -308,8 +354,8 @@ } if (blk_end < end) { - raw_spin_unlock_irqrestore(lock, flags); - raw_spin_lock_irqsave(lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_unlock_irqrestore)(lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_lock_irqsave)(lock, flags); } } @@ -321,7 +367,7 @@ void __iomem *base = l2x0_base; unsigned long flags; - raw_spin_lock_irqsave(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_lock_irqsave)(&l2x0_lock, flags); if ((start | end) & (CACHE_LINE_SIZE - 1)) { if (start & (CACHE_LINE_SIZE - 1)) { start &= ~(CACHE_LINE_SIZE - 1); @@ -340,7 +386,7 @@ start, end, flags); l2c_wait_mask(base + L2X0_INV_LINE_PA, 1); __l2c220_cache_sync(base); - raw_spin_unlock_irqrestore(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_unlock_irqrestore)(&l2x0_lock, flags); } static void l2c220_clean_range(unsigned long start, unsigned long end) @@ -354,12 +400,12 @@ return; } - raw_spin_lock_irqsave(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_lock_irqsave)(&l2x0_lock, flags); flags = l2c220_op_pa_range(base + L2X0_CLEAN_LINE_PA, start, end, flags); l2c_wait_mask(base + L2X0_CLEAN_INV_LINE_PA, 1); __l2c220_cache_sync(base); - raw_spin_unlock_irqrestore(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_unlock_irqrestore)(&l2x0_lock, flags); } static void l2c220_flush_range(unsigned long start, unsigned long end) @@ -373,12 +419,12 @@ return; } - raw_spin_lock_irqsave(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_lock_irqsave)(&l2x0_lock, flags); flags = l2c220_op_pa_range(base + L2X0_CLEAN_INV_LINE_PA, start, end, flags); l2c_wait_mask(base + L2X0_CLEAN_INV_LINE_PA, 1); __l2c220_cache_sync(base); - raw_spin_unlock_irqrestore(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_unlock_irqrestore)(&l2x0_lock, flags); } static void l2c220_flush_all(void) @@ -390,9 +436,9 @@ { unsigned long flags; - raw_spin_lock_irqsave(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_lock_irqsave)(&l2x0_lock, flags); __l2c220_cache_sync(l2x0_base); - raw_spin_unlock_irqrestore(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_unlock_irqrestore)(&l2x0_lock, flags); } static void l2c220_enable(void __iomem *base, unsigned num_lock) @@ -484,7 +530,7 @@ unsigned long flags; /* Erratum 588369 for both clean+invalidate operations */ - raw_spin_lock_irqsave(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_lock_irqsave)(&l2x0_lock, flags); l2c_set_debug(base, 0x03); if (start & (CACHE_LINE_SIZE - 1)) { @@ -501,7 +547,7 @@ } l2c_set_debug(base, 0x00); - raw_spin_unlock_irqrestore(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_unlock_irqrestore)(&l2x0_lock, flags); } __l2c210_op_pa_range(base + L2X0_INV_LINE_PA, start, end); @@ -514,7 +560,7 @@ unsigned long flags; void __iomem *base = l2x0_base; - raw_spin_lock_irqsave(lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_lock_irqsave)(lock, flags); while (start < end) { unsigned long blk_end = start + min(end - start, 4096UL); @@ -527,11 +573,11 @@ l2c_set_debug(base, 0x00); if (blk_end < end) { - raw_spin_unlock_irqrestore(lock, flags); - raw_spin_lock_irqsave(lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_unlock_irqrestore)(lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_lock_irqsave)(lock, flags); } } - raw_spin_unlock_irqrestore(lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_unlock_irqrestore)(lock, flags); __l2c210_cache_sync(base); } @@ -540,12 +586,12 @@ void __iomem *base = l2x0_base; unsigned long flags; - raw_spin_lock_irqsave(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_lock_irqsave)(&l2x0_lock, flags); l2c_set_debug(base, 0x03); __l2c_op_way(base + L2X0_CLEAN_INV_WAY); l2c_set_debug(base, 0x00); __l2c210_cache_sync(base); - raw_spin_unlock_irqrestore(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_unlock_irqrestore)(&l2x0_lock, flags); } static void __init l2c310_save(void __iomem *base) @@ -786,6 +832,13 @@ .disable = l2c310_disable, .sync = l2c210_sync, .resume = l2c310_resume, +#if defined(CONFIG_BCM_KF_L2CACHE_OPTIMIZATION) + ._spin_lock_irqsave = l2c_spin_lock_irqsave, + .spin_unlock_irqrestore = l2c_spin_unlock_irqrestore, + .sync_no_lock = l2c210_sync, + .flush_line_no_lock = l2c210_flush_line_no_lock, + .inv_line_no_lock = l2c210_inv_line_no_lock, +#endif }, }; @@ -1328,6 +1381,13 @@ .disable = l2c310_disable, .sync = l2c210_sync, .resume = l2c310_resume, +#if defined(CONFIG_BCM_KF_L2CACHE_OPTIMIZATION) + ._spin_lock_irqsave = l2c_spin_lock_irqsave, + .spin_unlock_irqrestore = l2c_spin_unlock_irqrestore, + .sync_no_lock = l2c210_sync, + .flush_line_no_lock = l2c210_flush_line_no_lock, + .inv_line_no_lock = l2c210_inv_line_no_lock, +#endif }, }; @@ -1403,10 +1463,10 @@ while (start < end) { range_end = aurora_range_end(start, end); - raw_spin_lock_irqsave(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_lock_irqsave)(&l2x0_lock, flags); writel_relaxed(start, base + AURORA_RANGE_BASE_ADDR_REG); writel_relaxed(range_end - CACHE_LINE_SIZE, base + offset); - raw_spin_unlock_irqrestore(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_unlock_irqrestore)(&l2x0_lock, flags); writel_relaxed(0, base + AURORA_SYNC_REG); start = range_end; @@ -1441,9 +1501,9 @@ unsigned long flags; /* clean all ways */ - raw_spin_lock_irqsave(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_lock_irqsave)(&l2x0_lock, flags); __l2c_op_way(base + L2X0_CLEAN_INV_WAY); - raw_spin_unlock_irqrestore(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_unlock_irqrestore)(&l2x0_lock, flags); writel_relaxed(0, base + AURORA_SYNC_REG); } @@ -1458,12 +1518,12 @@ void __iomem *base = l2x0_base; unsigned long flags; - raw_spin_lock_irqsave(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_lock_irqsave)(&l2x0_lock, flags); __l2c_op_way(base + L2X0_CLEAN_INV_WAY); writel_relaxed(0, base + AURORA_SYNC_REG); l2c_write_sec(0, base, L2X0_CTRL); dsb(st); - raw_spin_unlock_irqrestore(&l2x0_lock, flags); + __BUILD_AVM_CONTEXT_FUNC(raw_spin_unlock_irqrestore)(&l2x0_lock, flags); } static void aurora_save(void __iomem *base)