]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bnxt_en: Improve -ENOMEM logic in NAPI poll loop.
authorMichael Chan <michael.chan@broadcom.com>
Mon, 28 Aug 2017 17:40:30 +0000 (13:40 -0400)
committerJack Vogel <jack.vogel@oracle.com>
Fri, 9 Mar 2018 04:49:46 +0000 (20:49 -0800)
Orabug: 2764835527648339

If we cannot allocate RX buffers in the NAPI poll loop when processing
an RX event, the current code does not count that event towards the NAPI
budget.  This can cause us to potentially loop forever in NAPI if we
consistently cannot allocate new buffers.  Improve it by counting
-ENOMEM event as 1 towards the NAPI budget.

Cc: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Reported-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 903649e718f80da2ba4b65a0adf6930219b4b2e5)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
Reviewed-by: Jack Vogel <jack.vogel@oracle.com>
drivers/net/ethernet/broadcom/bnxt/bnxt.c

index bdef2e8441114b7b52fb307135b25f3ac8bdcbef..90491892c44473c23453ffbc410144a6bac41462 100644 (file)
@@ -1840,6 +1840,13 @@ static int bnxt_poll_work(struct bnxt *bp, struct bnxt_napi *bnapi, int budget)
                                                           &event);
                        if (likely(rc >= 0))
                                rx_pkts += rc;
+                       /* Increment rx_pkts when rc is -ENOMEM to count towards
+                        * the NAPI budget.  Otherwise, we may potentially loop
+                        * here forever if we consistently cannot allocate
+                        * buffers.
+                        */
+                       else if (rc == -ENOMEM)
+                               rx_pkts++;
                        else if (rc == -EBUSY)  /* partial completion */
                                break;
                } else if (unlikely((TX_CMP_TYPE(txcmp) ==