drivers/edac/edac_mc_sysfs.c
Source file repositories/reference/linux-study-clean/drivers/edac/edac_mc_sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/edac/edac_mc_sysfs.c- Extension
.c- Size
- 16274 bytes
- Lines
- 675
- Domain
- Driver Families
- Bucket
- drivers/edac
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/ctype.hlinux/slab.hlinux/edac.hlinux/bug.hlinux/pm_runtime.hlinux/uaccess.hedac_mc.hedac_module.h
Detected Declarations
function edac_mc_get_log_uefunction edac_mc_get_log_cefunction edac_mc_get_panic_on_uefunction edac_mc_get_poll_msecfunction edac_set_poll_msecfunction dimmdev_location_showfunction dimmdev_label_showfunction dimmdev_label_storefunction dimmdev_size_showfunction dimmdev_mem_type_showfunction dimmdev_dev_type_showfunction dimmdev_edac_mode_showfunction dimmdev_ce_count_showfunction dimmdev_ue_count_showfunction dimm_releasefunction mci_reset_counters_storefunction mci_for_each_dimmfunction mci_sdram_scrub_rate_storefunction mci_sdram_scrub_rate_showfunction mci_ue_count_showfunction mci_ce_count_showfunction mci_ce_noinfo_showfunction mci_ue_noinfo_showfunction mci_seconds_showfunction mci_ctl_name_showfunction mci_size_mb_showfunction mci_max_location_showfunction mci_attr_is_visiblefunction edac_create_sysfs_mci_devicefunction edac_remove_sysfs_mci_devicefunction mci_for_each_dimmfunction mc_attr_releasefunction edac_mc_sysfs_initfunction edac_mc_sysfs_exit
Annotated Snippet
err = device_add(&dimm->dev);
if (err) {
edac_dbg(1, "failure: create device %s\n", dev_name(&dimm->dev));
put_device(&dimm->dev);
return err;
}
if (IS_ENABLED(CONFIG_EDAC_DEBUG)) {
char location[80];
edac_dimm_info_location(dimm, location, sizeof(location));
edac_dbg(0, "device %s created at location %s\n",
dev_name(&dimm->dev), location);
}
return 0;
}
/*
* Memory controller device
*/
#define to_mci(k) container_of(k, struct mem_ctl_info, dev)
static ssize_t mci_reset_counters_store(struct device *dev,
struct device_attribute *mattr,
const char *data, size_t count)
{
struct mem_ctl_info *mci = to_mci(dev);
struct dimm_info *dimm;
int row, chan;
mci->ue_mc = 0;
mci->ce_mc = 0;
mci->ue_noinfo_count = 0;
mci->ce_noinfo_count = 0;
for (row = 0; row < mci->nr_csrows; row++) {
struct csrow_info *ri = mci->csrows[row];
ri->ue_count = 0;
ri->ce_count = 0;
for (chan = 0; chan < ri->nr_channels; chan++)
ri->channels[chan]->ce_count = 0;
}
mci_for_each_dimm(mci, dimm) {
dimm->ue_count = 0;
dimm->ce_count = 0;
}
mci->start_time = jiffies;
return count;
}
/* Memory scrubbing interface:
*
* A MC driver can limit the scrubbing bandwidth based on the CPU type.
* Therefore, ->set_sdram_scrub_rate should be made to return the actual
* bandwidth that is accepted or 0 when scrubbing is to be disabled.
*
* Negative value still means that an error has occurred while setting
* the scrub rate.
*/
static ssize_t mci_sdram_scrub_rate_store(struct device *dev,
struct device_attribute *mattr,
const char *data, size_t count)
{
struct mem_ctl_info *mci = to_mci(dev);
unsigned long bandwidth = 0;
int new_bw = 0;
if (kstrtoul(data, 10, &bandwidth) < 0)
return -EINVAL;
new_bw = mci->set_sdram_scrub_rate(mci, bandwidth);
if (new_bw < 0) {
edac_printk(KERN_WARNING, EDAC_MC,
"Error setting scrub rate to: %lu\n", bandwidth);
return -EINVAL;
}
return count;
}
/*
* ->get_sdram_scrub_rate() return value semantics same as above.
*/
static ssize_t mci_sdram_scrub_rate_show(struct device *dev,
Annotation
- Immediate include surface: `linux/ctype.h`, `linux/slab.h`, `linux/edac.h`, `linux/bug.h`, `linux/pm_runtime.h`, `linux/uaccess.h`, `edac_mc.h`, `edac_module.h`.
- Detected declarations: `function edac_mc_get_log_ue`, `function edac_mc_get_log_ce`, `function edac_mc_get_panic_on_ue`, `function edac_mc_get_poll_msec`, `function edac_set_poll_msec`, `function dimmdev_location_show`, `function dimmdev_label_show`, `function dimmdev_label_store`, `function dimmdev_size_show`, `function dimmdev_mem_type_show`.
- Atlas domain: Driver Families / drivers/edac.
- 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.