Commit ce7ec3d7 authored by Vineet Gupta's avatar Vineet Gupta Committed by Greg Kroah-Hartman

ARC: mm: arc700: Don't assume 2 colours for aliasing VIPT dcache

commit 08fe0079 upstream.

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.
Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9d33a399
...@@ -85,6 +85,10 @@ void flush_anon_page(struct vm_area_struct *vma, ...@@ -85,6 +85,10 @@ void flush_anon_page(struct vm_area_struct *vma,
*/ */
#define PG_dc_clean PG_arch_1 #define PG_dc_clean PG_arch_1
#define CACHE_COLORS_NUM 4
#define CACHE_COLORS_MSK (CACHE_COLORS_NUM - 1)
#define CACHE_COLOR(addr) (((unsigned long)(addr) >> (PAGE_SHIFT)) & CACHE_COLORS_MSK)
/* /*
* Simple wrapper over config option * Simple wrapper over config option
* Bootup code ensures that hardware matches kernel configuration * Bootup code ensures that hardware matches kernel configuration
...@@ -94,8 +98,6 @@ static inline int cache_is_vipt_aliasing(void) ...@@ -94,8 +98,6 @@ static inline int cache_is_vipt_aliasing(void)
return IS_ENABLED(CONFIG_ARC_CACHE_VIPT_ALIASING); return IS_ENABLED(CONFIG_ARC_CACHE_VIPT_ALIASING);
} }
#define CACHE_COLOR(addr) (((unsigned long)(addr) >> (PAGE_SHIFT)) & 1)
/* /*
* checks if two addresses (after page aligning) index into same cache set * checks if two addresses (after page aligning) index into same cache set
*/ */
......
...@@ -979,13 +979,18 @@ void arc_cache_init(void) ...@@ -979,13 +979,18 @@ void arc_cache_init(void)
/* check for D-Cache aliasing on ARCompact: ARCv2 has PIPT */ /* check for D-Cache aliasing on ARCompact: ARCv2 has PIPT */
if (is_isa_arcompact()) { if (is_isa_arcompact()) {
int handled = IS_ENABLED(CONFIG_ARC_CACHE_VIPT_ALIASING); int handled = IS_ENABLED(CONFIG_ARC_CACHE_VIPT_ALIASING);
int num_colors = dc->sz_k/dc->assoc/TO_KB(PAGE_SIZE);
if (dc->alias && !handled) if (dc->alias) {
if (!handled)
panic("Enable CONFIG_ARC_CACHE_VIPT_ALIASING\n"); panic("Enable CONFIG_ARC_CACHE_VIPT_ALIASING\n");
else if (!dc->alias && handled) if (CACHE_COLORS_NUM != num_colors)
panic("CACHE_COLORS_NUM not optimized for config\n");
} else if (!dc->alias && handled) {
panic("Disable CONFIG_ARC_CACHE_VIPT_ALIASING\n"); panic("Disable CONFIG_ARC_CACHE_VIPT_ALIASING\n");
} }
} }
}
if (is_isa_arcv2() && l2_line_sz && !slc_enable) { if (is_isa_arcv2() && l2_line_sz && !slc_enable) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment