From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: Tim.Deegan@citrix.com, david.vrabel@citrix.com,
Ian.Campbell@citrix.com,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH 4/5] xen/vgic: vgic: support irq enable/disable
Date: Wed, 6 Jun 2012 12:22:09 +0100 [thread overview]
Message-ID: <1338981730-14816-4-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <1338981730-14816-1-git-send-email-stefano.stabellini@eu.citrix.com>
If vgic_vcpu_inject_irq is called (for example by a device emulator like
vtimer.c) but the corresponding irq is not enabled in the virtual gicd
just queue it in the inflight_irqs list.
When the irq is enabled make sure to call gic_set_guest_irq.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
xen/arch/arm/vgic.c | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
index 5a624bd..4cdfec5 100644
--- a/xen/arch/arm/vgic.c
+++ b/xen/arch/arm/vgic.c
@@ -343,6 +343,22 @@ read_as_zero:
return 1;
}
+static void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
+{
+ struct pending_irq *p;
+ unsigned int irq;
+ int i = 0;
+
+ while ( (i = find_next_bit((const long unsigned int *) &r,
+ sizeof(uint32_t), i)) < sizeof(uint32_t) ) {
+ irq = i + (32 * n);
+ p = irq_to_pending(v, irq);
+ if ( !list_empty(&p->inflight) )
+ gic_set_guest_irq(v, irq, GICH_LR_PENDING, p->priority);
+ i++;
+ }
+}
+
static int vgic_distr_mmio_write(struct vcpu *v, mmio_info_t *info)
{
struct hsr_dabt dabt = info->dabt;
@@ -351,6 +367,7 @@ static int vgic_distr_mmio_write(struct vcpu *v, mmio_info_t *info)
struct vgic_irq_rank *rank;
int offset = (int)(info->gpa - VGIC_DISTR_BASE_ADDRESS);
int gicd_reg = REG(offset);
+ uint32_t tr;
switch ( gicd_reg )
{
@@ -378,8 +395,10 @@ static int vgic_distr_mmio_write(struct vcpu *v, mmio_info_t *info)
rank = vgic_irq_rank(v, 8, gicd_reg - GICD_ISENABLER);
if ( rank == NULL) goto write_ignore;
vgic_lock_rank(v, rank);
+ tr = rank->ienable;
rank->ienable |= *r;
vgic_unlock_rank(v, rank);
+ vgic_enable_irqs(v, (*r) & (~tr), gicd_reg - GICD_ISENABLER);
return 1;
case GICD_ICENABLER ... GICD_ICENABLERN:
@@ -569,7 +588,9 @@ void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq, int virtual)
else
n->desc = NULL;
- gic_set_guest_irq(v, irq, GICH_LR_PENDING, priority);
+ /* the irq is enabled */
+ if ( rank->ienable & (1 << (irq % 32)) )
+ gic_set_guest_irq(v, irq, GICH_LR_PENDING, priority);
spin_lock_irqsave(&v->arch.vgic.lock, flags);
list_for_each_entry ( iter, &v->arch.vgic.inflight_irqs, inflight )
--
1.7.2.5
next prev parent reply other threads:[~2012-06-06 11:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-06 11:20 [PATCH 0/5] xen/arm: multiple guests support in the GIC and VGIC Stefano Stabellini
2012-06-06 11:22 ` [PATCH 1/5] arm/vtimer: do not let the guest interact with the physical timer Stefano Stabellini
2012-06-06 11:22 ` [PATCH 2/5] arm/gic: fix gic context switch Stefano Stabellini
2012-06-26 13:55 ` Ian Campbell
2012-06-06 11:22 ` [PATCH 3/5] xen/gic: support injecting IRQs even to VCPUs not currently running Stefano Stabellini
2012-06-07 12:46 ` Tim Deegan
2012-06-07 15:43 ` Stefano Stabellini
2012-06-26 14:07 ` Ian Campbell
2012-06-26 17:28 ` Stefano Stabellini
2012-06-06 11:22 ` Stefano Stabellini [this message]
2012-06-26 14:05 ` [PATCH 4/5] xen/vgic: vgic: support irq enable/disable Ian Campbell
2012-06-06 11:22 ` [PATCH 5/5] xen/vgic: initialize pending_irqs.lr_queue Stefano Stabellini
2012-06-26 14:08 ` Ian Campbell
2012-06-26 17:53 ` Stefano Stabellini
2012-06-27 8:52 ` Ian Campbell
2012-06-27 11:06 ` Stefano Stabellini
2012-06-26 13:55 ` [PATCH 1/5] arm/vtimer: do not let the guest interact with the physical timer Ian Campbell
2012-06-26 17:25 ` Stefano Stabellini
2012-06-07 12:47 ` [PATCH 0/5] xen/arm: multiple guests support in the GIC and VGIC Tim Deegan
2012-06-07 15:47 ` 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=1338981730-14816-4-git-send-email-stefano.stabellini@eu.citrix.com \
--to=stefano.stabellini@eu.citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=Tim.Deegan@citrix.com \
--cc=david.vrabel@citrix.com \
--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).