drivers/cxl/core/regs.c
Source file repositories/reference/linux-study-clean/drivers/cxl/core/regs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/cxl/core/regs.c- Extension
.c- Size
- 17121 bytes
- Lines
- 644
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/io-64-nonatomic-lo-hi.hlinux/device.hlinux/slab.hlinux/pci.hcxlmem.hcxlpci.hpmu.hcore.h
Detected Declarations
struct mapinfostruct mapinfofunction DVSECfunction cxl_probe_device_regsfunction cxl_map_component_regsfunction cxl_map_device_regsfunction cxl_decode_regblockfunction __cxl_find_regblock_instancefunction cxl_find_regblock_instancefunction cxl_find_regblockfunction cxl_count_regblockfunction cxl_map_pmu_regsfunction cxl_map_regblockfunction cxl_unmap_regblockfunction cxl_probe_regsfunction cxl_setup_regsfunction cxl_rcrb_to_aerfunction cxl_rcrb_to_linkcapfunction cxl_dport_map_rcd_linkcapfunction __rcrb_to_componentfunction cxl_rcd_component_reg_phys
Annotated Snippet
struct mapinfo {
const struct cxl_reg_map *rmap;
void __iomem **addr;
} mapinfo[] = {
{ &map->component_map.hdm_decoder, ®s->hdm_decoder },
{ &map->component_map.ras, ®s->ras },
};
int i;
for (i = 0; i < ARRAY_SIZE(mapinfo); i++) {
struct mapinfo *mi = &mapinfo[i];
resource_size_t addr;
resource_size_t length;
if (!mi->rmap->valid)
continue;
if (!test_bit(mi->rmap->id, &map_mask))
continue;
addr = map->resource + mi->rmap->offset;
length = mi->rmap->size;
*(mi->addr) = devm_cxl_iomap_block(host, addr, length);
if (!*(mi->addr))
return -ENOMEM;
}
return 0;
}
EXPORT_SYMBOL_NS_GPL(cxl_map_component_regs, "CXL");
int cxl_map_device_regs(const struct cxl_register_map *map,
struct cxl_device_regs *regs)
{
struct device *host = map->host;
resource_size_t phys_addr = map->resource;
struct mapinfo {
const struct cxl_reg_map *rmap;
void __iomem **addr;
} mapinfo[] = {
{ &map->device_map.status, ®s->status, },
{ &map->device_map.mbox, ®s->mbox, },
{ &map->device_map.memdev, ®s->memdev, },
};
int i;
for (i = 0; i < ARRAY_SIZE(mapinfo); i++) {
struct mapinfo *mi = &mapinfo[i];
resource_size_t length;
resource_size_t addr;
if (!mi->rmap->valid)
continue;
addr = phys_addr + mi->rmap->offset;
length = mi->rmap->size;
*(mi->addr) = devm_cxl_iomap_block(host, addr, length);
if (!*(mi->addr))
return -ENOMEM;
}
return 0;
}
EXPORT_SYMBOL_NS_GPL(cxl_map_device_regs, "CXL");
static bool cxl_decode_regblock(struct pci_dev *pdev, u32 reg_lo, u32 reg_hi,
struct cxl_register_map *map)
{
u8 reg_type = FIELD_GET(PCI_DVSEC_CXL_REG_LOCATOR_BLOCK_ID, reg_lo);
int bar = FIELD_GET(PCI_DVSEC_CXL_REG_LOCATOR_BIR, reg_lo);
u64 offset = ((u64)reg_hi << 32) |
(reg_lo & PCI_DVSEC_CXL_REG_LOCATOR_BLOCK_OFF_LOW);
if (offset > pci_resource_len(pdev, bar)) {
dev_warn(&pdev->dev,
"BAR%d: %pr: too small (offset: %pa, type: %d)\n", bar,
&pdev->resource[bar], &offset, reg_type);
return false;
}
map->reg_type = reg_type;
map->resource = pci_resource_start(pdev, bar) + offset;
map->max_size = pci_resource_len(pdev, bar) - offset;
return true;
}
/*
* __cxl_find_regblock_instance() - Locate a register block or count instances by type / index
* Use CXL_INSTANCES_COUNT for @index if counting instances.
*
* __cxl_find_regblock_instance() may return:
* 0 - if register block enumerated.
Annotation
- Immediate include surface: `linux/io-64-nonatomic-lo-hi.h`, `linux/device.h`, `linux/slab.h`, `linux/pci.h`, `cxlmem.h`, `cxlpci.h`, `pmu.h`, `core.h`.
- Detected declarations: `struct mapinfo`, `struct mapinfo`, `function DVSEC`, `function cxl_probe_device_regs`, `function cxl_map_component_regs`, `function cxl_map_device_regs`, `function cxl_decode_regblock`, `function __cxl_find_regblock_instance`, `function cxl_find_regblock_instance`, `function cxl_find_regblock`.
- 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.