dmaengine: Add Synopsys eDMA IP PCIe glue-logic
RFC v3 5/7 dmaengine: Add Synopsys eDMA IP PCIe glue-logic
Quoted 35 lines · Gustavo Pimentel
Synopsys eDMA IP is normally distributed along with Synopsys PCIe EndPoint IP (depends of the use and licensing agreement).
This IP requires some basic configurations, such as:
- eDMA registers BAR
- eDMA registers offset
- eDMA registers size
- eDMA linked list memory BAR
- eDMA linked list memory offset
- eDMA linked list memory sze
- eDMA data memory BAR
- eDMA data memory offset
- eDMA data memory size
- eDMA version
- eDMA mode
- IRQs available for eDMAAs a working example, PCIe glue-logic will attach to a Synopsys PCIe EndPoint IP prototype kit (Vendor ID =
0x16c3, Device ID =0xedda), which has built-in an eDMA IP with this default configuration:
- eDMA registers BAR = 0
- eDMA registers offset =0x00001000(4 Kbytes)
- eDMA registers size =0x00002000(8 Kbytes)
- eDMA linked list memory BAR = 2
- eDMA linked list memory offset =0x00000000(0 Kbytes)
- eDMA linked list memory size =0x00800000(8 Mbytes)
- eDMA data memory BAR = 2
- eDMA data memory offset =0x00800000(8 Mbytes)
- eDMA data memory size =0x03800000(56 Mbytes)
- eDMA version = 0
- eDMA mode =EDMA_MODE_UNROLL
- IRQs = 1This driver can be compile as built-in or external module in kernel.
Quoted 7 lines
To enable this driver just select
DW_EDMA_PCIEoption in kernel configuration, however it requires and selects automaticallyDW_EDMAoption too.Changes:
RFCv1->RFCv2:
Changes go after '--- ' line.
Quoted 22 lines
- Replace comments // (C99 style) by /**/
- Merge twopcim_iomap_regions()calls into just one call
- Removepci_try_set_mwi()call
- Replace somedev_info()bydev_dbg()to reduce *noise*
- Removepci_name(pdev)call after being calldw_edma_remove()
- Remove all power management support
- Fix the headers of the .c and .h files according to the most recent convention
- Fix errors and checks pointed out by checkpatch with --strict option
- Replace patch small description tag from dma by dmaengine
RFCv2->RFCv3:
- Fix printk variable ofphys_addr_ttype
- Fix missing variable initialization (chan->configured)
- Change linked list size to 512 Kbytes
- Add data memory information
- Add register size information
- Add comments or improve existing ones
- Add possibility to work with multiple IRQs feature
- Replace MSI and MSI-X enable condition bypci_dev_msi_enabled()
- Replace code to acquire MSI(-X) address and data byget_cached_msi_msg()
Review
Quoted 8 lines
(quoted diff) +8
-0+enum dw_edma_pcie_bar { + BAR_0, + BAR_1, + BAR_2, + BAR_3, + BAR_4, + BAR_5 +};
pci-epf.h has this.
Why duplicate?
What else is being duplicated from PCI core?
Review
Quoted 3 lines
(quoted diff) +3
-0+static bool disable_msix; +module_param(disable_msix, bool, 0644); +MODULE_PARM_DESC(disable_msix, "Disable MSI-X interrupts");
Why?!
We are no allow new module parameters without very strong arguments.
Quoted 6 lines
(quoted diff) +6
-0+ +static int dw_edma_pcie_probe(struct pci_dev *pdev, + const struct pci_device_id *pid) +{ + const struct dw_edma_pcie_data *pdata = (void *)pid->driver_data; + struct device *dev = &pdev->dev;
Review
Quoted 10 lines
(quoted diff) +9
-0+ struct dw_edma_chip *chip; + struct dw_edma *dw; + unsigned int irq_flags = PCI_IRQ_MSI; + int err, nr_irqs, i; + + if (!pdata) { + dev_err(dev, "%s missing data structure\n", pci_name(pdev)); + return -EFAULT; + }
Useless check.
Quoted 7 lines
(quoted diff) +7
-0+ + /* Enable PCI device */ + err = pcim_enable_device(pdev); + if (err) { + dev_err(dev, "%s enabling device failed\n", pci_name(pdev)); + return err; + }
Review
Quoted 10 lines
(quoted diff) +9
-0+ + /* Mapping PCI BAR regions */ + err = pcim_iomap_regions(pdev, BIT(pdata->rg_bar) | + BIT(pdata->ll_bar) | + BIT(pdata->dt_bar), + pci_name(pdev)); + if (err) { + dev_err(dev, "%s eDMA BAR I/O remapping failed\n", + pci_name(pdev));
Isn't it pci_err() ?
Same comment for the rest similar cases above and below.
Quoted 11 lines
(quoted diff) +11
-0+ return err; + } + + pci_set_master(pdev); + + nr_irqs = pci_alloc_irq_vectors(pdev, 1, pdata->irqs_cnt, irq_flags); + if (nr_irqs < 1) { + dev_err(dev, "%s failed to alloc IRQ vector (Number of IRQs=%u)\n", + pci_name(pdev), nr_irqs); + return -EPERM; + }
Review
Quoted 10 lines
(quoted diff) +9
-0+ + /* Data structure initialization */ + chip->dw = dw; + chip->dev = dev; + chip->id = pdev->devfn; + chip->irq = pdev->irq; + + if (!pcim_iomap_table(pdev)) + return -EACCES;
Never happen condition. Thus useless.
Review
Quoted 1 line
(quoted diff) +1
-0+ dev_info(dev, "DesignWare eDMA PCIe driver loaded completely\n");
Useless.
Quoted 7 lines
(quoted diff) +7
-0+} + +static void dw_edma_pcie_remove(struct pci_dev *pdev) +{ + struct dw_edma_chip *chip = pci_get_drvdata(pdev); + struct device *dev = &pdev->dev; + int err;
Review
Quoted 10 lines
(quoted diff) +10
-0+ + /* Stopping eDMA driver */ + err = dw_edma_remove(chip); + if (err) + dev_warn(dev, "can't remove device properly: %d\n", err); + + /* Freeing IRQs */ + pci_free_irq_vectors(pdev); + + dev_info(dev, "DesignWare eDMA PCIe driver unloaded completely\n");
Ditto.
Review
Quoted 9 lines
(quoted diff) +8
-0+} +MODULE_DEVICE_TABLE(pci, dw_edma_pcie_id_table); + +static struct pci_driver dw_edma_pcie_driver = { + .name = "dw-edma-pcie", + .id_table = dw_edma_pcie_id_table, + .probe = dw_edma_pcie_probe, + .remove = dw_edma_pcie_remove,
Power management?
Quoted 1 line
+};