drivers/ras/amd/fmpm.c
Source file repositories/reference/linux-study-clean/drivers/ras/amd/fmpm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ras/amd/fmpm.c- Extension
.c- Size
- 24778 bytes
- Lines
- 1043
- Domain
- Driver Families
- Bucket
- drivers/ras
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/cper.hlinux/ras.hlinux/cpu.hacpi/apei.hasm/cpu_device_id.hasm/cpuid/api.hasm/mce.h../debugfs.hatl/internal.h
Detected Declarations
struct cper_sec_fru_mem_poisonstruct cper_fru_poison_descstruct fru_recfunction get_fmp_lenfunction for_each_frufunction do_fmp_checksumfunction update_record_on_storagefunction rec_has_valid_entriesfunction fpds_equalfunction rec_has_fpdfunction save_spafunction update_fru_recordfunction retire_dram_rowfunction fru_handle_mem_poisonfunction retire_mem_fmpfunction for_each_online_cpufunction retire_mem_recordsfunction for_each_frufunction set_rec_fieldsfunction save_new_recordsfunction for_each_frufunction fmp_is_usablefunction fmp_is_validfunction get_saved_recordsfunction set_fmp_fieldsfunction init_fmpsfunction for_each_frufunction for_each_online_cpufunction get_system_infofunction free_recordsfunction allocate_recordsfunction fmpm_stopfunction fmpm_openfunction setup_debugfsfunction fru_mem_poison_initfunction fru_mem_poison_exitmodule init fru_mem_poison_init
Annotated Snippet
static const struct file_operations fmpm_fops = {
.open = fmpm_open,
.release = seq_release,
.read = seq_read,
.llseek = seq_lseek,
};
static void setup_debugfs(void)
{
struct dentry *dfs = ras_get_debugfs_root();
if (!dfs)
return;
fmpm_dfs_dir = debugfs_create_dir("fmpm", dfs);
if (!fmpm_dfs_dir)
return;
fmpm_dfs_entries = debugfs_create_file("entries", 0400, fmpm_dfs_dir, NULL, &fmpm_fops);
if (!fmpm_dfs_entries)
debugfs_remove(fmpm_dfs_dir);
}
static const struct x86_cpu_id fmpm_cpuids[] = {
X86_MATCH_VENDOR_FAM(AMD, 0x19, NULL),
{ }
};
MODULE_DEVICE_TABLE(x86cpu, fmpm_cpuids);
static int __init fru_mem_poison_init(void)
{
int ret;
if (!x86_match_cpu(fmpm_cpuids)) {
ret = -ENODEV;
goto out;
}
if (erst_disable) {
pr_debug("ERST not available\n");
ret = -ENODEV;
goto out;
}
ret = get_system_info();
if (ret)
goto out;
ret = allocate_records();
if (ret)
goto out;
ret = init_fmps();
if (ret)
goto out_free;
ret = get_saved_records();
if (ret)
goto out_free;
ret = save_new_records();
if (ret)
goto out_free;
setup_debugfs();
retire_mem_records();
mce_register_decode_chain(&fru_mem_poison_nb);
pr_info("FRU Memory Poison Manager initialized\n");
return 0;
out_free:
free_records();
out:
return ret;
}
static void __exit fru_mem_poison_exit(void)
{
mce_unregister_decode_chain(&fru_mem_poison_nb);
debugfs_remove(fmpm_dfs_dir);
free_records();
}
module_init(fru_mem_poison_init);
module_exit(fru_mem_poison_exit);
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/cper.h`, `linux/ras.h`, `linux/cpu.h`, `acpi/apei.h`, `asm/cpu_device_id.h`, `asm/cpuid/api.h`, `asm/mce.h`, `../debugfs.h`.
- Detected declarations: `struct cper_sec_fru_mem_poison`, `struct cper_fru_poison_desc`, `struct fru_rec`, `function get_fmp_len`, `function for_each_fru`, `function do_fmp_checksum`, `function update_record_on_storage`, `function rec_has_valid_entries`, `function fpds_equal`, `function rec_has_fpd`.
- Atlas domain: Driver Families / drivers/ras.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.