xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: vijay.kilari@gmail.com
To: Ian.Campbell@citrix.com, julien.grall@citrix.com,
	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: [PATCH v6 30/31] xen/arm: ITS: Generate ITS node for Dom0
Date: Mon, 31 Aug 2015 16:36:47 +0530	[thread overview]
Message-ID: <1441019208-2764-31-git-send-email-vijay.kilari@gmail.com> (raw)
In-Reply-To: <1441019208-2764-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>
---
v6: - Introduced get_its_phandle in gic_hw_ops
    - Removed make_hwdom_its_dt_node callback in gic_hw_ops
    - Renamed gic_get_msi_handle() as gic_update_msi_phandle()
    - Renamed its_get_phandle to its_update_phandle()
    - ITS node generation is wrapped inside GICv3
    - Update msi-parent phandle only if msi-parent is ITS
      and find its phandle on demand
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   |   11 ++++
 xen/arch/arm/gic-v3-its.c     |  120 +++++++++++++++++++++++++++++++++++++++++
 xen/arch/arm/gic-v3.c         |   14 ++++-
 xen/arch/arm/gic.c            |    6 +++
 xen/include/asm-arm/gic-its.h |    2 +
 xen/include/asm-arm/gic.h     |    3 ++
 6 files changed, 155 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index a059de6..19cd40d 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -469,6 +469,17 @@ 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") )
+        {
+            DPRINT(" Set msi-parent with ITS phandle (if ITS available)\n");
+            gic_update_msi_phandle(kinfo->fdt, prop);
+            continue;
+        }
+
         res = fdt_property(kinfo->fdt, prop->name, prop_data, prop_len);
 
         xfree(new_data);
diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c
index e825d1e..9787f81 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>
@@ -1244,6 +1246,124 @@ static void its_cpu_init_collection(void)
     spin_unlock(&its_lock);
 }
 
+int its_make_dt_node(const struct domain *d, void *fdt)
+{
+    struct its_node *its;
+    const struct dt_device_node *node;
+    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);
+    }
+
+    node = its->dt_node;
+
+    compatible = dt_get_property(node, "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 ( res )
+        return res;
+
+    if ( node->phandle )
+    {
+        res = fdt_property_cell(fdt, "phandle", node->phandle);
+        if ( res )
+            return res;
+    }
+
+    res = fdt_end_node(fdt);
+
+    return res;
+}
+
+static int its_find_compatible_phandle(fdt32_t msi_parent_phandle)
+{
+    struct its_node *its;
+    const struct dt_device_node *node;
+    fdt32_t phandle;
+
+    list_for_each_entry(its, &its_nodes, entry)
+    {
+        node = its->dt_node;
+
+        if ( node->phandle )
+        {
+            phandle = cpu_to_fdt32(node->phandle);
+            if ( phandle == msi_parent_phandle )
+               return 0;
+        }
+    }
+
+    return -FDT_ERR_XEN(ENOENT);
+}
+
+int its_update_phandle(void *fdt, const struct dt_property *prop)
+{
+    struct its_node *its;
+    const struct dt_device_node *node;
+    fdt32_t phandle, msi_parent_phandle;
+
+    memcpy(&msi_parent_phandle, prop->value, sizeof(msi_parent_phandle));
+
+    /* chech if msi-parent phandle is ITS */
+    if ( its_find_compatible_phandle(msi_parent_phandle) )
+        return -FDT_ERR_XEN(ENOENT);
+
+    /* Only first ITS node phandle is considered */
+    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);
+    }
+
+    node = its->dt_node;
+
+    if ( node->phandle )
+    {
+        phandle = cpu_to_fdt32(node->phandle);
+        fdt_property(fdt, prop->name, (void *)&phandle, sizeof(phandle));
+
+        return 0;
+    }
+
+    return -FDT_ERR_XEN(ENOENT);
+}
+
 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 9260c6d..4389c6a 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -1080,6 +1080,11 @@ static void gicv3_irq_set_affinity(struct irq_desc *desc, const cpumask_t *mask)
     spin_unlock(&gicv3.lock);
 }
 
+static int gicv3_update_its_phandle(void *fdt, const struct dt_property *prop)
+{
+    return its_update_phandle(fdt, prop);
+}
+
 static int gicv3_make_hwdom_dt_node(const struct domain *d,
                                     const struct dt_device_node *node,
                                     void *fdt)
