aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/mm
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2014-08-07 03:26:33 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2014-09-25 09:14:56 -0400
commit9e34992a622a15fb915471ccdebed19a87d8d531 (patch)
tree631d2a92cfb586c12fab20d14e1a05f73c8f184d /arch/powerpc/mm
parent87d99c0e2c2f9d1386d8e284a5fbc13e96adbe25 (diff)
powerpc/mm: Unindent htab_dt_scan_page_sizes()
We can unindent the bulk of htab_dt_scan_page_sizes() by returning early if the property is not found. That is nice in and of itself, but also has the advantage of making it clear that we always return success once we have found the ibm,segment-page-sizes property. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/mm')
-rw-r--r--arch/powerpc/mm/hash_utils_64.c121
1 files changed, 60 insertions, 61 deletions
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 5786f2a81efe..dd73b63f9479 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -334,70 +334,69 @@ static int __init htab_dt_scan_page_sizes(unsigned long node,
334 return 0; 334 return 0;
335 335
336 prop = of_get_flat_dt_prop(node, "ibm,segment-page-sizes", &size); 336 prop = of_get_flat_dt_prop(node, "ibm,segment-page-sizes", &size);
337 if (prop != NULL) { 337 if (!prop)
338 pr_info("Page sizes from device-tree:\n"); 338 return 0;
339 size /= 4; 339
340 cur_cpu_spec->mmu_features &= ~(MMU_FTR_16M_PAGE); 340 pr_info("Page sizes from device-tree:\n");
341 while(size > 0) { 341 size /= 4;
342 unsigned int base_shift = be32_to_cpu(prop[0]); 342 cur_cpu_spec->mmu_features &= ~(MMU_FTR_16M_PAGE);
343 unsigned int slbenc = be32_to_cpu(prop[1]); 343 while(size > 0) {
344 unsigned int lpnum = be32_to_cpu(prop[2]); 344 unsigned int base_shift = be32_to_cpu(prop[0]);
345 struct mmu_psize_def *def; 345 unsigned int slbenc = be32_to_cpu(prop[1]);
346 int idx, base_idx; 346 unsigned int lpnum = be32_to_cpu(prop[2]);
347 347 struct mmu_psize_def *def;
348 size -= 3; prop += 3; 348 int idx, base_idx;
349 base_idx = get_idx_from_shift(base_shift); 349
350 if (base_idx < 0) { 350 size -= 3; prop += 3;
351 /* 351 base_idx = get_idx_from_shift(base_shift);
352 * skip the pte encoding also 352 if (base_idx < 0) {
353 */ 353 /* skip the pte encoding also */
354 prop += lpnum * 2; size -= lpnum * 2; 354 prop += lpnum * 2; size -= lpnum * 2;
355 continue;
356 }
357 def = &mmu_psize_defs[base_idx];
358 if (base_idx == MMU_PAGE_16M)
359 cur_cpu_spec->mmu_features |= MMU_FTR_16M_PAGE;
360
361 def->shift = base_shift;
362 if (base_shift <= 23)
363 def->avpnm = 0;
364 else
365 def->avpnm = (1 << (base_shift - 23)) - 1;
366 def->sllp = slbenc;
367 /*
368 * We don't know for sure what's up with tlbiel, so
369 * for now we only set it for 4K and 64K pages
370 */
371 if (base_idx == MMU_PAGE_4K || base_idx == MMU_PAGE_64K)
372 def->tlbiel = 1;
373 else
374 def->tlbiel = 0;
375
376 while (size > 0 && lpnum) {
377 unsigned int shift = be32_to_cpu(prop[0]);
378 int penc = be32_to_cpu(prop[1]);
379
380 prop += 2; size -= 2;
381 lpnum--;
382
383 idx = get_idx_from_shift(shift);
384 if (idx < 0)
355 continue; 385 continue;
356 } 386
357 def = &mmu_psize_defs[base_idx]; 387 if (penc == -1)
358 if (base_idx == MMU_PAGE_16M) 388 pr_err("Invalid penc for base_shift=%d "
359 cur_cpu_spec->mmu_features |= MMU_FTR_16M_PAGE; 389 "shift=%d\n", base_shift, shift);
360 390
361 def->shift = base_shift; 391 def->penc[idx] = penc;
362 if (base_shift <= 23) 392 pr_info("base_shift=%d: shift=%d, sllp=0x%04lx,"
363 def->avpnm = 0; 393 " avpnm=0x%08lx, tlbiel=%d, penc=%d\n",
364 else 394 base_shift, shift, def->sllp,
365 def->avpnm = (1 << (base_shift - 23)) - 1; 395 def->avpnm, def->tlbiel, def->penc[idx]);
366 def->sllp = slbenc;
367 /*
368 * We don't know for sure what's up with tlbiel, so
369 * for now we only set it for 4K and 64K pages
370 */
371 if (base_idx == MMU_PAGE_4K || base_idx == MMU_PAGE_64K)
372 def->tlbiel = 1;
373 else
374 def->tlbiel = 0;
375
376 while (size > 0 && lpnum) {
377 unsigned int shift = be32_to_cpu(prop[0]);
378 int penc = be32_to_cpu(prop[1]);
379
380 prop += 2; size -= 2;
381 lpnum--;
382
383 idx = get_idx_from_shift(shift);
384 if (idx < 0)
385 continue;
386
387 if (penc == -1)
388 pr_err("Invalid penc for base_shift=%d "
389 "shift=%d\n", base_shift, shift);
390
391 def->penc[idx] = penc;
392 pr_info("base_shift=%d: shift=%d, sllp=0x%04lx,"
393 " avpnm=0x%08lx, tlbiel=%d, penc=%d\n",
394 base_shift, shift, def->sllp,
395 def->avpnm, def->tlbiel, def->penc[idx]);
396 }
397 } 396 }
398 return 1;
399 } 397 }
400 return 0; 398
399 return 1;
401} 400}
402 401
403#ifdef CONFIG_HUGETLB_PAGE 402#ifdef CONFIG_HUGETLB_PAGE