linux-parisc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] net: Phase out hybrid PCI devres API
@ 2025-04-16 16:44 Philipp Stanner
  2025-04-16 16:44 ` [PATCH 1/8] net: prestera: Use pure " Philipp Stanner
                   ` (8 more replies)
  0 siblings, 9 replies; 14+ messages in thread
From: Philipp Stanner @ 2025-04-16 16:44 UTC (permalink / raw)
  To: Sunil Goutham, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Geetha sowjanya, Subbaraya Sundeep,
	hariprasad, Bharat Bhushan, Taras Chornyi, Daniele Venzano,
	Heiner Kallweit, Russell King, Thomas Gleixner, Philipp Stanner,
	Helge Deller, Ingo Molnar, Simon Horman, Al Viro, Sabrina Dubroca,
	Jacob Keller
  Cc: linux-arm-kernel, netdev, linux-kernel, linux-parisc

Fixes a number of minor issues with the usage of the PCI API in net.
Notbaly, it replaces calls to the sometimes-managed
pci_request_regions() to the always-managed pcim_request_all_regions(),
enabling us to remove that hybrid functionality from PCI.

Philipp Stanner (8):
  net: prestera: Use pure PCI devres API
  net: octeontx2: Use pure PCI devres API
  net: tulip: Use pure PCI devres API
  net: ethernet: natsemi: Use pure PCI devres API
  net: ethernet: sis900: Use pure PCI devres API
  net: mdio: thunder: Use pure PCI devres API
  net: thunder_bgx: Use pure PCI devres API
  net: thunder_bgx: Don't disable PCI device manually

 drivers/net/ethernet/cavium/thunder/thunder_bgx.c  | 13 ++++---------
 drivers/net/ethernet/dec/tulip/tulip_core.c        |  2 +-
 drivers/net/ethernet/dec/tulip/winbond-840.c       |  2 +-
 .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c   | 14 ++++----------
 .../net/ethernet/marvell/octeontx2/nic/otx2_vf.c   | 14 ++++----------
 drivers/net/ethernet/marvell/octeontx2/nic/rep.c   |  4 +---
 .../net/ethernet/marvell/prestera/prestera_pci.c   |  6 ++----
 drivers/net/ethernet/natsemi/natsemi.c             |  2 +-
 drivers/net/ethernet/sis/sis900.c                  |  2 +-
 drivers/net/mdio/mdio-thunder.c                    | 10 +++-------
 10 files changed, 22 insertions(+), 47 deletions(-)

-- 
2.48.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/8] net: prestera: Use pure PCI devres API
  2025-04-16 16:44 [PATCH 0/8] net: Phase out hybrid PCI devres API Philipp Stanner
@ 2025-04-16 16:44 ` Philipp Stanner
  2025-04-16 16:44 ` [PATCH 2/8] net: octeontx2: " Philipp Stanner
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Philipp Stanner @ 2025-04-16 16:44 UTC (permalink / raw)
  To: Sunil Goutham, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Geetha sowjanya, Subbaraya Sundeep,
	hariprasad, Bharat Bhushan, Taras Chornyi, Daniele Venzano,
	Heiner Kallweit, Russell King, Thomas Gleixner, Philipp Stanner,
	Helge Deller, Ingo Molnar, Simon Horman, Al Viro, Sabrina Dubroca,
	Jacob Keller
  Cc: linux-arm-kernel, netdev, linux-kernel, linux-parisc

The currently used function pci_request_regions() is one of the
problematic "hybrid devres" PCI functions, which are sometimes managed
through devres, and sometimes not (depending on whether
pci_enable_device() or pcim_enable_device() has been called before).

The PCI subsystem wants to remove this behavior and, therefore, needs to
port all users to functions that don't have this problem.

Furthermore, the PCI function being managed implies that it's not
necessary to call pci_release_regions() manually.

Remove the calls to pci_release_regions().

Replace pci_request_regions() with pcim_request_all_regions().

Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
 drivers/net/ethernet/marvell/prestera/prestera_pci.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/marvell/prestera/prestera_pci.c b/drivers/net/ethernet/marvell/prestera/prestera_pci.c
index 35857dc19542..c45d108b2f6d 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_pci.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_pci.c
@@ -845,9 +845,9 @@ static int prestera_pci_probe(struct pci_dev *pdev,
 		goto err_pci_enable_device;
 	}
 
-	err = pci_request_regions(pdev, driver_name);
+	err = pcim_request_all_regions(pdev, driver_name);
 	if (err) {
-		dev_err(&pdev->dev, "pci_request_regions failed\n");
+		dev_err(&pdev->dev, "pcim_request_all_regions failed\n");
 		goto err_pci_request_regions;
 	}
 
