drivers/dma/ioat/init.c

Source file repositories/reference/linux-study-clean/drivers/dma/ioat/init.c

File Facts

System
Linux kernel
Corpus path
drivers/dma/ioat/init.c
Extension
.c
Size
38954 bytes
Lines
1456
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.

Dependency Surface

Detected Declarations

Annotated Snippet

static struct pci_driver ioat_pci_driver = {
	.name		= DRV_NAME,
	.id_table	= ioat_pci_tbl,
	.probe		= ioat_pci_probe,
	.remove		= ioat_remove,
	.shutdown	= ioat_shutdown,
	.err_handler	= &ioat_err_handler,
};

static void release_ioatdma(struct dma_device *device)
{
	struct ioatdma_device *d = to_ioatdma_device(device);
	int i;

	for (i = 0; i < IOAT_MAX_CHANS; i++)
		kfree(d->idx[i]);

	dma_pool_destroy(d->completion_pool);
	kfree(d);
}

static struct ioatdma_device *
alloc_ioatdma(struct pci_dev *pdev, void __iomem *iobase)
{
	struct ioatdma_device *d = kzalloc_obj(*d);

	if (!d)
		return NULL;
	d->pdev = pdev;
	d->reg_base = iobase;
	d->dma_dev.device_release = release_ioatdma;
	return d;
}

static int ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
	void __iomem * const *iomap;
	struct device *dev = &pdev->dev;
	struct ioatdma_device *device;
	unsigned int i;
	u8 version;
	int err;

	err = pcim_enable_device(pdev);
	if (err)
		return err;

	err = pcim_iomap_regions(pdev, 1 << IOAT_MMIO_BAR, DRV_NAME);
	if (err)
		return err;
	iomap = pcim_iomap_table(pdev);
	if (!iomap)
		return -ENOMEM;

	version = readb(iomap[IOAT_MMIO_BAR] + IOAT_VER_OFFSET);
	if (version < IOAT_VER_3_0)
		return -ENODEV;

	err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
	if (err)
		return err;

	device = alloc_ioatdma(pdev, iomap[IOAT_MMIO_BAR]);
	if (!device)
		return -ENOMEM;
	pci_set_master(pdev);
	pci_set_drvdata(pdev, device);

	device->version = version;
	if (device->version >= IOAT_VER_3_4)
		ioat_dca_enabled = 0;

	if (is_skx_ioat(pdev))
		device->version = IOAT_VER_3_2;

	err = ioat3_dma_probe(device, ioat_dca_enabled);
	if (err) {
		for (i = 0; i < IOAT_MAX_CHANS; i++)
			kfree(device->idx[i]);
		kfree(device);
		dev_err(dev, "Intel(R) I/OAT DMA Engine init failed\n");
		return -ENODEV;
	}

	return 0;
}

static void ioat_remove(struct pci_dev *pdev)
{
	struct ioatdma_device *device = pci_get_drvdata(pdev);

Annotation

Implementation Notes