[v3] mempool/cnxk: fix mempool destroy for empty pools

Message ID 20221108065558.2092290-1-asekhar@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series [v3] mempool/cnxk: fix mempool destroy for empty pools |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/github-robot: build success github build: passed
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS

Commit Message

Ashwin Sekhar T K Nov. 8, 2022, 6:55 a.m. UTC
  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: bbf19e89b87c ("mempool/cnxk: add generic operations")

Signed-off-by: Ashwin Sekhar T K <asekhar@marvell.com>
---
 drivers/mempool/cnxk/cnxk_mempool_ops.c | 8 ++++++++
 1 file changed, 8 insertions(+)
  

Comments

Thomas Monjalon Nov. 15, 2022, 3:24 a.m. UTC | #1
08/11/2022 07:55, Ashwin Sekhar T K:
> 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: bbf19e89b87c ("mempool/cnxk: add generic operations")
> 
> Signed-off-by: Ashwin Sekhar T K <asekhar@marvell.com>

+ Cc: stable@dpdk.org

Applied with the title "fix destroying empty pool".
  

Patch

diff --git a/drivers/mempool/cnxk/cnxk_mempool_ops.c b/drivers/mempool/cnxk/cnxk_mempool_ops.c
index a0b94bb95c..3769afd3d1 100644
--- a/drivers/mempool/cnxk/cnxk_mempool_ops.c
+++ b/drivers/mempool/cnxk/cnxk_mempool_ops.c
@@ -126,6 +126,14 @@  cnxk_mempool_free(struct rte_mempool *mp)
 	int rc = 0;
 
 	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);
 	if (rc)
 		plt_err("Failed to free pool or aura rc=%d", rc);