@@ -938,7 +938,6 @@ static int prestera_pci_probe(struct pci_dev *pdev,
 err_pp_ioremap:
 err_mem_ioremap:
 err_dma_mask:
-	pci_release_regions(pdev);
 err_pci_request_regions:
 err_pci_enable_device:
 	return err;
@@ -953,7 +952,6 @@ static void prestera_pci_remove(struct pci_dev *pdev)
 	pci_free_irq_vectors(pdev);
 	destroy_workqueue(fw->wq);
 	prestera_fw_uninit(fw);
-	pci_release_regions(pdev);
 }
 
 static const struct pci_device_id prestera_pci_devices[] = {
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/8] net: octeontx2: Use pure PCI devres API
  2025-04-16 16:44 [PATCH 0/8] net: Phase out hybrid PCI devres API Philipp Stanner
  2025-04-16 16:44 ` [PATCH 1/8] net: prestera: Use pure " Philipp Stanner
@ 2025-04-16 16:44 ` Philipp Stanner
  2025-04-23  0:49   ` Jakub Kicinski
  2025-04-16 16:44 ` [PATCH 3/8] net: tulip: " Philipp Stanner
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Philipp Stanner @ 2025-04-16 16:44 UTC (permalink / raw)
  To: Sunil Goutham, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Geetha sowjanya, Subbaraya Sundeep,
	hariprasad, Bharat Bhushan, Taras Chornyi, Daniele Venzano,
	Heiner Kallweit, Russell King, Thomas Gleixner, Philipp Stanner,
	Helge Deller, Ingo Molnar, Simon Horman, Al Viro, Sabrina Dubroca,
	Jacob Keller
  Cc: linux-arm-kernel, netdev, linux-kernel, linux-parisc

The currently used function pci_request_regions() is one of the
problematic "hybrid devres" PCI functions, which are sometimes managed
through devres, and sometimes not (depending on whether
pci_enable_device() or pcim_enable_device() has been called before).

The PCI subsystem wants to remove this behavior and, therefore, needs to
port all users to functions that don't have this problem.

Furthermore, the PCI function being managed implies that it's not
necessary to call pci_release_regions() manually.

Remove the calls to pci_release_regions().

Replace pci_request_regions() with pcim_request_all_regions().

Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
 .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c   | 14 ++++----------
 .../net/ethernet/marvell/octeontx2/nic/otx2_vf.c   | 14 ++++----------
 drivers/net/ethernet/marvell/octeontx2/nic/rep.c   |  4 +---
 3 files changed, 9 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
index cfed9ec5b157..0aee8e3861f3 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
@@ -3048,7 +3048,7 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		return err;
 	}
 
-	err = pci_request_regions(pdev, DRV_NAME);
+	err = pcim_request_all_regions(pdev, DRV_NAME);
 	if (err) {
 		dev_err(dev, "PCI request regions failed 0x%x\n", err);
 		return err;
@@ -3057,7 +3057,7 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	err = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48));
 	if (err) {
 		dev_err(dev, "DMA mask config failed, abort\n");
-		goto err_release_regions;
+		return err;
 	}
 
 	pci_set_master(pdev);
@@ -3067,10 +3067,8 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	qos_txqs = min_t(int, qcount, OTX2_QOS_MAX_LEAF_NODES);
 
 	netdev = alloc_etherdev_mqs(sizeof(*pf), qcount + qos_txqs, qcount);
-	if (!netdev) {
-		err = -ENOMEM;
-		goto err_release_regions;
-	}
+	if (!netdev)
+		return -ENOMEM;
 
 	pci_set_drvdata(pdev, netdev);
 	SET_NETDEV_DEV(netdev, &pdev->dev);
@@ -3246,8 +3244,6 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 err_free_netdev:
 	pci_set_drvdata(pdev, NULL);
 	free_netdev(netdev);
-err_release_regions:
-	pci_release_regions(pdev);
 	return err;
 }
 
@@ -3447,8 +3443,6 @@ static void otx2_remove(struct pci_dev *pdev)
 	pci_free_irq_vectors(pf->pdev);
 	pci_set_drvdata(pdev, NULL);
 	free_netdev(netdev);
-
-	pci_release_regions(pdev);
 }
 
 static struct pci_driver otx2_pf_driver = {
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
index 7ef3ba477d49..fb4da816d218 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
@@ -548,7 +548,7 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		return err;
 	}
 
-	err = pci_request_regions(pdev, DRV_NAME);
+	err = pcim_request_all_regions(pdev, DRV_NAME);
 	if (err) {
 		dev_err(dev, "PCI request regions failed 0x%x\n", err);
 		return err;
@@ -557,7 +557,7 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	err = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48));
 	if (err) {
 		dev_err(dev, "DMA mask config failed, abort\n");
-		goto err_release_regions;
+		return err;
 	}
 
 	pci_set_master(pdev);
@@ -565,10 +565,8 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	qcount = num_online_cpus();
 	qos_txqs = min_t(int, qcount, OTX2_QOS_MAX_LEAF_NODES);
 	netdev = alloc_etherdev_mqs(sizeof(*vf), qcount + qos_txqs, qcount);
