dmaengine: idxd: removal of pcim managed mmio mapping
authorDave Jiang <dave.jiang@intel.com>
Thu, 15 Apr 2021 23:37:21 +0000 (16:37 -0700)
committerVinod Koul <vkoul@kernel.org>
Tue, 20 Apr 2021 11:13:52 +0000 (16:43 +0530)
The devm managed lifetime is incompatible with 'struct device' objects that
resides in idxd context. This is one of the series that clean up the idxd
driver 'struct device' lifetime. Remove pcim_* management of the PCI device
and the ioremap of MMIO BAR and replace with unmanaged versions. This is
for consistency of removing all the pcim/devm based calls.

Reported-by: Jason Gunthorpe <jgg@nvidia.com>
Fixes: bfe1d56091c1 ("dmaengine: idxd: Init and probe for Intel data accelerators")
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Link: https://lore.kernel.org/r/161852984150.2203940.8043988289748519056.stgit@djiang5-desk3.ch.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/idxd/init.c

index 5cf1bf095ae1a1074b83f57fee65075853fe4b84..11a2e14b5b80744311675ff835849853641cfae5 100644 (file)
@@ -384,32 +384,36 @@ static int idxd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        struct idxd_device *idxd;
        int rc;
 
-       rc = pcim_enable_device(pdev);
+       rc = pci_enable_device(pdev);
        if (rc)
                return rc;
 
        dev_dbg(dev, "Alloc IDXD context\n");
        idxd = idxd_alloc(pdev);
-       if (!idxd)
-               return -ENOMEM;
+       if (!idxd) {
+               rc = -ENOMEM;
+               goto err_idxd_alloc;
+       }
 
        dev_dbg(dev, "Mapping BARs\n");
-       idxd->reg_base = pcim_iomap(pdev, IDXD_MMIO_BAR, 0);
-       if (!idxd->reg_base)
-               return -ENOMEM;
+       idxd->reg_base = pci_iomap(pdev, IDXD_MMIO_BAR, 0);
+       if (!idxd->reg_base) {
+               rc = -ENOMEM;
+               goto err_iomap;
+       }
 
        dev_dbg(dev, "Set DMA masks\n");
        rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
        if (rc)
                rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
        if (rc)
-               return rc;
+               goto err;
 
        rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
        if (rc)
                rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
        if (rc)
-               return rc;
+               goto err;
 
        idxd_set_type(idxd);
 
@@ -423,13 +427,13 @@ static int idxd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        rc = idxd_probe(idxd);
        if (rc) {
                dev_err(dev, "Intel(R) IDXD DMA Engine init failed\n");
-               return -ENODEV;
+               goto err;
        }
 
        rc = idxd_setup_sysfs(idxd);
        if (rc) {
                dev_err(dev, "IDXD sysfs setup failed\n");
-               return -ENODEV;
+               goto err;
        }
 
        idxd->state = IDXD_DEV_CONF_READY;
@@ -438,6 +442,13 @@ static int idxd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
                 idxd->hw.version);
 
        return 0;
+
+ err:
+       pci_iounmap(pdev, idxd->reg_base);
+ err_iomap:
+ err_idxd_alloc:
+       pci_disable_device(pdev);
+       return rc;
 }
 
 static void idxd_flush_pending_llist(struct idxd_irq_entry *ie)
@@ -493,6 +504,8 @@ static void idxd_shutdown(struct pci_dev *pdev)
 
        idxd_msix_perm_clear(idxd);
        pci_free_irq_vectors(pdev);
+       pci_iounmap(pdev, idxd->reg_base);
+       pci_disable_device(pdev);
        destroy_workqueue(idxd->wq);
 }