Skip to content

Commit 69fd539

Browse files
zhangyuan21xiaoxiang781216
authored andcommitted
arch/armv7ar: use robust code sequences for cache maintenance
Invalidate operations at DDI0246H_l2c310_r3p3_trm: If there is a stale entry in the L2 cache, the system enables the invalidation of the L1 cache. But before the controller invalidates the L2 cache, it allocates a line from the L2 cache to an L1 cache. The robust code sequence for invalidation with a non-exclusive cache arrangement is: 1. InvalLevel2 Address ; forces the address out past level 2 2. CACHE SYNC ; Ensures completion of the L2 inval 3. InvalLevel1 Address ; This is broadcast within the cluster 4. DSB ; Ensure completion of the inval as far as Level 2. This sequence ensures that, if there is an allocation to L1 after the L1 invalidation, the data picked up is the new data and not stale data from the L2 Signed-off-by: zhangyuan21 <[email protected]>
1 parent d189a86 commit 69fd539

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

arch/arm/src/armv7-a/arm_cache.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ size_t up_get_dcache_linesize(void)
216216

217217
void up_invalidate_dcache(uintptr_t start, uintptr_t end)
218218
{
219-
cp15_invalidate_dcache(start, end);
220219
l2cc_invalidate(start, end);
220+
cp15_invalidate_dcache(start, end);
221221
}
222222

223223
/****************************************************************************
@@ -241,8 +241,8 @@ void up_invalidate_dcache_all(void)
241241
{
242242
#ifdef CONFIG_ARCH_L2CACHE
243243
irqstate_t flags = enter_critical_section();
244-
cp15_invalidate_dcache_all();
245244
l2cc_invalidate_all();
245+
cp15_invalidate_dcache_all();
246246
leave_critical_section(flags);
247247
#else
248248
cp15_invalidate_dcache_all();
@@ -338,14 +338,15 @@ void up_flush_dcache(uintptr_t start, uintptr_t end)
338338
{
339339
if ((end - start) < cp15_cache_size())
340340
{
341-
cp15_flush_dcache(start, end);
341+
cp15_clean_dcache(start, end);
342342
}
343343
else
344344
{
345-
cp15_flush_dcache_all();
345+
cp15_clean_dcache_all();
346346
}
347347

348348
l2cc_flush(start, end);
349+
cp15_invalidate_dcache(start, end);
349350
}
350351

351352
/****************************************************************************
@@ -372,8 +373,9 @@ void up_flush_dcache(uintptr_t start, uintptr_t end)
372373

373374
void up_flush_dcache_all(void)
374375
{
375-
cp15_flush_dcache_all();
376+
cp15_clean_dcache_all();
376377
l2cc_flush_all();
378+
cp15_invalidate_dcache_all();
377379
}
378380

379381
/****************************************************************************

arch/arm/src/armv7-r/arm_cache.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ size_t up_get_dcache_linesize(void)
216216

217217
void up_invalidate_dcache(uintptr_t start, uintptr_t end)
218218
{
219-
cp15_invalidate_dcache(start, end);
220219
l2cc_invalidate(start, end);
220+
cp15_invalidate_dcache(start, end);
221221
}
222222

223223
/****************************************************************************
@@ -241,8 +241,8 @@ void up_invalidate_dcache_all(void)
241241
{
242242
#ifdef CONFIG_ARCH_L2CACHE
243243
irqstate_t flags = enter_critical_section();
244-
cp15_invalidate_dcache_all();
245244
l2cc_invalidate_all();
245+
cp15_invalidate_dcache_all();
246246
leave_critical_section(flags);
247247
#else
248248
cp15_invalidate_dcache_all();
@@ -338,14 +338,15 @@ void up_flush_dcache(uintptr_t start, uintptr_t end)
338338
{
339339
if ((end - start) < cp15_cache_size())
340340
{
341-
cp15_flush_dcache(start, end);
341+
cp15_clean_dcache(start, end);
342342
}
343343
else
344344
{
345-
cp15_flush_dcache_all();
345+
cp15_clean_dcache_all();
346346
}
347347

348348
l2cc_flush(start, end);
349+
cp15_invalidate_dcache(start, end);
349350
}
350351

351352
/****************************************************************************
@@ -372,8 +373,9 @@ void up_flush_dcache(uintptr_t start, uintptr_t end)
372373

373374
void up_flush_dcache_all(void)
374375
{
375-
cp15_flush_dcache_all();
376+
cp15_clean_dcache_all();
376377
l2cc_flush_all();
378+
cp15_invalidate_dcache_all();
377379
}
378380

379381
/****************************************************************************

0 commit comments

Comments
 (0)