From: Michael Chan Date: Mon, 28 Aug 2017 17:40:30 +0000 (-0400) Subject: bnxt_en: Improve -ENOMEM logic in NAPI poll loop. X-Git-Tag: v4.1.12-124.31.3~955 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a3eb127ea2756abeb91c0e4172e00ea508f5a9bc;p=users%2Fjedix%2Flinux-maple.git bnxt_en: Improve -ENOMEM logic in NAPI poll loop. Orabug: 27648355, 27648339 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 Signed-off-by: Michael Chan Reported-by: Martin KaFai Lau Acked-by: Martin KaFai Lau Signed-off-by: David S. Miller (cherry picked from commit 903649e718f80da2ba4b65a0adf6930219b4b2e5) Signed-off-by: Brian Maly Reviewed-by: Jack Vogel --- diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index bdef2e844111..90491892c444 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -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) ==