-	if (!netdev) {
-		err = -ENOMEM;
-		goto err_release_regions;
-	}
+	if (!netdev)
+		return -ENOMEM;
 
 	pci_set_drvdata(pdev, netdev);
 	SET_NETDEV_DEV(netdev, &pdev->dev);
@@ -765,8 +763,6 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 err_free_netdev:
 	pci_set_drvdata(pdev, NULL);
 	free_netdev(netdev);
-err_release_regions:
-	pci_release_regions(pdev);
 	return err;
 }
 
@@ -815,8 +811,6 @@ static void otx2vf_remove(struct pci_dev *pdev)
 	pci_free_irq_vectors(vf->pdev);
 	pci_set_drvdata(pdev, NULL);
 	free_netdev(netdev);
-
-	pci_release_regions(pdev);
 }
 
 static struct pci_driver otx2vf_driver = {
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
index 04e08e06f30f..516471f172d1 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
@@ -763,7 +763,7 @@ static int rvu_rep_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		return err;
 	}
 
-	err = pci_request_regions(pdev, DRV_NAME);
+	err = pcim_request_all_regions(pdev, DRV_NAME);
 	if (err) {
 		dev_err(dev, "PCI request regions failed 0x%x\n", err);
 		return err;
@@ -822,7 +822,6 @@ static int rvu_rep_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	pci_free_irq_vectors(pdev);
 err_release_regions:
 	pci_set_drvdata(pdev, NULL);
-	pci_release_regions(pdev);
 	return err;
 }
 
@@ -842,7 +841,6 @@ static void rvu_rep_remove(struct pci_dev *pdev)
 	otx2_pfaf_mbox_destroy(priv);
 	pci_free_irq_vectors(priv->pdev);
 	pci_set_drvdata(pdev, NULL);
-	pci_release_regions(pdev);
 }
 
 static struct pci_driver rvu_rep_driver = {
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/8] net: tulip: Use pure PCI devres API
  2025-04-16 16:44 [PATCH 0/8] net: Phase out hybrid PCI devres API Philipp Stanner
  2025-04-16 16:44 ` [PATCH 1/8] net: prestera: Use pure " Philipp Stanner
  2025-04-16 16:44 ` [PATCH 2/8] net: octeontx2: " Philipp Stanner
@ 2025-04-16 16:44 ` Philipp Stanner
  2025-04-16 16:44 ` [PATCH 4/8] net: ethernet: natsemi: " Philipp Stanner
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Philipp Stanner @ 2025-04-16 16:44 UTC (permalink / raw)
  To: Sunil Goutham, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Geetha sowjanya, Subbaraya Sundeep,
	hariprasad, Bharat Bhushan, Taras Chornyi, Daniele Venzano,
	Heiner Kallweit, Russell King, Thomas Gleixner, Philipp Stanner,
	Helge Deller, Ingo Molnar, Simon Horman, Al Viro, Sabrina Dubroca,
	Jacob Keller
  Cc: linux-arm-kernel, netdev, linux-kernel, linux-parisc

The currently used function pci_request_regions() is one of the
problematic "hybrid devres" PCI functions, which are sometimes managed
through devres, and sometimes not (depending on whether
pci_enable_device() or pcim_enable_device() has been called before).

The PCI subsystem wants to remove this behavior and, therefore, needs to
port all users to functions that don't have this problem.

Replace pci_request_regions() with pcim_request_all_regions().

Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
 drivers/net/ethernet/dec/tulip/tulip_core.c  | 2 +-
 drivers/net/ethernet/dec/tulip/winbond-840.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/dec/tulip/tulip_core.c b/drivers/net/ethernet/dec/tulip/tulip_core.c
index c8c53121557f..bec76e7bf5dd 100644
--- a/drivers/net/ethernet/dec/tulip/tulip_core.c
+++ b/drivers/net/ethernet/dec/tulip/tulip_core.c
@@ -1411,7 +1411,7 @@ static int tulip_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	/* grab all resources from both PIO and MMIO regions, as we
 	 * don't want anyone else messing around with our hardware */
-	if (pci_request_regions(pdev, DRV_NAME))
+	if (pcim_request_all_regions(pdev, DRV_NAME))
 		return -ENODEV;
 
 	ioaddr = pcim_iomap(pdev, TULIP_BAR, tulip_tbl[chip_idx].io_size);
diff --git a/drivers/net/ethernet/dec/tulip/winbond-840.c b/drivers/net/ethernet/dec/tulip/winbond-840.c
index 5930cdec6f2f..e593273b2867 100644
--- a/drivers/net/ethernet/dec/tulip/winbond-840.c
+++ b/drivers/net/ethernet/dec/tulip/winbond-840.c
@@ -375,7 +375,7 @@ static int w840_probe1(struct pci_dev *pdev, const struct pci_device_id *ent)
 		return -ENOMEM;
 	SET_NETDEV_DEV(dev, &pdev->dev);
 
