drivers/cxl/core/cdat.c
Source file repositories/reference/linux-study-clean/drivers/cxl/core/cdat.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/cxl/core/cdat.c- Extension
.c- Size
- 28278 bytes
- Lines
- 1075
- 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/acpi.hlinux/xarray.hlinux/fw_table.hlinux/node.hlinux/overflow.hcxlpci.hcxlmem.hcore.hcxl.h
Detected Declarations
struct dsmas_entrystruct acpi_cdat_sslbis_tablestruct cxl_perf_ctxfunction cdat_normalizefunction cdat_dsmas_handlerfunction __cxl_access_coordinate_setfunction cxl_access_coordinate_setfunction cdat_dslbis_handlerfunction cdat_table_parse_outputfunction cxl_cdat_endpoint_processfunction cxl_port_perf_data_calculatefunction xa_for_eachfunction update_perf_entryfunction cxl_memdev_set_qos_classfunction xa_for_eachfunction match_cxlrd_qos_classfunction reset_dpa_perffunction cxl_qos_matchfunction match_cxlrd_hbfunction cxl_qos_class_verifyfunction discard_dsmasfunction xa_for_eachfunction cxl_endpoint_parse_cdatfunction cdat_sslbis_handlerfunction cxl_switch_parse_cdatfunction __cxl_coordinates_combinefunction cxl_coordinates_combinefunction cxl_bandwidth_addfunction dpa_perf_containsfunction cxl_endpoint_gather_bandwidthfunction free_perf_xafunction ERR_PTRfunction xa_for_eachfunction xa_for_eachfunction xa_for_eachfunction cxl_region_update_bandwidthfunction cxl_region_shared_upstream_bandwidth_updatefunction cxl_region_perf_data_calculate
Annotated Snippet
struct dsmas_entry {
struct range dpa_range;
u8 handle;
struct access_coordinate coord[ACCESS_COORDINATE_MAX];
struct access_coordinate cdat_coord[ACCESS_COORDINATE_MAX];
int entries;
int qos_class;
};
static u32 cdat_normalize(u16 entry, u64 base, u8 type)
{
u32 value;
/*
* Check for invalid and overflow values
*/
if (entry == 0xffff || !entry)
return 0;
if (base > (UINT_MAX / (entry)))
return 0;
/*
* CDAT fields follow the format of HMAT fields. See table 5 Device
* Scoped Latency and Bandwidth Information Structure in Coherent Device
* Attribute Table (CDAT) Specification v1.01.
*/
value = entry * base;
switch (type) {
case ACPI_HMAT_ACCESS_LATENCY:
case ACPI_HMAT_READ_LATENCY:
case ACPI_HMAT_WRITE_LATENCY:
value = DIV_ROUND_UP(value, 1000);
break;
default:
break;
}
return value;
}
static int cdat_dsmas_handler(union acpi_subtable_headers *header, void *arg,
const unsigned long end)
{
struct acpi_cdat_header *hdr = &header->cdat;
struct acpi_cdat_dsmas *dsmas;
int size = sizeof(*hdr) + sizeof(*dsmas);
struct xarray *dsmas_xa = arg;
struct dsmas_entry *dent;
u16 len;
int rc;
len = le16_to_cpu((__force __le16)hdr->length);
if (len != size || (unsigned long)hdr + len > end) {
pr_warn("Malformed DSMAS table length: (%u:%u)\n", size, len);
return -EINVAL;
}
/* Skip common header */
dsmas = (struct acpi_cdat_dsmas *)(hdr + 1);
dent = kzalloc_obj(*dent);
if (!dent)
return -ENOMEM;
dent->handle = dsmas->dsmad_handle;
dent->dpa_range.start = le64_to_cpu((__force __le64)dsmas->dpa_base_address);
dent->dpa_range.end = le64_to_cpu((__force __le64)dsmas->dpa_base_address) +
le64_to_cpu((__force __le64)dsmas->dpa_length) - 1;
rc = xa_insert(dsmas_xa, dent->handle, dent, GFP_KERNEL);
if (rc) {
kfree(dent);
return rc;
}
return 0;
}
static void __cxl_access_coordinate_set(struct access_coordinate *coord,
int access, unsigned int val)
{
switch (access) {
case ACPI_HMAT_ACCESS_LATENCY:
coord->read_latency = val;
coord->write_latency = val;
break;
case ACPI_HMAT_READ_LATENCY:
coord->read_latency = val;
break;
case ACPI_HMAT_WRITE_LATENCY:
coord->write_latency = val;
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/xarray.h`, `linux/fw_table.h`, `linux/node.h`, `linux/overflow.h`, `cxlpci.h`, `cxlmem.h`, `core.h`.
- Detected declarations: `struct dsmas_entry`, `struct acpi_cdat_sslbis_table`, `struct cxl_perf_ctx`, `function cdat_normalize`, `function cdat_dsmas_handler`, `function __cxl_access_coordinate_set`, `function cxl_access_coordinate_set`, `function cdat_dslbis_handler`, `function cdat_table_parse_output`, `function cxl_cdat_endpoint_process`.
- 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.