hv/mod_irq: split IRQ handling into common and arch specific parts

The common IRQ handling routine calls arch specific functions
pre_irq_arch() and post_irq_arch() before and after calling the
registered action function respectively.

Tracked-On: #5825
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
Liang Yi 2021-03-15 10:11:08 +08:00 committed by wenlingz
parent ac3e0a1718
commit 038e0cae92

View File

@ -310,32 +310,57 @@ static inline bool irq_need_unmask(const struct irq_desc *desc)
&& is_ioapic_irq(desc->irq)); && is_ioapic_irq(desc->irq));
} }
static inline void handle_irq(const struct irq_desc *desc) static void pre_irq_arch(const struct irq_desc *desc)
{ {
irq_action_t action = desc->action;
if (irq_need_mask(desc)) { if (irq_need_mask(desc)) {
ioapic_gsi_mask_irq(desc->irq); ioapic_gsi_mask_irq(desc->irq);
} }
/* Send EOI to LAPIC/IOAPIC IRR */ /* Send EOI to LAPIC/IOAPIC IRR */
send_lapic_eoi(); send_lapic_eoi();
}
if (action != NULL) { static void post_irq_arch(const struct irq_desc *desc)
action(desc->irq, desc->priv_data); {
}
if (irq_need_unmask(desc)) { if (irq_need_unmask(desc)) {
ioapic_gsi_unmask_irq(desc->irq); ioapic_gsi_unmask_irq(desc->irq);
} }
} }
/* do_IRQ() */ static inline void handle_irq(const struct irq_desc *desc)
{
irq_action_t action = desc->action;
pre_irq_arch(desc);
if (action != NULL) {
action(desc->irq, desc->priv_data);
}
post_irq_arch(desc);
}
void do_irq(const uint32_t irq)
{
struct irq_desc *desc;
if (irq < NR_IRQS) {
desc = &irq_desc_array[irq];
per_cpu(irq_count, get_pcpu_id())[irq]++;
/* XXX irq_alloc_bitmap is used lockless here */
if (bitmap_test((uint16_t)(irq & 0x3FU), irq_alloc_bitmap + (irq >> 6U))) {
handle_irq(desc);
}
}
do_softirq();
}
void dispatch_interrupt(const struct intr_excp_ctx *ctx) void dispatch_interrupt(const struct intr_excp_ctx *ctx)
{ {
uint32_t vr = ctx->vector; uint32_t vr = ctx->vector;
uint32_t irq = vector_to_irq[vr]; uint32_t irq = vector_to_irq[vr];
struct irq_desc *desc;
struct x86_irq_data *irqd; struct x86_irq_data *irqd;
/* The value from vector_to_irq[] must be: /* The value from vector_to_irq[] must be:
@ -345,25 +370,21 @@ void dispatch_interrupt(const struct intr_excp_ctx *ctx)
* Any other value means there is something wrong. * Any other value means there is something wrong.
*/ */
if (irq < NR_IRQS) { if (irq < NR_IRQS) {
desc = &irq_desc_array[irq]; irqd = &irq_data[irq];
irqd = desc->arch_data;
per_cpu(irq_count, get_pcpu_id())[irq]++;
if ((vr == irqd->vector) && if (vr == irqd->vector) {
bitmap_test((uint16_t)(irq & 0x3FU), irq_alloc_bitmap + (irq >> 6U))) {
#ifdef PROFILING_ON #ifdef PROFILING_ON
/* Saves ctx info into irq_desc */ /* Saves ctx info into irq_desc */
irqd->ctx_rip = ctx->rip; irqd->ctx_rip = ctx->rip;
irqd->ctx_rflags = ctx->rflags; irqd->ctx_rflags = ctx->rflags;
irqd->ctx_cs = ctx->cs; irqd->ctx_cs = ctx->cs;
#endif #endif
handle_irq(desc); /* Call the generic IRQ handling routine */
do_irq(irq);
} }
} else { } else {
handle_spurious_interrupt(vr); handle_spurious_interrupt(vr);
} }
do_softirq();
} }
void dispatch_exception(struct intr_excp_ctx *ctx) void dispatch_exception(struct intr_excp_ctx *ctx)