drivers/edac/thunderx_edac.c
Source file repositories/reference/linux-study-clean/drivers/edac/thunderx_edac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/edac/thunderx_edac.c- Extension
.c- Size
- 53986 bytes
- Lines
- 2147
- Domain
- Driver Families
- Bucket
- drivers/edac
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/module.hlinux/pci.hlinux/edac.hlinux/interrupt.hlinux/string.hlinux/stop_machine.hlinux/delay.hlinux/sizes.hlinux/atomic.hlinux/bitfield.hlinux/circ_buf.hasm/page.hedac_module.h
Detected Declarations
struct error_descrstruct debugfs_entrystruct lmc_err_ctxstruct thunderx_lmcstruct ocx_com_err_ctxstruct ocx_link_err_ctxstruct thunderx_ocxstruct l2c_err_ctxstruct thunderx_l2cfunction decode_registerfunction get_bitsfunction thunderx_lmc_inject_int_writefunction thunderx_lmc_int_readfunction inject_ecc_fnfunction thunderx_lmc_inject_ecc_writefunction thunderx_create_debugfs_nodesfunction thunderx_faddr_to_physfunction thunderx_get_num_lmcsfunction thunderx_lmc_err_isrfunction thunderx_lmc_threaded_isrfunction pci_dev_to_mc_idxfunction thunderx_lmc_probefunction thunderx_lmc_removefunction thunderx_ocx_com_isrfunction thunderx_ocx_com_threaded_isrfunction thunderx_ocx_lnk_isrfunction thunderx_ocx_lnk_threaded_isrfunction thunderx_ocx_clearstatsfunction thunderx_ocx_probefunction thunderx_ocx_removefunction thunderx_l2c_tad_isrfunction thunderx_l2c_cbc_isrfunction thunderx_l2c_mci_isrfunction thunderx_l2c_threaded_isrfunction thunderx_l2c_probefunction thunderx_l2c_removefunction thunderx_edac_initfunction thunderx_edac_exitmodule init thunderx_edac_init
Annotated Snippet
const struct file_operations fops;
};
struct lmc_err_ctx {
u64 reg_int;
u64 reg_fadr;
u64 reg_nxm_fadr;
u64 reg_scram_fadr;
u64 reg_ecc_synd;
};
struct thunderx_lmc {
void __iomem *regs;
struct pci_dev *pdev;
struct msix_entry msix_ent;
atomic_t ecc_int;
u64 mask0;
u64 mask2;
u64 parity_test;
u64 node;
int xbits;
int bank_width;
int pbank_lsb;
int dimm_lsb;
int rank_lsb;
int bank_lsb;
int row_lsb;
int col_hi_lsb;
int xor_bank;
int l2c_alias;
struct page *mem;
struct lmc_err_ctx err_ctx[RING_ENTRIES];
unsigned long ring_head;
unsigned long ring_tail;
};
#define ring_pos(pos, size) ((pos) & (size - 1))
#define DEBUGFS_STRUCT(_name, _mode, _write, _read) \
static struct debugfs_entry debugfs_##_name = { \
.name = __stringify(_name), \
.mode = VERIFY_OCTAL_PERMISSIONS(_mode), \
.fops = { \
.open = simple_open, \
.write = _write, \
.read = _read, \
.llseek = generic_file_llseek, \
}, \
}
#define DEBUGFS_FIELD_ATTR(_type, _field) \
static ssize_t thunderx_##_type##_##_field##_read(struct file *file, \
char __user *data, \
size_t count, loff_t *ppos) \
{ \
struct thunderx_##_type *pdata = file->private_data; \
char buf[20]; \
\
snprintf(buf, count, "0x%016llx", pdata->_field); \
return simple_read_from_buffer(data, count, ppos, \
buf, sizeof(buf)); \
} \
\
static ssize_t thunderx_##_type##_##_field##_write(struct file *file, \
const char __user *data, \
size_t count, loff_t *ppos) \
{ \
struct thunderx_##_type *pdata = file->private_data; \
int res; \
\
res = kstrtoull_from_user(data, count, 0, &pdata->_field); \
\
return res ? res : count; \
} \
\
DEBUGFS_STRUCT(_field, 0600, \
thunderx_##_type##_##_field##_write, \
thunderx_##_type##_##_field##_read) \
#define DEBUGFS_REG_ATTR(_type, _name, _reg) \
static ssize_t thunderx_##_type##_##_name##_read(struct file *file, \
char __user *data, \
size_t count, loff_t *ppos) \
{ \
Annotation
- Immediate include surface: `linux/module.h`, `linux/pci.h`, `linux/edac.h`, `linux/interrupt.h`, `linux/string.h`, `linux/stop_machine.h`, `linux/delay.h`, `linux/sizes.h`.
- Detected declarations: `struct error_descr`, `struct debugfs_entry`, `struct lmc_err_ctx`, `struct thunderx_lmc`, `struct ocx_com_err_ctx`, `struct ocx_link_err_ctx`, `struct thunderx_ocx`, `struct l2c_err_ctx`, `struct thunderx_l2c`, `function decode_register`.
- Atlas domain: Driver Families / drivers/edac.
- Implementation status: pattern 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.