[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC PATCH v1 03/10] xen/arm: move vgic data to vgic driver



From: Vijaya Kumar K <Vijaya.Kumar@xxxxxxxxxxxxxxxxxx>

vgic_irq_rank structure contains gic specific
data elements. Move this out of domain.h and
allocate memory dynamically in vgic driver

Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@xxxxxxxxxxxxxxxxxx>
---
 xen/arch/arm/vgic.c          |   35 ++++++++++++++++++++++++++++-------
 xen/include/asm-arm/domain.h |   13 ++-----------
 2 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
index d2a13fb..694a15c 100644
--- a/xen/arch/arm/vgic.c
+++ b/xen/arch/arm/vgic.c
@@ -35,6 +35,15 @@
 /* Number of ranks of interrupt registers for a domain */
 #define DOMAIN_NR_RANKS(d) (((d)->arch.vgic.nr_lines+31)/32)
 
+/* Represents state corresponding to a block of 32 interrupts */
+struct vgic_irq_rank {
+    spinlock_t lock; /* Covers access to all other members of this struct */
+    uint32_t ienable, iactive, ipend, pendsgi;
+    uint32_t icfg[2];
+    uint32_t ipriority[8];
+    uint32_t itargets[8];
+};
+
 /*
  * Rank containing GICD_<FOO><n> for GICD_<FOO> with
  * <b>-bits-per-interrupt
@@ -66,9 +75,10 @@ static struct vgic_irq_rank *vgic_irq_rank(struct vcpu *v, 
int b, int n)
     int rank = REG_RANK_NR(b, n);
 
     if ( rank == 0 )
-        return &v->arch.vgic.private_irqs;
+        return (struct vgic_irq_rank *)v->arch.vgic.private_irqs;
     else if ( rank <= DOMAIN_NR_RANKS(v->domain) )
-        return &v->domain->arch.vgic.shared_irqs[rank - 1];
+       return (struct vgic_irq_rank *)((unsigned char 
*)(v->domain->arch.vgic.shared_irqs)
+                           + (sizeof(struct vgic_irq_rank) *(rank - 1)));
     else
         return NULL;
 }
@@ -82,9 +92,11 @@ void domain_vgic_free(struct domain *d)
 int vcpu_vgic_init(struct vcpu *v)
 {
     int i;
-    memset(&v->arch.vgic.private_irqs, 0, sizeof(v->arch.vgic.private_irqs));
+    struct vgic_irq_rank *vir;
 
-    spin_lock_init(&v->arch.vgic.private_irqs.lock);
+    vir =  xzalloc(struct vgic_irq_rank);
+    memset(vir, 0, sizeof(struct vgic_irq_rank));
+    spin_lock_init(&vir->lock);
 
     memset(&v->arch.vgic.pending_irqs, 0, sizeof(v->arch.vgic.pending_irqs));
     for (i = 0; i < 32; i++)
@@ -95,11 +107,14 @@ int vcpu_vgic_init(struct vcpu *v)
 
     /* For SGI and PPI the target is always this CPU */
     for ( i = 0 ; i < 8 ; i++ )
-        v->arch.vgic.private_irqs.itargets[i] =
+        vir->itargets[i] =
               (1<<(v->vcpu_id+0))
             | (1<<(v->vcpu_id+8))
             | (1<<(v->vcpu_id+16))
             | (1<<(v->vcpu_id+24));
+
+    v->arch.vgic.private_irqs = (struct vgic_irq_irank *)vir;
+
     INIT_LIST_HEAD(&v->arch.vgic.inflight_irqs);
     INIT_LIST_HEAD(&v->arch.vgic.lr_pending);
     spin_lock_init(&v->arch.vgic.lock);
@@ -636,6 +651,7 @@ static struct mmio_handler vgic_distr_mmio_handler = {
 int domain_vgic_init(struct domain *d)
 {
     int i;
+    struct vgic_irq_rank *r;
 
     d->arch.vgic.ctlr = 0;
 
@@ -648,7 +664,8 @@ int domain_vgic_init(struct domain *d)
         d->arch.vgic.nr_lines = 0; /* We don't need SPIs for the guest */
 
     d->arch.vgic.shared_irqs =
-        xzalloc_array(struct vgic_irq_rank, DOMAIN_NR_RANKS(d));
+        (struct vgic_irq_rank *)xzalloc_array(struct vgic_irq_rank, 
DOMAIN_NR_RANKS(d));
+
     d->arch.vgic.pending_irqs =
         xzalloc_array(struct pending_irq, d->arch.vgic.nr_lines);
     for (i=0; i<d->arch.vgic.nr_lines; i++)
@@ -657,7 +674,11 @@ int domain_vgic_init(struct domain *d)
         INIT_LIST_HEAD(&d->arch.vgic.pending_irqs[i].lr_queue);
     }
     for (i=0; i<DOMAIN_NR_RANKS(d); i++)
-        spin_lock_init(&d->arch.vgic.shared_irqs[i].lock);
+    {
+        r = (struct vgic_irq_rank *)((unsigned char 
*)(d->arch.vgic.shared_irqs)
+                                      + sizeof(struct vgic_irq_rank) * i);
+        spin_lock_init(&r->lock);
+    }
 
     register_mmio_handler(&vgic_distr_mmio_handler);
     return 0;
diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h
index bc20a15..d49ab68 100644
--- a/xen/include/asm-arm/domain.h
+++ b/xen/include/asm-arm/domain.h
@@ -10,15 +10,6 @@
 #include <public/hvm/params.h>
 #include <xen/serial.h>
 
-/* Represents state corresponding to a block of 32 interrupts */
-struct vgic_irq_rank {
-    spinlock_t lock; /* Covers access to all other members of this struct */
-    uint32_t ienable, iactive, ipend, pendsgi;
-    uint32_t icfg[2];
-    uint32_t ipriority[8];
-    uint32_t itargets[8];
-};
-
 struct pending_irq
 {
     int irq;
@@ -142,7 +133,7 @@ struct arch_domain
         spinlock_t lock;
         int ctlr;
         int nr_lines; /* Number of SPIs */
-        struct vgic_irq_rank *shared_irqs;
+        void *shared_irqs;
         /*
          * SPIs are domain global, SGIs and PPIs are per-VCPU and stored in
          * struct arch_vcpu.
@@ -263,7 +254,7 @@ struct arch_vcpu
          * struct arch_domain.
          */
         struct pending_irq pending_irqs[32];
-        struct vgic_irq_rank private_irqs;
+        void *private_irqs;
 
         /* This list is ordered by IRQ priority and it is used to keep
          * track of the IRQs that the VGIC injected into the guest.
-- 
1.7.9.5


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.