Skip to content

Commit 6605f95

Browse files
zhangyuan21xiaoxiang781216
authored andcommitted
l2cc: Do not repeat disabling the cache when the cache is already disabled
When l2cc is already in disable state, performing a disable operation again will flush incorrect cache data to memory Signed-off-by: zhangyuan21 <[email protected]>
1 parent 69fd539 commit 6605f95

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,12 @@ void l2cc_enable(void)
437437
/* Invalidate and enable the cache (must be disabled to do this!) */
438438

439439
flags = enter_critical_section();
440+
441+
if ((getreg32(L2CC_CR) & L2CC_CR_L2CEN) != 0)
442+
{
443+
l2cc_disable();
444+
}
445+
440446
l2cc_invalidate_all();
441447
putreg32(L2CC_CR_L2CEN, L2CC_CR);
442448
ARM_DSB();
@@ -520,17 +526,11 @@ void l2cc_sync(void)
520526
void l2cc_invalidate_all(void)
521527
{
522528
irqstate_t flags;
523-
uint32_t regval;
524529

525530
/* Invalidate all ways */
526531

527532
flags = enter_critical_section();
528533

529-
/* Disable the L2 cache while we invalidate it */
530-
531-
regval = getreg32(L2CC_CR);
532-
l2cc_disable();
533-
534534
/* Invalidate all ways by writing the bit mask of ways to be invalidated
535535
* the Invalidate Way Register (IWR).
536536
*/
@@ -547,9 +547,6 @@ void l2cc_invalidate_all(void)
547547

548548
putreg32(0, L2CC_CSR);
549549

550-
/* Then re-enable the L2 cache if it was enabled before */
551-
552-
putreg32(regval, L2CC_CR);
553550
leave_critical_section(flags);
554551
}
555552

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,12 @@ void l2cc_enable(void)
437437
/* Invalidate and enable the cache (must be disabled to do this!) */
438438

439439
flags = enter_critical_section();
440+
441+
if ((getreg32(L2CC_CR) & L2CC_CR_L2CEN) != 0)
442+
{
443+
l2cc_disable();
444+
}
445+
440446
l2cc_invalidate_all();
441447
putreg32(L2CC_CR_L2CEN, L2CC_CR);
442448
ARM_DSB();
@@ -520,17 +526,11 @@ void l2cc_sync(void)
520526
void l2cc_invalidate_all(void)
521527
{
522528
irqstate_t flags;
523-
uint32_t regval;
524529

525530
/* Invalidate all ways */
526531

527532
flags = enter_critical_section();
528533

529-
/* Disable the L2 cache while we invalidate it */
530-
531-
regval = getreg32(L2CC_CR);
532-
l2cc_disable();
533-
534534
/* Invalidate all ways by writing the bit mask of ways to be invalidated
535535
* the Invalidate Way Register (IWR).
536536
*/
@@ -547,9 +547,6 @@ void l2cc_invalidate_all(void)
547547

548548
putreg32(0, L2CC_CSR);
549549

550-
/* Then re-enable the L2 cache if it was enabled before */
551-
552-
putreg32(regval, L2CC_CR);
553550
leave_critical_section(flags);
554551
}
555552

0 commit comments

Comments
 (0)