Commit adbf627f authored by Stanislav Fomichev's avatar Stanislav Fomichev Committed by Jakub Kicinski
Browse files

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: 004b5008 ("eth: bnxt: remove most dependencies on RTNL")
Signed-off-by: default avatarStanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20250309215851.2003708-3-sdf@fomichev.me


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent eaca6e5d
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -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 acti
	struct 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 acti
		if (!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 acti
			msleep(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);