@@ -1101,6 +1106,10 @@ static int gicv3_make_hwdom_dt_node(const struct domain *d,
     if ( res )
         return res;
 
+    res = fdt_property(fdt, "ranges", NULL, 0);
+    if ( res )
+        return res;
+
     res = fdt_property_cell(fdt, "redistributor-stride",
                             d->arch.vgic.rdist_stride);
     if ( res )
@@ -1132,8 +1141,10 @@ static int gicv3_make_hwdom_dt_node(const struct domain *d,
 
     res = fdt_property(fdt, "reg", new_cells, len);
     xfree(new_cells);
+    if ( res )
+        return res;
 
-    return res;
+    return its_make_dt_node(d, fdt);
 }
 
 static const hw_irq_controller gicv3_host_irq_type = {
@@ -1366,6 +1377,7 @@ static const struct gic_hw_operations gicv3_ops = {
     .read_vmcr_priority  = gicv3_read_vmcr_priority,
     .read_apr            = gicv3_read_apr,
     .secondary_init      = gicv3_secondary_cpu_init,
+    .update_its_phandle  = gicv3_update_its_phandle,
     .make_hwdom_dt_node  = gicv3_make_hwdom_dt_node,
 };
 
diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index d91623a..2b5842e 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -758,6 +758,12 @@ void __cpuinit init_maintenance_interrupt(void)
                 "irq-maintenance", NULL);
 }
 
+void gic_update_msi_phandle(void *fdt, const struct dt_property *prop)
+{
+    if ( gic_lpi_supported() )
+        gic_hw_ops->update_its_phandle(fdt, prop);
+}
+
 int gic_make_hwdom_dt_node(const struct domain *d,
                            const struct dt_device_node *node,
                            void *fdt)
diff --git a/xen/include/asm-arm/gic-its.h b/xen/include/asm-arm/gic-its.h
index 75a9c95..c620b17 100644
--- a/xen/include/asm-arm/gic-its.h
+++ b/xen/include/asm-arm/gic-its.h
@@ -356,6 +356,7 @@ struct its_device *irqdesc_get_its_device(struct irq_desc *desc);
 void irqdesc_set_its_device(struct irq_desc *desc, struct its_device *dev);
 bool_t is_valid_collection(struct domain *d, uint32_t col);
 unsigned int its_get_nr_event_ids(void);
+int its_make_dt_node(const struct domain *d, void *fdt);
 int its_init(struct rdist_prop *rdists);
 int its_cpu_init(void);
 int its_add_device(u32 devid, u32 nr_ites, struct dt_device_node *dt_its);
@@ -363,6 +364,7 @@ int its_assign_device(struct domain *d, u32 vdevid, u32 pdevid);
 void its_set_lpi_properties(struct irq_desc *desc,
                             const cpumask_t *cpu_mask,
                             unsigned int priority);
+int its_update_phandle(void *fdt, const struct dt_property *prop);
 int vits_access_guest_table(struct domain *d, paddr_t entry, void *addr,
                             uint32_t size, bool_t set);
 int vits_domain_init(struct domain *d);
diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h
index abb8616..f620aff 100644
--- a/xen/include/asm-arm/gic.h
+++ b/xen/include/asm-arm/gic.h
@@ -151,6 +151,7 @@
 
 #ifndef __ASSEMBLY__
 #include <xen/device_tree.h>
+#include <xen/libfdt/libfdt.h>
 #include <xen/irq.h>
 #include <asm-arm/vgic.h>
 
@@ -369,6 +370,7 @@ 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 (*update_its_phandle)(void *fdt, const struct dt_property *prop);
 };
 
 void register_gic_ops(const struct gic_hw_operations *ops);
@@ -376,6 +378,7 @@ 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);
+void gic_update_msi_phandle(void *fdt, const struct dt_property *prop);
 
 #endif /* __ASSEMBLY__ */
 #endif
