Skip to content

Commit 0be032c

Browse files
chenhuacairalfbaechle
authored andcommitted
MIPS: c-r4k: Fix Loongson-3's vcache/scache waysize calculation
If scache.waysize is 0, r4k___flush_cache_all() will do nothing and then cause bugs. BTW, though vcache.waysize isn't being used by now, we also fix its calculation. Signed-off-by: Huacai Chen <chenhc@lemote.com> Cc: John Crispin <john@phrozen.org> Cc: Steven J . Hill <Steven.Hill@caviumnetworks.com> Cc: Fuxin Zhang <zhangfx@lemote.com> Cc: Zhangjin Wu <wuzhangjin@gmail.com> Cc: linux-mips@linux-mips.org Cc: stable@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/15756/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 0115f6c commit 0be032c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

arch/mips/mm/c-r4k.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,7 @@ static void probe_vcache(void)
15621562
vcache_size = c->vcache.sets * c->vcache.ways * c->vcache.linesz;
15631563

15641564
c->vcache.waybit = 0;
1565+
c->vcache.waysize = vcache_size / c->vcache.ways;
15651566

15661567
pr_info("Unified victim cache %ldkB %s, linesize %d bytes.\n",
15671568
vcache_size >> 10, way_string[c->vcache.ways], c->vcache.linesz);
@@ -1664,6 +1665,7 @@ static void __init loongson3_sc_init(void)
16641665
/* Loongson-3 has 4 cores, 1MB scache for each. scaches are shared */
16651666
scache_size *= 4;
16661667
c->scache.waybit = 0;
1668+
c->scache.waysize = scache_size / c->scache.ways;
16671669
pr_info("Unified secondary cache %ldkB %s, linesize %d bytes.\n",
16681670
scache_size >> 10, way_string[c->scache.ways], c->scache.linesz);
16691671
if (scache_size)

0 commit comments

Comments
 (0)