Phase out hybrid PCI devres API
Subsystems (9)
v2 cover Phase out hybrid PCI devres API
Changes in v2:
- Rename error path. (Jakub)
- Apply some RBs
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 | 12 +++++------- .../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, 26 insertions(+), 51 deletions(-)
Signature · 1 line
2.48.1
PATCH v2 1/8 net: prestera: Use pure PCI devres API
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().
--- drivers/net/ethernet/marvell/prestera/prestera_pci.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/marvell/prestera/prestera_pci.c +2 -4
@@ -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[] = {
Signature · 1 line
2.48.1
PATCH v2 2/8 net: octeontx2: Use pure PCI devres API
In reply to Philipp StannerThe 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().
--- .../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 | 12 +++++------- 3 files changed, 13 insertions(+), 27 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +4 -10
@@ -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 = {
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +4 -10
@@ -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 = {
drivers/net/ethernet/marvell/octeontx2/nic/rep.c +5 -7
@@ -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;
@@ -772,7 +772,7 @@ static int rvu_rep_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; + goto err_set_drv_data; }pci_set_master (pdev);
@@ -780,7 +780,7 @@ static int rvu_rep_probe(struct pci_dev *pdev, const struct pci_device_id *id) priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL );if (!priv) { err = -ENOMEM ; - goto err_release_regions; + goto err_set_drv_data; }pci_set_drvdata (pdev, priv);
@@ -797,7 +797,7 @@ static int rvu_rep_probe(struct pci_dev *pdev, const struct pci_device_id *id) err =otx2_init_rsrc (pdev, priv);if (err) - goto err_release_regions; + goto err_set_drv_data; priv->iommu_domain =iommu_get_domain_for_dev (dev);
@@ -820,9 +820,8 @@ static int rvu_rep_probe(struct pci_dev *pdev, const struct pci_device_id *id)otx2_disable_mbox_intr (priv);otx2_pfaf_mbox_destroy (priv);pci_free_irq_vectors (pdev); -err_release_regions: +err_set_drv_data: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 = {
Signature · 1 line
2.48.1
PATCH v2 3/8 net: tulip: Use pure PCI devres API
In reply to Philipp StannerThe 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().
--- 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(-)
drivers/net/ethernet/dec/tulip/tulip_core.c +1 -1
@@ -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);
drivers/net/ethernet/dec/tulip/winbond-840.c +1 -1
@@ -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);
Signature · 1 line
2.48.1
PATCH v2 4/8 net: ethernet: natsemi: Use pure PCI devres API
In reply to Philipp StannerThe 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().
--- drivers/net/ethernet/natsemi/natsemi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/natsemi/natsemi.c +1 -1
@@ -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;
Signature · 1 line
2.48.1
PATCH v2 5/8 net: ethernet: sis900: Use pure PCI devres API
In reply to Philipp StannerThe 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().
--- drivers/net/ethernet/sis/sis900.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/sis/sis900.c +1 -1
@@ -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;
Signature · 1 line
2.48.1
Re: [PATCH v2 5/8] net: ethernet: sis900: Use pure PCI devres API
Quoted 5 lines · Philipp Stanner
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 whetherpci_enable_device()orpcim_enable_device()has been called before).
Quoted 7 lines
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()withpcim_request_all_regions().Signed-off-by Philipp Stanner <[email protected]>Reviewed-by Jacob Keller <[email protected]>
Quoted 17 lines
--- drivers/net/ethernet/sis/sis900.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/sis/sis900.c +1
-1@@ -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;
PATCH v2 6/8 net: mdio: thunder: Use pure PCI devres API
In reply to Philipp StannerThe 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().
--- drivers/net/mdio/mdio-thunder.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/net/mdio/mdio-thunder.c +3 -7
@@ -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 ); }
Signature · 1 line
2.48.1
PATCH v2 7/8 net: thunder_bgx: Use pure PCI devres API
In reply to Philipp StannerThe 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().
--- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/cavium/thunder/thunder_bgx.c +2 -5
@@ -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 ); }
Signature · 1 line
2.48.1
PATCH v2 8/8 net: thunder_bgx: Don't disable PCI device manually
In reply to Philipp Stannerthunder_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().
--- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/net/ethernet/cavium/thunder/thunder_bgx.c +3 -5
@@ -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 ); }
Signature · 1 line
2.48.1
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 18 lines · On Fri, 25 Apr 2025 10:57:33 +0200 you wrote:
Changes in v2:
- Rename error path. (Jakub)
- Apply some RBsFixes 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-managedpcim_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
Quoted 1 line
[...]
Here is the summary with links:
- [v2,1/8] net: prestera: Use pure PCI devres API
https://git.kernel.org/netdev/net-next/c/66ada7471155 - [v2,2/8] net: octeontx2: Use pure PCI devres API https://git.kernel.org/netdev/net-next/c/48217b834529 - [v2,3/8] net: tulip: Use pure PCI devres API https://git.kernel.org/netdev/net-next/c/adc36d0914f6 - [v2,4/8] net: ethernet: natsemi: Use pure PCI devres API https://git.kernel.org/netdev/net-next/c/2a5a74947a2b - [v2,5/8] net: ethernet: sis900: Use pure PCI devres API https://git.kernel.org/netdev/net-next/c/6e5f7a5b5e0c - [v2,6/8] net: mdio: thunder: Use pure PCI devres API https://git.kernel.org/netdev/net-next/c/fad4d94d9ae5 - [v2,7/8] net: thunder_bgx: Use pure PCI devres API https://git.kernel.org/netdev/net-next/c/06133ddc3590 - [v2,8/8] net: thunder_bgx: Don't disable PCI device manually https://git.kernel.org/netdev/net-next/c/1549bd06e340
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html