-- 
1.7.9.5

  parent reply	other threads:[~2015-08-31 11:06 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-31 11:06 [PATCH v6 00/31] Add ITS support vijay.kilari
2015-08-31 11:06 ` [PATCH v6 01/31] xen/dt: Handle correctly node with interrupt-map in dt_for_each_irq_map vijay.kilari
2015-08-31 14:20   ` Julien Grall
2015-09-02 15:28     ` Ian Campbell
2015-09-02 15:30       ` Wei Liu
2015-09-02 15:45       ` Julien Grall
2015-09-02 15:52         ` Ian Campbell
2015-09-04 14:41         ` Ian Campbell
2015-08-31 11:06 ` [PATCH v6 02/31] xen/arm: Add bitmap_find_next_zero_area helper function vijay.kilari
2015-08-31 11:06 ` [PATCH v6 03/31] xen: Add log2 functionality vijay.kilari
2015-08-31 11:21   ` Jan Beulich
2015-08-31 11:06 ` [PATCH v6 04/31] xen/arm: Set nr_cpu_ids to available number of cpus vijay.kilari
2015-08-31 14:25   ` Julien Grall
2015-09-09 12:48     ` Ian Campbell
2015-08-31 11:06 ` [PATCH v6 05/31] xen/arm: Rename NR_IRQs and vgic_num_irqs helper function vijay.kilari
2015-08-31 14:40   ` Julien Grall
2015-09-09 13:08     ` Ian Campbell
2015-09-09 13:23       ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 06/31] xen/arm: ITS: Port ITS driver to Xen vijay.kilari
2015-08-31 15:41   ` Julien Grall
2015-09-03 17:02   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 07/31] xen/arm: ITS: Add helper functions to manage its_devices vijay.kilari
2015-08-31 11:06 ` [PATCH v6 08/31] xen/arm: ITS: Introduce msi_desc for LPIs vijay.kilari
2015-08-31 16:20   ` Julien Grall
2015-09-09 13:16   ` Ian Campbell
2015-09-09 13:28     ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 09/31] xen/arm: ITS: Add APIs to add and assign device vijay.kilari
2015-09-03 17:34   ` Julien Grall
2015-09-09 13:28     ` Ian Campbell
2015-09-09 13:44       ` Julien Grall
2015-09-09 15:07         ` Ian Campbell
2015-09-09 16:19           ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 10/31] xen/arm: ITS: Introduce gic_is_lpi helper function vijay.kilari
2015-08-31 16:49   ` Julien Grall
2015-09-01  9:02     ` Vijay Kilari
2015-09-01 11:40       ` Julien Grall
2015-09-01 11:56         ` Vijay Kilari
2015-09-01 13:02           ` Julien Grall
2015-09-03  6:32             ` Vijay Kilari
2015-09-03  9:48               ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 11/31] xen/arm: ITS: Enable compilation of physical ITS driver vijay.kilari
2015-08-31 11:06 ` [PATCH v6 12/31] xen/arm: Move vgic locking inside get_irq_priority callback vijay.kilari
2015-08-31 16:34   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 13/31] xen/arm: ITS: implement hw_irq_controller for LPIs vijay.kilari
2015-08-31 17:53   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 14/31] xen/arm: ITS: Initialize physical ITS and export lpi support vijay.kilari
2015-08-31 18:35   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 15/31] xen/arm: ITS: Add virtual ITS driver vijay.kilari
2015-09-02 17:20   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 16/31] xen/arm: ITS: Add virtual ITS commands support vijay.kilari
2015-09-03 15:07   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 17/31] xen/arm: ITS: Store LPIs allocated and IRQ ID bits per domain vijay.kilari
2015-09-03 16:25   ` Julien Grall
2015-09-07  6:59     ` Vijay Kilari
2015-09-07 10:56       ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 18/31] xen/arm: ITS: Enable virtual ITS driver vijay.kilari
2015-08-31 11:06 ` [PATCH v6 19/31] xen/arm: ITS: Export ITS info to Virtual ITS vijay.kilari
2015-09-03 16:48   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 20/31] xen/arm: ITS: Introduce helper to get number of event IDs vijay.kilari
2015-09-03 17:51   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 21/31] xen/arm: ITS: Add GITS registers emulation vijay.kilari
2015-09-07 13:14   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 22/31] xen/arm: ITS: Add virtual ITS availability check helper vijay.kilari
2015-09-07 13:41   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 23/31] xen/arm: ITS: Add 32-bit access to GICR_TYPER vijay.kilari
2015-08-31 16:06   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 24/31] xen/arm: ITS: Add GICR register emulation vijay.kilari
2015-09-07 14:20   ` Julien Grall
2015-09-07 15:26     ` Vijay Kilari
2015-09-09 13:55       ` Ian Campbell
2015-09-09 16:11         ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 25/31] xen/arm: ITS: Allocate irq descriptors for LPIs vijay.kilari
2015-08-31 11:06 ` [PATCH v6 26/31] xen/arm: ITS: Allocate pending_lpi " vijay.kilari
2015-08-31 11:06 ` [PATCH v6 27/31] xen/arm: ITS: Route LPIs vijay.kilari
2015-08-31 11:06 ` [PATCH v6 28/31] xen/arm: ITS: Add domain specific ITS initialization vijay.kilari
2015-08-31 11:06 ` [PATCH v6 29/31] xen/arm: ITS: Map ITS translation space vijay.kilari
2015-08-31 19:07   ` Julien Grall
2015-08-31 11:06 ` vijay.kilari [this message]
2015-08-31 11:06 ` [PATCH v6 31/31] xen/arm: ITS: Add pci devices in ThunderX vijay.kilari
2015-09-09 15:22   ` Ian Campbell
2015-09-02 15:38 ` [PATCH v6 00/31] Add ITS support Ian Campbell
2015-09-02 15:52   ` Ian Campbell
2015-09-03 16:45 ` Julien Grall
2015-09-09 15:29 ` Ian Campbell
2015-09-14 11:00   ` Vijay Kilari
2015-09-14 11:09     ` Julien Grall
2015-09-14 13:04       ` Vijay Kilari

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=1441019208-2764-31-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@citrix.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).