All of lore.kernel.org
 help / color / mirror / Atom feed
From: vijay.kilari@gmail.com
To: Ian.Campbell@citrix.com, julien.grall@linaro.org,
	stefano.stabellini@eu.citrix.com, stefano.stabellini@citrix.com,
	tim@xen.org, xen-devel@lists.xen.org
Cc: Prasun.Kapoor@caviumnetworks.com,
	Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>,
	manish.jaggi@caviumnetworks.com, vijay.kilari@gmail.com
Subject: [RFC PATCH 18/19] xen/arm: its: Generate ITS node for Dom0
Date: Mon,  2 Mar 2015 18:00:34 +0530	[thread overview]
Message-ID: <1425299435-3278-19-git-send-email-vijay.kilari@gmail.com> (raw)
In-Reply-To: <1425299435-3278-1-git-send-email-vijay.kilari@gmail.com>

From: Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>

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@caviumnetworks.com>
---
 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

  parent reply	other threads:[~2015-03-02 12:30 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-02 12:30 [RFC PATCH 00/19] xen/arm: Add ITS support vijay.kilari
2015-03-02 12:30 ` [RFC PATCH 01/19] xen/arm: add linked list apis vijay.kilari
2015-03-02 13:21   ` Jan Beulich
2015-03-02 12:30 ` [RFC PATCH 02/19] xen/arm: its: Import GICv3 ITS driver from linux vijay.kilari
2015-03-13 10:24   ` Julien Grall
2015-03-13 10:35     ` Julien Grall
2015-03-16  9:55       ` Vijay Kilari
2015-03-16 10:12         ` Stefano Stabellini
2015-03-16 13:04           ` Julien Grall
2015-03-16 13:15         ` Julien Grall
2015-03-16 13:32           ` Vijay Kilari
2015-03-02 12:30 ` [RFC PATCH 03/19] xen/arm: its: Port ITS driver to xen vijay.kilari
2015-03-13 11:46   ` Julien Grall
2015-03-16 14:06     ` Vijay Kilari
2015-03-16 14:20       ` Julien Grall
2015-03-16 16:03         ` Vijay Kilari
2015-03-16 16:18           ` Julien Grall
2015-03-02 12:30 ` [RFC PATCH 04/19] xen/arm: its: Move ITS command encode helper functions vijay.kilari
2015-03-02 12:30 ` [RFC PATCH 05/19] xen/arm: its: Remove unused code in ITS driver vijay.kilari
2015-03-02 12:30 ` [RFC PATCH 06/19] xen/arm: its: Add helper functions to decode ITS Command vijay.kilari
2015-03-02 12:30 ` [RFC PATCH 07/19] xen/arm: vits: Move LPI handling to basic virtual its driver vijay.kilari
2015-03-02 12:30 ` [RFC PATCH 08/19] xen/arm: Add helper function to get domain page vijay.kilari
2015-03-02 12:30 ` [RFC PATCH 09/19] xen/arm: Update irq descriptor for LPIs support vijay.kilari
2015-03-02 14:17   ` Julien Grall
2015-03-03 17:54   ` Stefano Stabellini
2015-03-02 12:30 ` [RFC PATCH 10/19] xen/arm: its: Add virtual ITS command support vijay.kilari
2015-03-02 12:30 ` [RFC PATCH 11/19] xen/arm: its: Add emulation of ITS control registers vijay.kilari
2015-03-02 12:30 ` [RFC PATCH 12/19] xen/arm: its: Add support to emulate GICR register for LPIs vijay.kilari
2015-03-03 17:16   ` Stefano Stabellini
2015-03-04 12:10     ` Stefano Stabellini
2015-03-02 12:30 ` [RFC PATCH 13/19] xen/arm: its: implement hw_irq_controller " vijay.kilari
2015-03-03 17:28   ` Stefano Stabellini
2015-03-09 13:03     ` Vijay Kilari
2015-03-09 16:09       ` Stefano Stabellini
2015-03-09 16:32         ` Vijay Kilari
2015-03-02 12:30 ` [RFC PATCH 14/19] xen/arm: vits: Map ITS translation space vijay.kilari
2015-03-03 17:31   ` Stefano Stabellini
2015-03-03 17:41     ` Julien Grall
2015-03-02 12:30 ` [RFC PATCH 15/19] xen/arm: gicv3: Refactor redistributor information vijay.kilari
2015-03-02 12:30 ` [RFC PATCH 16/19] xen/arm: its: Dynamic allocation of LPI descriptors vijay.kilari
2015-03-02 12:30 ` [RFC PATCH 17/19] xen/arm: its: Support ITS interrupt handling vijay.kilari
2015-03-03 18:07   ` Stefano Stabellini
2015-03-03 19:49     ` Julien Grall
2015-03-04  9:57       ` Stefano Stabellini
2015-03-02 12:30 ` vijay.kilari [this message]
2015-03-02 12:30 ` [RFC PATCH 19/19] xen/arm: its: Initialize virtual and physical ITS driver vijay.kilari
2015-03-02 13:19 ` [RFC PATCH 00/19] xen/arm: Add ITS support Julien Grall
2015-03-03  3:55   ` Vijay Kilari
2015-03-03 11:43     ` Julien Grall
2015-03-09 12:57       ` Vijay Kilari
2015-03-09 16:06         ` Stefano Stabellini
2015-03-09 18:16         ` Julien Grall
2015-03-13  4:48           ` Vijay Kilari
2015-03-13 10:13             ` Julien Grall
2015-03-16 10:30               ` Vijay Kilari
2015-03-02 14:53 ` Ian Campbell
2015-03-02 17:39   ` Ian Campbell
2015-03-03  4:02     ` Vijay Kilari
2015-03-03 10:07       ` Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425299435-3278-19-git-send-email-vijay.kilari@gmail.com \
    --to=vijay.kilari@gmail.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Prasun.Kapoor@caviumnetworks.com \
    --cc=Vijaya.Kumar@caviumnetworks.com \
    --cc=julien.grall@linaro.org \
    --cc=manish.jaggi@caviumnetworks.com \
    --cc=stefano.stabellini@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.