From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: julien.grall@citrix.com, Julien Grall <julien.grall@linaro.org>,
Ian.Campbell@citrix.com,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH v2 5/6] xen/arm: Only enable physical IRQs when the guest asks
Date: Tue, 10 Dec 2013 13:06:07 +0000 [thread overview]
Message-ID: <1386680768-15543-5-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1312101302200.7093@kaball.uk.xensource.com>
From: Julien Grall <julien.grall@linaro.org>
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@eu.citrix.com>
Signed-off-by: Julien Grall <julien.grall@citrix.com>
Changes in v2:
- protect startup and shutdown with gic and desc locks.
---
xen/arch/arm/gic.c | 46 ++++++++++++++++++++++++++--------------------
xen/arch/arm/vgic.c | 6 ++----
2 files changed, 28 insertions(+), 24 deletions(-)
diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index 5e60c5a..62330dd 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -133,16 +133,26 @@ static void gic_irq_enable(struct irq_desc *desc)
{
int irq = desc->irq;
+ spin_lock(&desc->lock);
+ spin_lock(&gic.lock);
/* Enable routing */
GICD[GICD_ISENABLER + irq / 32] = (1u << (irq % 32));
+ desc->status &= ~IRQ_DISABLED;
+ spin_unlock(&gic.lock);
+ spin_unlock(&desc->lock);
}
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 +257,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 +563,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 +586,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 +600,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;
}
@@ -740,6 +741,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)
@@ -766,6 +768,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 75df571..5886696 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++;
}
}
@@ -692,10 +694,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
next prev parent reply other threads:[~2013-12-10 13:06 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-10 13:05 [PATCH v2 0/6] interrupt handling fixes Stefano Stabellini
2013-12-10 13:06 ` [PATCH v2 1/6] xen/arm: Physical IRQ is not always equal to virtual IRQ Stefano Stabellini
2013-12-10 13:06 ` [PATCH v2 2/6] xen/arm: track the state of guest IRQs Stefano Stabellini
2013-12-10 13:06 ` [PATCH v2 3/6] xen/arm: do not add a second irq to the LRs if one is already present Stefano Stabellini
2013-12-10 15:22 ` Ian Campbell
2013-12-10 13:06 ` [PATCH v2 4/6] xen/arm: implement gic_irq_enable and gic_irq_disable Stefano Stabellini
2013-12-10 13:06 ` Stefano Stabellini [this message]
2013-12-10 15:18 ` [PATCH v2 5/6] xen/arm: Only enable physical IRQs when the guest asks Ian Campbell
2013-12-10 13:06 ` [PATCH v2 6/6] xen/arm: disable a physical IRQ when the guest disables the corresponding IRQ Stefano Stabellini
2013-12-10 15:20 ` Ian Campbell
2013-12-10 18:36 ` Stefano Stabellini
2013-12-11 10:28 ` Ian Campbell
2013-12-11 19:01 ` Stefano Stabellini
2013-12-12 10:21 ` Ian Campbell
2013-12-10 15:22 ` [PATCH v2 0/6] interrupt handling fixes Ian Campbell
2013-12-10 15:30 ` Julien Grall
2013-12-10 15:36 ` Stefano Stabellini
2013-12-10 16:06 ` Ian Campbell
2013-12-10 16:46 ` Stefano Stabellini
2013-12-10 18:52 ` Stefano Stabellini
2013-12-10 18:34 ` Stefano Stabellini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1386680768-15543-5-git-send-email-stefano.stabellini@eu.citrix.com \
--to=stefano.stabellini@eu.citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=julien.grall@citrix.com \
--cc=julien.grall@linaro.org \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).