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,
	xen-devel@lists.xen.org
Cc: Prasun.Kapoor@caviumnetworks.com,
	Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>,
	vijay.kilari@gmail.com
Subject: [PATCH v4 15/16] xen/arm: Update Dom0 GIC dt node with GICv3 information
Date: Mon, 26 May 2014 15:56:48 +0530	[thread overview]
Message-ID: <1401100009-7326-16-git-send-email-vijay.kilari@gmail.com> (raw)
In-Reply-To: <1401100009-7326-1-git-send-email-vijay.kilari@gmail.com>

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

Update GIC device tree node for DOM0 with GICv3
information. GIC hw specfic device tree information
is moved to respective GIC driver.

Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>
---
 xen/arch/arm/domain_build.c |   47 ++------------------------
 xen/arch/arm/gic-v2.c       |   51 ++++++++++++++++++++++++++++
 xen/arch/arm/gic-v3.c       |   77 +++++++++++++++++++++++++++++++++++++++++++
 xen/arch/arm/gic.c          |    6 ++++
 xen/include/asm-arm/gic.h   |    7 +++-
 5 files changed, 142 insertions(+), 46 deletions(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 15ed97b..c5905af 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -524,9 +524,6 @@ static int make_gic_node(const struct domain *d, void *fdt,
                          const struct dt_device_node *node)
 {
     const struct dt_device_node *gic = dt_interrupt_controller;
-    const void *compatible = NULL;
-    u32 len;
-    __be32 *new_cells, *tmp;
     int res = 0;
 
     /*
@@ -541,48 +538,7 @@ static int make_gic_node(const struct domain *d, void *fdt,
 
     DPRINT("Create gic node\n");
 
-    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, "interrupt-controller");
-    if ( res )
-        return res;
-
-    res = fdt_property(fdt, "compatible", compatible, len);
-    if ( res )
-        return res;
-
-    res = fdt_property_cell(fdt, "#interrupt-cells", 3);
-    if ( res )
-        return res;
-
-    res = fdt_property(fdt, "interrupt-controller", NULL, 0);
-
-    if ( res )
-        return res;
-
-    len = dt_cells_to_size(dt_n_addr_cells(node) + dt_n_size_cells(node));
-    len *= 2; /* GIC has two memory regions: Distributor + CPU interface */
-    new_cells = xzalloc_bytes(len);
-    if ( new_cells == NULL )
-        return -FDT_ERR_XEN(ENOMEM);
-
-    tmp = new_cells;
-    DPRINT("  Set Distributor Base 0x%"PRIpaddr"-0x%"PRIpaddr"\n",
-           d->arch.vgic.dbase, d->arch.vgic.dbase + PAGE_SIZE - 1);
-    dt_set_range(&tmp, node, d->arch.vgic.dbase, PAGE_SIZE);
-
-    DPRINT("  Set Cpu Base 0x%"PRIpaddr"-0x%"PRIpaddr"\n",
-           d->arch.vgic.cbase, d->arch.vgic.cbase + (PAGE_SIZE * 2) - 1);
-    dt_set_range(&tmp, node, d->arch.vgic.cbase, PAGE_SIZE * 2);
-
-    res = fdt_property(fdt, "reg", new_cells, len);
-    xfree(new_cells);
-
+    res = gic_make_node(d, node, fdt);
     if ( res )
         return res;
 
@@ -781,6 +737,7 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,
     static const struct dt_device_match gic_matches[] __initconst =
     {
         DT_MATCH_GIC_V2,
+        DT_MATCH_GIC_V3,
         { /* sentinel */ },
     };
     static const struct dt_device_match timer_matches[] __initconst =
diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index 8060de3..a1f65c3 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -27,6 +27,7 @@
 #include <xen/softirq.h>
 #include <xen/list.h>
 #include <xen/device_tree.h>
+#include <xen/libfdt/libfdt.h>
 #include <asm/p2m.h>
 #include <asm/domain.h>
 #include <asm/platform.h>
@@ -538,6 +539,55 @@ static void gicv2_irq_set_affinity(struct irq_desc *desc, const cpumask_t *mask)
     BUG();
 }
 
+static int gicv2_make_dt_node(const struct domain *d,
+                              const struct dt_device_node *node, void *fdt)
+{
+    const struct dt_device_node *gic = dt_interrupt_controller;
+    const void *compatible = NULL;
+    u32 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, "interrupt-controller");
+    if ( res )
+        return res;
+
+    res = fdt_property(fdt, "compatible", compatible, len);
+    if ( res )
+        return res;
+
+    res = fdt_property_cell(fdt, "#interrupt-cells", 3);
+    if ( res )
+        return res;
+
+    res = fdt_property(fdt, "interrupt-controller", NULL, 0);
+
+    if ( res )
+        return res;
+
+    len = dt_cells_to_size(dt_n_addr_cells(node) + dt_n_size_cells(node));
+    len *= 2; /* GIC has two memory regions: Distributor + CPU interface */
+    new_cells = xzalloc_bytes(len);
+    if ( new_cells == NULL )
+        return -FDT_ERR_XEN(ENOMEM);
+
+    tmp = new_cells;
+    dt_set_range(&tmp, node, d->arch.vgic.dbase, PAGE_SIZE);
+    dt_set_range(&tmp, node, d->arch.vgic.cbase, PAGE_SIZE * 2);
+
+    res = fdt_property(fdt, "reg", new_cells, len);
+    xfree(new_cells);
+
+    return res;
+}
+
 /* XXX different for level vs edge */
 static hw_irq_controller gicv2_host_irq_type = {
     .typename     = "gic-v2",
@@ -582,6 +632,7 @@ const static struct gic_hw_operations gicv2_ops = {
     .read_lr             = gicv2_read_lr,
     .write_lr            = gicv2_write_lr,
     .read_vmcr_priority  = gicv2_read_vmcr_priority,
+    .make_dt_node        = gicv2_make_dt_node,
 };
 
 /* Set up the GIC */
diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index 7543fb4..654234f 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -953,6 +953,82 @@ static void gicv3_irq_set_affinity(struct irq_desc *desc, const cpumask_t *mask)
     BUG();
 }
 
