From 4a28169c87ec7c59af887056850000340b45462d Mon Sep 17 00:00:00 2001 From: Oleksii Moisieiev Date: Mon, 23 Sep 2024 11:36:11 +0300 Subject: [PATCH] xen: domain_build: Integration of the SCMI mediator to Domain-0 Integration of the SCMI-Mediator feature to the Domain-0 construction process. It includes shared memory node creation and mapping with phandle update on the scmi node. Signed-off-by: Oleksii Moisieiev --- xen/arch/arm/domain_build.c | 27 ++++++++++++++++++++++++++- xen/drivers/passthrough/device_tree.c | 5 +++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 64737600fa57..57dddcc8122c 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -38,6 +38,7 @@ #include #include #include +#include #include static unsigned int __initdata opt_dom0_max_vcpus; @@ -1627,7 +1628,7 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo, DT_MATCH_TYPE("memory"), /* The memory mapped timer is not supported by Xen. */ DT_MATCH_COMPATIBLE("arm,armv7-timer-mem"), - /* SCPI shared memory is handled by Xen */ + /* SCMI shared memory is handled by Xen */ DT_MATCH_COMPATIBLE("arm,scmi-shmem"), { /* sentinel */ }, }; @@ -1643,6 +1644,13 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo, DT_MATCH_PATH("/hypervisor"), { /* sentinel */ }, }; +#ifdef CONFIG_SCMI_SMC + static const struct dt_device_match scmi_matches[] __initconst = + { + DT_MATCH_PATH("/firmware/scmi"), + { /* sentinel */ }, + }; +#endif /* CONFIG_SCMI_SMC */ struct dt_device_node *child; int res, i, nirq, irq_id; const char *name; @@ -1756,6 +1764,10 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo, evtchn_allocate(d); #ifdef CONFIG_SCMI_SMC + res = scmi_dt_make_shmem_node(kinfo); + if ( res ) + return res; + res = mem_permit_access(kinfo->d, kinfo->d->arch.sci_channel.paddr, 0x1000); if ( res ) @@ -1799,6 +1811,15 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo, return res; } +#ifdef CONFIG_SCMI_SMC + if ( dt_match_node(scmi_matches, node) ) + { + res = scmi_dt_set_phandle(kinfo, dt_node_full_name(node)); + if ( res ) + return res; + } +#endif + res = fdt_end_node(kinfo->fdt); return res; @@ -1814,6 +1835,8 @@ static int __init prepare_dtb_hwdom(struct domain *d, struct kernel_info *kinfo) ASSERT(dt_host && (dt_host->sibling == NULL)); kinfo->phandle_gic = dt_interrupt_controller->phandle; + kinfo->phandle_sci_shmem = GUEST_PHANDLE_SCMI; + fdt = device_tree_flattened; new_size = fdt_totalsize(fdt) + DOM0_FDT_EXTRA_SIZE; @@ -2112,9 +2135,11 @@ static int __init construct_dom0(struct domain *d) if ( rc < 0 ) return rc; +#if CONFIG_ARM_SCI rc = sci_domain_init(d, sci_get_type(), NULL); if ( rc < 0 ) return rc; +#endif if ( acpi_disabled ) { diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthrough/device_tree.c index 075fb25a3706..ace66b86296b 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -15,6 +15,7 @@ * GNU General Public License for more details. */ +#include #include #include #include @@ -318,6 +319,10 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, struct domain *d, break; } + ret = ac_assign_dt_device(dev, d); + if ( ret < 0 ) + return ret; + ret = iommu_assign_dt_device(d, dev); if ( ret )