Commit aed031da authored by Michael Chan's avatar Michael Chan Committed by Jakub Kicinski
Browse files

bnxt_en: Fix netdev locking in ULP IRQ functions



netdev_lock is already held when calling bnxt_ulp_irq_stop() and
bnxt_ulp_irq_restart().  When converting rtnl_lock to netdev_lock,
the original code was rtnl_dereference() to indicate that rtnl_lock
was already held.  rcu_dereference_protected() is the correct
conversion after replacing rtnl_lock with netdev_lock.

Add a new helper netdev_lock_dereference() similar to
rtnl_dereference().

Fixes: 004b5008 ("eth: bnxt: remove most dependencies on RTNL")
Reviewed-by: default avatarAndy Gospodarek <andrew.gospodarek@broadcom.com>
Reviewed-by: default avatarPavan Chebbi <pavan.chebbi@broadcom.com>
Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250519204130.3097027-2-michael.chan@broadcom.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 48a62855
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <asm/byteorder.h>
#include <linux/bitmap.h>
#include <linux/auxiliary_bus.h>
#include <net/netdev_lock.h>

#include "bnxt_hsi.h"
#include "bnxt.h"
@@ -309,14 +310,12 @@ void bnxt_ulp_irq_stop(struct bnxt *bp)
		if (!ulp->msix_requested)
			return;

		netdev_lock(bp->dev);
		ops = rcu_dereference(ulp->ulp_ops);
		ops = netdev_lock_dereference(ulp->ulp_ops, bp->dev);
		if (!ops || !ops->ulp_irq_stop)
			return;
		if (test_bit(BNXT_STATE_FW_RESET_DET, &bp->state))
			reset = true;
		ops->ulp_irq_stop(ulp->handle, reset);
		netdev_unlock(bp->dev);
	}
}

@@ -335,8 +334,7 @@ void bnxt_ulp_irq_restart(struct bnxt *bp, int err)
		if (!ulp->msix_requested)
			return;

		netdev_lock(bp->dev);
		ops = rcu_dereference(ulp->ulp_ops);
		ops = netdev_lock_dereference(ulp->ulp_ops, bp->dev);
		if (!ops || !ops->ulp_irq_restart)
			return;

@@ -348,7 +346,6 @@ void bnxt_ulp_irq_restart(struct bnxt *bp, int err)
			bnxt_fill_msix_vecs(bp, ent);
		}
		ops->ulp_irq_restart(ulp->handle, ent);
		netdev_unlock(bp->dev);
		kfree(ent);
	}
}
+3 −0
Original line number Diff line number Diff line
@@ -98,6 +98,9 @@ static inline int netdev_lock_cmp_fn(const struct lockdep_map *a,
				  &qdisc_xmit_lock_key);	\
}

#define netdev_lock_dereference(p, dev)				\
	rcu_dereference_protected(p, lockdep_is_held(&(dev)->lock))

int netdev_debug_event(struct notifier_block *nb, unsigned long event,
		       void *ptr);