mempool/cnxk: fix destroying empty pool

In scenarios where rte_mempool_free() is called immediately
after rte_mempool_create_empty(), the NPA pool will not be
created. In such cases the free path should not call
roc_npa_pool_destroy().

Fixes: bbf19e89b8 ("mempool/cnxk: add generic operations")
Cc: stable@dpdk.org

Signed-off-by: Ashwin Sekhar T K <asekhar@marvell.com>
This commit is contained in:
Ashwin Sekhar T K 2022-11-08 12:25:58 +05:30 committed by Thomas Monjalon
parent b1a6b1e909
commit 3af7276eaf

View File

@ -126,6 +126,14 @@ cnxk_mempool_free(struct rte_mempool *mp)
int rc = 0; int rc = 0;
plt_npa_dbg("aura_handle=0x%" PRIx64, mp->pool_id); plt_npa_dbg("aura_handle=0x%" PRIx64, mp->pool_id);
/* It can happen that rte_mempool_free() is called immediately after
* rte_mempool_create_empty(). In such cases the NPA pool will not be
* allocated.
*/
if (roc_npa_aura_handle_to_base(mp->pool_id) == 0)
return;
rc = roc_npa_pool_destroy(mp->pool_id); rc = roc_npa_pool_destroy(mp->pool_id);
if (rc) if (rc)
plt_err("Failed to free pool or aura rc=%d", rc); plt_err("Failed to free pool or aura rc=%d", rc);