drivers/cxl/core/hdm.c
Source file repositories/reference/linux-study-clean/drivers/cxl/core/hdm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/cxl/core/hdm.c- Extension
.c- Size
- 35427 bytes
- Lines
- 1280
- 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/seq_file.hlinux/device.hlinux/delay.hcxlmem.hcore.h
Detected Declarations
function add_hdm_decoderfunction specificationfunction parse_hdm_decoder_capsfunction should_emulate_decodersfunction __cxl_dpa_debugfunction cxl_dpa_debugfunction __adjust_skipfunction __cxl_dpa_releasefunction cxl_dpa_releasefunction devm_cxl_dpa_releasefunction request_skipfunction __cxl_dpa_reservefunction add_dpa_resfunction cxl_dpa_setupfunction devm_cxl_dpa_reservefunction cxl_dpa_sizefunction cxl_dpa_resource_startfunction cxl_resource_contains_addrfunction cxl_dpa_freefunction cxl_dpa_set_partfunction __cxl_dpa_allocfunction cxl_dpa_allocfunction cxld_set_interleavefunction cxld_set_typefunction cxlsd_set_targetsfunction cxld_await_commitfunction setup_hw_decoderfunction cxl_decoder_commitfunction commit_reapfunction cxl_port_commit_reapfunction cxl_decoder_resetfunction cxl_setup_hdm_decoder_from_dvsecfunction init_hdm_decoderfunction cxl_settle_decodersfunction devm_cxl_enumerate_decodersfunction devm_cxl_switch_port_decoders_setupfunction devm_cxl_endpoint_decoders_setupexport cxl_dpa_setup
Annotated Snippet
if (!info || !info->mem_enabled) {
dev_err(dev, "No component registers mapped\n");
return ERR_PTR(-ENXIO);
}
cxlhdm->decoder_count = info->ranges;
return cxlhdm;
}
if (!reg_map->component_map.hdm_decoder.valid) {
dev_dbg(&port->dev, "HDM decoder registers not implemented\n");
/* unique error code to indicate no HDM decoder capability */
return ERR_PTR(-ENODEV);
}
rc = cxl_map_component_regs(reg_map, &cxlhdm->regs,
BIT(CXL_CM_CAP_CAP_ID_HDM));
if (rc) {
dev_err(dev, "Failed to map HDM capability.\n");
return ERR_PTR(rc);
}
parse_hdm_decoder_caps(cxlhdm);
if (cxlhdm->decoder_count < 0) {
dev_err(dev, "Spec violation. Caps invalid\n");
return ERR_PTR(-ENXIO);
}
/*
* Now that the hdm capability is parsed, decide if range
* register emulation is needed and fixup cxlhdm accordingly.
*/
if (should_emulate_decoders(info)) {
dev_dbg(dev, "Fallback map %d range register%s\n", info->ranges,
str_plural(info->ranges));
cxlhdm->decoder_count = info->ranges;
}
return cxlhdm;
}
static void __cxl_dpa_debug(struct seq_file *file, struct resource *r, int depth)
{
unsigned long long start = r->start, end = r->end;
seq_printf(file, "%*s%08llx-%08llx : %s\n", depth * 2, "", start, end,
r->name);
}
void cxl_dpa_debug(struct seq_file *file, struct cxl_dev_state *cxlds)
{
struct resource *p1, *p2;
guard(rwsem_read)(&cxl_rwsem.dpa);
for (p1 = cxlds->dpa_res.child; p1; p1 = p1->sibling) {
__cxl_dpa_debug(file, p1, 0);
for (p2 = p1->child; p2; p2 = p2->sibling)
__cxl_dpa_debug(file, p2, 1);
}
}
EXPORT_SYMBOL_NS_GPL(cxl_dpa_debug, "CXL");
/* See request_skip() kernel-doc */
static resource_size_t __adjust_skip(struct cxl_dev_state *cxlds,
const resource_size_t skip_base,
const resource_size_t skip_len,
const char *requester)
{
const resource_size_t skip_end = skip_base + skip_len - 1;
for (int i = 0; i < cxlds->nr_partitions; i++) {
const struct resource *part_res = &cxlds->part[i].res;
resource_size_t adjust_start, adjust_end, size;
adjust_start = max(skip_base, part_res->start);
adjust_end = min(skip_end, part_res->end);
if (adjust_end < adjust_start)
continue;
size = adjust_end - adjust_start + 1;
if (!requester)
__release_region(&cxlds->dpa_res, adjust_start, size);
else if (!__request_region(&cxlds->dpa_res, adjust_start, size,
requester, 0))
return adjust_start - skip_base;
}
return skip_len;
Annotation
- Immediate include surface: `linux/seq_file.h`, `linux/device.h`, `linux/delay.h`, `cxlmem.h`, `core.h`.
- Detected declarations: `function add_hdm_decoder`, `function specification`, `function parse_hdm_decoder_caps`, `function should_emulate_decoders`, `function __cxl_dpa_debug`, `function cxl_dpa_debug`, `function __adjust_skip`, `function __cxl_dpa_release`, `function cxl_dpa_release`, `function devm_cxl_dpa_release`.
- 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.