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

[Xen-devel] [PATCH v5 21/22] xen/arm: ITS: Generate ITS node for Dom0



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

Parse host dt and generate ITS node for Dom0.
ITS node resides inside GIC node so when GIC node
is encountered look for ITS node.

Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@xxxxxxxxxxxxxxxxxx>
---
v5: - Moved ITS dt node generation to ITS driver
v4: - Generate only one ITS node for Dom0
    - Replace msi-parent references to single its phandle
---
 xen/arch/arm/domain_build.c   |   17 ++++++++++
 xen/arch/arm/gic-v3-its.c     |   74 +++++++++++++++++++++++++++++++++++++++++
 xen/arch/arm/gic-v3.c         |   29 ++++++++++++++++
 xen/arch/arm/gic.c            |   18 ++++++++++
 xen/include/asm-arm/gic-its.h |    3 ++
 xen/include/asm-arm/gic.h     |    7 ++++
 6 files changed, 148 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 8556afd..6b6f013 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -469,6 +469,19 @@ static int write_properties(struct domain *d, struct 
kernel_info *kinfo,
             continue;
         }
 
+        /*
+         * Replace all msi-parent phandle references to single ITS node
+         * generated for Dom0
+         */
+        if ( dt_property_name_is_equal(prop, "msi-parent") )
+        {
+            fdt32_t phandle = gic_get_msi_handle();
+            DPRINT(" Set msi-parent(ITS) phandle 0x%x\n",phandle);
+            fdt_property(kinfo->fdt, prop->name, (void *)&phandle,
+                         sizeof(phandle));
+            continue;
+        }
+
         res = fdt_property(kinfo->fdt, prop->name, prop_data, prop_len);
 
         xfree(new_data);
@@ -875,6 +888,10 @@ static int make_gic_node(const struct domain *d, void *fdt,
         return res;
 
     res = fdt_end_node(fdt);
+    if ( res )
+        return res;
+
+    res = gic_its_hwdom_dt_node(d, node, fdt);
 
     return res;
 }
diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c
index 99f6edc..042c70d 100644
--- a/xen/arch/arm/gic-v3-its.c
+++ b/xen/arch/arm/gic-v3-its.c
@@ -27,6 +27,8 @@
 #include <xen/sched.h>
 #include <xen/errno.h>
 #include <xen/delay.h>
+#include <xen/device_tree.h>
+#include <xen/libfdt/libfdt.h>
 #include <xen/list.h>
 #include <xen/sizes.h>
 #include <xen/vmap.h>
@@ -96,6 +98,7 @@ static struct rdist_prop  *gic_rdists;
 static struct rb_root rb_its_dev;
 static struct gic_its_info its_data;
 static DEFINE_SPINLOCK(rb_its_dev_lock);
+static fdt32_t its_phandle;
 
 #define gic_data_rdist()    (this_cpu(rdist))
 
@@ -1198,6 +1201,77 @@ static void its_cpu_init_collection(void)
     spin_unlock(&its_lock);
 }
 