-	if (pci_request_regions(pdev, DRV_NAME))
+	if (pcim_request_all_regions(pdev, DRV_NAME))
 		goto err_out_netdev;
 
 	ioaddr = pci_iomap(pdev, TULIP_BAR, netdev_res_size);
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/8] net: ethernet: natsemi: Use pure PCI devres API
  2025-04-16 16:44 [PATCH 0/8] net: Phase out hybrid PCI devres API Philipp Stanner
                   ` (2 preceding siblings ...)
  2025-04-16 16:44 ` [PATCH 3/8] net: tulip: " Philipp Stanner
@ 2025-04-16 16:44 ` Philipp Stanner
  2025-04-16 16:44 ` [PATCH 5/8] net: ethernet: sis900: " Philipp Stanner
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Philipp Stanner @ 2025-04-16 16:44 UTC (permalink / raw)
  To: Sunil Goutham, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Geetha sowjanya, Subbaraya Sundeep,
	hariprasad, Bharat Bhushan, Taras Chornyi, Daniele Venzano,
	Heiner Kallweit, Russell King, Thomas Gleixner, Philipp Stanner,
	Helge Deller, Ingo Molnar, Simon Horman, Al Viro, Sabrina Dubroca,
	Jacob Keller
  Cc: linux-arm-kernel, netdev, linux-kernel, linux-parisc

The currently used function pci_request_regions() is one of the
problematic "hybrid devres" PCI functions, which are sometimes managed
through devres, and sometimes not (depending on whether
pci_enable_device() or pcim_enable_device() has been called before).

The PCI subsystem wants to remove this behavior and, therefore, needs to
port all users to functions that don't have this problem.

Replace pci_request_regions() with pcim_request_all_regions().

Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
 drivers/net/ethernet/natsemi/natsemi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/natsemi/natsemi.c b/drivers/net/ethernet/natsemi/natsemi.c
index 05606692e631..dd279788cf9e 100644
--- a/drivers/net/ethernet/natsemi/natsemi.c
+++ b/drivers/net/ethernet/natsemi/natsemi.c
@@ -846,7 +846,7 @@ static int natsemi_probe1(struct pci_dev *pdev, const struct pci_device_id *ent)
 		return -ENOMEM;
 	SET_NETDEV_DEV(dev, &pdev->dev);
 
-	i = pci_request_regions(pdev, DRV_NAME);
+	i = pcim_request_all_regions(pdev, DRV_NAME);
 	if (i)
 		goto err_pci_request_regions;
 
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/8] net: ethernet: sis900: Use pure PCI devres API
  2025-04-16 16:44 [PATCH 0/8] net: Phase out hybrid PCI devres API Philipp Stanner
                   ` (3 preceding siblings ...)
  2025-04-16 16:44 ` [PATCH 4/8] net: ethernet: natsemi: " Philipp Stanner
@ 2025-04-16 16:44 ` Philipp Stanner
  2025-04-16 16:44 ` [PATCH 6/8] net: mdio: thunder: " Philipp Stanner
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Philipp Stanner @ 2025-04-16 16:44 UTC (permalink / raw)
  To: Sunil Goutham, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Geetha sowjanya, Subbaraya Sundeep,
	hariprasad, Bharat Bhushan, Taras Chornyi, Daniele Venzano,
	Heiner Kallweit, Russell King, Thomas Gleixner, Philipp Stanner,
	Helge Deller, Ingo Molnar, Simon Horman, Al Viro, Sabrina Dubroca,
	Jacob Keller
  Cc: linux-arm-kernel, netdev, linux-kernel, linux-parisc

The currently used function pci_request_regions() is one of the
problematic "hybrid devres" PCI functions, which are sometimes managed
through devres, and sometimes not (depending on whether
pci_enable_device() or pcim_enable_device() has been called before).

The PCI subsystem wants to remove this behavior and, therefore, needs to
port all users to functions that don't have this problem.

Replace pci_request_regions() with pcim_request_all_regions().

Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
 drivers/net/ethernet/sis/sis900.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/sis/sis900.c b/drivers/net/ethernet/sis/sis900.c
index 332cbd725900..df869f82cae8 100644
--- a/drivers/net/ethernet/sis/sis900.c
+++ b/drivers/net/ethernet/sis/sis900.c
@@ -468,7 +468,7 @@ static int sis900_probe(struct pci_dev *pci_dev,
 	SET_NETDEV_DEV(net_dev, &pci_dev->dev);
 
 	/* We do a request_region() to register /proc/ioports info. */
-	ret = pci_request_regions(pci_dev, "sis900");
+	ret = pcim_request_all_regions(pci_dev, "sis900");
 	if (ret)
 		goto err_out;
 
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 6/8] net: mdio: thunder: Use pure PCI devres API
  2025-04-16 16:44 [PATCH 0/8] net: Phase out hybrid PCI devres API Philipp Stanner
                   ` (4 preceding siblings ...)
  2025-04-16 16:44 ` [PATCH 5/8] net: ethernet: sis900: " Philipp Stanner
