Return-Path: Received: from smtpbg202.qq.com ([184.105.206.29]:59497 "EHLO smtpbg202.qq.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751182AbdCPNGB (ORCPT ); Thu, 16 Mar 2017 09:06:01 -0400 From: Huacai Chen To: Ralf Baechle Cc: John Crispin , "Steven J . Hill" , linux-mips@linux-mips.org, Fuxin Zhang , Zhangjin Wu , Huacai Chen , stable@vger.kernel.org Subject: [PATCH RESEND V2 5/7] MIPS: c-r4k: Fix Loongson-3's vcache/scache waysize calculation Date: Thu, 16 Mar 2017 21:00:29 +0800 Message-Id: <1489669231-28162-5-git-send-email-chenhc@lemote.com> In-Reply-To: <1489669231-28162-1-git-send-email-chenhc@lemote.com> References: <1489669231-28162-1-git-send-email-chenhc@lemote.com> Sender: stable-owner@vger.kernel.org List-ID: 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. Cc: stable@vger.kernel.org Signed-off-by: Huacai Chen --- arch/mips/mm/c-r4k.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c index e7f798d..3fe99cb 100644 --- a/arch/mips/mm/c-r4k.c +++ b/arch/mips/mm/c-r4k.c @@ -1562,6 +1562,7 @@ static void probe_vcache(void) vcache_size = c->vcache.sets * c->vcache.ways * c->vcache.linesz; c->vcache.waybit = 0; + c->vcache.waysize = vcache_size / c->vcache.ways; pr_info("Unified victim cache %ldkB %s, linesize %d bytes.\n", vcache_size >> 10, way_string[c->vcache.ways], c->vcache.linesz); @@ -1664,6 +1665,7 @@ static void __init loongson3_sc_init(void) /* Loongson-3 has 4 cores, 1MB scache for each. scaches are shared */ scache_size *= 4; c->scache.waybit = 0; + c->scache.waysize = scache_size / c->scache.ways; pr_info("Unified secondary cache %ldkB %s, linesize %d bytes.\n", scache_size >> 10, way_string[c->scache.ways], c->scache.linesz); if (scache_size) -- 2.7.0