+int its_make_dt_node(const struct domain *d,
+                     const struct dt_device_node *node, void *fdt)
+{
+    struct its_node *its;
+    const struct dt_device_node *gic;
+    const void *compatible = NULL;
+    u32 len;
+    __be32 *new_cells, *tmp;
+    int res = 0;
+
+    /* Will pass only first ITS node info */
+    its = list_first_entry(&its_nodes, struct its_node, entry);
+    if ( !its )
+    {
+        dprintk(XENLOG_ERR, "ITS node not found\n");
+        return -FDT_ERR_XEN(ENOENT);
+    }
+
+    gic = its->dt_node;
+
+    compatible = dt_get_property(gic, "compatible", &len);
+    if ( !compatible )
+    {
+        dprintk(XENLOG_ERR, "Can't find compatible property for the its 
node\n");
+        return -FDT_ERR_XEN(ENOENT);
+    }
+
+    res = fdt_begin_node(fdt, "gic-its");
+    if ( res )
+        return res;
+
+    res = fdt_property(fdt, "compatible", compatible, len);
+    if ( res )
+        return res;
+
+    res = fdt_property(fdt, "msi-controller", NULL, 0);
+    if ( res )
+        return res;
+
+    len = dt_cells_to_size(dt_n_addr_cells(node) + dt_n_size_cells(node));
+
+    new_cells = xzalloc_bytes(len);
+    if ( new_cells == NULL )
+        return -FDT_ERR_XEN(ENOMEM);
+    tmp = new_cells;
+
+    dt_set_range(&tmp, node, its->phys_base, its->phys_size);
+
+    res = fdt_property(fdt, "reg", new_cells, len);
+    xfree(new_cells);
+
+    if ( node->phandle )
+    {
+        res = fdt_property_cell(fdt, "phandle", node->phandle);
+        if ( res )
+            return res;
+
+        its_phandle = cpu_to_fdt32(node->phandle);
+    }
+
+    res = fdt_end_node(fdt);
+
+    return res;
+}
+
+
+fdt32_t its_get_lpi_handle(void)
+{
+    return its_phandle;
+}
+
 static int its_force_quiescent(void __iomem *base)
 {
     u32 count = 1000000;   /* 1s */
diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index 23eb47c..828bf27 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -1143,6 +1143,34 @@ static int gicv3_make_hwdom_dt_node(const struct domain 
*d,
     return res;
 }
 
+static int gicv3_make_hwdom_its_dt_node(const struct domain *d,
+                                        const struct dt_device_node *node,
+                                        void *fdt)
+{
+    struct dt_device_node *gic_child;
+    int res = 0;
+
+    static const struct dt_device_match its_matches[] __initconst =
+    {
+        DT_MATCH_GIC_ITS,
+        { /* sentinel */ },
+    };
+
+    dt_for_each_child_node(node, gic_child)
+    {
+        if ( gic_child != NULL )
+        {
+            if ( dt_match_node(its_matches, gic_child) )
+            {
+                res = its_make_dt_node(d, gic_child, fdt);
+                break;
+            }
+        }
+    }
+
+    return res;
+}
+
 static const hw_irq_controller gicv3_host_irq_type = {
     .typename     = "gic-v3",
     .startup      = gicv3_irq_startup,
@@ -1372,6 +1400,7 @@ static const struct gic_hw_operations gicv3_ops = {
     .read_apr            = gicv3_read_apr,
     .secondary_init      = gicv3_secondary_cpu_init,
     .make_hwdom_dt_node  = gicv3_make_hwdom_dt_node,
+    .make_hwdom_its_dt_node  = gicv3_make_hwdom_its_dt_node,
     .is_lpi              = gicv3_is_lpi,
 };
 
diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index f6be0e9..88c1427 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -753,6 +753,15 @@ void __cpuinit init_maintenance_interrupt(void)
                 "irq-maintenance", NULL);
 }
 
+fdt32_t gic_get_msi_handle(void)
+{
+#ifdef HAS_GICV3
+    if ( gic_lpi_supported() )
+        return its_get_lpi_handle();
+#endif
+    return 0;
+}
+
 int gic_make_hwdom_dt_node(const struct domain *d,
                            const struct dt_device_node *node,
                            void *fdt)
@@ -760,6 +769,15 @@ int gic_make_hwdom_dt_node(const struct domain *d,
     return gic_hw_ops->make_hwdom_dt_node(d, node, fdt);
 }
 
+int gic_its_hwdom_dt_node(const struct domain *d,
+                           const struct dt_device_node *node,
+                           void *fdt)
+{
+    if ( gic_lpi_supported() )
+        return gic_hw_ops->make_hwdom_its_dt_node(d, node, fdt);
+    return 0;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/include/asm-arm/gic-its.h b/xen/include/asm-arm/gic-its.h
index 77f694f..f312a88 100644
--- a/xen/include/asm-arm/gic-its.h
+++ b/xen/include/asm-arm/gic-its.h
@@ -362,11 +362,14 @@ bool_t is_domain_lpi(struct domain *d, unsigned int lpi);
 hw_irq_controller *its_get_host_lpi_type(void);
 hw_irq_controller *its_get_guest_lpi_type(void);
 u32 its_get_nr_event_ids(void);
+int its_make_dt_node(const struct domain *d,
+                     const struct dt_device_node *node, void *fdt);
 int its_init(struct rdist_prop *rdists);
 int its_cpu_init(void);
 void its_set_lpi_properties(struct irq_desc *desc,
                             const cpumask_t *cpu_mask,
                             unsigned int priority);
+fdt32_t its_get_lpi_handle(void);
 int vits_domain_init(struct domain *d);
 void vits_domain_free(struct domain *d);
 int its_add_device(u32 devid, u32 nr_ites, struct dt_device_node *dt_its);
diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h
index 15bd6eb..d7050a9 100644
--- a/xen/include/asm-arm/gic.h
+++ b/xen/include/asm-arm/gic.h
@@ -152,6 +152,7 @@
 
 #ifndef __ASSEMBLY__
 #include <xen/device_tree.h>
+#include <xen/libfdt/libfdt.h>
 #include <xen/irq.h>
 #include <asm-arm/vgic.h>
 
@@ -372,6 +373,8 @@ struct gic_hw_operations {
     int (*secondary_init)(void);
     int (*make_hwdom_dt_node)(const struct domain *d,
                               const struct dt_device_node *node, void *fdt);
+    int (*make_hwdom_its_dt_node)(const struct domain *d,
+                                  const struct dt_device_node *node, void 
*fdt);
     bool_t (*is_lpi)(unsigned int irq);
 };
 
@@ -387,6 +390,10 @@ int gic_make_hwdom_dt_node(const struct domain *d,
                            const struct dt_device_node *node,
                            void *fdt);
 bool_t gic_is_lpi(unsigned int irq);
+int gic_its_hwdom_dt_node(const struct domain *d,
+                          const struct dt_device_node *node,
+                          void *fdt);
+fdt32_t gic_get_msi_handle(void);
 
 #endif /* __ASSEMBLY__ */
 #endif
-- 
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®.