From 3379c749690a507bd05f3c44623f48eb73e601a8 Mon Sep 17 00:00:00 2001 From: "Pamidipati, Vijay" Date: Wed, 1 Nov 2017 18:50:43 +0530 Subject: [PATCH] qcacmn: Fix descriptor leak issue in DP In the DMA descriptor reap code, the check for NAPI quota is after Tail pointer is updated. This is causing a descriptor leak in high load conditions when loop is exited without processing the reaped descriptor. This change moves the quota check to end of while loop. Change-Id: I2f3432bf257947f85abc2216a0f2dfc44813c44c CRs-Fixed: 2137017 --- dp/wifi3.0/dp_rx.c | 5 ++--- dp/wifi3.0/dp_rx_err.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/dp/wifi3.0/dp_rx.c b/dp/wifi3.0/dp_rx.c index d70494fb8fef..7b139ad31117 100644 --- a/dp/wifi3.0/dp_rx.c +++ b/dp/wifi3.0/dp_rx.c @@ -957,9 +957,8 @@ dp_rx_process(struct dp_intr *int_ctx, void *hal_ring, uint32_t quota) * them in per vdev queue. * Process the received pkts in a different per vdev loop. */ - while (qdf_likely((ring_desc = - hal_srng_dst_get_next(hal_soc, hal_ring)) - && quota)) { + while (qdf_likely(quota && (ring_desc = + hal_srng_dst_get_next(hal_soc, hal_ring)))) { error = HAL_RX_ERROR_STATUS_GET(ring_desc); ring_id = hal_srng_ring_id_get(hal_ring); diff --git a/dp/wifi3.0/dp_rx_err.c b/dp/wifi3.0/dp_rx_err.c index 8f24f3d85b6a..a77ef50c1182 100644 --- a/dp/wifi3.0/dp_rx_err.c +++ b/dp/wifi3.0/dp_rx_err.c @@ -774,9 +774,9 @@ dp_rx_err_process(struct dp_soc *soc, void *hal_ring, uint32_t quota) goto done; } - while (qdf_likely((ring_desc = - hal_srng_dst_get_next(hal_soc, hal_ring)) - && quota--)) { + while (qdf_likely(quota-- && (ring_desc = + hal_srng_dst_get_next(hal_soc, hal_ring)))) { + DP_STATS_INC(soc, rx.err_ring_pkts, 1); error = HAL_RX_ERROR_STATUS_GET(ring_desc); @@ -843,6 +843,7 @@ dp_rx_err_process(struct dp_soc *soc, void *hal_ring, uint32_t quota) /* Return link descriptor through WBM ring (SW2WBM)*/ dp_rx_link_desc_return(soc, ring_desc, HAL_BM_ACTION_PUT_IN_IDLE_LIST); + } done: @@ -913,9 +914,8 @@ dp_rx_wbm_err_process(struct dp_soc *soc, void *hal_ring, uint32_t quota) goto done; } - while (qdf_likely((ring_desc = - hal_srng_dst_get_next(hal_soc, hal_ring)) - && quota--)) { + while (qdf_likely(quota-- && (ring_desc = + hal_srng_dst_get_next(hal_soc, hal_ring)))) { /* XXX */ wbm_err_src = HAL_RX_WBM_ERR_SRC_GET(ring_desc); @@ -1248,8 +1248,8 @@ dp_rxdma_err_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) return 0; } - while (qdf_likely((rxdma_dst_ring_desc = - hal_srng_dst_get_next(hal_soc, err_dst_srng)) && quota--)) { + while (qdf_likely(quota-- && (rxdma_dst_ring_desc = + hal_srng_dst_get_next(hal_soc, err_dst_srng)))) { rx_bufs_used += dp_rx_err_mpdu_pop(soc, mac_id, rxdma_dst_ring_desc,