common/cnxk: remove BPHY IRQ stack
authorTomasz Duszynski <tduszynski@marvell.com>
Mon, 21 Jun 2021 15:04:36 +0000 (17:04 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 5 Jul 2021 21:07:59 +0000 (23:07 +0200)
Add support for removing existing IRQ stack.

Signed-off-by: Jakub Palider <jpalider@marvell.com>
Signed-off-by: Tomasz Duszynski <tduszynski@marvell.com>
Reviewed-by: Jerin Jacob <jerinj@marvell.com>
drivers/common/cnxk/roc_bphy_irq.c
drivers/common/cnxk/roc_bphy_irq.h
drivers/common/cnxk/version.map

index 04ad129..a90c055 100644 (file)
@@ -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)
 {
index e66b2aa..549a84a 100644 (file)
@@ -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);
index 5423649..78601fe 100644 (file)
@@ -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;