[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC PATCH v2 20/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> --- v2: - Generate all available ITS node in host DT for Dom0 - its_node structure will hold pointer to ITS dt node that helps in search --- xen/arch/arm/domain_build.c | 50 +++++++++++++++++++++++++++++++- xen/arch/arm/gic-v3-its.c | 63 +++++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/gic-its.h | 2 ++ xen/include/asm-arm/gic.h | 1 + 4 files changed, 115 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 9f1f59f..800b40c 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" @@ -779,6 +780,34 @@ 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) +{ + int res = 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 ( node->phandle ) + { + DPRINT(" Set phandle = 0x%x\n", node->phandle); + res = fdt_property_cell(fdt, "phandle", node->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) { @@ -1041,12 +1070,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; @@ -1070,7 +1105,20 @@ 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) ) + { + dt_for_each_child_node(node, gic_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 eacd244..a59bbb5 100644 --- a/xen/arch/arm/gic-v3-its.c +++ b/xen/arch/arm/gic-v3-its.c @@ -153,6 +153,18 @@ uint32_t its_get_nr_its(void) return nr_its; } +static struct its_node * find_its_node(const struct dt_device_node *node) +{ + struct its_node *its; + + list_for_each_entry(its, &its_nodes, entry) { + if ( its->dt_node == node ) + return its; + } + + return NULL; +} + struct its_node * its_get_phys_node(uint32_t dev_id) { struct its_node *its; @@ -988,6 +1000,57 @@ int gic_its_send_cmd(struct vcpu *v, struct its_node *its, return ret; } +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; + uint32_t len; + __be32 *new_cells, *tmp; + int res = 0; + + its = find_its_node(node); + if (its == NULL) { + 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); + + return res; +} + static int its_force_quiescent(void __iomem *base) { u32 count = 1000000; /* 1s */ diff --git a/xen/include/asm-arm/gic-its.h b/xen/include/asm-arm/gic-its.h index dc1b98c..ed9cbc9 100644 --- a/xen/include/asm-arm/gic-its.h +++ b/xen/include/asm-arm/gic-its.h @@ -224,6 +224,8 @@ int its_get_target(uint8_t pcid, uint64_t *pta); int its_alloc_device_irq(struct its_device *dev, uint32_t *plpi); int gic_its_send_cmd(struct vcpu *v, struct its_node *its, struct its_cmd_block *phys_cmd, int send_all); +int its_make_dt_node(const struct domain *d, + const struct dt_device_node *node, void *fdt); void its_lpi_free(unsigned long *bitmap, int base, int nr_ids); void its_set_affinity(struct irq_desc *d, int cpu); void lpi_set_config(struct irq_desc *d, int enable); diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index f816664..d927f35 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -161,6 +161,7 @@ DT_MATCH_COMPATIBLE("arm,gic-400") #define DT_MATCH_GIC_V3 DT_MATCH_COMPATIBLE("arm,gic-v3") +#define DT_MATCH_GIC_ITS DT_MATCH_COMPATIBLE("arm,gic-v3-its") #define is_lpi(lpi) (lpi >= NR_GIC_LPI) -- 1.7.9.5 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |