Skip to content

Commit a39c7cd

Browse files
davejiangvinodkoul
authored andcommitted
dmaengine: idxd: removal of pcim managed mmio mapping
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 <[email protected]> Fixes: bfe1d56 ("dmaengine: idxd: Init and probe for Intel data accelerators") Signed-off-by: Dave Jiang <[email protected]> Reviewed-by: Dan Williams <[email protected]> Link: https://lore.kernel.org/r/161852984150.2203940.8043988289748519056.stgit@djiang5-desk3.ch.intel.com Signed-off-by: Vinod Koul <[email protected]>
1 parent 5fc8e85 commit a39c7cd

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

drivers/dma/idxd/init.c

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -384,32 +384,36 @@ static int idxd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
384384
struct idxd_device *idxd;
385385
int rc;
386386

387-
rc = pcim_enable_device(pdev);
387+
rc = pci_enable_device(pdev);
388388
if (rc)
389389
return rc;
390390

391391
dev_dbg(dev, "Alloc IDXD context\n");
392392
idxd = idxd_alloc(pdev);
393-
if (!idxd)
394-
return -ENOMEM;
393+
if (!idxd) {
394+
rc = -ENOMEM;
395+
goto err_idxd_alloc;
396+
}
395397

396398
dev_dbg(dev, "Mapping BARs\n");
397-
idxd->reg_base = pcim_iomap(pdev, IDXD_MMIO_BAR, 0);
398-
if (!idxd->reg_base)
399-
return -ENOMEM;
399+
idxd->reg_base = pci_iomap(pdev, IDXD_MMIO_BAR, 0);
400+
if (!idxd->reg_base) {
401+
rc = -ENOMEM;
402+
goto err_iomap;
403+
}
400404

401405
dev_dbg(dev, "Set DMA masks\n");
402406
rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
403407
if (rc)
404408
rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
405409
if (rc)
406-
return rc;
410+
goto err;
407411

408412
rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
409413
if (rc)
410414
rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
411415
if (rc)
412-
return rc;
416+
goto err;
413417

414418
idxd_set_type(idxd);
415419

@@ -423,13 +427,13 @@ static int idxd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
423427
rc = idxd_probe(idxd);
424428
if (rc) {
425429
dev_err(dev, "Intel(R) IDXD DMA Engine init failed\n");
426-
return -ENODEV;
430+
goto err;
427431
}
428432

429433
rc = idxd_setup_sysfs(idxd);
430434
if (rc) {
431435
dev_err(dev, "IDXD sysfs setup failed\n");
432-
return -ENODEV;
436+
goto err;
433437
}
434438

435439
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)
438442
idxd->hw.version);
439443

440444
return 0;
445+
446+
err:
447+
pci_iounmap(pdev, idxd->reg_base);
448+
err_iomap:
449+
err_idxd_alloc:
450+
pci_disable_device(pdev);
451+
return rc;
441452
}
442453

443454
static void idxd_flush_pending_llist(struct idxd_irq_entry *ie)
@@ -493,6 +504,8 @@ static void idxd_shutdown(struct pci_dev *pdev)
493504

494505
idxd_msix_perm_clear(idxd);
495506
pci_free_irq_vectors(pdev);
507+
pci_iounmap(pdev, idxd->reg_base);
508+
pci_disable_device(pdev);
496509
destroy_workqueue(idxd->wq);
497510
}
498511

0 commit comments

Comments
 (0)