From 71a35ce9dfa0751f0d5ab180eef5ae78291e99f6 Mon Sep 17 00:00:00 2001 From: Ashok Vuyyuru Date: Thu, 21 Nov 2019 16:09:02 +0530 Subject: [PATCH] msm: ipa4: Fix to unmap the page if skb allocation failed Currently skb allocation failed scenario not unmap the rx_pkt pointer and not deleting from the list. Add changes to unmap the page and deleting from pending packet list if skb allocation failed scenario. Change-Id: Ie5732fda220837b849016f5de328f6f6042d3c6b Signed-off-by: Ashok Vuyyuru --- drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c | 4 ++- drivers/platform/msm/ipa/ipa_v3/ipa_dp.c | 27 ++++++++++++++----- drivers/platform/msm/ipa/ipa_v3/ipa_i.h | 1 + 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c b/drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c index dd6d17eaa032..672a24a1dffb 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c +++ b/drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c @@ -1427,6 +1427,7 @@ static ssize_t ipa3_read_stats(struct file *file, char __user *ubuf, "lan_repl_rx_empty=%u\n" "flow_enable=%u\n" "flow_disable=%u\n", + "rx_page_drop_cnt=%u\n", ipa3_ctx->stats.tx_sw_pkts, ipa3_ctx->stats.tx_hw_pkts, ipa3_ctx->stats.tx_non_linear, @@ -1442,7 +1443,8 @@ static ssize_t ipa3_read_stats(struct file *file, char __user *ubuf, ipa3_ctx->stats.lan_rx_empty, ipa3_ctx->stats.lan_repl_rx_empty, ipa3_ctx->stats.flow_enable, - ipa3_ctx->stats.flow_disable); + ipa3_ctx->stats.flow_disable, + ipa3_ctx->stats.rx_page_drop_cnt); cnt += nbytes; for (i = 0; i < IPAHAL_PKT_STATUS_EXCEPTION_MAX; i++) { diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c b/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c index 83da77f0982c..9ed92508d561 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c +++ b/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c @@ -3398,10 +3398,17 @@ static struct sk_buff *handle_page_completion(struct gsi_chan_xfer_notify IPAERR("update_truesize not supported\n"); if (notify->veid >= GSI_VEID_MAX) { - rx_pkt->sys->free_rx_wrapper(rx_pkt); - if (!rx_page.is_tmp_alloc) - init_page_count(rx_page.page); IPAERR("notify->veid > GSI_VEID_MAX\n"); + if (!rx_page.is_tmp_alloc) { + init_page_count(rx_page.page); + } else { + dma_unmap_page(ipa3_ctx->pdev, rx_page.dma_addr, + rx_pkt->len, DMA_FROM_DEVICE); + __free_pages(rx_pkt->page_data.page, + IPA_WAN_PAGE_ORDER); + } + rx_pkt->sys->free_rx_wrapper(rx_pkt); + IPA_STATS_INC_CNT(ipa3_ctx->stats.rx_page_drop_cnt); return NULL; } @@ -3415,10 +3422,18 @@ static struct sk_buff *handle_page_completion(struct gsi_chan_xfer_notify sys->ep->client == IPA_CLIENT_APPS_LAN_CONS) { rx_skb = alloc_skb(0, GFP_ATOMIC); if (unlikely(!rx_skb)) { - rx_pkt->sys->free_rx_wrapper(rx_pkt); - if (!rx_page.is_tmp_alloc) - init_page_count(rx_page.page); IPAERR("skb alloc failure\n"); + list_del(&rx_pkt->link); + if (!rx_page.is_tmp_alloc) { + init_page_count(rx_page.page); + } else { + dma_unmap_page(ipa3_ctx->pdev, rx_page.dma_addr, + rx_pkt->len, DMA_FROM_DEVICE); + __free_pages(rx_pkt->page_data.page, + IPA_WAN_PAGE_ORDER); + } + rx_pkt->sys->free_rx_wrapper(rx_pkt); + IPA_STATS_INC_CNT(ipa3_ctx->stats.rx_page_drop_cnt); return NULL; } /* go over the list backward to save computations on updating length */ diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_i.h b/drivers/platform/msm/ipa/ipa_v3/ipa_i.h index dde7e7b80a34..07c13f849f1a 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipa_i.h +++ b/drivers/platform/msm/ipa/ipa_v3/ipa_i.h @@ -1397,6 +1397,7 @@ struct ipa3_stats { u32 flow_enable; u32 flow_disable; u32 tx_non_linear; + u32 rx_page_drop_cnt; struct ipa3_page_recycle_stats page_recycle_stats[2]; };