drivers/cxl/core/edac.c
Source file repositories/reference/linux-study-clean/drivers/cxl/core/edac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/cxl/core/edac.c- Extension
.c- Size
- 57128 bytes
- Lines
- 2119
- Domain
- Driver Families
- Bucket
- drivers/cxl
- 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/cleanup.hlinux/edac.hlinux/limits.hlinux/unaligned.hlinux/xarray.hcxl/features.hcxl.hcxlmem.hcore.htrace.h
Detected Declarations
struct cxl_patrol_scrub_contextstruct cxl_scrub_rd_attrbsstruct cxl_scrub_wr_attrbsstruct cxl_ecs_contextstruct cxl_ecs_fru_rd_attrbsstruct cxl_ecs_rd_attrbsstruct cxl_ecs_fru_wr_attrbsstruct cxl_ecs_wr_attrbsstruct cxl_mbox_maintenance_hdrstruct cxl_memdev_maintenance_pistruct cxl_mem_err_recstruct cxl_mem_repair_attrbsstruct cxl_mem_sparing_contextstruct cxl_memdev_repair_rd_attrbs_hdrstruct cxl_memdev_sparing_rd_attrbsstruct cxl_memdev_sparing_in_payloadstruct cxl_mem_sparing_descstruct cxl_ppr_contextstruct cxl_memdev_ppr_rd_attrbsstruct cxl_memdev_ppr_maintenance_attrbsenum cxl_ecs_count_modeenum cxl_mem_repair_typeenum cxl_mem_sparing_granularityfunction cxl_mem_scrub_get_attrbsfunction cxl_scrub_get_attrbsfunction cxl_scrub_set_attrbs_regionfunction cxl_scrub_set_attrbs_devicefunction cxl_scrub_set_attrbsfunction cxl_patrol_scrub_get_enabled_bgfunction cxl_patrol_scrub_set_enabled_bgfunction cxl_patrol_scrub_get_min_scrub_cyclefunction cxl_patrol_scrub_get_max_scrub_cyclefunction cxl_patrol_scrub_get_scrub_cyclefunction cxl_patrol_scrub_set_scrub_cyclefunction cxl_memdev_scrub_initfunction cxl_region_scrub_initfunction cxl_mem_ecs_get_attrbsfunction cxl_mem_ecs_set_attrbsfunction cxl_get_ecs_log_entry_typefunction cxl_get_ecs_thresholdfunction cxl_get_ecs_count_modefunction cxl_set_ecs_log_entry_typefunction cxl_set_ecs_thresholdfunction cxl_set_ecs_count_modefunction cxl_set_ecs_reset_counterfunction cxl_memdev_ecs_initfunction cxl_perform_maintenancefunction cxl_find_rec_gen_media
Annotated Snippet
struct cxl_patrol_scrub_context {
u8 instance;
u16 get_feat_size;
u16 set_feat_size;
u8 get_version;
u8 set_version;
u16 effects;
struct cxl_memdev *cxlmd;
struct cxl_region *cxlr;
};
/*
* See CXL spec rev 3.2 @8.2.10.9.11.1 Table 8-222 Device Patrol Scrub Control
* Feature Readable Attributes.
*/
struct cxl_scrub_rd_attrbs {
u8 scrub_cycle_cap;
__le16 scrub_cycle_hours;
u8 scrub_flags;
} __packed;
/*
* See CXL spec rev 3.2 @8.2.10.9.11.1 Table 8-223 Device Patrol Scrub Control
* Feature Writable Attributes.
*/
struct cxl_scrub_wr_attrbs {
u8 scrub_cycle_hours;
u8 scrub_flags;
} __packed;
#define CXL_SCRUB_CONTROL_CHANGEABLE BIT(0)
#define CXL_SCRUB_CONTROL_REALTIME BIT(1)
#define CXL_SCRUB_CONTROL_CYCLE_MASK GENMASK(7, 0)
#define CXL_SCRUB_CONTROL_MIN_CYCLE_MASK GENMASK(15, 8)
#define CXL_SCRUB_CONTROL_ENABLE BIT(0)
#define CXL_GET_SCRUB_CYCLE_CHANGEABLE(cap) \
FIELD_GET(CXL_SCRUB_CONTROL_CHANGEABLE, cap)
#define CXL_GET_SCRUB_CYCLE(cycle) \
FIELD_GET(CXL_SCRUB_CONTROL_CYCLE_MASK, cycle)
#define CXL_GET_SCRUB_MIN_CYCLE(cycle) \
FIELD_GET(CXL_SCRUB_CONTROL_MIN_CYCLE_MASK, cycle)
#define CXL_GET_SCRUB_EN_STS(flags) FIELD_GET(CXL_SCRUB_CONTROL_ENABLE, flags)
#define CXL_SET_SCRUB_CYCLE(cycle) \
FIELD_PREP(CXL_SCRUB_CONTROL_CYCLE_MASK, cycle)
#define CXL_SET_SCRUB_EN(en) FIELD_PREP(CXL_SCRUB_CONTROL_ENABLE, en)
static int cxl_mem_scrub_get_attrbs(struct cxl_mailbox *cxl_mbox, u8 *cap,
u16 *cycle, u8 *flags, u8 *min_cycle)
{
size_t rd_data_size = sizeof(struct cxl_scrub_rd_attrbs);
size_t data_size;
struct cxl_scrub_rd_attrbs *rd_attrbs __free(kfree) =
kzalloc(rd_data_size, GFP_KERNEL);
if (!rd_attrbs)
return -ENOMEM;
data_size = cxl_get_feature(cxl_mbox, &CXL_FEAT_PATROL_SCRUB_UUID,
CXL_GET_FEAT_SEL_CURRENT_VALUE, rd_attrbs,
rd_data_size, 0, NULL);
if (!data_size)
return -EIO;
*cap = rd_attrbs->scrub_cycle_cap;
*cycle = le16_to_cpu(rd_attrbs->scrub_cycle_hours);
*flags = rd_attrbs->scrub_flags;
if (min_cycle)
*min_cycle = CXL_GET_SCRUB_MIN_CYCLE(*cycle);
return 0;
}
static int cxl_scrub_get_attrbs(struct cxl_patrol_scrub_context *cxl_ps_ctx,
u8 *cap, u16 *cycle, u8 *flags, u8 *min_cycle)
{
struct cxl_mailbox *cxl_mbox;
struct cxl_region_params *p;
struct cxl_memdev *cxlmd;
struct cxl_region *cxlr;
u8 min_scrub_cycle = 0;
int i, ret;
if (!cxl_ps_ctx->cxlr) {
cxl_mbox = &cxl_ps_ctx->cxlmd->cxlds->cxl_mbox;
return cxl_mem_scrub_get_attrbs(cxl_mbox, cap, cycle,
flags, min_cycle);
}
ACQUIRE(rwsem_read_intr, rwsem)(&cxl_rwsem.region);
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/edac.h`, `linux/limits.h`, `linux/unaligned.h`, `linux/xarray.h`, `cxl/features.h`, `cxl.h`, `cxlmem.h`.
- Detected declarations: `struct cxl_patrol_scrub_context`, `struct cxl_scrub_rd_attrbs`, `struct cxl_scrub_wr_attrbs`, `struct cxl_ecs_context`, `struct cxl_ecs_fru_rd_attrbs`, `struct cxl_ecs_rd_attrbs`, `struct cxl_ecs_fru_wr_attrbs`, `struct cxl_ecs_wr_attrbs`, `struct cxl_mbox_maintenance_hdr`, `struct cxl_memdev_maintenance_pi`.
- Atlas domain: Driver Families / drivers/cxl.
- 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.