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

[Xen-devel] [RFC PATCH 18/19] 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>
---
 xen/arch/arm/domain_build.c   |   59 ++++++++++++++++++++++++++++++++++++++++-
 xen/arch/arm/gic-v3-its.c     |   46 ++++++++++++++++++++++++++++++++
 xen/common/device_tree.c      |    2 ++
 xen/include/asm-arm/gic-its.h |    2 ++
 xen/include/asm-arm/gic.h     |    2 ++
 xen/include/xen/device_tree.h |    1 +
 6 files changed, 111 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 0be639b..9960d25 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -20,6 +20,7 @@
 #include <asm/cpufeature.h>
 
 #include <asm/gic.h>
+#include <asm/gic-its.h>
 #include <xen/irq.h>
 #include "kernel.h"
 
@@ -785,6 +786,45 @@ static int make_cpus_node(const struct domain *d, void 
*fdt,
     return res;
 }
 
+static int make_its_node(const struct domain *d, void *fdt,
+                         const struct dt_device_node *node)
+{
+    const struct dt_device_node *its = dt_msi_controller;
+    int res = 0;
+
+    /*
+     * Xen currently supports only a single GIC. Discard any secondary
+     * GIC entries.
+     */
+    if ( node != dt_msi_controller )
+    {
+        DPRINT("  Skipping Secondary ITS\n");
+        return 0;
+    }
+
+    DPRINT("Create GIC ITS node\n");
+
+    res = its_make_dt_node(d, node, fdt);
+    if ( res )
+        return res;
+
+    /*
+     * The value of the property "phandle" in the property "interrupts"
+     * to know on which interrupt controller the interrupt is wired.
+     */
+    if ( its->phandle )
+    {
+        DPRINT("  Set phandle = 0x%x\n", its->phandle);
+        res = fdt_property_cell(fdt, "phandle", its->phandle);
+        if ( res )
+            return res;
+    }
+
+    res = fdt_end_node(fdt);
+
+    return res;
+}
+
 static int make_gic_node(const struct domain *d, void *fdt,
                          const struct dt_device_node *node)
 {
@@ -1042,12 +1082,18 @@ static int handle_node(struct domain *d, struct 
kernel_info *kinfo,
         DT_MATCH_GIC_V3,
         { /* sentinel */ },
     };
+    static const struct dt_device_match gits_matches[] __initconst =
+    {
+        DT_MATCH_GIC_ITS,
+        { /* sentinel */ },
+    };
     static const struct dt_device_match timer_matches[] __initconst =
     {
         DT_MATCH_TIMER,
         { /* sentinel */ },
     };
     struct dt_device_node *child;
+    struct dt_device_node *gic_child;
     int res;
     const char *name;
     const char *path;
@@ -1071,7 +1117,18 @@ static int handle_node(struct domain *d, struct 
kernel_info *kinfo,
     /* Replace these nodes with our own. Note that the original may be
      * used_by DOMID_XEN so this check comes first. */
     if ( dt_match_node(gic_matches, node) )
-        return make_gic_node(d, kinfo->fdt, node);
+    {
+        if ( !make_gic_node(d, kinfo->fdt, node) )
+        {
+            gic_child = node->child;
+            if ( gic_child != NULL )
+            {
+                if ( dt_match_node(gits_matches, gic_child) )
+                    return make_its_node(d, kinfo->fdt, gic_child);
+            }
+        }
+        return 0;
+    }
     if ( dt_match_node(timer_matches, node) )
         return make_timer_node(d, kinfo->fdt, node);
 
diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c
index 7adbee4..dbfda30 100644
--- a/xen/arch/arm/gic-v3-its.c
+++ b/xen/arch/arm/gic-v3-its.c
@@ -857,6 +857,49 @@ 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)
+{
+    const struct dt_device_node *gic = dt_msi_controller;
+    const void *compatible = NULL;
+    uint32_t len;
+    __be32 *new_cells, *tmp;
+    int res = 0;
+
+    compatible = dt_get_property(gic, "compatible", &len);
+    if ( !compatible )
+    {
+        dprintk(XENLOG_ERR, "Can't find compatible property for the gic 
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, d->arch.vits->phys_base, d->arch.vits->phys_size);
+
+    res = fdt_property(fdt, "reg", new_cells, len);
+    xfree(new_cells);
+
+    return res;
+}
+
 static int its_probe(struct dt_device_node *node)
 {
     paddr_t its_addr, its_size;
@@ -886,6 +929,9 @@ static int its_probe(struct dt_device_node *node)
         goto out_unmap;
     }
 
+    /* Set the ITS as the primary MSI controller */
+    dt_msi_controller = node;
+
     its_info("ITS: %s\n", node->full_name);
 
     its = xzalloc(struct its_node);
diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index f72b2e9..e1382c7 100644
--- a/xen/common/device_tree.c
+++ b/xen/common/device_tree.c
@@ -30,6 +30,8 @@ dt_irq_xlate_func dt_irq_xlate;
 struct dt_device_node *dt_host;
 /* Interrupt controller node*/
 const struct dt_device_node *dt_interrupt_controller;
+/* MSI controller node*/
+const struct dt_device_node *dt_msi_controller;
 
 /**
  * struct dt_alias_prop - Alias property in 'aliases' node
diff --git a/xen/include/asm-arm/gic-its.h b/xen/include/asm-arm/gic-its.h
index 5329e9d..0defe6e 100644
--- a/xen/include/asm-arm/gic-its.h
+++ b/xen/include/asm-arm/gic-its.h
@@ -236,6 +236,8 @@ int its_get_target(uint8_t pcid, uint64_t *pta);
 uint32_t its_get_pta_type(void);
 int its_get_physical_cid(uint32_t *col_id, uint64_t ta);
 int gic_its_send_cmd(struct vcpu *v, struct its_cmd_block *phys_cmd);
+int its_make_dt_node(const struct domain *d,
+                     const struct dt_device_node *node, void *fdt);
 
 #endif /* __ASM_ARM_GIC_ITS_H__ */
 
diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h
index 075f488..efc9ac3 100644
--- a/xen/include/asm-arm/gic.h
+++ b/xen/include/asm-arm/gic.h
@@ -156,6 +156,7 @@
 #include <asm-arm/vgic.h>
 
 #define DT_COMPAT_GIC_400            "arm,gic-400"
+#define DT_COMPAT_GIC_ITS            "arm,gic-v3-its"
 #define DT_COMPAT_GIC_CORTEX_A15     "arm,cortex-a15-gic"
 #define DT_COMPAT_GIC_CORTEX_A7      "arm,cortex-a7-gic"
 
@@ -166,6 +167,7 @@
 #define DT_COMPAT_GIC_V3             "arm,gic-v3"
 
 #define DT_MATCH_GIC_V3 DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_V3)
+#define DT_MATCH_GIC_ITS DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_ITS)
 
 #define is_lpi(lpi) ((lpi) >= 8192)
 
diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
index 08db8bc..71732ee 100644
--- a/xen/include/xen/device_tree.h
+++ b/xen/include/xen/device_tree.h
@@ -192,6 +192,7 @@ extern struct dt_device_node *dt_host;
  * TODO: Handle multiple GIC
  */
 extern const struct dt_device_node *dt_interrupt_controller;
+extern const struct dt_device_node *dt_msi_controller;
 
 /**
  * Find the interrupt controller
-- 
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®.