Commit 0bd55080 authored by Anup Patel's avatar Anup Patel Committed by Thomas Gleixner
Browse files

irqchip/riscv-imsic: Avoid interrupt translation in interrupt handler



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: default avatarAnup Patel <apatel@ventanamicro.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250217085657.789309-10-apatel@ventanamicro.com
parent 51611130
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -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;

@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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;

+4 −4
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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);
}
@@ -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;
		}
	}

+2 −2
Original line number Diff line number Diff line
@@ -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;
@@ -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);