From 43da5b8892bcbaae343fbe7d174b75056e222cb0 Mon Sep 17 00:00:00 2001 From: Harsh Kumar Bijlani Date: Tue, 3 Aug 2021 19:53:05 +0530 Subject: [PATCH] qcacmn: Add API for unmap with physical and virtual addr of nbuf Tx data transfer in host mode with nbuf map_unmap debug frmwk enabled and enhanced stats disabled results in an assert. This is because on Tx completion path, nbuf unmap is done using API qdf_mem_unmap_nbytes_single which takes physical address of nbuf for unmap and does not remove nbuf from map_unmap tracking list and when nbuf is freed, it results in assert as the tracking list still contains that nbuf entry. In order to fix this, define a new API for nbuf unmap passing physical and virtual address of nbuf as arguments. Physical address is passed as an argument in order to avoid cache miss in per packet path which eventually helps in improving the KPI. Change-Id: I77ab6ac3ac98556b9caff8aa3ee82bc23cd26de7 CRs-Fixed: 3006671 --- dp/wifi3.0/dp_tx.c | 9 +++++---- qdf/inc/qdf_nbuf.h | 18 ++++++++++++++++++ qdf/linux/src/qdf_nbuf.c | 13 +++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/dp/wifi3.0/dp_tx.c b/dp/wifi3.0/dp_tx.c index 098b8ea2d3..a9f7dc5bb5 100644 --- a/dp/wifi3.0/dp_tx.c +++ b/dp/wifi3.0/dp_tx.c @@ -4310,10 +4310,11 @@ dp_tx_comp_process_desc_list(struct dp_soc *soc, next = desc->next; dp_tx_desc_history_add(soc, desc->dma_addr, desc->nbuf, desc->id, DP_TX_COMP_UNMAP); - qdf_mem_unmap_nbytes_single(soc->osdev, - desc->dma_addr, - QDF_DMA_TO_DEVICE, - desc->length); + qdf_nbuf_unmap_nbytes_single_paddr(soc->osdev, + desc->nbuf, + desc->dma_addr, + QDF_DMA_TO_DEVICE, + desc->length); qdf_nbuf_free(desc->nbuf); dp_tx_desc_free(soc, desc, desc->pool_id); desc = next; diff --git a/qdf/inc/qdf_nbuf.h b/qdf/inc/qdf_nbuf.h index 8adbbe7b96..8e1d270338 100644 --- a/qdf/inc/qdf_nbuf.h +++ b/qdf/inc/qdf_nbuf.h @@ -862,6 +862,16 @@ void qdf_nbuf_unmap_nbytes_single_debug(qdf_device_t osdev, qdf_nbuf_unmap_nbytes_single_debug(osdev, buf, dir, nbytes, \ __func__, __LINE__) +void qdf_nbuf_unmap_nbytes_single_paddr_debug(qdf_device_t osdev, + qdf_nbuf_t buf, + qdf_dma_addr_t phy_addr, + qdf_dma_dir_t dir, int nbytes, + const char *func, uint32_t line); + +#define qdf_nbuf_unmap_nbytes_single_paddr(osdev, buf, phy_addr, dir, nbytes) \ + qdf_nbuf_unmap_nbytes_single_paddr_debug(osdev, buf, phy_addr, \ + dir, nbytes, __func__, \ + __LINE__) #else /* NBUF_MAP_UNMAP_DEBUG */ static inline void qdf_nbuf_map_check_for_leaks(void) {} @@ -917,6 +927,14 @@ qdf_nbuf_unmap_nbytes_single( { return __qdf_nbuf_unmap_nbytes_single(osdev, buf, dir, nbytes); } + +static inline void +qdf_nbuf_unmap_nbytes_single_paddr(qdf_device_t osdev, qdf_nbuf_t buf, + qdf_dma_addr_t phy_addr, qdf_dma_dir_t dir, + int nbytes) +{ + __qdf_mem_unmap_nbytes_single(osdev, phy_addr, dir, nbytes); +} #endif /* NBUF_MAP_UNMAP_DEBUG */ /** diff --git a/qdf/linux/src/qdf_nbuf.c b/qdf/linux/src/qdf_nbuf.c index ab1e08555b..9b6f328287 100644 --- a/qdf/linux/src/qdf_nbuf.c +++ b/qdf/linux/src/qdf_nbuf.c @@ -996,6 +996,19 @@ void qdf_nbuf_unmap_nbytes_single_debug(qdf_device_t osdev, qdf_export_symbol(qdf_nbuf_unmap_nbytes_single_debug); +void qdf_nbuf_unmap_nbytes_single_paddr_debug(qdf_device_t osdev, + qdf_nbuf_t buf, + qdf_dma_addr_t phy_addr, + qdf_dma_dir_t dir, int nbytes, + const char *func, uint32_t line) +{ + qdf_nbuf_untrack_map(buf, func, line); + __qdf_mem_unmap_nbytes_single(osdev, phy_addr, dir, nbytes); + qdf_net_buf_debug_update_unmap_node(buf, func, line); +} + +qdf_export_symbol(qdf_nbuf_unmap_nbytes_single_paddr_debug); + static void qdf_nbuf_panic_on_free_if_mapped(qdf_nbuf_t nbuf, const char *func, uint32_t line)