@ 2025-04-16 16:44 ` Philipp Stanner
  2025-04-16 16:44 ` [PATCH 7/8] net: thunder_bgx: " Philipp Stanner
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Philipp Stanner @ 2025-04-16 16:44 UTC (permalink / raw)
  To: Sunil Goutham, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Geetha sowjanya, Subbaraya Sundeep,
	hariprasad, Bharat Bhushan, Taras Chornyi, Daniele Venzano,
	Heiner Kallweit, Russell King, Thomas Gleixner, Philipp Stanner,
	Helge Deller, Ingo Molnar, Simon Horman, Al Viro, Sabrina Dubroca,
	Jacob Keller
  Cc: linux-arm-kernel, netdev, linux-kernel, linux-parisc

The currently used function pci_request_regions() is one of the
problematic "hybrid devres" PCI functions, which are sometimes managed
through devres, and sometimes not (depending on whether
pci_enable_device() or pcim_enable_device() has been called before).

The PCI subsystem wants to remove this behavior and, therefore, needs to
port all users to functions that don't have this problem.

Furthermore, the PCI function being managed implies that it's not
necessary to call pci_release_regions() manually.

Remove the calls to pci_release_regions().

Replace pci_request_regions() with pcim_request_all_regions().

Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
 drivers/net/mdio/mdio-thunder.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/net/mdio/mdio-thunder.c b/drivers/net/mdio/mdio-thunder.c
index 1e1aa72b1eff..a3047f7258a7 100644
--- a/drivers/net/mdio/mdio-thunder.c
+++ b/drivers/net/mdio/mdio-thunder.c
@@ -40,16 +40,16 @@ static int thunder_mdiobus_pci_probe(struct pci_dev *pdev,
 		return err;
 	}
 
-	err = pci_request_regions(pdev, KBUILD_MODNAME);
+	err = pcim_request_all_regions(pdev, KBUILD_MODNAME);
 	if (err) {
-		dev_err(&pdev->dev, "pci_request_regions failed\n");
+		dev_err(&pdev->dev, "pcim_request_all_regions failed\n");
 		goto err_disable_device;
 	}
 
 	nexus->bar0 = pcim_iomap(pdev, 0, pci_resource_len(pdev, 0));
 	if (!nexus->bar0) {
 		err = -ENOMEM;
-		goto err_release_regions;
+		goto err_disable_device;
 	}
 
 	i = 0;
@@ -107,9 +107,6 @@ static int thunder_mdiobus_pci_probe(struct pci_dev *pdev,
 	}
 	return 0;
 
-err_release_regions:
-	pci_release_regions(pdev);
-
 err_disable_device:
 	pci_set_drvdata(pdev, NULL);
 	return err;
@@ -129,7 +126,6 @@ static void thunder_mdiobus_pci_remove(struct pci_dev *pdev)
 		mdiobus_unregister(bus->mii_bus);
 		oct_mdio_writeq(0, bus->register_base + SMI_EN);
 	}
-	pci_release_regions(pdev);
 	pci_set_drvdata(pdev, NULL);
 }
 
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 7/8] net: thunder_bgx: Use pure PCI devres API
  2025-04-16 16:44 [PATCH 0/8] net: Phase out hybrid PCI devres API Philipp Stanner
                   ` (5 preceding siblings ...)
  2025-04-16 16:44 ` [PATCH 6/8] net: mdio: thunder: " Philipp Stanner
