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.

Dependency Surface

Detected Declarations

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

Implementation Notes