+static int gicv3_make_dt_node(const struct domain *d,
+                              const struct dt_device_node *node, void *fdt)
+{
+    const struct dt_device_node *gic = dt_interrupt_controller;
+    const void *compatible = NULL;
+    uint32_t len;
+    __be32 *new_cells, *tmp;
+    uint32_t rd_stride = 0;
+    uint32_t rd_count = 0;
+
+    int i, 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, "interrupt-controller");
+    if ( res )
+        return res;
+
+    res = fdt_property(fdt, "compatible", compatible, len);
+    if ( res )
+        return res;
+
+    res = fdt_property_cell(fdt, "#interrupt-cells", 3);
+    if ( res )
+        return res;
+
+    res = fdt_property(fdt, "interrupt-controller", NULL, 0);
+    if ( res )
+        return res;
+
+    res = dt_property_read_u32(gic, "redistributor-stride", &rd_stride);
+    if ( !res )
+        rd_stride = 0;
+
+    res = dt_property_read_u32(gic, "#redistributor-regions", &rd_count);
+    if ( !res )
+        rd_count = 1;
+
+    res = fdt_property_cell(fdt, "redistributor-stride", rd_stride);
+    if ( res )
+        return res;
+
+    res = fdt_property_cell(fdt, "#redistributor-regions", rd_count);
+    if ( res )
+        return res;
+
+    len = dt_cells_to_size(dt_n_addr_cells(node) + dt_n_size_cells(node));
+    /*
+     * GIC has two memory regions: Distributor + rdist regions
+     * CPU interface and virtual cpu interfaces accessesed as System registers
+     * So cells are created only for Distributor and rdist regions
+     */
+    len = len * (d->arch.vgic.rdist_count + 1);
+    new_cells = xzalloc_bytes(len);
+    if ( new_cells == NULL )
+        return -FDT_ERR_XEN(ENOMEM);
+
+    tmp = new_cells;
+
+    dt_set_range(&tmp, node, d->arch.vgic.dbase, d->arch.vgic.dbase_size);
+
+    for ( i = 0; i < d->arch.vgic.rdist_count; i++ )
+        dt_set_range(&tmp, node, d->arch.vgic.rbase[i],
+                     d->arch.vgic.rbase_size[i]);
+
+    res = fdt_property(fdt, "reg", new_cells, len);
+    xfree(new_cells);
+
+    return res;
+}
+
 const static hw_irq_controller gicv3_host_irq_type = {
     .typename     = "gic-v3",
     .startup      = gicv3_irq_startup,
@@ -996,6 +1072,7 @@ const static struct gic_hw_operations gicv3_ops = {
     .write_lr            = gicv3_write_lr,
     .read_vmcr_priority  = gicv3_read_vmcr_priority,
     .secondary_init      = gicv3_secondary_cpu_init,
+    .make_dt_node        = gicv3_make_dt_node,
 };
 
 /* Set up the GIC */
diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index 9331216..2c50c72 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -622,6 +622,12 @@ void __cpuinit init_maintenance_interrupt(void)
                 "irq-maintenance", NULL);
 }
 
