Skip to content

Commit

Permalink
irqchip/riscv-imsic: Implement irq_force_complete_move() for IMSIC
Browse files Browse the repository at this point in the history
Implement irq_force_complete_move() for IMSIC driver so that in-flight
vector movements on a CPU can be cleaned-up when the CPU goes down.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250217085657.789309-9-apatel@ventanamicro.com
  • Loading branch information
Anup Patel authored and Thomas Gleixner committed Feb 20, 2025
1 parent 0f67911 commit 5161113
Showing 3 changed files with 50 additions and 0 deletions.
32 changes: 32 additions & 0 deletions drivers/irqchip/irq-riscv-imsic-platform.c
Original file line number Diff line number Diff line change
@@ -129,6 +129,37 @@ static int imsic_irq_set_affinity(struct irq_data *d, const struct cpumask *mask

return IRQ_SET_MASK_OK_DONE;
}

static void imsic_irq_force_complete_move(struct irq_data *d)
{
struct imsic_vector *mvec, *vec = irq_data_get_irq_chip_data(d);
unsigned int cpu = smp_processor_id();

if (WARN_ON(!vec))
return;

/* Do nothing if there is no in-flight move */
mvec = imsic_vector_get_move(vec);
if (!mvec)
return;

/* Do nothing if the old IMSIC vector does not belong to current CPU */
if (mvec->cpu != cpu)
return;

/*
* The best we can do is force cleanup the old IMSIC vector.
*
* The challenges over here are same as x86 vector domain so
* refer to the comments in irq_force_complete_move() function
* implemented at arch/x86/kernel/apic/vector.c.
*/

/* Force cleanup in-flight move */
pr_info("IRQ fixup: irq %d move in progress, old vector cpu %d local_id %d\n",
d->irq, mvec->cpu, mvec->local_id);
imsic_vector_force_move_cleanup(vec);
}
#endif

static struct irq_chip imsic_irq_base_chip = {
@@ -137,6 +168,7 @@ static struct irq_chip imsic_irq_base_chip = {
.irq_unmask = imsic_irq_unmask,
#ifdef CONFIG_SMP
.irq_set_affinity = imsic_irq_set_affinity,
.irq_force_complete_move = imsic_irq_force_complete_move,
#endif
.irq_retrigger = imsic_irq_retrigger,
.irq_compose_msi_msg = imsic_irq_compose_msg,
17 changes: 17 additions & 0 deletions drivers/irqchip/irq-riscv-imsic-state.c
Original file line number Diff line number Diff line change
@@ -311,6 +311,23 @@ void imsic_vector_unmask(struct imsic_vector *vec)
raw_spin_unlock(&lpriv->lock);
}

void imsic_vector_force_move_cleanup(struct imsic_vector *vec)
{
struct imsic_local_priv *lpriv;
struct imsic_vector *mvec;
unsigned long flags;

lpriv = per_cpu_ptr(imsic->lpriv, vec->cpu);
raw_spin_lock_irqsave(&lpriv->lock, flags);

mvec = READ_ONCE(vec->move_prev);
WRITE_ONCE(vec->move_prev, NULL);
if (mvec)
imsic_vector_free(mvec);

raw_spin_unlock_irqrestore(&lpriv->lock, flags);
}

static bool imsic_vector_move_update(struct imsic_local_priv *lpriv,
struct imsic_vector *vec, bool is_old_vec,
bool new_enable, struct imsic_vector *move_vec)
1 change: 1 addition & 0 deletions drivers/irqchip/irq-riscv-imsic-state.h
Original file line number Diff line number Diff line change
@@ -91,6 +91,7 @@ static inline struct imsic_vector *imsic_vector_get_move(struct imsic_vector *ve
return READ_ONCE(vec->move_prev);
}

void imsic_vector_force_move_cleanup(struct imsic_vector *vec);
void imsic_vector_move(struct imsic_vector *old_vec, struct imsic_vector *new_vec);

struct imsic_vector *imsic_vector_from_local_id(unsigned int cpu, unsigned int local_id);

0 comments on commit 5161113

Please sign in to comment.