Skip to content

Commit 2839e06

Browse files
Santosh ShilimkarRussell King
authored andcommitted
ARM: 6795/1: l2x0: Errata fix for flush by Way operation can cause data corrupti
PL310 implements the Clean & Invalidate by Way L2 cache maintenance operation (offset 0x7FC). This operation runs in background so that PL310 can handle normal accesses while it is in progress. Under very rare circumstances, due to this erratum, write data can be lost when PL310 treats a cacheable write transaction during a Clean & Invalidate by Way operation. Workaround: Disable Write-Back and Cache Linefill (Debug Control Register) Clean & Invalidate by Way (0x7FC) Re-enable Write-Back and Cache Linefill (Debug Control Register) This patch also removes any OMAP dependency on PL310 Errata's Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent d239b1d commit 2839e06

3 files changed

Lines changed: 31 additions & 17 deletions

File tree

‎arch/arm/Kconfig‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ config ARM_ERRATA_742231
11351135

11361136
config PL310_ERRATA_588369
11371137
bool "Clean & Invalidate maintenance operations do not invalidate clean lines"
1138-
depends on CACHE_L2X0 && ARCH_OMAP4
1138+
depends on CACHE_L2X0
11391139
help
11401140
The PL310 L2 cache controller implements three types of Clean &
11411141
Invalidate maintenance operations: by Physical Address
@@ -1144,8 +1144,7 @@ config PL310_ERRATA_588369
11441144
clean operation followed immediately by an invalidate operation,
11451145
both performing to the same memory location. This functionality
11461146
is not correctly implemented in PL310 as clean lines are not
1147-
invalidated as a result of these operations. Note that this errata
1148-
uses Texas Instrument's secure monitor api.
1147+
invalidated as a result of these operations.
11491148

11501149
config ARM_ERRATA_720789
11511150
bool "ARM errata: TLBIASIDIS and TLBIMVAIS operations can broadcast a faulty ASID"
@@ -1172,6 +1171,16 @@ config ARM_ERRATA_743622
11721171
visible impact on the overall performance or power consumption of the
11731172
processor.
11741173

1174+
config PL310_ERRATA_727915
1175+
bool "Background Clean & Invalidate by Way operation can cause data corruption"
1176+
depends on CACHE_L2X0
1177+
help
1178+
PL310 implements the Clean & Invalidate by Way L2 cache maintenance
1179+
operation (offset 0x7FC). This operation runs in background so that
1180+
PL310 can handle normal accesses while it is in progress. Under very
1181+
rare circumstances, due to this erratum, write data can be lost when
1182+
PL310 treats a cacheable write transaction during a Clean &
1183+
Invalidate by Way operation.
11751184
endmenu
11761185

11771186
source "arch/arm/common/Kconfig"

‎arch/arm/include/asm/outercache.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct outer_cache_fns {
3131
#ifdef CONFIG_OUTER_CACHE_SYNC
3232
void (*sync)(void);
3333
#endif
34+
void (*set_debug)(unsigned long);
3435
};
3536

3637
#ifdef CONFIG_OUTER_CACHE

‎arch/arm/mm/cache-l2x0.c‎

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,24 @@ static inline void l2x0_inv_line(unsigned long addr)
6767
writel_relaxed(addr, base + L2X0_INV_LINE_PA);
6868
}
6969

70-
#ifdef CONFIG_PL310_ERRATA_588369
71-
static void debug_writel(unsigned long val)
72-
{
73-
extern void omap_smc1(u32 fn, u32 arg);
70+
#if defined(CONFIG_PL310_ERRATA_588369) || defined(CONFIG_PL310_ERRATA_727915)
7471

75-
/*
76-
* Texas Instrument secure monitor api to modify the
77-
* PL310 Debug Control Register.
78-
*/
79-
omap_smc1(0x100, val);
72+
#define debug_writel(val) outer_cache.set_debug(val)
73+
74+
static void l2x0_set_debug(unsigned long val)
75+
{
76+
writel_relaxed(val, l2x0_base + L2X0_DEBUG_CTRL);
8077
}
78+
#else
79+
/* Optimised out for non-errata case */
80+
static inline void debug_writel(unsigned long val)
81+
{
82+
}
83+
84+
#define l2x0_set_debug NULL
85+
#endif
8186

87+
#ifdef CONFIG_PL310_ERRATA_588369
8288
static inline void l2x0_flush_line(unsigned long addr)
8389
{
8490
void __iomem *base = l2x0_base;
@@ -91,11 +97,6 @@ static inline void l2x0_flush_line(unsigned long addr)
9197
}
9298
#else
9399

94-
/* Optimised out for non-errata case */
95-
static inline void debug_writel(unsigned long val)
96-
{
97-
}
98-
99100
static inline void l2x0_flush_line(unsigned long addr)
100101
{
101102
void __iomem *base = l2x0_base;
@@ -119,9 +120,11 @@ static void l2x0_flush_all(void)
119120

120121
/* clean all ways */
121122
spin_lock_irqsave(&l2x0_lock, flags);
123+
debug_writel(0x03);
122124
writel_relaxed(l2x0_way_mask, l2x0_base + L2X0_CLEAN_INV_WAY);
123125
cache_wait_way(l2x0_base + L2X0_CLEAN_INV_WAY, l2x0_way_mask);
124126
cache_sync();
127+
debug_writel(0x00);
125128
spin_unlock_irqrestore(&l2x0_lock, flags);
126129
}
127130

@@ -329,6 +332,7 @@ void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask)
329332
outer_cache.flush_all = l2x0_flush_all;
330333
outer_cache.inv_all = l2x0_inv_all;
331334
outer_cache.disable = l2x0_disable;
335+
outer_cache.set_debug = l2x0_set_debug;
332336

333337
printk(KERN_INFO "%s cache controller enabled\n", type);
334338
printk(KERN_INFO "l2x0: %d ways, CACHE_ID 0x%08x, AUX_CTRL 0x%08x, Cache size: %d B\n",

0 commit comments

Comments
 (0)