Skip to content

Commit

Permalink
irqchip/riscv-imsic: Avoid interrupt translation in interrupt handler
Browse files Browse the repository at this point in the history
Currently, imsic_handle_irq() uses generic_handle_domain_irq() to handle
the interrupt, which internally has an extra step of resolving hwirq using
domain.

Avoid the translation step by replacing the hardware interrupt number with
the Linux interrupt number in the IMSIC vector data and directly call
generic_handle_irq().

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250217085657.789309-10-apatel@ventanamicro.com
  • Loading branch information
Anup Patel authored and Thomas Gleixner committed Feb 20, 2025
1 parent 5161113 commit 0bd5508
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
6 changes: 2 additions & 4 deletions drivers/irqchip/irq-riscv-imsic-early.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static int __init imsic_ipi_domain_init(void) { return 0; }
static void imsic_handle_irq(struct irq_desc *desc)
{
struct irq_chip *chip = irq_desc_get_chip(desc);
int err, cpu = smp_processor_id();
int cpu = smp_processor_id();
struct imsic_vector *vec;
unsigned long local_id;

Expand Down Expand Up @@ -103,9 +103,7 @@ static void imsic_handle_irq(struct irq_desc *desc)
continue;
}

err = generic_handle_domain_irq(imsic->base_domain, vec->hwirq);
if (unlikely(err))
pr_warn_ratelimited("hwirq 0x%x mapping not found\n", vec->hwirq);
generic_handle_irq(vec->irq);
}

chained_irq_exit(chip, desc);
Expand Down
2 changes: 1 addition & 1 deletion drivers/irqchip/irq-riscv-imsic-platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static int imsic_irq_set_affinity(struct irq_data *d, const struct cpumask *mask
return -EBUSY;

/* Get a new vector on the desired set of CPUs */
new_vec = imsic_vector_alloc(old_vec->hwirq, mask_val);
new_vec = imsic_vector_alloc(old_vec->irq, mask_val);
if (!new_vec)
return -ENOSPC;

Expand Down
8 changes: 4 additions & 4 deletions drivers/irqchip/irq-riscv-imsic-state.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ struct imsic_vector *imsic_vector_from_local_id(unsigned int cpu, unsigned int l
return &lpriv->vectors[local_id];
}

struct imsic_vector *imsic_vector_alloc(unsigned int hwirq, const struct cpumask *mask)
struct imsic_vector *imsic_vector_alloc(unsigned int irq, const struct cpumask *mask)
{
struct imsic_vector *vec = NULL;
struct imsic_local_priv *lpriv;
Expand All @@ -438,7 +438,7 @@ struct imsic_vector *imsic_vector_alloc(unsigned int hwirq, const struct cpumask

lpriv = per_cpu_ptr(imsic->lpriv, cpu);
vec = &lpriv->vectors[local_id];
vec->hwirq = hwirq;
vec->irq = irq;
vec->enable = false;
vec->move_next = NULL;
vec->move_prev = NULL;
Expand All @@ -451,7 +451,7 @@ void imsic_vector_free(struct imsic_vector *vec)
unsigned long flags;

raw_spin_lock_irqsave(&imsic->matrix_lock, flags);
vec->hwirq = UINT_MAX;
vec->irq = 0;
irq_matrix_free(imsic->matrix, vec->cpu, vec->local_id, false);
raw_spin_unlock_irqrestore(&imsic->matrix_lock, flags);
}
Expand Down Expand Up @@ -510,7 +510,7 @@ static int __init imsic_local_init(void)
vec = &lpriv->vectors[i];
vec->cpu = cpu;
vec->local_id = i;
vec->hwirq = UINT_MAX;
vec->irq = 0;
}
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/irqchip/irq-riscv-imsic-state.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct imsic_vector {
unsigned int cpu;
unsigned int local_id;
/* Details saved by driver in the vector */
unsigned int hwirq;
unsigned int irq;
/* Details accessed using local lock held */
bool enable;
struct imsic_vector *move_next;
Expand Down Expand Up @@ -96,7 +96,7 @@ void imsic_vector_move(struct imsic_vector *old_vec, struct imsic_vector *new_ve

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

struct imsic_vector *imsic_vector_alloc(unsigned int hwirq, const struct cpumask *mask);
struct imsic_vector *imsic_vector_alloc(unsigned int irq, const struct cpumask *mask);
void imsic_vector_free(struct imsic_vector *vector);

void imsic_vector_debug_show(struct seq_file *m, struct imsic_vector *vec, int ind);
Expand Down

0 comments on commit 0bd5508

Please sign in to comment.