arch/powerpc/platforms/powernv/opal-imc.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/powernv/opal-imc.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/powernv/opal-imc.c- Extension
.c- Size
- 7741 bytes
- Lines
- 324
- 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/platform_device.hlinux/of.hlinux/of_address.hlinux/crash_dump.hlinux/debugfs.hasm/opal.hasm/io.hasm/imc-pmu.hasm/cputhreads.h
Detected Declarations
function imc_mem_getfunction imc_mem_setfunction imc_debugfs_create_x64function export_imc_mode_and_cmdfunction imc_get_mem_addr_nestfunction disable_nest_pmu_countersfunction disable_core_pmu_countersfunction get_max_nest_devfunction for_each_compatible_nodefunction opal_imc_counters_probefunction for_each_compatible_nodefunction opal_imc_counters_shutdown
Annotated Snippet
if (of_property_read_u32(imc_dev, "type", &type)) {
pr_warn("IMC Device without type property\n");
continue;
}
switch (type) {
case IMC_TYPE_CHIP:
domain = IMC_DOMAIN_NEST;
break;
case IMC_TYPE_CORE:
domain =IMC_DOMAIN_CORE;
break;
case IMC_TYPE_THREAD:
domain = IMC_DOMAIN_THREAD;
break;
case IMC_TYPE_TRACE:
domain = IMC_DOMAIN_TRACE;
break;
default:
pr_warn("IMC Unknown Device type \n");
domain = -1;
break;
}
pmu = imc_pmu_create(imc_dev, pmu_count, domain);
if (pmu != NULL) {
if (domain == IMC_DOMAIN_NEST) {
if (!imc_debugfs_parent)
export_imc_mode_and_cmd(imc_dev, pmu);
pmu_count++;
}
if (domain == IMC_DOMAIN_CORE)
core_imc_reg = true;
if (domain == IMC_DOMAIN_THREAD)
thread_imc_reg = true;
}
}
/* If core imc is not registered, unregister thread-imc */
if (!core_imc_reg && thread_imc_reg)
unregister_thread_imc();
return 0;
}
static void opal_imc_counters_shutdown(struct platform_device *pdev)
{
/*
* Function only stops the engines which is bare minimum.
* TODO: Need to handle proper memory cleanup and pmu
* unregister.
*/
disable_nest_pmu_counters();
disable_core_pmu_counters();
}
static const struct of_device_id opal_imc_match[] = {
{ .compatible = IMC_DTB_COMPAT },
{},
};
static struct platform_driver opal_imc_driver = {
.driver = {
.name = "opal-imc-counters",
.of_match_table = opal_imc_match,
},
.probe = opal_imc_counters_probe,
.shutdown = opal_imc_counters_shutdown,
};
builtin_platform_driver(opal_imc_driver);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/platform_device.h`, `linux/of.h`, `linux/of_address.h`, `linux/crash_dump.h`, `linux/debugfs.h`, `asm/opal.h`, `asm/io.h`.
- Detected declarations: `function imc_mem_get`, `function imc_mem_set`, `function imc_debugfs_create_x64`, `function export_imc_mode_and_cmd`, `function imc_get_mem_addr_nest`, `function disable_nest_pmu_counters`, `function disable_core_pmu_counters`, `function get_max_nest_dev`, `function for_each_compatible_node`, `function opal_imc_counters_probe`.
- 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.