Skip to contentSkip to conversation

PCI: Remove pcim_iounmap_regions()

PATCH In review Philipp Stanner 8 participants 11 messages Mar 27, 2025 – Apr 9, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover PCI: Remove pcim_iounmap_regions()

The last remaining user of pcim_iounmap_regions() is mtip32 (in Linus's current master)

So we could finally remove this deprecated API. I suggest that this gets merged through the PCI tree. (I also suggest we watch with an eagle's eyes for folks who want to re-add calls to that function before the next merge window opens).

P.

Philipp Stanner (2):
mtip32xx: Remove unnecessary PCI function calls
PCI: Remove pcim_iounmap_regions()

 .../driver-api/driver-model/devres.rst        |  1 -
 drivers/block/mtip32xx/mtip32xx.c             |  7 ++----
 drivers/pci/devres.c                          | 24 -------------------
 include/linux/pci.h                           |  1 -
 4 files changed, 2 insertions(+), 31 deletions(-)
Signature · 1 line
2.48.1
#1 lore raw

PATCH 1/2 mtip32xx: Remove unnecessary PCI function calls

pcim_iounmap_regions() is deprecated. Moreover, it is not necessary to call it in the driver's remove() function or if probe() fails, since it does cleanup automatically on driver detach.

Remove all calls to pcim_iounmap_regions().

---
 drivers/block/mtip32xx/mtip32xx.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/block/mtip32xx/mtip32xx.c +2 -5
index 95361099a2dc..63b9c41d3c25 100644
@@ -3717,7 +3717,7 @@ static int mtip_pci_probe(struct pci_dev *pdev,
 	rv = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
 	if (rv) {
 		dev_warn(&pdev->dev, "64-bit DMA enable failed\n");
-		goto setmask_err;
+		goto iomap_err;
 	}
 
 	/* Copy the info we may need later into the private data structure. */
@@ -3733,7 +3733,7 @@ static int mtip_pci_probe(struct pci_dev *pdev,
 	if (!dd->isr_workq) {
 		dev_warn(&pdev->dev, "Can't create wq %d\n", dd->instance);
 		rv = -ENOMEM;
-		goto setmask_err;
+		goto iomap_err;
 	}
 
 	memset(cpu_list, 0, sizeof(cpu_list));
@@ -3830,8 +3830,6 @@ static int mtip_pci_probe(struct pci_dev *pdev,
 		drop_cpu(dd->work[1].cpu_binding);
 		drop_cpu(dd->work[2].cpu_binding);
 	}
-setmask_err:
-	pcim_iounmap_regions(pdev, 1 << MTIP_ABAR);
 
 iomap_err:
 	kfree(dd);
@@ -3907,7 +3905,6 @@ static void mtip_pci_remove(struct pci_dev *pdev)
 
 	pci_disable_msi(pdev);
 
-	pcim_iounmap_regions(pdev, 1 << MTIP_ABAR);
 	pci_set_drvdata(pdev, NULL);
 
 	put_disk(dd->disk);
Signature · 1 line
2.48.1
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] mtip32xx: Remove unnecessary PCI function calls

Quoted 3 lines · Philipp Stanner

pcim_iounmap_regions() is deprecated. Moreover, it is not necessary to call it in the driver's remove() function or if probe() fails, since it does cleanup automatically on driver detach.

maintainer Acked-by on v1 1/2
#3 lore raw

Re: [PATCH 1/2] mtip32xx: Remove unnecessary PCI function calls

In reply to Philipp Stanner
Quoted 5 lines · Philipp Stanner

pcim_iounmap_regions() is deprecated. Moreover, it is not necessary to call it in the driver's remove() function or if probe() fails, since it does cleanup automatically on driver detach.

Remove all calls to pcim_iounmap_regions().

Signature · 1 line
Jens Axboe
#4 lore raw

PATCH 2/2 PCI: Remove pcim_iounmap_regions()

In reply to Philipp Stanner

From: Philipp Stanner <[email protected]>

All users of the deprecated function pcim_iounmap_regions() have been ported by now. Remove it.

---
 .../driver-api/driver-model/devres.rst        |  1 -
 drivers/pci/devres.c                          | 24 -------------------
 include/linux/pci.h                           |  1 -
 3 files changed, 26 deletions(-)
Documentation/driver-api/driver-model/devres.rst +0 -1
index d75728eb05f8..601f1a74d34d 100644
@@ -396,7 +396,6 @@ PCI
   pcim_iomap_regions()		: do request_region() and iomap() on multiple BARs
   pcim_iomap_table()		: array of mapped addresses indexed by BAR
   pcim_iounmap()		: do iounmap() on a single BAR
-  pcim_iounmap_regions()	: do iounmap() and release_region() on multiple BARs
   pcim_pin_device()		: keep PCI device enabled after release
   pcim_set_mwi()		: enable Memory-Write-Invalidate PCI transaction
 
drivers/pci/devres.c +0 -24
index 3431a7df3e0d..c60441555758 100644
@@ -946,30 +946,6 @@ int pcim_request_all_regions(struct pci_dev *pdev, const char *name)
 }
 EXPORT_SYMBOL(pcim_request_all_regions);
 
-/**
- * pcim_iounmap_regions - Unmap and release PCI BARs (DEPRECATED)
- * @pdev: PCI device to map IO resources for
- * @mask: Mask of BARs to unmap and release
- *
- * Unmap and release regions specified by @mask.
- *
- * This function is DEPRECATED. Do not use it in new code.
- * Use pcim_iounmap_region() instead.
- */
-void pcim_iounmap_regions(struct pci_dev *pdev, int mask)
-{
-	int i;
-
-	for (i = 0; i < PCI_STD_NUM_BARS; i++) {
-		if (!mask_contains_bar(mask, i))
-			continue;
-
-		pcim_iounmap_region(pdev, i);
-		pcim_remove_bar_from_legacy_table(pdev, i);
-	}
-}
-EXPORT_SYMBOL(pcim_iounmap_regions);
-
 /**
  * pcim_iomap_range - Create a ranged __iomap mapping within a PCI BAR
  * @pdev: PCI device to map IO resources for
include/linux/pci.h +0 -1
index 47b31ad724fa..7661f10913ca 100644
@@ -2323,7 +2323,6 @@ void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
 void __iomem * const *pcim_iomap_table(struct pci_dev *pdev);
 int pcim_request_region(struct pci_dev *pdev, int bar, const char *name);
 int pcim_iomap_regions(struct pci_dev *pdev, int mask, const char *name);
-void pcim_iounmap_regions(struct pci_dev *pdev, int mask);
 void __iomem *pcim_iomap_range(struct pci_dev *pdev, int bar,
 				unsigned long offset, unsigned long len);
 
Signature · 1 line
2.48.1
Reviewed-by on v1 2/2
#5 lore raw
Quoted 64 lines · Philipp Stanner

From: Philipp Stanner <[email protected]>

All users of the deprecated function pcim_iounmap_regions() have been ported by now. Remove it.

---
 .../driver-api/driver-model/devres.rst        |  1 -
 drivers/pci/devres.c                          | 24 -------------------
 include/linux/pci.h                           |  1 -
 3 files changed, 26 deletions(-)
Documentation/driver-api/driver-model/devres.rst +0 -1
index d75728eb05f8..601f1a74d34d 100644
@@ -396,7 +396,6 @@ PCI
   pcim_iomap_regions()		: do request_region() and iomap() on multiple BARs
   pcim_iomap_table()		: array of mapped addresses indexed by BAR
   pcim_iounmap()		: do iounmap() on a single BAR
-  pcim_iounmap_regions()	: do iounmap() and release_region() on multiple BARs
   pcim_pin_device()		: keep PCI device enabled after release
   pcim_set_mwi()		: enable Memory-Write-Invalidate PCI transaction
 
drivers/pci/devres.c +0 -24
index 3431a7df3e0d..c60441555758 100644
@@ -946,30 +946,6 @@ int pcim_request_all_regions(struct pci_dev *pdev, const char *name)
 }
 EXPORT_SYMBOL(pcim_request_all_regions);
 
-/**
- * pcim_iounmap_regions - Unmap and release PCI BARs (DEPRECATED)
- * @pdev: PCI device to map IO resources for
- * @mask: Mask of BARs to unmap and release
- *
- * Unmap and release regions specified by @mask.
- *
- * This function is DEPRECATED. Do not use it in new code.
- * Use pcim_iounmap_region() instead.
- */
-void pcim_iounmap_regions(struct pci_dev *pdev, int mask)
-{
-	int i;
-
-	for (i = 0; i < PCI_STD_NUM_BARS; i++) {
-		if (!mask_contains_bar(mask, i))
-			continue;
-
-		pcim_iounmap_region(pdev, i);
-		pcim_remove_bar_from_legacy_table(pdev, i);
-	}
-}
-EXPORT_SYMBOL(pcim_iounmap_regions);
-
 /**
  * pcim_iomap_range - Create a ranged __iomap mapping within a PCI BAR
  * @pdev: PCI device to map IO resources for
include/linux/pci.h +0 -0
index 47b31ad724fa..7661f10913ca 100644

include/linux/pci.h void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr); · line 2328

Quoted 7 lines
include/linux/pci.h +0 -1
@@ -2323,7 +2323,6 @@ void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
 void __iomem * const *pcim_iomap_table(struct pci_dev *pdev);
 int pcim_request_region(struct pci_dev *pdev, int bar, const char *name);
 int pcim_iomap_regions(struct pci_dev *pdev, int mask, const char *name);
-void pcim_iounmap_regions(struct pci_dev *pdev, int mask);
 void __iomem *pcim_iomap_range(struct pci_dev *pdev, int bar,
 				unsigned long offset, unsigned long len);
 
Reviewed-by on the v1 series
#6 lore raw
In reply to Philipp Stanner
Quoted 5 lines · Philipp Stanner

The last remaining user of pcim_iounmap_regions() is mtip32 (in Linus's current master)

So we could finally remove this deprecated API. I suggest that this gets merged through the PCI tree.

Good god! One API less, +1 to support this move.

Quoted 3 lines

(I also suggest we watch with an eagle's
eyes for folks who want to re-add calls to that function before the next merge window opens).

Instead of this I suggest that PCI can take this before merge window finishes and cooks the (second) PR with it. In such a case we wouldn't need to care, the developers will got broken builds.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw
Quoted 17 lines · Andy Shevchenko
Quoted 7 lines · Philipp Stanner

The last remaining user of pcim_iounmap_regions() is mtip32 (in Linus's
current master)

So we could finally remove this deprecated API. I suggest that this gets
merged through the PCI tree.

Good god! One API less, +1 to support this move.

Quoted 4 lines

(I also suggest we watch with an eagle's
eyes for folks who want to re-add calls to that function before the next
merge window opens).

Quoted 6 lines

Instead of this I suggest that PCI can take this before merge window finishes
and cooks the (second) PR with it. In such a case we wouldn't need to care,
the developers will got broken builds.

Normally Bjorn / PCI lets changes settle on a branch for >1 week before throwing them at mainline – but if we ask him very very nicely, maybe he would make an exception for this special case? :)

P.

#8 lore raw
Quoted 25 lines · On Wed, 02 Apr 2025 09:58:24 +0200 Philipp Stanner <[email protected]> wrote:
Quoted 17 lines · Andy Shevchenko
Quoted 7 lines · Philipp Stanner

The last remaining user of pcim_iounmap_regions() is mtip32 (in Linus's
current master)

So we could finally remove this deprecated API. I suggest that this gets
merged through the PCI tree.

Good god! One API less, +1 to support this move.

Quoted 4 lines

(I also suggest we watch with an eagle's
eyes for folks who want to re-add calls to that function before the next
merge window opens).

Quoted 6 lines

Instead of this I suggest that PCI can take this before merge window finishes
and cooks the (second) PR with it. In such a case we wouldn't need to care,
the developers will got broken builds.

Quoted 4 lines

Normally Bjorn / PCI lets changes settle on a branch for >1 week before throwing them at mainline – but if we ask him very very nicely, maybe he would make an exception for this special case? :)

linux-next should deal with any new users anyway so I wouldn't worry about it. Anyone who still has trees destined for the next merge window that aren't in next gets to deal with Linus being very grumpy at them.

Jonathan

Quoted 4 lines

P.

#9 lore raw
In reply to Philipp Stanner
Quoted 11 lines · Philipp Stanner

The last remaining user of pcim_iounmap_regions() is mtip32 (in Linus's
current master)

So we could finally remove this deprecated API. I suggest that this gets
merged through the PCI tree. (I also suggest we watch with an eagle's eyes for folks who want to re-add calls to that function before the next
merge window opens).

Quoted 5 lines

P.

Philipp Stanner (2):
  mtip32xx: Remove unnecessary PCI function calls
  PCI: Remove pcim_iounmap_regions()

Can this go in for the next merge window, Bjorn?

P.

Quoted 8 lines

 .../driver-api/driver-model/devres.rst        |  1 - drivers/block/mtip32xx/mtip32xx.c             |  7 ++---- drivers/pci/devres.c                          | 24 ----------------- --
 include/linux/pci.h                           |  1 -

 4 files changed, 2 insertions(+), 31 deletions(-)
#10 lore raw
In reply to Philipp Stanner
Quoted 8 lines · Philipp Stanner

The last remaining user of pcim_iounmap_regions() is mtip32 (in Linus's current master)

So we could finally remove this deprecated API. I suggest that this gets merged through the PCI tree. (I also suggest we watch with an eagle's eyes for folks who want to re-add calls to that function before the next merge window opens).

Quoted 5 lines

P.

Philipp Stanner (2):
mtip32xx: Remove unnecessary PCI function calls
PCI: Remove pcim_iounmap_regions()

Updated mtip32xx subject to:

mtip32xx: Remove unnecessary pcim_iounmap_regions() calls

and applied to pci/devres for v6.16, thanks!

Quoted 9 lines
 .../driver-api/driver-model/devres.rst        |  1 -
 drivers/block/mtip32xx/mtip32xx.c             |  7 ++----
 drivers/pci/devres.c                          | 24 -------------------
 include/linux/pci.h                           |  1 -
 4 files changed, 2 insertions(+), 31 deletions(-)
Signature · 1 line
2.48.1