[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v5 5/6] xen/arm: Only enable physical IRQs when the guest asks
From: Julien Grall <julien.grall@xxxxxxxxxx> Set/Unset IRQ_DISABLED from gic_irq_enable and gic_irq_disable. Enable IRQs when the guest requests it, not unconditionally at boot time. Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> Signed-off-by: Julien Grall <julien.grall@xxxxxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> --- Changes in v2: - protect startup and shutdown with gic and desc locks. Changes in v4: - disable interrupts in gic_irq_enable; - clear IRQ_DISABLED and dsb() before writing to the GICD register. --- xen/arch/arm/gic.c | 48 ++++++++++++++++++++++++++++-------------------- xen/arch/arm/vgic.c | 6 ++---- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index b2caced..ff83426 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -132,17 +132,29 @@ void gic_restore_state(struct vcpu *v) static void gic_irq_enable(struct irq_desc *desc) { int irq = desc->irq; + unsigned long flags; + spin_lock_irqsave(&desc->lock, flags); + spin_lock(&gic.lock); + desc->status &= ~IRQ_DISABLED; + dsb(); /* Enable routing */ GICD[GICD_ISENABLER + irq / 32] = (1u << (irq % 32)); + spin_unlock(&gic.lock); + spin_unlock_irqrestore(&desc->lock, flags); } static void gic_irq_disable(struct irq_desc *desc) { int irq = desc->irq; + spin_lock(&desc->lock); + spin_lock(&gic.lock); /* Disable routing */ GICD[GICD_ICENABLER + irq / 32] = (1u << (irq % 32)); + desc->status |= IRQ_DISABLED; + spin_unlock(&gic.lock); + spin_unlock(&desc->lock); } static unsigned int gic_irq_startup(struct irq_desc *desc) @@ -247,24 +259,20 @@ static int gic_route_irq(unsigned int irq, bool_t level, ASSERT(priority <= 0xff); /* Only 8 bits of priority */ ASSERT(irq < gic.lines); /* Can't route interrupts that don't exist */ - spin_lock_irqsave(&desc->lock, flags); - spin_lock(&gic.lock); - if ( desc->action != NULL ) - { - spin_unlock(&gic.lock); - spin_unlock(&desc->lock); return -EBUSY; - } - - desc->handler = &gic_host_irq_type; /* Disable interrupt */ desc->handler->shutdown(desc); - gic_set_irq_properties(irq, level, cpu_mask, priority); + spin_lock_irqsave(&desc->lock, flags); + + desc->handler = &gic_host_irq_type; + spin_lock(&gic.lock); + gic_set_irq_properties(irq, level, cpu_mask, priority); spin_unlock(&gic.lock); + spin_unlock_irqrestore(&desc->lock, flags); return 0; } @@ -557,16 +565,13 @@ void __init release_irq(unsigned int irq) desc = irq_to_desc(irq); + desc->handler->shutdown(desc); + spin_lock_irqsave(&desc->lock,flags); action = desc->action; desc->action = NULL; - desc->status |= IRQ_DISABLED; desc->status &= ~IRQ_GUEST; - spin_lock(&gic.lock); - desc->handler->shutdown(desc); - spin_unlock(&gic.lock); - spin_unlock_irqrestore(&desc->lock,flags); /* Wait to make sure it's not being used on another CPU */ @@ -583,11 +588,8 @@ static int __setup_irq(struct irq_desc *desc, unsigned int irq, return -EBUSY; desc->action = new; - desc->status &= ~IRQ_DISABLED; dsb(); - desc->handler->startup(desc); - return 0; } @@ -600,11 +602,12 @@ int __init setup_dt_irq(const struct dt_irq *irq, struct irqaction *new) desc = irq_to_desc(irq->irq); spin_lock_irqsave(&desc->lock, flags); - rc = __setup_irq(desc, irq->irq, new); - spin_unlock_irqrestore(&desc->lock, flags); + desc->handler->startup(desc); + + return rc; } @@ -745,6 +748,7 @@ int gic_route_irq_to_guest(struct domain *d, const struct dt_irq *irq, unsigned long flags; int retval; bool_t level; + struct pending_irq *p; action = xmalloc(struct irqaction); if (!action) @@ -771,6 +775,10 @@ int gic_route_irq_to_guest(struct domain *d, const struct dt_irq *irq, goto out; } + /* TODO: do not assume delivery to vcpu0 */ + p = irq_to_pending(d->vcpu[0], irq->irq); + p->desc = desc; + out: spin_unlock(&gic.lock); spin_unlock_irqrestore(&desc->lock, flags); diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index f2f1702..ad17d1d 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -372,6 +372,8 @@ static void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n) set_bit(GIC_IRQ_GUEST_ENABLED, &p->status); if ( !list_empty(&p->inflight) && !test_bit(GIC_IRQ_GUEST_VISIBLE, &p->status) ) gic_set_guest_irq(v, irq, GICH_LR_PENDING, p->priority); + if ( p->desc != NULL ) + p->desc->handler->enable(p->desc); i++; } } @@ -694,10 +696,6 @@ void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq, int virtual) n->irq = irq; set_bit(GIC_IRQ_GUEST_PENDING, &n->status); n->priority = priority; - if (!virtual) - n->desc = irq_to_desc(irq); - else - n->desc = NULL; /* the irq is enabled */ if ( test_bit(GIC_IRQ_GUEST_ENABLED, &n->status) ) -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |