eth: bnxt: switch to netif_close
PATCH v2 1/3 eth: bnxt: switch to netif_close
All (error) paths that call dev_close are already holding instance lock, so switch to netif_close to avoid the deadlock.
v2:
- add missing EXPORT_MODULE for netif_close
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 12 ++++++------ drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 4 ++-- net/core/dev.c | 1 + 3 files changed, 9 insertions(+), 8 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +6 -6
@@ -12802,7 +12802,7 @@ int bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) rc =__bnxt_open_nic (bp, irq_re_init, link_re_init);if (rc) {netdev_err (bp->dev,"nic open fail (rc: %x)\n" , rc); -dev_close (bp->dev); +netif_close (bp->dev); }return rc; }
@@ -12840,7 +12840,7 @@ int bnxt_half_open_nic(struct bnxt *bp) half_open_err:bnxt_free_skbs (bp);bnxt_free_mem (bp, true); -dev_close (bp->dev); +netif_close (bp->dev);return rc; }
@@ -14195,7 +14195,7 @@ void bnxt_fw_reset(struct bnxt *bp)netdev_err (bp->dev,"Firmware reset aborted, rc = %d\n" , n);clear_bit (BNXT_STATE_IN_FW_RESET , &bp->state); -dev_close (bp->dev); +netif_close (bp->dev); goto fw_reset_exit; }else if (n >0 ) {u16 vf_tmo_dsecs = n *10 ;
@@ -14810,7 +14810,7 @@ static void bnxt_fw_reset_abort(struct bnxt *bp, int rc)if (bp->fw_reset_state !=BNXT_FW_RESET_STATE_POLL_VF )bnxt_dl_health_fw_status_update (bp, false); bp->fw_reset_state =0 ; -dev_close (bp->dev); +netif_close (bp->dev); }static void bnxt_fw_reset_task (struct work_struct *work)
@@ -16276,7 +16276,7 @@ int bnxt_restore_pf_fw_resources(struct bnxt *bp)if (netif_running (bp->dev)) {if (rc) -dev_close (bp->dev); +netif_close (bp->dev);else rc =bnxt_open_nic (bp, true, false); }
@@ -16669,7 +16669,7 @@ static void bnxt_shutdown(struct pci_dev *pdev) goto shutdown_exit;if (netif_running (dev)) -dev_close (dev); +netif_close (dev);bnxt_ptp_clear (bp);bnxt_clear_int_mode (bp);
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +2 -2
@@ -461,7 +461,7 @@ static int bnxt_dl_reload_down(struct devlink *dl, bool netns_change,if (rc) {NL_SET_ERR_MSG_MOD (extack,"Failed to deregister" );if (netif_running (bp->dev)) -dev_close (bp->dev); +netif_close (bp->dev);netdev_unlock (bp->dev);rtnl_unlock ();break ;
@@ -576,7 +576,7 @@ static int bnxt_dl_reload_up(struct devlink *dl, enum devlink_reload_action acti *actions_performed |=BIT (action); }else if (netif_running (bp->dev)) {netdev_lock (bp->dev); -dev_close (bp->dev); +netif_close (bp->dev);netdev_unlock (bp->dev); }rtnl_unlock ();
net/core/dev.c +1 -0
@@ -1760,6 +1760,7 @@ void netif_close(struct net_device *dev)list_del (&single); } } +EXPORT_SYMBOL (netif_close);int dev_setup_tc (struct net_device *dev,enum tc_setup_type type,void *type_data)
Signature · 1 line
2.48.1
PATCH v2 2/3 eth: bnxt: request unconditional ops lock
netdev_lock_ops conditionally grabs instance lock when queue_mgmt_ops is defined. However queue_mgmt_ops support is signaled via FW so we can sometimes boot without queue_mgmt_ops being set. This will result in bnxt running without instance lock which the driver now heavily depends on. Set request_ops_lock to true unconditionally to always request netdev instance lock.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -0
@@ -16613,6 +16613,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) bp->rss_cap |=BNXT_RSS_CAP_MULTI_RSS_CTX ;if (BNXT_SUPPORTS_QUEUE_API (bp)) dev->queue_mgmt_ops = &bnxt_queue_mgmt_ops; + dev->request_ops_lock = true; rc =register_netdev (dev);if (rc)
Signature · 1 line
2.48.1
PATCH v2 3/3 eth: bnxt: add missing netdev lock management to bnxt_dl_reload_up
In reply to Stanislav Fomichevbnxt_dl_reload_up is completely missing instance lock management which can result in devlink dev reload leaving with instance lock held. Add the missing calls.
Also add netdev_assert_locked to make it clear that the up() method is running with the instance lock grabbed.
v2:
- add net/netdev_lock.h include to bnxt_devlink.c for netdev_assert_locked
--- drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +6 -2
@@ -11,6 +11,7 @@#include <linux/netdevice.h> #include <linux/vmalloc.h> #include <net/devlink.h> +#include <net/netdev_lock.h> #include "bnxt_hsi.h" #include "bnxt.h" #include "bnxt_hwrm.h"
@@ -518,6 +519,8 @@ static int bnxt_dl_reload_up(struct devlink *dl, enum devlink_reload_action actistruct bnxt *bp =bnxt_get_bp_from_dl (dl);int rc =0 ; +netdev_assert_locked (bp->dev); + *actions_performed =0 ;switch (action) {case DEVLINK_RELOAD_ACTION_DRIVER_REINIT : {
@@ -542,6 +545,7 @@ static int bnxt_dl_reload_up(struct devlink *dl, enum devlink_reload_action actiif (!netif_running (bp->dev))NL_SET_ERR_MSG_MOD (extack,"Device is closed, not waiting for reset notice that will never come" ); +netdev_unlock (bp->dev);rtnl_unlock ();while (test_bit (BNXT_STATE_FW_ACTIVATE , &bp->state)) {if (time_after (jiffies, timeout)) {
@@ -557,6 +561,7 @@ static int bnxt_dl_reload_up(struct devlink *dl, enum devlink_reload_action actimsleep (50 ); }rtnl_lock (); +netdev_lock (bp->dev);if (!rc) *actions_performed |=BIT (DEVLINK_RELOAD_ACTION_DRIVER_REINIT );clear_bit (BNXT_STATE_FW_ACTIVATE , &bp->state);
@@ -575,10 +580,9 @@ static int bnxt_dl_reload_up(struct devlink *dl, enum devlink_reload_action acti } *actions_performed |=BIT (action); }else if (netif_running (bp->dev)) { -netdev_lock (bp->dev);netif_close (bp->dev); -netdev_unlock (bp->dev); } +netdev_unlock (bp->dev);rtnl_unlock ();if (action ==DEVLINK_RELOAD_ACTION_DRIVER_REINIT )bnxt_ulp_start (bp, rc);
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 11 lines · On Sun, 9 Mar 2025 14:58:49 -0700 you wrote:
All (error) paths that call
dev_closeare already holding instance lock, so switch tonetif_closeto avoid the deadlock.v2:
- add missingEXPORT_MODULEfornetif_closeFixes 004b5008016a ("eth: bnxt: remove most dependencies on RTNL")Reported-by Jakub Kicinski <[email protected]>Signed-off-by Stanislav Fomichev <[email protected]>[...]
Here is the summary with links:
- [net-next,v2,1/3] eth: bnxt: switch to netif_close
(no matching commit)
- [net-next,v2,2/3] eth: bnxt: request unconditional ops lock
https://git.kernel.org/netdev/net-next/c/eaca6e5dc6ba
- [net-next,v2,3/3] eth: bnxt: add missing netdev lock management to bnxt_dl_reload_up
https://git.kernel.org/netdev/net-next/c/adbf627f1703
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html