Skip to content

Commit 5161113

Browse files
avpatelKAGA-KOKO
authored andcommitted
irqchip/riscv-imsic: Implement irq_force_complete_move() for IMSIC
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 <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 0f67911 commit 5161113

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

drivers/irqchip/irq-riscv-imsic-platform.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,37 @@ static int imsic_irq_set_affinity(struct irq_data *d, const struct cpumask *mask
129129

130130
return IRQ_SET_MASK_OK_DONE;
131131
}
132+
133+
static void imsic_irq_force_complete_move(struct irq_data *d)
134+
{
135+
struct imsic_vector *mvec, *vec = irq_data_get_irq_chip_data(d);
136+
unsigned int cpu = smp_processor_id();
137+
138+
if (WARN_ON(!vec))
139+
return;
140+
141+
/* Do nothing if there is no in-flight move */
142+
mvec = imsic_vector_get_move(vec);
143+
if (!mvec)
144+
return;
145+
146+
/* Do nothing if the old IMSIC vector does not belong to current CPU */
147+
if (mvec->cpu != cpu)
148+
return;
149+
150+
/*
151+
* The best we can do is force cleanup the old IMSIC vector.
152+
*
153+
* The challenges over here are same as x86 vector domain so
154+
* refer to the comments in irq_force_complete_move() function
155+
* implemented at arch/x86/kernel/apic/vector.c.
156+
*/
157+
158+
/* Force cleanup in-flight move */
159+
pr_info("IRQ fixup: irq %d move in progress, old vector cpu %d local_id %d\n",
160+
d->irq, mvec->cpu, mvec->local_id);
161+
imsic_vector_force_move_cleanup(vec);
162+
}
132163
#endif
133164

134165
static struct irq_chip imsic_irq_base_chip = {
@@ -137,6 +168,7 @@ static struct irq_chip imsic_irq_base_chip = {
137168
.irq_unmask = imsic_irq_unmask,
138169
#ifdef CONFIG_SMP
139170
.irq_set_affinity = imsic_irq_set_affinity,
171+
.irq_force_complete_move = imsic_irq_force_complete_move,
140172
#endif
141173
.irq_retrigger = imsic_irq_retrigger,
142174
.irq_compose_msi_msg = imsic_irq_compose_msg,

drivers/irqchip/irq-riscv-imsic-state.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,23 @@ void imsic_vector_unmask(struct imsic_vector *vec)
311311
raw_spin_unlock(&lpriv->lock);
312312
}
313313

314+
void imsic_vector_force_move_cleanup(struct imsic_vector *vec)
315+
{
316+
struct imsic_local_priv *lpriv;
317+
struct imsic_vector *mvec;
318+
unsigned long flags;
319+
320+
lpriv = per_cpu_ptr(imsic->lpriv, vec->cpu);
321+
raw_spin_lock_irqsave(&lpriv->lock, flags);
322+
323+
mvec = READ_ONCE(vec->move_prev);
324+
WRITE_ONCE(vec->move_prev, NULL);
325+
if (mvec)
326+
imsic_vector_free(mvec);
327+
328+
raw_spin_unlock_irqrestore(&lpriv->lock, flags);
329+
}
330+
314331
static bool imsic_vector_move_update(struct imsic_local_priv *lpriv,
315332
struct imsic_vector *vec, bool is_old_vec,
316333
bool new_enable, struct imsic_vector *move_vec)

drivers/irqchip/irq-riscv-imsic-state.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ static inline struct imsic_vector *imsic_vector_get_move(struct imsic_vector *ve
9191
return READ_ONCE(vec->move_prev);
9292
}
9393

94+
void imsic_vector_force_move_cleanup(struct imsic_vector *vec);
9495
void imsic_vector_move(struct imsic_vector *old_vec, struct imsic_vector *new_vec);
9596

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

0 commit comments

Comments
 (0)