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

[Xen-devel] [PATCH v7 23/28] xen/arm: ITS: Allocate pending_lpi descriptors for LPIs



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

Allocate dynamically pending_lpi descriptors for LPIs

Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@xxxxxxxxxxxxxxxxxx>
---
 xen/arch/arm/vgic-v3-its.c   |    9 +++++++++
 xen/arch/arm/vgic.c          |   20 +++++++++++++++++---
 xen/include/asm-arm/domain.h |    3 +++
 xen/include/asm-arm/vgic.h   |    4 +++-
 4 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c
index 37c2105..33b6e2e 100644
--- a/xen/arch/arm/vgic-v3-its.c
+++ b/xen/arch/arm/vgic-v3-its.c
@@ -852,6 +852,14 @@ int vits_domain_init(struct domain *d)
 
     vits = d->arch.vgic.vits;
 
+    d->arch.vgic.pending_lpis = xzalloc_array(struct pending_irq,
+                                              d->arch.vgic.nr_lpis);
+    if ( d->arch.vgic.pending_lpis == NULL )
+        return -ENOMEM;
+
+    for ( i = 0; i < d->arch.vgic.nr_lpis; i++ )
+        vgic_init_pending_irq(&d->arch.vgic.pending_lpis[i], i + 
FIRST_GIC_LPI);
+
     spin_lock_init(&vits->lock);
     spin_lock_init(&vits->prop_lock);
 
@@ -881,6 +889,7 @@ void vits_domain_free(struct domain *d)
 {
    free_xenheap_pages(d->arch.vgic.vits->prop_page,
                       get_order_from_bytes(d->arch.vgic.vits->prop_size));
+   xfree(d->arch.vgic.pending_lpis);
    xfree(d->arch.vgic.vits->collections);
    xfree(d->arch.vgic.vits);
 }
diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
index 3555833..160a873 100644
--- a/xen/arch/arm/vgic.c
+++ b/xen/arch/arm/vgic.c
@@ -67,7 +67,13 @@ bool_t vgic_is_lpi_supported(struct domain *d)
     return d->arch.vgic.its_enabled;
 }
 
-static void vgic_init_pending_irq(struct pending_irq *p, unsigned int virq)
+bool_t vgic_is_domain_lpi(struct domain *d, unsigned int lpi)
+{
+    return ((lpi >= FIRST_GIC_LPI) &&
+            (lpi < (d->arch.vgic.nr_lpis + FIRST_GIC_LPI)));
+}
+
+void vgic_init_pending_irq(struct pending_irq *p, unsigned int virq)
 {
     INIT_LIST_HEAD(&p->inflight);
     INIT_LIST_HEAD(&p->lr_queue);
@@ -382,13 +388,21 @@ int vgic_to_sgi(struct vcpu *v, register_t sgir, enum 
gic_sgi_mode irqmode, int
 
 struct pending_irq *irq_to_pending(struct vcpu *v, unsigned int irq)
 {
-    struct pending_irq *n;
+    struct pending_irq *n = NULL;
     /* Pending irqs allocation strategy: the first vgic.nr_spis irqs
-     * are used for SPIs; the rests are used for per cpu irqs */
+     * are used for SPIs; the rests are used for per cpu irqs.
+     * For LPIs pending_irq structures are allocated separately */
     if ( irq < 32 )
         n = &v->arch.vgic.pending_irqs[irq];
+#ifdef HAS_GICV3
+    else if ( vgic_is_domain_lpi(v->domain, irq) )
+        n = &v->domain->arch.vgic.pending_lpis[irq - FIRST_GIC_LPI];
+#endif
     else
         n = &v->domain->arch.vgic.pending_irqs[irq - 32];
+
+    ASSERT(n != NULL);
+
     return n;
 }
 
diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h
index 6a5c6a0..49630a3 100644
--- a/xen/include/asm-arm/domain.h
+++ b/xen/include/asm-arm/domain.h
@@ -101,6 +101,9 @@ struct arch_domain
          * struct arch_vcpu.
          */
         struct pending_irq *pending_irqs;
+#ifdef HAS_GICV3
+        struct pending_irq *pending_lpis;
+#endif
         /* Base address for guest GIC */
         paddr_t dbase; /* Distributor base address */
         paddr_t cbase; /* CPU base address */
diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h
index edeec9c..5ed840c 100644
--- a/xen/include/asm-arm/vgic.h
+++ b/xen/include/asm-arm/vgic.h
@@ -333,6 +333,7 @@ extern int vgic_to_sgi(struct vcpu *v, register_t sgir,
                        enum gic_sgi_mode irqmode, int virq,
                        const struct sgi_target *target);
 extern void vgic_migrate_irq(struct vcpu *old, struct vcpu *new, unsigned int 
irq);
+extern void vgic_init_pending_irq(struct pending_irq *p, unsigned int virq);
 
 /* Reserve a specific guest vIRQ */
 extern bool_t vgic_reserve_virq(struct domain *d, unsigned int virq);
@@ -365,7 +366,8 @@ void vgic_v3_setup_hw(paddr_t dbase,
                       const struct rdist_region *regions,
                       uint32_t rdist_stride, bool_t lpi_support);
 #endif
-
+bool_t vgic_is_domain_lpi(struct domain *d, unsigned int lpi);
+ 
 #endif /* __ASM_ARM_VGIC_H__ */
 
 /*
-- 
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®.