@ 2025-04-16 16:44 ` Philipp Stanner
  2025-04-16 16:44 ` [PATCH 8/8] net: thunder_bgx: Don't disable PCI device manually Philipp Stanner
  2025-04-16 17:10 ` [PATCH 0/8] net: Phase out hybrid PCI devres API Keller, Jacob E
  8 siblings, 0 replies; 14+ messages in thread
From: Philipp Stanner @ 2025-04-16 16:44 UTC (permalink / raw)
  To: Sunil Goutham, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Geetha sowjanya, Subbaraya Sundeep,
	hariprasad, Bharat Bhushan, Taras Chornyi, Daniele Venzano,
	Heiner Kallweit, Russell King, Thomas Gleixner, Philipp Stanner,
	Helge Deller, Ingo Molnar, Simon Horman, Al Viro, Sabrina Dubroca,
	Jacob Keller
  Cc: linux-arm-kernel, netdev, linux-kernel, linux-parisc

The currently used function pci_request_regions() is one of the
problematic "hybrid devres" PCI functions, which are sometimes managed
through devres, and sometimes not (depending on whether
pci_enable_device() or pcim_enable_device() has been called before).

The PCI subsystem wants to remove this behavior and, therefore, needs to
port all users to functions that don't have this problem.

Furthermore, the PCI function being managed implies that it's not
necessary to call pci_release_regions() manually.

Remove the calls to pci_release_regions().

Replace pci_request_regions() with pcim_request_all_regions().

Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
 drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
index 608cc6af5af1..c9369bdd04e0 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -1605,7 +1605,7 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		return dev_err_probe(dev, err, "Failed to enable PCI device\n");
 	}
 
-	err = pci_request_regions(pdev, DRV_NAME);
+	err = pcim_request_all_regions(pdev, DRV_NAME);
 	if (err) {
 		dev_err(dev, "PCI request regions failed 0x%x\n", err);
 		goto err_disable_device;
@@ -1616,7 +1616,7 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (!bgx->reg_base) {
 		dev_err(dev, "BGX: Cannot map CSR memory space, aborting\n");
 		err = -ENOMEM;
-		goto err_release_regions;
+		goto err_disable_device;
 	}
 
 	set_max_bgx_per_node(pdev);
@@ -1688,8 +1688,6 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 err_enable:
 	bgx_vnic[bgx->bgx_id] = NULL;
 	pci_free_irq(pdev, GMPX_GMI_TX_INT, bgx);
-err_release_regions:
-	pci_release_regions(pdev);
 err_disable_device:
 	pci_disable_device(pdev);
 	pci_set_drvdata(pdev, NULL);
@@ -1710,7 +1708,6 @@ static void bgx_remove(struct pci_dev *pdev)
 	pci_free_irq(pdev, GMPX_GMI_TX_INT, bgx);
 
 	bgx_vnic[bgx->bgx_id] = NULL;
-	pci_release_regions(pdev);
 	pci_disable_device(pdev);
 	pci_set_drvdata(pdev, NULL);
 }
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 8/8] net: thunder_bgx: Don't disable PCI device manually
  2025-04-16 16:44 [PATCH 0/8] net: Phase out hybrid PCI devres API Philipp Stanner
                   ` (6 preceding siblings ...)
  2025-04-16 16:44 ` [PATCH 7/8] net: thunder_bgx: " Philipp Stanner
@ 2025-04-16 16:44 ` Philipp Stanner
  2025-04-16 17:10 ` [PATCH 0/8] net: Phase out hybrid PCI devres API Keller, Jacob E
  8 siblings, 0 replies; 14+ messages in thread
From: Philipp Stanner @ 2025-04-16 16:44 UTC (permalink / raw)
  To: Sunil Goutham, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Geetha sowjanya, Subbaraya Sundeep,
	hariprasad, Bharat Bhushan, Taras Chornyi, Daniele Venzano,
	Heiner Kallweit, Russell King, Thomas Gleixner, Philipp Stanner,
	Helge Deller, Ingo Molnar, Simon Horman, Al Viro, Sabrina Dubroca,
	Jacob Keller
  Cc: linux-arm-kernel, netdev, linux-kernel, linux-parisc

thunder_bgx's PCI device is enabled with pcim_enable_device(), a managed
devres function which ensures that the device gets enabled on driver
detach automatically.

Remove the calls to pci_disable_device().

Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
 drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
index c9369bdd04e0..3b7ad744b2dd 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -1608,7 +1608,7 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	err = pcim_request_all_regions(pdev, DRV_NAME);
 	if (err) {
 		dev_err(dev, "PCI request regions failed 0x%x\n", err);
-		goto err_disable_device;
+		goto err_zero_drv_data;
 	}
 
 	/* MAP configuration registers */
@@ -1616,7 +1616,7 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (!bgx->reg_base) {
 		dev_err(dev, "BGX: Cannot map CSR memory space, aborting\n");
 		err = -ENOMEM;
-		goto err_disable_device;
+		goto err_zero_drv_data;
 	}
 
 	set_max_bgx_per_node(pdev);
@@ -1688,8 +1688,7 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 err_enable:
 	bgx_vnic[bgx->bgx_id] = NULL;
 	pci_free_irq(pdev, GMPX_GMI_TX_INT, bgx);
-err_disable_device:
-	pci_disable_device(pdev);
+err_zero_drv_data:
 	pci_set_drvdata(pdev, NULL);
 	return err;
 }
@@ -1708,7 +1707,6 @@ static void bgx_remove(struct pci_dev *pdev)
 	pci_free_irq(pdev, GMPX_GMI_TX_INT, bgx);
 
 	bgx_vnic[bgx->bgx_id] = NULL;
-	pci_disable_device(pdev);
 	pci_set_drvdata(pdev, NULL);
 }
 
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* RE: [PATCH 0/8] net: Phase out hybrid PCI devres API
  2025-04-16 16:44 [PATCH 0/8] net: Phase out hybrid PCI devres API Philipp Stanner
                   ` (7 preceding siblings ...)
  2025-04-16 16:44 ` [PATCH 8/8] net: thunder_bgx: Don't disable PCI device manually Philipp Stanner
@ 2025-04-16 17:10 ` Keller, Jacob E
  8 siblings, 0 replies; 14+ messages in thread
From: Keller, Jacob E @ 2025-04-16 17:10 UTC (permalink / raw)
  To: Philipp Stanner, Sunil Goutham, Andrew Lunn, David S. Miller,
	Dumazet, Eric, Jakub Kicinski, Paolo Abeni, Geetha sowjanya,
	Subbaraya Sundeep, hariprasad, Bharat Bhushan, Taras Chornyi,
	Daniele Venzano, Heiner Kallweit, Russell King, Thomas Gleixner,
	Helge Deller, Ingo Molnar, Simon Horman, Al Viro, Sabrina Dubroca
  Cc: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org



