Thread (8 messages) 8 messages, 3 authors, 2023-07-27

Re: [PATCH net] bnxt: don't handle XDP in netpoll

From: Michael Chan <michael.chan@broadcom.com>
Date: 2023-07-27 18:52:25

On Thu, Jul 27, 2023 at 10:05 AM Jakub Kicinski [off-list ref] wrote:
quoted hunk ↗ jump to hunk
Similarly to other recently fixed drivers make sure we don't
try to access XDP or page pool APIs when NAPI budget is 0.
NAPI budget of 0 may mean that we are in netpoll.

This may result in running software IRQs in hard IRQ context,
leading to deadlocks or crashes.

Fixes: 322b87ca55f2 ("bnxt_en: add page_pool support")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: michael.chan@broadcom.com
CC: gospo@broadcom.com

Side note - having to plumb the "budget" everywhere really makes
me wonder if we shouldn't have had those APIs accept a pointer
to napi_struct instead :S
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c     | 19 +++++++++++--------
 drivers/net/ethernet/broadcom/bnxt/bnxt.h     |  2 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c |  6 +++++-
 drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h |  3 ++-
 4 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c
index 5b6fbdc4dc40..33b7eddfbf41 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c
@@ -125,7 +125,8 @@ static void __bnxt_xmit_xdp_redirect(struct bnxt *bp,
        dma_unmap_len_set(tx_buf, len, 0);
 }

-void bnxt_tx_int_xdp(struct bnxt *bp, struct bnxt_napi *bnapi, int nr_pkts)
+void bnxt_tx_int_xdp(struct bnxt *bp, struct bnxt_napi *bnapi, int nr_pkts,
+                    int budget)
 {
        struct bnxt_tx_ring_info *txr = bnapi->tx_ring;
        struct bnxt_rx_ring_info *rxr = bnapi->rx_ring;
@@ -135,6 +136,9 @@ void bnxt_tx_int_xdp(struct bnxt *bp, struct bnxt_napi *bnapi, int nr_pkts)
        u16 last_tx_cons = tx_cons;
        int i, j, frags;

+       if (!budget)
+               return;
+
These TX packet completions have already been counted in
__bnxt_poll_work().  If we do nothing here, I think the TX ring will
forever be out-of-sync with the completion ring.

Attachments

  • smime.p7s [application/pkcs7-signature] 4209 bytes
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help