Re: [RFC PATCH v4 1/8] xen/arm: add generic SCI subsystem
On Mon, 19 May 2025, Oleksii Moisieiev wrote: > This patch adds the basic framework for ARM SCI mediator. SCI is System > Control Interface, which is designed to redirect requests from the Domains > to ARM specific Firmware (for example SCMI). This will allow the devices, > passed-through to the different Domains, to access to the System resources > (such as clocks/resets etc) by sending requests to the firmware. > > ARM SCI subsystem allows to implement different SCI drivers to handle > specific ARM firmware interfaces (like ARM SCMI) and mediate requests > between the Domains and the Firmware. Also it allows SCI drivers to perform > proper action during Domain creation/destruction which is vital for > handling use cases like Domain reboot. > > This patch introduces new DEVICE_FIRMWARE device subclass for probing SCI > drivers basing on device tree, SCI drivers register itself with > DT_DEVICE_START/END macro. On init - the SCI drivers should register its > SCI ops with sci_register(). Only one SCI driver can be supported. > > At run-time, the following SCI API calls are introduced: > > - sci_domain_sanitise_config() called from arch_sanitise_domain_config() > - sci_domain_init() called from arch_domain_create() > - sci_relinquish_resources() called from domain_relinquish_resources() > - sci_domain_destroy() called from arch_domain_destroy() > - sci_handle_call() called from vsmccc_handle_call() > - sci_dt_handle_node() > sci_dt_finalize() called from handle_node() (Dom0 DT) > > Signed-off-by: Oleksii Moisieiev > Signed-off-by: Grygorii Strashko This patch needs a pretty major rebase. But the looks OK to me. Reviewed-by: Stefano Stabellini > --- > > Changes in v4: > - fix SPDX-License > - rename DEVICE_ARM_SCI DT device class to FIRMWARE_DEVICE > - move XEN_DOMCTL_assign_device code in separate patch > - Add documentation for SCI SCMI drivers > > MAINTAINERS | 6 + > xen/arch/arm/device.c | 5 + > xen/arch/arm/dom0less-build.c | 7 + > xen/arch/arm/domain.c | 12 +- > xen/arch/arm/domain_build.c | 8 + > xen/arch/arm/firmware/Kconfig | 8 + > xen/arch/arm/firmware/Makefile | 1 + > xen/arch/arm/firmware/sci.c | 154 ++ > xen/arch/arm/include/asm/domain.h | 5 + > xen/arch/arm/include/asm/firmware/sci.h | 200 > xen/arch/arm/vsmc.c | 3 + > xen/include/asm-generic/device.h| 1 + > xen/include/public/arch-arm.h | 4 + > 13 files changed, 413 insertions(+), 1 deletion(-) > create mode 100644 xen/arch/arm/firmware/sci.c > create mode 100644 xen/arch/arm/include/asm/firmware/sci.h > > diff --git a/MAINTAINERS b/MAINTAINERS > index c11b82eca9..f5e3c48b96 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -507,6 +507,12 @@ R: George Dunlap > S: Supported > F: xen/common/sched/ > > +SCI MEDIATORS > +M: Oleksii Moisieiev > +S: Supported > +F: xen/arch/arm/firmware/sci.c > +F: xen/arch/arm/include/asm/firmware/sci.h > + > SEABIOS UPSTREAM > M: Wei Liu > S: Supported > diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c > index 5610cddcba..bdab96a408 100644 > --- a/xen/arch/arm/device.c > +++ b/xen/arch/arm/device.c > @@ -13,6 +13,7 @@ > #include > #include > > +#include > #include > > int map_irq_to_domain(struct domain *d, unsigned int irq, > @@ -303,6 +304,10 @@ int handle_device(struct domain *d, struct > dt_device_node *dev, p2m_type_t p2mt, > return res; > } > } > + > +res = sci_assign_dt_device(d, dev); > +if ( res ) > +return res; > } > > res = map_device_irqs_to_domain(d, dev, own_device, irq_ranges); > diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c > index 49d1f14d65..a09c4c4bd7 100644 > --- a/xen/arch/arm/dom0less-build.c > +++ b/xen/arch/arm/dom0less-build.c > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -321,6 +322,10 @@ static int __init handle_passthrough_prop(struct > kernel_info *kinfo, > return -EINVAL; > } > > +res = sci_assign_dt_device(kinfo->d, node); > +if ( res ) > +return res; > + > res = map_device_irqs_to_domain(kinfo->d, node, true, NULL); > if ( res < 0 ) > return res; > @@ -970,6 +975,8 @@ void __init create_domUs(void) > if ( !llc_coloring_enabled && llc_colors_str ) > panic("'llc-colors' found, but LLC coloring is disabled\n"); > > +d_cfg.arch.arm_sci_type = XEN_DOMCTL_CONFIG_ARM_SCI_NONE; > + > /* > * The variable max_init_domid is initialized with zero, so here it's > * very important to use the pre-increment operator to call > diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c > index 3ba959f866..652aeb7a55 1
[RFC PATCH v4 1/8] xen/arm: add generic SCI subsystem
This patch adds the basic framework for ARM SCI mediator. SCI is System Control Interface, which is designed to redirect requests from the Domains to ARM specific Firmware (for example SCMI). This will allow the devices, passed-through to the different Domains, to access to the System resources (such as clocks/resets etc) by sending requests to the firmware. ARM SCI subsystem allows to implement different SCI drivers to handle specific ARM firmware interfaces (like ARM SCMI) and mediate requests between the Domains and the Firmware. Also it allows SCI drivers to perform proper action during Domain creation/destruction which is vital for handling use cases like Domain reboot. This patch introduces new DEVICE_FIRMWARE device subclass for probing SCI drivers basing on device tree, SCI drivers register itself with DT_DEVICE_START/END macro. On init - the SCI drivers should register its SCI ops with sci_register(). Only one SCI driver can be supported. At run-time, the following SCI API calls are introduced: - sci_domain_sanitise_config() called from arch_sanitise_domain_config() - sci_domain_init() called from arch_domain_create() - sci_relinquish_resources() called from domain_relinquish_resources() - sci_domain_destroy() called from arch_domain_destroy() - sci_handle_call() called from vsmccc_handle_call() - sci_dt_handle_node() sci_dt_finalize() called from handle_node() (Dom0 DT) Signed-off-by: Oleksii Moisieiev Signed-off-by: Grygorii Strashko --- Changes in v4: - fix SPDX-License - rename DEVICE_ARM_SCI DT device class to FIRMWARE_DEVICE - move XEN_DOMCTL_assign_device code in separate patch - Add documentation for SCI SCMI drivers MAINTAINERS | 6 + xen/arch/arm/device.c | 5 + xen/arch/arm/dom0less-build.c | 7 + xen/arch/arm/domain.c | 12 +- xen/arch/arm/domain_build.c | 8 + xen/arch/arm/firmware/Kconfig | 8 + xen/arch/arm/firmware/Makefile | 1 + xen/arch/arm/firmware/sci.c | 154 ++ xen/arch/arm/include/asm/domain.h | 5 + xen/arch/arm/include/asm/firmware/sci.h | 200 xen/arch/arm/vsmc.c | 3 + xen/include/asm-generic/device.h| 1 + xen/include/public/arch-arm.h | 4 + 13 files changed, 413 insertions(+), 1 deletion(-) create mode 100644 xen/arch/arm/firmware/sci.c create mode 100644 xen/arch/arm/include/asm/firmware/sci.h diff --git a/MAINTAINERS b/MAINTAINERS index c11b82eca9..f5e3c48b96 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -507,6 +507,12 @@ R: George Dunlap S: Supported F: xen/common/sched/ +SCI MEDIATORS +M: Oleksii Moisieiev +S: Supported +F: xen/arch/arm/firmware/sci.c +F: xen/arch/arm/include/asm/firmware/sci.h + SEABIOS UPSTREAM M: Wei Liu S: Supported diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c index 5610cddcba..bdab96a408 100644 --- a/xen/arch/arm/device.c +++ b/xen/arch/arm/device.c @@ -13,6 +13,7 @@ #include #include +#include #include int map_irq_to_domain(struct domain *d, unsigned int irq, @@ -303,6 +304,10 @@ int handle_device(struct domain *d, struct dt_device_node *dev, p2m_type_t p2mt, return res; } } + +res = sci_assign_dt_device(d, dev); +if ( res ) +return res; } res = map_device_irqs_to_domain(d, dev, own_device, irq_ranges); diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 49d1f14d65..a09c4c4bd7 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -321,6 +322,10 @@ static int __init handle_passthrough_prop(struct kernel_info *kinfo, return -EINVAL; } +res = sci_assign_dt_device(kinfo->d, node); +if ( res ) +return res; + res = map_device_irqs_to_domain(kinfo->d, node, true, NULL); if ( res < 0 ) return res; @@ -970,6 +975,8 @@ void __init create_domUs(void) if ( !llc_coloring_enabled && llc_colors_str ) panic("'llc-colors' found, but LLC coloring is disabled\n"); +d_cfg.arch.arm_sci_type = XEN_DOMCTL_CONFIG_ARM_SCI_NONE; + /* * The variable max_init_domid is initialized with zero, so here it's * very important to use the pre-increment operator to call diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 3ba959f866..652aeb7a55 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -694,7 +695,7 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) return -EINVAL; } -return 0; +return sci_domain_sanitise_config(config); } int arch_domain_create(struct domain *d, @@