+int gic_make_node(const struct domain *d,const struct dt_device_node *node,
+                   void *fdt)
+{
+    return gic_hw_ops->make_dt_node(d, node, fdt);
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h
index b40beb5..acf1304 100644
--- a/xen/include/asm-arm/gic.h
+++ b/xen/include/asm-arm/gic.h
@@ -156,7 +156,7 @@
 
 #define DT_MATCH_GIC_V3_STRING1      "arm,gic-v3"
 
-#define DT_MATCH_GIC_V3 DT_MATCH_COMPATIBLE(DT_MATCH_GIC_V3_STRING1);
+#define DT_MATCH_GIC_V3 DT_MATCH_COMPATIBLE(DT_MATCH_GIC_V3_STRING1)
 
 /*
  * GICv3 registers that needs to be saved/restored
@@ -332,10 +332,15 @@ struct gic_hw_operations {
     unsigned int (*read_vmcr_priority)(void);
     /* Secondary CPU init */
     int (*secondary_init)(void);
+    int (*make_dt_node)(const struct domain *d,
+                        const struct dt_device_node *node, void *fdt);
 };
 
 void register_gic_ops(const struct gic_hw_operations *ops);
 extern void update_cpu_lr_mask(void);
+int gic_make_node(const struct domain *d,const struct dt_device_node *node,
+                  void *fdt);
+
 
 #endif /* __ASSEMBLY__ */
 #endif
