[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v6 36/36] ARM: vITS: create ITS subnodes for Dom0 DT
Dom0 expects all ITSes in the system to be propagated to be able to use MSIs. Create Dom0 DT nodes for each hardware ITS, keeping the register frame address the same, as the doorbell address that the Dom0 drivers program into the BARs has to match the hardware. Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx> --- xen/arch/arm/gic-v3-its.c | 78 ++++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/gic_v3_its.h | 10 ++++-- 2 files changed, 86 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c index 768c7e5..36f45c9 100644 --- a/xen/arch/arm/gic-v3-its.c +++ b/xen/arch/arm/gic-v3-its.c @@ -20,6 +20,7 @@ #include <xen/lib.h> #include <xen/delay.h> +#include <xen/libfdt/libfdt.h> #include <xen/mm.h> #include <xen/rbtree.h> #include <xen/sched.h> @@ -897,6 +898,83 @@ int gicv3_lpi_change_vcpu(struct domain *d, paddr_t vdoorbell, return 0; } +/* + * Create the respective guest DT nodes for a list of host ITSes. + * This copies the reg property, so the guest sees the ITS at the same address + * as the host. + * Giving NULL for the its_list will make it use the list of host ITSes. + */ +int gicv3_its_make_dt_nodes(struct list_head *its_list, + const struct domain *d, + const struct dt_device_node *gic, + void *fdt) +{ + uint32_t len; + int res; + const void *prop = NULL; + const struct dt_device_node *its = NULL; + const struct host_its *its_data; + + if ( !its_list ) + its_list = &host_its_list; + + if ( list_empty(its_list) ) + return 0; + + /* The sub-nodes require the ranges property */ + prop = dt_get_property(gic, "ranges", &len); + if ( !prop ) + { + printk(XENLOG_ERR "Can't find ranges property for the gic node\n"); + return -FDT_ERR_XEN(ENOENT); + } + + res = fdt_property(fdt, "ranges", prop, len); + if ( res ) + return res; + + list_for_each_entry(its_data, its_list, entry) + { + its = its_data->dt_node; + + res = fdt_begin_node(fdt, its->name); + if ( res ) + return res; + + res = fdt_property_string(fdt, "compatible", "arm,gic-v3-its"); + if ( res ) + return res; + + res = fdt_property(fdt, "msi-controller", NULL, 0); + if ( res ) + return res; + + if ( its->phandle ) + { + res = fdt_property_cell(fdt, "phandle", its->phandle); + if ( res ) + return res; + } + + /* Use the same reg regions as the ITS node in host DTB. */ + prop = dt_get_property(its, "reg", &len); + if ( !prop ) + { + printk(XENLOG_ERR "GICv3: Can't find ITS reg property.\n"); + res = -FDT_ERR_XEN(ENOENT); + return res; + } + + res = fdt_property(fdt, "reg", prop, len); + if ( res ) + return res; + + fdt_end_node(fdt); + } + + return res; +} + /* Scan the DT for any ITS nodes and create a list of host ITSes out of it. */ void gicv3_its_dt_init(const struct dt_device_node *node) { diff --git a/xen/include/asm-arm/gic_v3_its.h b/xen/include/asm-arm/gic_v3_its.h index 75ce534..08a09b7 100644 --- a/xen/include/asm-arm/gic_v3_its.h +++ b/xen/include/asm-arm/gic_v3_its.h @@ -160,6 +160,12 @@ void vgic_v3_its_free_domain(struct domain *d); int vgic_v3_its_init_virtual(struct domain *d, paddr_t guest_addr, unsigned int devid_bits, unsigned int intid_bits); +/* Given a list of ITSes, create the appropriate DT nodes for a domain. */ +int gicv3_its_make_dt_nodes(struct list_head *its_list, + const struct domain *d, + const struct dt_device_node *gic, + void *fdt); + /* * Map a device on the host by allocating an ITT on the host (ITS). * "nr_event" specifies how many events (interrupts) this device will need. @@ -235,8 +241,6 @@ static inline void vgic_v3_its_free_domain(struct domain *d) { } -#endif /* CONFIG_HAS_ITS */ - static inline int gicv3_its_make_dt_nodes(struct list_head *its_list, const struct domain *d, const struct dt_device_node *gic, @@ -245,6 +249,8 @@ static inline int gicv3_its_make_dt_nodes(struct list_head *its_list, return 0; } +#endif /* CONFIG_HAS_ITS */ + #endif /* -- 2.9.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |