drivers/edac/mem_repair.c
Source file repositories/reference/linux-study-clean/drivers/edac/mem_repair.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/edac/mem_repair.c- Extension
.c- Size
- 9652 bytes
- Lines
- 358
- Domain
- Driver Families
- Bucket
- drivers/edac
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/edac.h
Detected Declarations
struct edac_mem_repair_dev_attrstruct edac_mem_repair_contextenum edac_mem_repair_attributesfunction mem_repair_attr_visiblefunction mem_repair_create_descfunction edac_mem_repair_get_descexport edac_repair_type
Annotated Snippet
struct edac_mem_repair_dev_attr {
struct device_attribute dev_attr;
u8 instance;
};
struct edac_mem_repair_context {
char name[EDAC_FEAT_NAME_LEN];
struct edac_mem_repair_dev_attr mem_repair_dev_attr[MR_MAX_ATTRS];
struct attribute *mem_repair_attrs[MR_MAX_ATTRS + 1];
struct attribute_group group;
};
const char * const edac_repair_type[] = {
[EDAC_REPAIR_PPR] = "ppr",
[EDAC_REPAIR_CACHELINE_SPARING] = "cacheline-sparing",
[EDAC_REPAIR_ROW_SPARING] = "row-sparing",
[EDAC_REPAIR_BANK_SPARING] = "bank-sparing",
[EDAC_REPAIR_RANK_SPARING] = "rank-sparing",
};
EXPORT_SYMBOL_GPL(edac_repair_type);
#define TO_MR_DEV_ATTR(_dev_attr) \
container_of(_dev_attr, struct edac_mem_repair_dev_attr, dev_attr)
#define MR_ATTR_SHOW(attrib, cb, type, format) \
static ssize_t attrib##_show(struct device *ras_feat_dev, \
struct device_attribute *attr, char *buf) \
{ \
u8 inst = TO_MR_DEV_ATTR(attr)->instance; \
struct edac_dev_feat_ctx *ctx = dev_get_drvdata(ras_feat_dev); \
const struct edac_mem_repair_ops *ops = \
ctx->mem_repair[inst].mem_repair_ops; \
type data; \
int ret; \
\
ret = ops->cb(ras_feat_dev->parent, ctx->mem_repair[inst].private, \
&data); \
if (ret) \
return ret; \
\
return sysfs_emit(buf, format, data); \
}
MR_ATTR_SHOW(repair_type, get_repair_type, const char *, "%s\n")
MR_ATTR_SHOW(persist_mode, get_persist_mode, bool, "%u\n")
MR_ATTR_SHOW(repair_safe_when_in_use, get_repair_safe_when_in_use, bool, "%u\n")
MR_ATTR_SHOW(hpa, get_hpa, u64, "0x%llx\n")
MR_ATTR_SHOW(min_hpa, get_min_hpa, u64, "0x%llx\n")
MR_ATTR_SHOW(max_hpa, get_max_hpa, u64, "0x%llx\n")
MR_ATTR_SHOW(dpa, get_dpa, u64, "0x%llx\n")
MR_ATTR_SHOW(min_dpa, get_min_dpa, u64, "0x%llx\n")
MR_ATTR_SHOW(max_dpa, get_max_dpa, u64, "0x%llx\n")
MR_ATTR_SHOW(nibble_mask, get_nibble_mask, u32, "0x%x\n")
MR_ATTR_SHOW(bank_group, get_bank_group, u32, "%u\n")
MR_ATTR_SHOW(bank, get_bank, u32, "%u\n")
MR_ATTR_SHOW(rank, get_rank, u32, "%u\n")
MR_ATTR_SHOW(row, get_row, u32, "0x%x\n")
MR_ATTR_SHOW(column, get_column, u32, "%u\n")
MR_ATTR_SHOW(channel, get_channel, u32, "%u\n")
MR_ATTR_SHOW(sub_channel, get_sub_channel, u32, "%u\n")
#define MR_ATTR_STORE(attrib, cb, type, conv_func) \
static ssize_t attrib##_store(struct device *ras_feat_dev, \
struct device_attribute *attr, \
const char *buf, size_t len) \
{ \
u8 inst = TO_MR_DEV_ATTR(attr)->instance; \
struct edac_dev_feat_ctx *ctx = dev_get_drvdata(ras_feat_dev); \
const struct edac_mem_repair_ops *ops = \
ctx->mem_repair[inst].mem_repair_ops; \
type data; \
int ret; \
\
ret = conv_func(buf, 0, &data); \
if (ret < 0) \
return ret; \
\
ret = ops->cb(ras_feat_dev->parent, ctx->mem_repair[inst].private, \
data); \
if (ret) \
return ret; \
\
return len; \
}
MR_ATTR_STORE(persist_mode, set_persist_mode, unsigned long, kstrtoul)
MR_ATTR_STORE(hpa, set_hpa, u64, kstrtou64)
MR_ATTR_STORE(dpa, set_dpa, u64, kstrtou64)
MR_ATTR_STORE(nibble_mask, set_nibble_mask, unsigned long, kstrtoul)
MR_ATTR_STORE(bank_group, set_bank_group, unsigned long, kstrtoul)
Annotation
- Immediate include surface: `linux/edac.h`.
- Detected declarations: `struct edac_mem_repair_dev_attr`, `struct edac_mem_repair_context`, `enum edac_mem_repair_attributes`, `function mem_repair_attr_visible`, `function mem_repair_create_desc`, `function edac_mem_repair_get_desc`, `export edac_repair_type`.
- Atlas domain: Driver Families / drivers/edac.
- Implementation status: integration 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.