-- 
1.7.9.5

  parent reply	other threads:[~2014-05-26 10:26 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-26 10:26 [PATCH v4 00/16] xen/arm: Add GICv3 support vijay.kilari
2014-05-26 10:26 ` [PATCH v4 01/16] xen/arm: move io.h as mmio.h to include folder vijay.kilari
2014-05-26 11:28   ` Julien Grall
2014-05-28 13:55   ` Stefano Stabellini
2014-05-26 10:26 ` [PATCH v4 02/16] xen/arm: make mmio handlers domain specific vijay.kilari
2014-05-26 12:33   ` Julien Grall
2014-05-28 14:05     ` Stefano Stabellini
2014-05-28 14:11       ` Julien Grall
2014-05-26 10:26 ` [PATCH v4 03/16] xen/arm: make sgi handling generic vijay.kilari
2014-05-26 12:41   ` Julien Grall
2014-05-26 12:45     ` Julien Grall
2014-05-28 14:10   ` Stefano Stabellini
2014-06-09  9:58     ` Vijay Kilari
2014-05-26 10:26 ` [PATCH v4 04/16] xen/arm: remove unused parameter in do_sgi call vijay.kilari
2014-05-26 12:48   ` Julien Grall
2014-05-26 10:26 ` [PATCH v4 05/16] xen/arm: use ioremap to map gic-v2 registers vijay.kilari
2014-05-26 13:10   ` Julien Grall
2014-05-30 12:54     ` Vijay Kilari
2014-05-28 14:26   ` Stefano Stabellini
2014-06-09 10:29     ` Vijay Kilari
2014-05-26 10:26 ` [PATCH v4 06/16] xen/arm: segregate and split GIC low level functionality vijay.kilari
2014-05-26 14:09   ` Julien Grall
2014-05-27 19:13   ` Julien Grall
2014-05-28 14:43   ` Stefano Stabellini
2014-05-26 10:26 ` [PATCH v4 07/16] arm/xen: move GIC context data structure to gic driver vijay.kilari
2014-05-26 14:32   ` Julien Grall
2014-05-28 14:49     ` Stefano Stabellini
2014-05-26 10:26 ` [PATCH v4 08/16] xen/arm: use device api to detect GIC version vijay.kilari
2014-05-26 14:39   ` Julien Grall
2014-05-28 14:52     ` Stefano Stabellini
2014-05-26 10:26 ` [PATCH v4 09/16] xen/arm: move vgic rank data to gic header file vijay.kilari
2014-05-27 11:32   ` Julien Grall
2014-05-28 14:54   ` Stefano Stabellini
2014-05-26 10:26 ` [PATCH v4 10/16] xen/arm: move vgic defines to vgic " vijay.kilari
2014-05-27 11:49   ` Julien Grall
2014-06-10  8:30     ` Vijay Kilari
2014-05-26 10:26 ` [PATCH v4 11/16] xen/arm: calculate vgic irq rank based on register size vijay.kilari
2014-05-27 11:56   ` Julien Grall
2014-05-30  8:59     ` Vijay Kilari
2014-05-30  9:58       ` Julien Grall
2014-05-30 10:24         ` Vijay Kilari
2014-05-30 10:36           ` Julien Grall
2014-05-30 10:51             ` Vijay Kilari
2014-05-30 10:54               ` Julien Grall
2014-05-26 10:26 ` [PATCH v4 12/16] xen/arm: split vgic driver into generic and vgic-v2 driver vijay.kilari
2014-05-27 16:50   ` Julien Grall
2014-05-26 10:26 ` [PATCH v4 13/16] xen/arm: Add support for GIC v3 vijay.kilari
2014-05-27 19:47   ` Julien Grall
2014-06-02 17:33   ` Stefano Stabellini
2014-06-03  8:54     ` Ian Campbell
2014-06-03  9:05       ` Julien Grall
2014-06-03  9:07         ` Ian Campbell
2014-06-03 10:43           ` Stefano Stabellini
2014-06-03 10:46       ` Stefano Stabellini
2014-05-26 10:26 ` [PATCH v4 14/16] xen/arm: Add virtual GICv3 support vijay.kilari
2014-06-02 15:50   ` Stefano Stabellini
2014-06-11 11:36     ` Vijay Kilari
2014-06-11 12:44       ` Stefano Stabellini
2014-06-02 16:10   ` Julien Grall
2014-06-02 16:15     ` Ian Campbell
2014-06-02 16:18       ` Julien Grall
2014-06-02 16:38         ` Ian Campbell
2014-06-02 16:46           ` Julien Grall
2014-05-26 10:26 ` vijay.kilari [this message]
2014-05-26 10:26 ` [PATCH v4 16/16] xen/arm: add SGI handling for GICv3 vijay.kilari
2014-06-02 16:05   ` Stefano Stabellini
2014-06-02 16:13     ` Ian Campbell
2014-06-11 12:34       ` Vijay Kilari
2014-06-02 16:17   ` Julien Grall
2014-06-11 12:35     ` Vijay Kilari
2014-06-11 12:38       ` Julien Grall
2014-06-12  6:53         ` Vijay Kilari
2014-06-12 21:56           ` Julien Grall
2014-06-13  8:34             ` Ian Campbell
2014-06-15 18:44               ` Julien Grall
2014-06-20  8:48                 ` Vijay Kilari
2014-05-28 10:26 ` [PATCH v4 00/16] xen/arm: Add GICv3 support Ian Campbell
2014-05-28 12:34   ` 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=1401100009-7326-16-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=stefano.stabellini@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --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.