|
59 | 59 | #include <asm/epapr_hcalls.h> |
60 | 60 | #include <asm/firmware.h> |
61 | 61 | #include <asm/dt_cpu_ftrs.h> |
| 62 | +#include <asm/drmem.h> |
62 | 63 |
|
63 | 64 | #include <mm/mmu_decl.h> |
64 | 65 |
|
@@ -455,92 +456,74 @@ static int __init early_init_dt_scan_chosen_ppc(unsigned long node, |
455 | 456 |
|
456 | 457 | #ifdef CONFIG_PPC_PSERIES |
457 | 458 | /* |
458 | | - * Interpret the ibm,dynamic-memory property in the |
459 | | - * /ibm,dynamic-reconfiguration-memory node. |
| 459 | + * Interpret the ibm dynamic reconfiguration memory LMBs. |
460 | 460 | * This contains a list of memory blocks along with NUMA affinity |
461 | 461 | * information. |
462 | 462 | */ |
463 | | -static int __init early_init_dt_scan_drconf_memory(unsigned long node) |
| 463 | +static void __init early_init_drmem_lmb(struct drmem_lmb *lmb, |
| 464 | + const __be32 **usm) |
464 | 465 | { |
465 | | - const __be32 *dm, *ls, *usm; |
466 | | - int l; |
467 | | - unsigned long n, flags; |
468 | | - u64 base, size, memblock_size; |
469 | | - unsigned int is_kexec_kdump = 0, rngs; |
470 | | - |
471 | | - ls = of_get_flat_dt_prop(node, "ibm,lmb-size", &l); |
472 | | - if (ls == NULL || l < dt_root_size_cells * sizeof(__be32)) |
473 | | - return 0; |
474 | | - memblock_size = dt_mem_next_cell(dt_root_size_cells, &ls); |
| 466 | + u64 base, size; |
| 467 | + int is_kexec_kdump = 0, rngs; |
475 | 468 |
|
476 | | - dm = of_get_flat_dt_prop(node, "ibm,dynamic-memory", &l); |
477 | | - if (dm == NULL || l < sizeof(__be32)) |
478 | | - return 0; |
| 469 | + base = lmb->base_addr; |
| 470 | + size = drmem_lmb_size(); |
| 471 | + rngs = 1; |
479 | 472 |
|
480 | | - n = of_read_number(dm++, 1); /* number of entries */ |
481 | | - if (l < (n * (dt_root_addr_cells + 4) + 1) * sizeof(__be32)) |
482 | | - return 0; |
| 473 | + /* |
| 474 | + * Skip this block if the reserved bit is set in flags |
| 475 | + * or if the block is not assigned to this partition. |
| 476 | + */ |
| 477 | + if ((lmb->flags & DRCONF_MEM_RESERVED) || |
| 478 | + !(lmb->flags & DRCONF_MEM_ASSIGNED)) |
| 479 | + return; |
483 | 480 |
|
484 | | - /* check if this is a kexec/kdump kernel. */ |
485 | | - usm = of_get_flat_dt_prop(node, "linux,drconf-usable-memory", |
486 | | - &l); |
487 | | - if (usm != NULL) |
| 481 | + if (*usm) |
488 | 482 | is_kexec_kdump = 1; |
489 | 483 |
|
490 | | - for (; n != 0; --n) { |
491 | | - base = dt_mem_next_cell(dt_root_addr_cells, &dm); |
492 | | - flags = of_read_number(&dm[3], 1); |
493 | | - /* skip DRC index, pad, assoc. list index, flags */ |
494 | | - dm += 4; |
495 | | - /* skip this block if the reserved bit is set in flags |
496 | | - or if the block is not assigned to this partition */ |
497 | | - if ((flags & DRCONF_MEM_RESERVED) || |
498 | | - !(flags & DRCONF_MEM_ASSIGNED)) |
499 | | - continue; |
500 | | - size = memblock_size; |
501 | | - rngs = 1; |
| 484 | + if (is_kexec_kdump) { |
| 485 | + /* |
| 486 | + * For each memblock in ibm,dynamic-memory, a |
| 487 | + * corresponding entry in linux,drconf-usable-memory |
| 488 | + * property contains a counter 'p' followed by 'p' |
| 489 | + * (base, size) duple. Now read the counter from |
| 490 | + * linux,drconf-usable-memory property |
| 491 | + */ |
| 492 | + rngs = dt_mem_next_cell(dt_root_size_cells, usm); |
| 493 | + if (!rngs) /* there are no (base, size) duple */ |
| 494 | + return; |
| 495 | + } |
| 496 | + |
| 497 | + do { |
502 | 498 | if (is_kexec_kdump) { |
503 | | - /* |
504 | | - * For each memblock in ibm,dynamic-memory, a corresponding |
505 | | - * entry in linux,drconf-usable-memory property contains |
506 | | - * a counter 'p' followed by 'p' (base, size) duple. |
507 | | - * Now read the counter from |
508 | | - * linux,drconf-usable-memory property |
509 | | - */ |
510 | | - rngs = dt_mem_next_cell(dt_root_size_cells, &usm); |
511 | | - if (!rngs) /* there are no (base, size) duple */ |
| 499 | + base = dt_mem_next_cell(dt_root_addr_cells, usm); |
| 500 | + size = dt_mem_next_cell(dt_root_size_cells, usm); |
| 501 | + } |
| 502 | + |
| 503 | + if (iommu_is_off) { |
| 504 | + if (base >= 0x80000000ul) |
512 | 505 | continue; |
| 506 | + if ((base + size) > 0x80000000ul) |
| 507 | + size = 0x80000000ul - base; |
513 | 508 | } |
514 | | - do { |
515 | | - if (is_kexec_kdump) { |
516 | | - base = dt_mem_next_cell(dt_root_addr_cells, |
517 | | - &usm); |
518 | | - size = dt_mem_next_cell(dt_root_size_cells, |
519 | | - &usm); |
520 | | - } |
521 | | - if (iommu_is_off) { |
522 | | - if (base >= 0x80000000ul) |
523 | | - continue; |
524 | | - if ((base + size) > 0x80000000ul) |
525 | | - size = 0x80000000ul - base; |
526 | | - } |
527 | | - memblock_add(base, size); |
528 | | - } while (--rngs); |
529 | | - } |
530 | | - memblock_dump_all(); |
531 | | - return 0; |
| 509 | + |
| 510 | + DBG("Adding: %llx -> %llx\n", base, size); |
| 511 | + memblock_add(base, size); |
| 512 | + } while (--rngs); |
532 | 513 | } |
533 | | -#else |
534 | | -#define early_init_dt_scan_drconf_memory(node) 0 |
535 | 514 | #endif /* CONFIG_PPC_PSERIES */ |
536 | 515 |
|
537 | 516 | static int __init early_init_dt_scan_memory_ppc(unsigned long node, |
538 | 517 | const char *uname, |
539 | 518 | int depth, void *data) |
540 | 519 | { |
| 520 | +#ifdef CONFIG_PPC_PSERIES |
541 | 521 | if (depth == 1 && |
542 | | - strcmp(uname, "ibm,dynamic-reconfiguration-memory") == 0) |
543 | | - return early_init_dt_scan_drconf_memory(node); |
| 522 | + strcmp(uname, "ibm,dynamic-reconfiguration-memory") == 0) { |
| 523 | + walk_drmem_lmbs_early(node, early_init_drmem_lmb); |
| 524 | + return 0; |
| 525 | + } |
| 526 | +#endif |
544 | 527 |
|
545 | 528 | return early_init_dt_scan_memory(node, uname, depth, data); |
546 | 529 | } |
|
0 commit comments