Skip to content

Commit 08fe007

Browse files
committed
ARC: mm: arc700: Don't assume 2 colours for aliasing VIPT dcache
An ARC700 customer reported linux boot crashes when upgrading to bigger L1 dcache (64K from 32K). Turns out they had an aliasing VIPT config and current code only assumed 2 colours, while theirs had 4. So default to 4 colours and complain if there are fewer. Ideally this needs to be a Kconfig option, but heck that's too much of hassle for a single user. Cc: stable@vger.kernel.org Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
1 parent f64915b commit 08fe007

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

arch/arc/include/asm/cacheflush.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ void flush_anon_page(struct vm_area_struct *vma,
8585
*/
8686
#define PG_dc_clean PG_arch_1
8787

88+
#define CACHE_COLORS_NUM 4
89+
#define CACHE_COLORS_MSK (CACHE_COLORS_NUM - 1)
90+
#define CACHE_COLOR(addr) (((unsigned long)(addr) >> (PAGE_SHIFT)) & CACHE_COLORS_MSK)
91+
8892
/*
8993
* Simple wrapper over config option
9094
* Bootup code ensures that hardware matches kernel configuration
@@ -94,8 +98,6 @@ static inline int cache_is_vipt_aliasing(void)
9498
return IS_ENABLED(CONFIG_ARC_CACHE_VIPT_ALIASING);
9599
}
96100

97-
#define CACHE_COLOR(addr) (((unsigned long)(addr) >> (PAGE_SHIFT)) & 1)
98-
99101
/*
100102
* checks if two addresses (after page aligning) index into same cache set
101103
*/

arch/arc/mm/cache.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -972,11 +972,16 @@ void arc_cache_init(void)
972972
/* check for D-Cache aliasing on ARCompact: ARCv2 has PIPT */
973973
if (is_isa_arcompact()) {
974974
int handled = IS_ENABLED(CONFIG_ARC_CACHE_VIPT_ALIASING);
975-
976-
if (dc->alias && !handled)
977-
panic("Enable CONFIG_ARC_CACHE_VIPT_ALIASING\n");
978-
else if (!dc->alias && handled)
975+
int num_colors = dc->sz_k/dc->assoc/TO_KB(PAGE_SIZE);
976+
977+
if (dc->alias) {
978+
if (!handled)
979+
panic("Enable CONFIG_ARC_CACHE_VIPT_ALIASING\n");
980+
if (CACHE_COLORS_NUM != num_colors)
981+
panic("CACHE_COLORS_NUM not optimized for config\n");
982+
} else if (!dc->alias && handled) {
979983
panic("Disable CONFIG_ARC_CACHE_VIPT_ALIASING\n");
984+
}
980985
}
981986
}
982987

0 commit comments

Comments
 (0)