> -----Original Message-----
> From: Philipp Stanner <phasta@kernel.org>
> Sent: Wednesday, April 16, 2025 9:44 AM
> To: Sunil Goutham <sgoutham@marvell.com>; Andrew Lunn
> <andrew+netdev@lunn.ch>; David S. Miller <davem@davemloft.net>; Dumazet,
> Eric <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni
> <pabeni@redhat.com>; Geetha sowjanya <gakula@marvell.com>; Subbaraya
> Sundeep <sbhatta@marvell.com>; hariprasad <hkelam@marvell.com>; Bharat
> Bhushan <bbhushan2@marvell.com>; Taras Chornyi
> <taras.chornyi@plvision.eu>; Daniele Venzano <venza@brownhat.org>; Heiner
> Kallweit <hkallweit1@gmail.com>; Russell King <linux@armlinux.org.uk>; Thomas
> Gleixner <tglx@linutronix.de>; Philipp Stanner <phasta@kernel.org>; Helge Deller
> <deller@gmx.de>; Ingo Molnar <mingo@kernel.org>; Simon Horman
> <horms@kernel.org>; Al Viro <viro@zeniv.linux.org.uk>; Sabrina Dubroca
> <sd@queasysnail.net>; Keller, Jacob E <jacob.e.keller@intel.com>
> Cc: linux-arm-kernel@lists.infradead.org; netdev@vger.kernel.org; linux-
> kernel@vger.kernel.org; linux-parisc@vger.kernel.org
> Subject: [PATCH 0/8] net: Phase out hybrid PCI devres API
> 
> Fixes a number of minor issues with the usage of the PCI API in net.
> Notbaly, it replaces calls to the sometimes-managed
> pci_request_regions() to the always-managed pcim_request_all_regions(),
> enabling us to remove that hybrid functionality from PCI.
> 

Removing the problematic "sometimes" behavior is good.

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/8] net: octeontx2: Use pure PCI devres API
  2025-04-16 16:44 ` [PATCH 2/8] net: octeontx2: " Philipp Stanner
@ 2025-04-23  0:49   ` Jakub Kicinski
  2025-04-23  6:28     ` Philipp Stanner
  0 siblings, 1 reply; 14+ messages in thread
From: Jakub Kicinski @ 2025-04-23  0:49 UTC (permalink / raw)
  To: Philipp Stanner
  Cc: Sunil Goutham, Andrew Lunn, David S. Miller, Eric Dumazet,
	Paolo Abeni, Geetha sowjanya, Subbaraya Sundeep, hariprasad,
	Bharat Bhushan, Taras Chornyi, Daniele Venzano, Heiner Kallweit,
	Russell King, Thomas Gleixner, Helge Deller, Ingo Molnar,
	Simon Horman, Al Viro, Sabrina Dubroca, Jacob Keller,
	linux-arm-kernel, netdev, linux-kernel, linux-parisc

On Wed, 16 Apr 2025 18:44:02 +0200 Philipp Stanner wrote:
>  err_release_regions:
>  	pci_set_drvdata(pdev, NULL);
> -	pci_release_regions(pdev);

This error path should be renamed. Could you also apply your conversion
to drivers/net/ethernet/marvell/octeontx2/af/ ?
-- 
pw-bot: cr

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/8] net: octeontx2: Use pure PCI devres API
  2025-04-23  0:49   ` Jakub Kicinski
@ 2025-04-23  6:28     ` Philipp Stanner
  2025-04-23  8:38       ` Philipp Stanner
  0 siblings, 1 reply; 14+ messages in thread
From: Philipp Stanner @ 2025-04-23  6:28 UTC (permalink / raw)
  To: Jakub Kicinski, Philipp Stanner
  Cc: Sunil Goutham, Andrew Lunn, David S. Miller, Eric Dumazet,
	Paolo Abeni, Geetha sowjanya, Subbaraya Sundeep, hariprasad,
	Bharat Bhushan, Taras Chornyi, Daniele Venzano, Heiner Kallweit,
	Russell King, Thomas Gleixner, Helge Deller, Ingo Molnar,
	Simon Horman, Al Viro, Sabrina Dubroca, Jacob Keller,
	linux-arm-kernel, netdev, linux-kernel, linux-parisc

On Tue, 2025-04-22 at 17:49 -0700, Jakub Kicinski wrote:
> On Wed, 16 Apr 2025 18:44:02 +0200 Philipp Stanner wrote:
> >  err_release_regions:
> >  	pci_set_drvdata(pdev, NULL);
> > -	pci_release_regions(pdev);
> 
> This error path should be renamed. Could you also apply your
> conversion
> to drivers/net/ethernet/marvell/octeontx2/af/ ?

Hm, those must have slipped me for some reason. Will reiterate with
them and the error path.

