arch/powerpc/mm/drmem.c
Source file repositories/reference/linux-study-clean/arch/powerpc/mm/drmem.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/mm/drmem.c- Extension
.c- Size
- 11694 bytes
- Lines
- 513
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/of.hlinux/of_fdt.hlinux/memblock.hlinux/slab.hasm/drmem.h
Detected Declarations
function drmem_lmb_memory_maxfunction drmem_lmb_flagsfunction drmem_update_dt_v1function for_each_drmem_lmbfunction init_drconf_v2_cellfunction drmem_update_dt_v2function drmem_update_dtfunction read_drconf_v1_cellfunction __walk_drmem_v1_lmbsfunction read_drconf_v2_cellfunction __walk_drmem_v2_lmbsfunction walk_drmem_lmbs_earlyfunction update_lmbfunction for_each_drmem_lmbfunction drmem_update_lmbsfunction init_drmem_lmb_sizefunction existsfunction walk_drmem_lmbsfunction init_drmem_v1_lmbsfunction init_drmem_v2_lmbsfunction drmem_init
Annotated Snippet
if (!prev_lmb) {
prev_lmb = lmb;
lmb_sets++;
continue;
}
if (prev_lmb->aa_index != lmb->aa_index ||
drmem_lmb_flags(prev_lmb) != drmem_lmb_flags(lmb))
lmb_sets++;
prev_lmb = lmb;
}
prop_sz = lmb_sets * sizeof(*dr_cell) + sizeof(__be32);
new_prop = clone_property(prop, prop_sz);
if (!new_prop)
return -1;
p = new_prop->value;
*p++ = cpu_to_be32(lmb_sets);
dr_cell = (struct of_drconf_cell_v2 *)p;
/* Second pass, populate the LMB set data */
prev_lmb = NULL;
seq_lmbs = 0;
for_each_drmem_lmb(lmb) {
if (prev_lmb == NULL) {
/* Start of first LMB set */
prev_lmb = lmb;
init_drconf_v2_cell(dr_cell, lmb);
seq_lmbs++;
continue;
}
if (prev_lmb->aa_index != lmb->aa_index ||
drmem_lmb_flags(prev_lmb) != drmem_lmb_flags(lmb)) {
/* end of one set, start of another */
dr_cell->seq_lmbs = cpu_to_be32(seq_lmbs);
dr_cell++;
init_drconf_v2_cell(dr_cell, lmb);
seq_lmbs = 1;
} else {
seq_lmbs++;
}
prev_lmb = lmb;
}
/* close out last LMB set */
dr_cell->seq_lmbs = cpu_to_be32(seq_lmbs);
of_update_property(memory, new_prop);
return 0;
}
int drmem_update_dt(void)
{
struct device_node *memory;
struct property *prop;
int rc = -1;
memory = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
if (!memory)
return -1;
/*
* Set in_drmem_update to prevent the notifier callback to process the
* DT property back since the change is coming from the LMB tree.
*/
in_drmem_update = true;
prop = of_find_property(memory, "ibm,dynamic-memory", NULL);
if (prop) {
rc = drmem_update_dt_v1(memory, prop);
} else {
prop = of_find_property(memory, "ibm,dynamic-memory-v2", NULL);
if (prop)
rc = drmem_update_dt_v2(memory, prop);
}
in_drmem_update = false;
of_node_put(memory);
return rc;
}
static void read_drconf_v1_cell(struct drmem_lmb *lmb,
const __be32 **prop)
{
const __be32 *p = *prop;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/of.h`, `linux/of_fdt.h`, `linux/memblock.h`, `linux/slab.h`, `asm/drmem.h`.
- Detected declarations: `function drmem_lmb_memory_max`, `function drmem_lmb_flags`, `function drmem_update_dt_v1`, `function for_each_drmem_lmb`, `function init_drconf_v2_cell`, `function drmem_update_dt_v2`, `function drmem_update_dt`, `function read_drconf_v1_cell`, `function __walk_drmem_v1_lmbs`, `function read_drconf_v2_cell`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.