--- zzzz-none-000/linux-4.1.38/arch/arm/mm/cache-l2x0.c 2017-01-18 18:48:06.000000000 +0000 +++ bcm63-7582-715/linux-4.1.38/arch/arm/mm/cache-l2x0.c 2020-11-25 10:06:48.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 @@ -45,6 +51,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; @@ -166,6 +183,21 @@ l2c_enable(l2x0_base, l2x0_saved_regs.aux_ctrl, l2x0_data->num_lock); } +#if defined(CONFIG_BCM_KF_ARM_BCM963XX) + +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. * @@ -246,6 +278,23 @@ __l2c210_cache_sync(l2x0_base); } + +#if defined(CONFIG_BCM_KF_ARM_BCM963XX) +/* 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, @@ -283,10 +332,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, @@ -304,8 +353,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); } } @@ -317,7 +366,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); @@ -336,7 +385,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) @@ -350,12 +399,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) @@ -369,12 +418,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) @@ -386,9 +435,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, u32 aux, unsigned num_lock) @@ -472,7 +521,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)) { @@ -489,7 +538,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); @@ -502,7 +551,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); @@ -515,11 +564,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); } @@ -528,12 +577,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) @@ -771,6 +820,13 @@ .disable = l2c310_disable, .sync = l2c210_sync, .resume = l2c310_resume, +#if defined(CONFIG_BCM_KF_ARM_BCM963XX) + .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 }, }; @@ -1219,6 +1275,13 @@ .disable = l2c310_disable, .sync = l2c210_sync, .resume = l2c310_resume, +#if defined(CONFIG_BCM_KF_ARM_BCM963XX) + .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 }, }; @@ -1293,10 +1356,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; @@ -1331,9 +1394,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); } @@ -1348,12 +1411,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)