P.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/8] net: octeontx2: Use pure PCI devres API
  2025-04-23  6:28     ` Philipp Stanner
@ 2025-04-23  8:38       ` Philipp Stanner
  2025-04-23 22:14         ` Jakub Kicinski
  0 siblings, 1 reply; 14+ messages in thread
From: Philipp Stanner @ 2025-04-23  8:38 UTC (permalink / raw)
  To: phasta, Jakub Kicinski
  Cc: Sunil Goutham, Andrew Lunn, David S. Miller, Eric Dumazet,
	Paolo Abeni, Geetha sowjanya, Subbaraya Sundeep, hariprasad,
	Bharat Bhushan, Taras Chornyi, Daniele Venzano, Heiner Kallweit,
	Russell King, Thomas Gleixner, Helge Deller, Ingo Molnar,
	Simon Horman, Al Viro, Sabrina Dubroca, Jacob Keller,
	linux-arm-kernel, netdev, linux-kernel, linux-parisc

On Wed, 2025-04-23 at 08:28 +0200, Philipp Stanner wrote:
> On Tue, 2025-04-22 at 17:49 -0700, Jakub Kicinski wrote:
> > On Wed, 16 Apr 2025 18:44:02 +0200 Philipp Stanner wrote:
> > >  err_release_regions:
> > >  	pci_set_drvdata(pdev, NULL);
> > > -	pci_release_regions(pdev);
> > 
> > This error path should be renamed. Could you also apply your
> > conversion
> > to drivers/net/ethernet/marvell/octeontx2/af/ ?
> 
> Hm, those must have slipped me for some reason. Will reiterate with
> them and the error path.

Wait, false alarm. I actually did look at them and those in af/ don't
seem to use the combination of pcim_enable_device() + pci_request_*

Only users of that combination have to be ported. Users of
pci_enable_device() + pcim_* functions and pcim_enable_device() +
pcim_* functions are fine.

Correct me if I missed the first mentioned combination up there.

P.

> 
> P.
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/8] net: octeontx2: Use pure PCI devres API
  2025-04-23  8:38       ` Philipp Stanner
@ 2025-04-23 22:14         ` Jakub Kicinski
  0 siblings, 0 replies; 14+ messages in thread
From: Jakub Kicinski @ 2025-04-23 22:14 UTC (permalink / raw)
  To: Philipp Stanner
  Cc: phasta, Sunil Goutham, Andrew Lunn, David S. Miller, Eric Dumazet,
	Paolo Abeni, Geetha sowjanya, Subbaraya Sundeep, hariprasad,
	Bharat Bhushan, Taras Chornyi, Daniele Venzano, Heiner Kallweit,
	Russell King, Thomas Gleixner, Helge Deller, Ingo Molnar,
	Simon Horman, Al Viro, Sabrina Dubroca, Jacob Keller,
	linux-arm-kernel, netdev, linux-kernel, linux-parisc

On Wed, 23 Apr 2025 10:38:01 +0200 Philipp Stanner wrote:
> > > This error path should be renamed. Could you also apply your
> > > conversion
> > > to drivers/net/ethernet/marvell/octeontx2/af/ ?  
> > 
> > Hm, those must have slipped me for some reason. Will reiterate with
> > them and the error path.  
> 
> Wait, false alarm. I actually did look at them and those in af/ don't
> seem to use the combination of pcim_enable_device() + pci_request_*
> 
> Only users of that combination have to be ported. Users of
> pci_enable_device() + pcim_* functions and pcim_enable_device() +
> pcim_* functions are fine.
> 
> Correct me if I missed the first mentioned combination up there.

I think you're right, there are apparently multiple but separate
drivers in that directory.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-04-23 22:14 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-16 16:44 [PATCH 0/8] net: Phase out hybrid PCI devres API Philipp Stanner
2025-04-16 16:44 ` [PATCH 1/8] net: prestera: Use pure " Philipp Stanner
2025-04-16 16:44 ` [PATCH 2/8] net: octeontx2: " Philipp Stanner
2025-04-23  0:49   ` Jakub Kicinski
2025-04-23  6:28     ` Philipp Stanner
2025-04-23  8:38       ` Philipp Stanner
2025-04-23 22:14         ` Jakub Kicinski
2025-04-16 16:44 ` [PATCH 3/8] net: tulip: " Philipp Stanner
2025-04-16 16:44 ` [PATCH 4/8] net: ethernet: natsemi: " Philipp Stanner
2025-04-16 16:44 ` [PATCH 5/8] net: ethernet: sis900: " Philipp Stanner
2025-04-16 16:44 ` [PATCH 6/8] net: mdio: thunder: " Philipp Stanner
2025-04-16 16:44 ` [PATCH 7/8] net: thunder_bgx: " Philipp Stanner
2025-04-16 16:44 ` [PATCH 8/8] net: thunder_bgx: Don't disable PCI device manually Philipp Stanner
2025-04-16 17:10 ` [PATCH 0/8] net: Phase out hybrid PCI devres API Keller, Jacob E

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).