drivers/cdx/controller/cdx_controller.c
Source file repositories/reference/linux-study-clean/drivers/cdx/controller/cdx_controller.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/cdx/controller/cdx_controller.c- Extension
.c- Size
- 6107 bytes
- Lines
- 259
- Domain
- Driver Families
- Bucket
- drivers/cdx
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/mod_devicetable.hlinux/platform_device.hlinux/slab.hlinux/cdx/cdx_bus.hlinux/irqdomain.hcdx_controller.h../cdx.hmcdi_functions.hmcdid.h
Detected Declarations
function Copyrightfunction cdx_mcdi_requestfunction cdx_bus_enablefunction cdx_bus_disablefunction cdx_rpmsg_post_probefunction cdx_rpmsg_pre_removefunction cdx_configure_devicefunction cdx_scan_devicesfunction xlnx_cdx_probefunction xlnx_cdx_remove
Annotated Snippet
if (ret < 0) {
dev_err(cdx->dev,
"Get devices on CDX bus %d failed: %d\n", bus_num, ret);
continue;
}
num_cdx_dev = (u8)ret;
for (dev_num = 0; dev_num < num_cdx_dev; dev_num++) {
struct cdx_dev_params dev_params;
/* MCDI FW: Get the device config */
ret = cdx_mcdi_get_dev_config(cdx_mcdi, bus_num,
dev_num, &dev_params);
if (ret) {
dev_err(cdx->dev,
"CDX device config get failed for %d(bus):%d(dev), %d\n",
bus_num, dev_num, ret);
continue;
}
dev_params.cdx = cdx;
dev_params.parent = bus_dev;
/* Add the device to the cdx bus */
ret = cdx_device_add(&dev_params);
if (ret) {
dev_err(cdx->dev, "registering cdx dev: %d failed: %d\n",
dev_num, ret);
continue;
}
dev_dbg(cdx->dev, "CDX dev: %d on cdx bus: %d created\n",
dev_num, bus_num);
}
}
return 0;
}
static struct cdx_ops cdx_ops = {
.bus_enable = cdx_bus_enable,
.bus_disable = cdx_bus_disable,
.scan = cdx_scan_devices,
.dev_configure = cdx_configure_device,
};
static int xlnx_cdx_probe(struct platform_device *pdev)
{
struct cdx_controller *cdx;
struct cdx_mcdi *cdx_mcdi;
int ret;
cdx_mcdi = kzalloc_obj(*cdx_mcdi);
if (!cdx_mcdi)
return -ENOMEM;
/* Store the MCDI ops */
cdx_mcdi->mcdi_ops = &mcdi_ops;
/* MCDI FW: Initialize the FW path */
ret = cdx_mcdi_init(cdx_mcdi);
if (ret) {
dev_err_probe(&pdev->dev, ret, "MCDI Initialization failed\n");
goto mcdi_init_fail;
}
cdx = kzalloc_obj(*cdx);
if (!cdx) {
ret = -ENOMEM;
goto cdx_alloc_fail;
}
platform_set_drvdata(pdev, cdx);
cdx->dev = &pdev->dev;
cdx->priv = cdx_mcdi;
cdx->ops = &cdx_ops;
/* Create MSI domain */
if (IS_ENABLED(CONFIG_GENERIC_MSI_IRQ))
cdx->msi_domain = cdx_msi_domain_init(&pdev->dev);
if (!cdx->msi_domain) {
ret = dev_err_probe(&pdev->dev, -ENODEV, "cdx_msi_domain_init() failed");
goto cdx_msi_fail;
}
ret = cdx_setup_rpmsg(pdev);
if (ret) {
dev_err_probe(&pdev->dev, ret, "Failed to register CDX RPMsg transport\n");
goto cdx_rpmsg_fail;
}
return 0;
Annotation
- Immediate include surface: `linux/mod_devicetable.h`, `linux/platform_device.h`, `linux/slab.h`, `linux/cdx/cdx_bus.h`, `linux/irqdomain.h`, `cdx_controller.h`, `../cdx.h`, `mcdi_functions.h`.
- Detected declarations: `function Copyright`, `function cdx_mcdi_request`, `function cdx_bus_enable`, `function cdx_bus_disable`, `function cdx_rpmsg_post_probe`, `function cdx_rpmsg_pre_remove`, `function cdx_configure_device`, `function cdx_scan_devices`, `function xlnx_cdx_probe`, `function xlnx_cdx_remove`.
- Atlas domain: Driver Families / drivers/cdx.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.