Skip to content

Commit adbf627

Browse files
Stanislav Fomichevkuba-moo
authored andcommitted
eth: bnxt: add missing netdev lock management to bnxt_dl_reload_up
bnxt_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 Fixes: 004b500 ("eth: bnxt: remove most dependencies on RTNL") Signed-off-by: Stanislav Fomichev <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent eaca6e5 commit adbf627

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/netdevice.h>
1212
#include <linux/vmalloc.h>
1313
#include <net/devlink.h>
14+
#include <net/netdev_lock.h>
1415
#include "bnxt_hsi.h"
1516
#include "bnxt.h"
1617
#include "bnxt_hwrm.h"
@@ -518,6 +519,8 @@ static int bnxt_dl_reload_up(struct devlink *dl, enum devlink_reload_action acti
518519
struct bnxt *bp = bnxt_get_bp_from_dl(dl);
519520
int rc = 0;
520521

522+
netdev_assert_locked(bp->dev);
523+
521524
*actions_performed = 0;
522525
switch (action) {
523526
case DEVLINK_RELOAD_ACTION_DRIVER_REINIT: {
@@ -542,6 +545,7 @@ static int bnxt_dl_reload_up(struct devlink *dl, enum devlink_reload_action acti
542545
if (!netif_running(bp->dev))
543546
NL_SET_ERR_MSG_MOD(extack,
544547
"Device is closed, not waiting for reset notice that will never come");
548+
netdev_unlock(bp->dev);
545549
rtnl_unlock();
546550
while (test_bit(BNXT_STATE_FW_ACTIVATE, &bp->state)) {
547551
if (time_after(jiffies, timeout)) {
@@ -557,6 +561,7 @@ static int bnxt_dl_reload_up(struct devlink *dl, enum devlink_reload_action acti
557561
msleep(50);
558562
}
559563
rtnl_lock();
564+
netdev_lock(bp->dev);
560565
if (!rc)
561566
*actions_performed |= BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT);
562567
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
575580
}
576581
*actions_performed |= BIT(action);
577582
} else if (netif_running(bp->dev)) {
578-
netdev_lock(bp->dev);
579583
netif_close(bp->dev);
580-
netdev_unlock(bp->dev);
581584
}
585+
netdev_unlock(bp->dev);
582586
rtnl_unlock();
583587
if (action == DEVLINK_RELOAD_ACTION_DRIVER_REINIT)
584588
bnxt_ulp_start(bp, rc);

0 commit comments

Comments
 (0)