arch/powerpc/platforms/pseries/pmem.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/pseries/pmem.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/pseries/pmem.c- Extension
.c- Size
- 3923 bytes
- Lines
- 168
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/interrupt.hlinux/delay.hlinux/sched.hlinux/sched/hotplug.hlinux/cpu.hlinux/of.hlinux/of_platform.hlinux/slab.hasm/rtas.hasm/firmware.hasm/machdep.hasm/vdso_datapage.hasm/plpar_wrappers.hasm/topology.hpseries.h
Detected Declarations
function pmem_drc_add_nodefunction pmem_drc_remove_nodefunction for_each_child_of_nodefunction dlpar_hp_pmemfunction pseries_pmem_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Handles hot and cold plug of persistent memory regions on pseries.
*/
#define pr_fmt(fmt) "pseries-pmem: " fmt
#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/sched.h> /* for idle_task_exit */
#include <linux/sched/hotplug.h>
#include <linux/cpu.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/slab.h>
#include <asm/rtas.h>
#include <asm/firmware.h>
#include <asm/machdep.h>
#include <asm/vdso_datapage.h>
#include <asm/plpar_wrappers.h>
#include <asm/topology.h>
#include "pseries.h"
static struct device_node *pmem_node;
static ssize_t pmem_drc_add_node(u32 drc_index)
{
struct device_node *dn;
int rc;
pr_debug("Attempting to add pmem node, drc index: %x\n", drc_index);
rc = dlpar_acquire_drc(drc_index);
if (rc) {
pr_err("Failed to acquire DRC, rc: %d, drc index: %x\n",
rc, drc_index);
return -EINVAL;
}
dn = dlpar_configure_connector(cpu_to_be32(drc_index), pmem_node);
if (!dn) {
pr_err("configure-connector failed for drc %x\n", drc_index);
dlpar_release_drc(drc_index);
return -EINVAL;
}
/* NB: The of reconfig notifier creates platform device from the node */
rc = dlpar_attach_node(dn, pmem_node);
if (rc) {
pr_err("Failed to attach node %pOF, rc: %d, drc index: %x\n",
dn, rc, drc_index);
if (dlpar_release_drc(drc_index))
dlpar_free_cc_nodes(dn);
return rc;
}
pr_info("Successfully added %pOF, drc index: %x\n", dn, drc_index);
return 0;
}
static ssize_t pmem_drc_remove_node(u32 drc_index)
{
struct device_node *dn;
uint32_t index;
int rc;
for_each_child_of_node(pmem_node, dn) {
if (of_property_read_u32(dn, "ibm,my-drc-index", &index))
continue;
if (index == drc_index)
break;
}
if (!dn) {
pr_err("Attempting to remove unused DRC index %x\n", drc_index);
return -ENODEV;
}
pr_debug("Attempting to remove %pOF, drc index: %x\n", dn, drc_index);
/* * NB: tears down the ibm,pmemory device as a side-effect */
rc = dlpar_detach_node(dn);
if (rc)
return rc;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/sched.h`, `linux/sched/hotplug.h`, `linux/cpu.h`, `linux/of.h`, `linux/of_platform.h`.
- Detected declarations: `function pmem_drc_add_node`, `function pmem_drc_remove_node`, `function for_each_child_of_node`, `function dlpar_hp_pmem`, `function pseries_pmem_init`.
- 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.