drivers/edac/al_mc_edac.c
Source file repositories/reference/linux-study-clean/drivers/edac/al_mc_edac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/edac/al_mc_edac.c- Extension
.c- Size
- 9595 bytes
- Lines
- 351
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/bitops.hlinux/edac.hlinux/of_irq.hlinux/platform_device.hlinux/spinlock.hedac_module.h
Detected Declarations
struct al_mc_edacfunction prepare_msgfunction handle_cefunction handle_uefunction al_mc_edac_checkfunction al_mc_edac_irq_handler_uefunction al_mc_edac_irq_handler_cefunction get_scrub_modefunction devm_al_mc_edac_freefunction devm_al_mc_edac_delfunction al_mc_edac_probefunction interrupts
Annotated Snippet
struct al_mc_edac {
void __iomem *mmio_base;
spinlock_t lock;
int irq_ce;
int irq_ue;
};
static void prepare_msg(char *message, size_t buffer_size,
enum hw_event_mc_err_type type,
u8 rank, u32 row, u8 bg, u8 bank, u16 column,
u32 syn0, u32 syn1, u32 syn2)
{
snprintf(message, buffer_size,
"%s rank=0x%x row=0x%x bg=0x%x bank=0x%x col=0x%x syn0: 0x%x syn1: 0x%x syn2: 0x%x",
type == HW_EVENT_ERR_UNCORRECTED ? "UE" : "CE",
rank, row, bg, bank, column, syn0, syn1, syn2);
}
static int handle_ce(struct mem_ctl_info *mci)
{
u32 eccerrcnt, ecccaddr0, ecccaddr1, ecccsyn0, ecccsyn1, ecccsyn2, row;
struct al_mc_edac *al_mc = mci->pvt_info;
char msg[AL_MC_EDAC_MSG_MAX];
u16 ce_count, column;
unsigned long flags;
u8 rank, bg, bank;
eccerrcnt = readl_relaxed(al_mc->mmio_base + AL_MC_ECC_ERR_COUNT);
ce_count = FIELD_GET(AL_MC_ECC_ERR_COUNT_CE, eccerrcnt);
if (!ce_count)
return 0;
ecccaddr0 = readl_relaxed(al_mc->mmio_base + AL_MC_ECC_CE_ADDR0);
ecccaddr1 = readl_relaxed(al_mc->mmio_base + AL_MC_ECC_CE_ADDR1);
ecccsyn0 = readl_relaxed(al_mc->mmio_base + AL_MC_ECC_CE_SYND0);
ecccsyn1 = readl_relaxed(al_mc->mmio_base + AL_MC_ECC_CE_SYND1);
ecccsyn2 = readl_relaxed(al_mc->mmio_base + AL_MC_ECC_CE_SYND2);
writel_relaxed(AL_MC_ECC_CLEAR_CE_COUNT | AL_MC_ECC_CLEAR_CE_ERR,
al_mc->mmio_base + AL_MC_ECC_CLEAR);
dev_dbg(mci->pdev, "eccuaddr0=0x%08x eccuaddr1=0x%08x\n",
ecccaddr0, ecccaddr1);
rank = FIELD_GET(AL_MC_ECC_CE_ADDR0_RANK, ecccaddr0);
row = FIELD_GET(AL_MC_ECC_CE_ADDR0_ROW, ecccaddr0);
bg = FIELD_GET(AL_MC_ECC_CE_ADDR1_BG, ecccaddr1);
bank = FIELD_GET(AL_MC_ECC_CE_ADDR1_BANK, ecccaddr1);
column = FIELD_GET(AL_MC_ECC_CE_ADDR1_COLUMN, ecccaddr1);
prepare_msg(msg, sizeof(msg), HW_EVENT_ERR_CORRECTED,
rank, row, bg, bank, column,
ecccsyn0, ecccsyn1, ecccsyn2);
spin_lock_irqsave(&al_mc->lock, flags);
edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci,
ce_count, 0, 0, 0, 0, 0, -1, mci->ctl_name, msg);
spin_unlock_irqrestore(&al_mc->lock, flags);
return ce_count;
}
static int handle_ue(struct mem_ctl_info *mci)
{
u32 eccerrcnt, eccuaddr0, eccuaddr1, eccusyn0, eccusyn1, eccusyn2, row;
struct al_mc_edac *al_mc = mci->pvt_info;
char msg[AL_MC_EDAC_MSG_MAX];
u16 ue_count, column;
unsigned long flags;
u8 rank, bg, bank;
eccerrcnt = readl_relaxed(al_mc->mmio_base + AL_MC_ECC_ERR_COUNT);
ue_count = FIELD_GET(AL_MC_ECC_ERR_COUNT_UE, eccerrcnt);
if (!ue_count)
return 0;
eccuaddr0 = readl_relaxed(al_mc->mmio_base + AL_MC_ECC_UE_ADDR0);
eccuaddr1 = readl_relaxed(al_mc->mmio_base + AL_MC_ECC_UE_ADDR1);
eccusyn0 = readl_relaxed(al_mc->mmio_base + AL_MC_ECC_UE_SYND0);
eccusyn1 = readl_relaxed(al_mc->mmio_base + AL_MC_ECC_UE_SYND1);
eccusyn2 = readl_relaxed(al_mc->mmio_base + AL_MC_ECC_UE_SYND2);
writel_relaxed(AL_MC_ECC_CLEAR_UE_COUNT | AL_MC_ECC_CLEAR_UE_ERR,
al_mc->mmio_base + AL_MC_ECC_CLEAR);
dev_dbg(mci->pdev, "eccuaddr0=0x%08x eccuaddr1=0x%08x\n",
eccuaddr0, eccuaddr1);
rank = FIELD_GET(AL_MC_ECC_UE_ADDR0_RANK, eccuaddr0);
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bitops.h`, `linux/edac.h`, `linux/of_irq.h`, `linux/platform_device.h`, `linux/spinlock.h`, `edac_module.h`.
- Detected declarations: `struct al_mc_edac`, `function prepare_msg`, `function handle_ce`, `function handle_ue`, `function al_mc_edac_check`, `function al_mc_edac_irq_handler_ue`, `function al_mc_edac_irq_handler_ce`, `function get_scrub_mode`, `function devm_al_mc_edac_free`, `function devm_al_mc_edac_del`.
- Atlas domain: Driver Families / drivers/edac.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.