Skip to contentSkip to conversation

common/cnxk: fix flow aging cleanup

PATCH Applied [email protected] 2 participants 2 messages May 8, 2024 – May 27, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/cnxk: fix flow aging cleanup

From: Satheesh Paul <[email protected]>

The aged flows poll thread is not stopped before NPC cleanup resulting in a segmentation fault. Fixing this by stopping aged flows poll thread before proceeding with NPC cleanup.

Fixes 357f5ebc8a24 ("common/cnxk: support flow aging")
---
 drivers/common/cnxk/roc_npc.c       | 5 +++--
 drivers/common/cnxk/roc_npc_aging.c | 8 +++++---
 2 files changed, 8 insertions(+), 5 deletions(-)
drivers/common/cnxk/roc_npc.c +3 -2
index d6ad3756bb..37e1a6a7ef 100644
@@ -389,6 +389,8 @@ roc_npc_fini(struct roc_npc *roc_npc)
 	struct npc *npc = roc_npc_to_npc_priv(roc_npc);
 	int rc;
 
+	npc_aging_ctrl_thread_destroy(roc_npc);
+
 	rc = npc_flow_free_all_resources(npc);
 	if (rc) {
 		plt_err("Error when deleting NPC MCAM entries, counters");
@@ -1810,8 +1812,7 @@ roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow)
 	if (flow->has_age_action)
 		npc_age_flow_list_entry_delete(roc_npc, flow);
 
-	if (roc_npc->flow_age.age_flow_refcnt == 0 &&
-		plt_thread_is_valid(roc_npc->flow_age.aged_flows_poll_thread))
+	if (roc_npc->flow_age.age_flow_refcnt == 0)
 		npc_aging_ctrl_thread_destroy(roc_npc);
 
 done:
drivers/common/cnxk/roc_npc_aging.c +5 -3
index e0f2dc2291..15f6e61d76 100644
@@ -303,9 +303,11 @@ npc_aging_ctrl_thread_destroy(struct roc_npc *roc_npc)
 	struct roc_npc_flow_age *flow_age;
 
 	flow_age = &roc_npc->flow_age;
-	flow_age->aged_flows_get_thread_exit = true;
-	plt_thread_join(flow_age->aged_flows_poll_thread, NULL);
-	npc_aged_flows_bitmap_free(roc_npc);
+	if (plt_thread_is_valid(flow_age->aged_flows_poll_thread)) {
+		flow_age->aged_flows_get_thread_exit = true;
+		plt_thread_join(flow_age->aged_flows_poll_thread, NULL);
+		npc_aged_flows_bitmap_free(roc_npc);
+	}
 }
 
 void *
Signature · 1 line
2.39.2
Applied
#1 lore raw
Quoted 7 lines · On Wed, May 8, 2024 at 4:37 PM <[email protected]> wrote:

From: Satheesh Paul <[email protected]>

The aged flows poll thread is not stopped before NPC cleanup resulting in a segmentation fault. Fixing this by stopping aged flows poll thread before proceeding with NPC cleanup.

Quoted 5 lines
Fixes 357f5ebc8a24 ("common/cnxk: support flow aging")

Applied to dpdk-next-net-mrvl/for-main. Thanks