drivers/dma/idxd/init.c
Source file repositories/reference/linux-study-clean/drivers/dma/idxd/init.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/idxd/init.c- Extension
.c- Size
- 35515 bytes
- Lines
- 1395
- Domain
- Driver Families
- Bucket
- drivers/dma
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/init.hlinux/kernel.hlinux/module.hlinux/slab.hlinux/pci.hlinux/interrupt.hlinux/delay.hlinux/dma-mapping.hlinux/workqueue.hlinux/fs.hlinux/io-64-nonatomic-lo-hi.hlinux/device.hlinux/idr.hlinux/iommu.huapi/linux/idxd.hlinux/dmaengine.h../dmaengine.hregisters.hidxd.hperfmon.h
Detected Declarations
function idxd_setup_interruptsfunction idxd_cleanup_interruptsfunction idxd_clean_wqsfunction idxd_setup_wqsfunction idxd_clean_enginesfunction idxd_setup_enginesfunction idxd_clean_groupsfunction idxd_setup_groupsfunction idxd_cleanup_internalsfunction idxd_init_evlfunction idxd_setup_internalsfunction idxd_read_table_offsetsfunction multi_u64_to_bmapfunction idxd_read_capsfunction idxd_freefunction idxd_enable_system_pasidfunction idxd_disable_system_pasidfunction idxd_probefunction idxd_cleanupfunction idxd_bindfunction idxd_unbindfunction idxd_free_savedfunction idxd_device_config_savefunction idxd_device_config_restorefunction idxd_reset_preparefunction idxd_reset_donefunction idxd_pci_probe_allocfunction idxd_pci_probefunction idxd_wqs_quiescefunction idxd_shutdownfunction idxd_removefunction idxd_init_modulefunction idxd_exit_modulemodule init idxd_init_module
Annotated Snippet
static int idxd_bind(struct device_driver *drv, const char *buf)
{
const struct bus_type *bus = drv->bus;
struct device *dev;
int err = -ENODEV;
dev = bus_find_device_by_name(bus, NULL, buf);
if (dev)
err = device_driver_attach(drv, dev);
put_device(dev);
return err;
}
/*
* Detach IDXD device from driver.
*/
static void idxd_unbind(struct device_driver *drv, const char *buf)
{
const struct bus_type *bus = drv->bus;
struct device *dev;
dev = bus_find_device_by_name(bus, NULL, buf);
if (dev && dev->driver == drv)
device_release_driver(dev);
put_device(dev);
}
#define idxd_free_saved_configs(saved_configs, count) \
do { \
int i; \
\
for (i = 0; i < (count); i++) \
kfree(saved_configs[i]); \
} while (0)
static void idxd_free_saved(struct idxd_group **saved_groups,
struct idxd_engine **saved_engines,
struct idxd_wq **saved_wqs,
struct idxd_device *idxd)
{
if (saved_groups)
idxd_free_saved_configs(saved_groups, idxd->max_groups);
if (saved_engines)
idxd_free_saved_configs(saved_engines, idxd->max_engines);
if (saved_wqs)
idxd_free_saved_configs(saved_wqs, idxd->max_wqs);
}
/*
* Save IDXD device configurations including engines, groups, wqs etc.
* The saved configurations can be restored when needed.
*/
static int idxd_device_config_save(struct idxd_device *idxd,
struct idxd_saved_states *idxd_saved)
{
struct device *dev = &idxd->pdev->dev;
int i;
memcpy(&idxd_saved->saved_idxd, idxd, sizeof(*idxd));
if (idxd->evl) {
memcpy(&idxd_saved->saved_evl, idxd->evl,
sizeof(struct idxd_evl));
}
struct idxd_group **saved_groups __free(kfree) =
kcalloc_node(idxd->max_groups,
sizeof(struct idxd_group *),
GFP_KERNEL, dev_to_node(dev));
if (!saved_groups)
return -ENOMEM;
for (i = 0; i < idxd->max_groups; i++) {
struct idxd_group *saved_group __free(kfree) =
kzalloc_node(sizeof(*saved_group), GFP_KERNEL,
dev_to_node(dev));
if (!saved_group) {
/* Free saved groups */
idxd_free_saved(saved_groups, NULL, NULL, idxd);
return -ENOMEM;
}
memcpy(saved_group, idxd->groups[i], sizeof(*saved_group));
saved_groups[i] = no_free_ptr(saved_group);
}
Annotation
- Immediate include surface: `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/pci.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/dma-mapping.h`.
- Detected declarations: `function idxd_setup_interrupts`, `function idxd_cleanup_interrupts`, `function idxd_clean_wqs`, `function idxd_setup_wqs`, `function idxd_clean_engines`, `function idxd_setup_engines`, `function idxd_clean_groups`, `function idxd_setup_groups`, `function idxd_cleanup_internals`, `function idxd_init_evl`.
- Atlas domain: Driver Families / drivers/dma.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.