drivers/cxl/mem.c
Source file repositories/reference/linux-study-clean/drivers/cxl/mem.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/cxl/mem.c- Extension
.c- Size
- 8718 bytes
- Lines
- 316
- 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/debugfs.hlinux/device.hlinux/module.hlinux/pci.hcxlmem.hcxlpci.h
Detected Declarations
function thosefunction remove_debugfsfunction cxl_mem_dpa_showfunction cxl_debugfs_poison_injectfunction cxl_debugfs_poison_clearfunction cxl_memdev_poison_enablefunction cxl_mem_probefunction scoped_guardfunction trigger_poison_list_storefunction cxl_poison_attr_visiblefunction cxl_mem_visible
Annotated Snippet
if (rc) {
if (rc == -ENODEV)
dev_info(dev, "PMEM disabled by platform\n");
return rc;
}
}
if (dport->rch)
endpoint_parent = parent_port->uport_dev;
else
endpoint_parent = &parent_port->dev;
scoped_guard(device, endpoint_parent) {
if (!endpoint_parent->driver) {
dev_err(dev, "CXL port topology %s not enabled\n",
dev_name(endpoint_parent));
return -ENXIO;
}
rc = devm_cxl_add_endpoint(endpoint_parent, cxlmd, dport);
if (rc)
return rc;
}
if (cxlmd->attach) {
rc = cxlmd->attach->probe(cxlmd);
if (rc)
return rc;
}
rc = devm_cxl_memdev_edac_register(cxlmd);
if (rc)
dev_dbg(dev, "CXL memdev EDAC registration failed rc=%d\n", rc);
/*
* The kernel may be operating out of CXL memory on this device,
* there is no spec defined way to determine whether this device
* preserves contents over suspend, and there is no simple way
* to arrange for the suspend image to avoid CXL memory which
* would setup a circular dependency between PCI resume and save
* state restoration.
*
* TODO: support suspend when all the regions this device is
* hosting are locked and covered by the system address map,
* i.e. platform firmware owns restoring the HDM configuration
* that it locked.
*/
cxl_mem_active_inc();
return devm_add_action_or_reset(dev, enable_suspend, NULL);
}
/**
* devm_cxl_add_classdev - Add a CXL memory class-code device
* @cxlds: CXL device state to associate with the memdev
*
* Upon return the device will have had a chance to attach to the
* cxl_mem driver, but may fail to attach if the CXL topology is not ready
* (hardware CXL link down, or software platform CXL root not attached).
*
* The parent of the resulting device and the devm context for allocations is
* @cxlds->dev.
*/
struct cxl_memdev *devm_cxl_add_classdev(struct cxl_dev_state *cxlds)
{
return __devm_cxl_add_memdev(cxlds, NULL);
}
EXPORT_SYMBOL_NS_GPL(devm_cxl_add_classdev, "CXL");
/**
* devm_cxl_probe_mem - Add a CXL memory device and probe its region
* @cxlds: CXL device state to associate with the memdev
* @hpa_range: CXL.mem physical address range result
*
* Upon return the device will have had a chance to attach to the
* cxl_mem driver, but may fail to attach if the CXL topology is not ready
* (hardware CXL link down, or software platform CXL root not attached).
*
* Failure to probe the memdev and/or setup a region for the memdev
* results in this function failing.
*
* The parent of the resulting device and the devm context for allocations is
* @cxlds->dev.
*/
struct cxl_memdev *devm_cxl_probe_mem(struct cxl_dev_state *cxlds,
struct range *hpa_range)
{
struct cxl_attach_region *attach =
devm_kmalloc(cxlds->dev, sizeof(*attach), GFP_KERNEL);
struct cxl_memdev *cxlmd;
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/device.h`, `linux/module.h`, `linux/pci.h`, `cxlmem.h`, `cxlpci.h`.
- Detected declarations: `function those`, `function remove_debugfs`, `function cxl_mem_dpa_show`, `function cxl_debugfs_poison_inject`, `function cxl_debugfs_poison_clear`, `function cxl_memdev_poison_enable`, `function cxl_mem_probe`, `function scoped_guard`, `function trigger_poison_list_store`, `function cxl_poison_attr_visible`.
- 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.