aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/mm/sc-mips.c
diff options
context:
space:
mode:
authorGovindraj Raja <govindraj.raja@imgtec.com>2016-02-29 06:41:20 -0500
committerRalf Baechle <ralf@linux-mips.org>2016-02-29 09:44:23 -0500
commit56fa81fc9a5445938f3aa2e63d15ab63dc938ad6 (patch)
tree6cd4ed3f609f2ed8e4c2bfd69b1e16280eaf4a22 /arch/mips/mm/sc-mips.c
parent51ff5d7767eae285969da75c209e9425d84b012d (diff)
MIPS: scache: Fix scache init with invalid line size.
In current scache init cache line_size is determined from cpu config register, however if there there no scache then mips_sc_probe_cm3 function populates a invalid line_size of 2. The invalid line_size can cause a NULL pointer deference during r4k_dma_cache_inv as r4k_blast_scache is populated based on line_size. Scache line_size of 2 is invalid option in r4k_blast_scache_setup. This issue was faced during a MIPS I6400 based virtual platform bring up where scache was not available in virtual platform model. Signed-off-by: Govindraj Raja <Govindraj.Raja@imgtec.com> Fixes: 7d53e9c4cd21("MIPS: CM3: Add support for CM3 L2 cache.") Cc: Paul Burton <paul.burton@imgtec.com> Cc: James Hogan <james.hogan@imgtec.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: James Hartley <James.Hartley@imgtec.com> Cc: linux-mips@linux-mips.org Cc: stable@vger.kernel.org # v4.2+ Patchwork: https://patchwork.linux-mips.org/patch/12710/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/mm/sc-mips.c')
-rw-r--r--arch/mips/mm/sc-mips.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/arch/mips/mm/sc-mips.c b/arch/mips/mm/sc-mips.c
index 249647578e58..91dec32c77b7 100644
--- a/arch/mips/mm/sc-mips.c
+++ b/arch/mips/mm/sc-mips.c
@@ -164,11 +164,13 @@ static int __init mips_sc_probe_cm3(void)
164 164
165 sets = cfg & CM_GCR_L2_CONFIG_SET_SIZE_MSK; 165 sets = cfg & CM_GCR_L2_CONFIG_SET_SIZE_MSK;
166 sets >>= CM_GCR_L2_CONFIG_SET_SIZE_SHF; 166 sets >>= CM_GCR_L2_CONFIG_SET_SIZE_SHF;
167 c->scache.sets = 64 << sets; 167 if (sets)
168 c->scache.sets = 64 << sets;
168 169
169 line_sz = cfg & CM_GCR_L2_CONFIG_LINE_SIZE_MSK; 170 line_sz = cfg & CM_GCR_L2_CONFIG_LINE_SIZE_MSK;
170 line_sz >>= CM_GCR_L2_CONFIG_LINE_SIZE_SHF; 171 line_sz >>= CM_GCR_L2_CONFIG_LINE_SIZE_SHF;
171 c->scache.linesz = 2 << line_sz; 172 if (line_sz)
173 c->scache.linesz = 2 << line_sz;
172 174
173 assoc = cfg & CM_GCR_L2_CONFIG_ASSOC_MSK; 175 assoc = cfg & CM_GCR_L2_CONFIG_ASSOC_MSK;
174 assoc >>= CM_GCR_L2_CONFIG_ASSOC_SHF; 176 assoc >>= CM_GCR_L2_CONFIG_ASSOC_SHF;
@@ -176,9 +178,12 @@ static int __init mips_sc_probe_cm3(void)
176 c->scache.waysize = c->scache.sets * c->scache.linesz; 178 c->scache.waysize = c->scache.sets * c->scache.linesz;
177 c->scache.waybit = __ffs(c->scache.waysize); 179 c->scache.waybit = __ffs(c->scache.waysize);
178 180
179 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT; 181 if (c->scache.linesz) {
182 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
183 return 1;
184 }
180 185
181 return 1; 186 return 0;
182} 187}
183 188
184static inline int __init mips_sc_probe(void) 189static inline int __init mips_sc_probe(void)