Skip to content

Commit aed031d

Browse files
Michael Chankuba-moo
authored andcommitted
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: 004b500 ("eth: bnxt: remove most dependencies on RTNL") Reviewed-by: Andy Gospodarek <[email protected]> Reviewed-by: Pavan Chebbi <[email protected]> Signed-off-by: Michael Chan <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 48a6285 commit aed031d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <asm/byteorder.h>
2121
#include <linux/bitmap.h>
2222
#include <linux/auxiliary_bus.h>
23+
#include <net/netdev_lock.h>
2324

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

312-
netdev_lock(bp->dev);
313-
ops = rcu_dereference(ulp->ulp_ops);
313+
ops = netdev_lock_dereference(ulp->ulp_ops, bp->dev);
314314
if (!ops || !ops->ulp_irq_stop)
315315
return;
316316
if (test_bit(BNXT_STATE_FW_RESET_DET, &bp->state))
317317
reset = true;
318318
ops->ulp_irq_stop(ulp->handle, reset);
319-
netdev_unlock(bp->dev);
320319
}
321320
}
322321

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

338-
netdev_lock(bp->dev);
339-
ops = rcu_dereference(ulp->ulp_ops);
337+
ops = netdev_lock_dereference(ulp->ulp_ops, bp->dev);
340338
if (!ops || !ops->ulp_irq_restart)
341339
return;
342340

@@ -348,7 +346,6 @@ void bnxt_ulp_irq_restart(struct bnxt *bp, int err)
348346
bnxt_fill_msix_vecs(bp, ent);
349347
}
350348
ops->ulp_irq_restart(ulp->handle, ent);
351-
netdev_unlock(bp->dev);
352349
kfree(ent);
353350
}
354351
}

include/net/netdev_lock.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ static inline int netdev_lock_cmp_fn(const struct lockdep_map *a,
9898
&qdisc_xmit_lock_key); \
9999
}
100100

101+
#define netdev_lock_dereference(p, dev) \
102+
rcu_dereference_protected(p, lockdep_is_held(&(dev)->lock))
103+
101104
int netdev_debug_event(struct notifier_block *nb, unsigned long event,
102105
void *ptr);
103106

0 commit comments

Comments
 (0)