[dpdk-dev] [PATCH 19/28] common/cnxk: add support for removing irq stack

Tomasz Duszynski tduszynski at marvell.com
Mon May 31 23:41:33 CEST 2021


Add support for removing existing irq stack.

Signed-off-by: Jakub Palider <jpalider at marvell.com>
Signed-off-by: Tomasz Duszynski <tduszynski at marvell.com>
---
 drivers/common/cnxk/roc_bphy_irq.c | 30 ++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_bphy_irq.h |  1 +
 drivers/common/cnxk/version.map    |  1 +
 3 files changed, 32 insertions(+)

diff --git a/drivers/common/cnxk/roc_bphy_irq.c b/drivers/common/cnxk/roc_bphy_irq.c
index 04ad129ac..a90c055ff 100644
--- a/drivers/common/cnxk/roc_bphy_irq.c
+++ b/drivers/common/cnxk/roc_bphy_irq.c
@@ -110,6 +110,36 @@ roc_bphy_intr_fini(struct roc_bphy_irq_chip *irq_chip)
 	plt_free(irq_chip);
 }
 
+void
+roc_bphy_irq_stack_remove(int cpu)
+{
+	struct roc_bphy_irq_stack *curr_stack;
+
+	if (pthread_mutex_lock(&stacks_mutex))
+		return;
+
+	STAILQ_FOREACH(curr_stack, &irq_stacks, entries) {
+		if (curr_stack->cpu == cpu)
+			break;
+	}
+
+	if (curr_stack == NULL)
+		goto leave;
+
+	if (curr_stack->inuse > 0)
+		curr_stack->inuse--;
+
+	if (curr_stack->inuse == 0) {
+		STAILQ_REMOVE(&irq_stacks, curr_stack, roc_bphy_irq_stack,
+			      entries);
+		plt_free(curr_stack->sp_buffer);
+		plt_free(curr_stack);
+	}
+
+leave:
+	pthread_mutex_unlock(&stacks_mutex);
+}
+
 void *
 roc_bphy_irq_stack_get(int cpu)
 {
diff --git a/drivers/common/cnxk/roc_bphy_irq.h b/drivers/common/cnxk/roc_bphy_irq.h
index e66b2aa7c..549a84a7d 100644
--- a/drivers/common/cnxk/roc_bphy_irq.h
+++ b/drivers/common/cnxk/roc_bphy_irq.h
@@ -23,6 +23,7 @@ struct roc_bphy_irq_chip {
 
 __roc_api struct roc_bphy_irq_chip *roc_bphy_intr_init(void);
 __roc_api void roc_bphy_intr_fini(struct roc_bphy_irq_chip *irq_chip);
+__roc_api void roc_bphy_irq_stack_remove(int cpu);
 __roc_api void *roc_bphy_irq_stack_get(int cpu);
 __roc_api bool roc_bphy_intr_available(struct roc_bphy_irq_chip *irq_chip,
 				       int irq_num);
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 542364926..78601fe31 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -26,6 +26,7 @@ INTERNAL {
 	roc_bphy_intr_fini;
 	roc_bphy_intr_init;
 	roc_bphy_irq_stack_get;
+	roc_bphy_irq_stack_remove;
 	roc_clk_freq_get;
 	roc_error_msg_get;
 	roc_idev_lmt_base_addr_get;
-- 
2.25.1



More information about the dev mailing list