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

[Xen-devel] [PATCH v4 14/17] xen/arm: ITS: Add domain specific ITS initialization



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

Add Domain and vcpu specific ITS initialization

Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@xxxxxxxxxxxxxxxxxx>
---
 xen/arch/arm/gic-v3-its.c         |   17 ++++++++++++++++
 xen/arch/arm/setup.c              |    4 +++-
 xen/arch/arm/vgic-v3-its.c        |   39 +++++++++++++++++++++++++++++++++++++
 xen/arch/arm/vgic-v3.c            |    3 +++
 xen/include/asm-arm/gic-its.h     |    2 ++
 xen/include/asm-arm/gic_v3_defs.h |    2 ++
 xen/include/asm-arm/vgic.h        |    1 +
 7 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c
index 5e6c7f2..b159b0b 100644
--- a/xen/arch/arm/gic-v3-its.c
+++ b/xen/arch/arm/gic-v3-its.c
@@ -1256,6 +1256,23 @@ static int its_force_quiescent(void __iomem *base)
     }
 }
 
+void its_domain_init(struct domain *d)
+{
+    struct its_node *its;
+
+    if ( is_hardware_domain(d) )
+    {
+        /*
+         * Only one virtual ITS is provided to domain.
+         * Assign first physical ITS address to Dom0 virtual ITS.
+         */
+        its = list_first_entry(&its_nodes, struct its_node, entry);
+        d->arch.vits->gits_base = its->phys_base;
+        d->arch.vits->gits_size = its->phys_size;
+    }
+    /* TODO: DomU */
+}
+
 static int its_probe(struct dt_device_node *node)
 {
     paddr_t its_addr, its_size;
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 06f8e54..3bd1f2e 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -776,7 +776,9 @@ void __init start_xen(unsigned long boot_phys_offset,
     init_xen_time();
 
     gic_init();
-
+#ifdef CONFIG_ARM_64
+    vgic_its_init();
+#endif
     p2m_vmid_allocator_init();
 
     softirq_init();
diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c
index 4649b07..74e6ee7 100644
--- a/xen/arch/arm/vgic-v3-its.c
+++ b/xen/arch/arm/vgic-v3-its.c
@@ -1082,6 +1082,45 @@ static const struct mmio_handler_ops 
vgic_gits_mmio_handler = {
     .write_handler = vgic_v3_gits_mmio_write,
 };
 
+int vits_domain_init(struct domain *d)
+{
+    int i;
+
+    d->arch.vits = xzalloc(struct vgic_its);
+    if ( !d->arch.vits )
+        return -ENOMEM;
+
+    spin_lock_init(&d->arch.vits->lock);
+    spin_lock_init(&d->arch.vits->dev_lock);
+    spin_lock_init(&d->arch.vits->prop_lock);
+
+    d->arch.vits->collections = xzalloc_array(struct its_collection,
+                                              nr_cpu_ids);
+    if ( !d->arch.vits->collections )
+        return -ENOMEM;
+
+    for ( i = 0; i < nr_cpu_ids; i++ )
+        d->arch.vits->collections[i].target_address = ~0UL;
+
+    d->arch.vits->baser = GITS_BASER_INIT_VAL;
+    d->arch.vits->dev_root = RB_ROOT;
+
+    spin_lock_init(&d->arch.vits->lock);
+
+    its_domain_init(d);
+    register_mmio_handler(d, &vgic_gits_mmio_handler,
+                          d->arch.vits->gits_base,
+                          SZ_64K);
+
+    return 0;
+}
+
+void vgic_its_init(void)
+{
+    if ( gic_lpi_supported() )
+        its_lpi_init(gic_nr_id_bits());
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c
index 4e14439..79dbfc4 100644
--- a/xen/arch/arm/vgic-v3.c
+++ b/xen/arch/arm/vgic-v3.c
@@ -1217,6 +1217,9 @@ static int vgic_v3_domain_init(struct domain *d)
 
     d->arch.vgic.ctlr = VGICD_CTLR_DEFAULT;
 
+    if ( gic_lpi_supported() )
+        vits_domain_init(d);
+
     return 0;
 }
 
diff --git a/xen/include/asm-arm/gic-its.h b/xen/include/asm-arm/gic-its.h
index fbed905..cbe7596 100644
--- a/xen/include/asm-arm/gic-its.h
+++ b/xen/include/asm-arm/gic-its.h
@@ -265,6 +265,8 @@ struct its_device *its_find_device(u32 devid);
 int its_insert_device(struct its_device *dev);
 int its_add_device(u32 devid);
 int its_assign_device(struct domain *d, u32 vdevid, u32 pdevid);
+void its_domain_init(struct domain *d);
+int vits_domain_init(struct domain *d);
 int vits_set_vitt_entry(struct domain *d, uint32_t devid,
                         uint32_t event, struct vitt *entry);
 int vits_get_vitt_entry(struct domain *d, uint32_t devid,
diff --git a/xen/include/asm-arm/gic_v3_defs.h 
b/xen/include/asm-arm/gic_v3_defs.h
index 368ebb3..24ef547 100644
--- a/xen/include/asm-arm/gic_v3_defs.h
+++ b/xen/include/asm-arm/gic_v3_defs.h
@@ -243,6 +243,8 @@
 #define GITS_BASER_TYPE_RESERVED5       5
 #define GITS_BASER_TYPE_RESERVED6       6
 #define GITS_BASER_TYPE_RESERVED7       7
+#define GITS_BASER_INIT_VAL             ((1UL << GITS_BASER_TYPE_SHIFT) | \
+                                         (0x7UL << 
GITS_BASER_ENTRY_SIZE_SHIFT))
 /* GITS_PIDRn register values for ARM implementations */
 #define GITS_PIDR0_VAL                  (0x94)
 #define GITS_PIDR1_VAL                  (0xb4)
diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h
index f8928ab..4509e9a 100644
--- a/xen/include/asm-arm/vgic.h
+++ b/xen/include/asm-arm/vgic.h
@@ -178,6 +178,7 @@ enum gic_sgi_mode;
 #define vgic_num_irqs(d)        ((d)->arch.vgic.nr_spis + 32)
 
 extern int domain_vgic_init(struct domain *d, unsigned int nr_spis);
+extern void vgic_its_init(void);
 extern void domain_vgic_free(struct domain *d);
 extern int vcpu_vgic_init(struct vcpu *v);
 extern struct vcpu *vgic_get_target_vcpu(struct vcpu *v, unsigned int irq);
-- 
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®.