Skip to contentSkip to conversation

xen/arm: Add support for S32CC platforms and LINFlexD UART

PATCH In review Andrei Cherechesu (OSS) 2 participants 10 messages Dec 19, 2024 – Dec 20, 2024

lore
Share & tools
lore
#0 lore raw

v4 cover xen/arm: Add support for S32CC platforms and LINFlexD UART

From: Andrei Cherechesu <[email protected]>

Targeting: Xen 4.20
This v4 version of this patch series finishes the work left to support NXP S32G3 Processors [0], part of the NXP S32CC Family. The LINFlexD UART support patches have been merged in v2. Platforms using S32G3 Processors are not affected by the TLBI by VA erratum (discussed in v2), and are security supported without a workaround needed in Xen or guests. The workaround needed for S32G2 [1] / S32R45 [2] will be addressed in future series.

The 1st patch introduces a generic mechanism for forwarding SCMI over SMC calls to firmware running at EL3, selected via CONFIG_SCMI_SMC. The 2nd patch refactors the SiP SMC handling in vSMC mechanism, to rely firstly on platform_smc() if implemented, then on the previously introduced generic SCMI handling/forwarding mechanism.

The 3rd patch adds S32G3 platform config to enable the required drivers for S32G3-based platforms.

The 4th, 5th and 6th patches modify the CHANGELOG.md, SUPPORT.md and MAINTAINERS files, respectively, to add mentions about LINFlexD UART support, S32G3 Processors support, and the new SCMI-SMC layer introduced.

[0] https://www.nxp.com/products/S32G3
[1] https://www.nxp.com/products/S32G2
[2] https://www.nxp.com/products/S32R45

v3->v4:
- SCMI-SMC handling layer (Patch [v4,1/6]):
- Changed license for scmi-smc.c and scmi-smc.h to GPLv2-only
- Renamed scmi_support bool variable to scmi_enabled
- Dropped scmi_is_enabled() public function. Driver's internal state is now managed internally and based on scmi_enabled var. The public stub scmi_handle_smc() checks first scmi_enabled, instead of letting callers do this work.
- Dropped include statement for <asm/regs.h>, replaced with forward declaration for struct cpu_user_regs
- Addressed indentation issue for err label
- Changed the gprintk from scmi_handle_smc() to gdprintk, and dropped redundant info in the print statement.
- Handling SiP as SCMI SMC (Patch [v4,2/6]):
- Dropped usage of scmi_is_enabled() since SCMI-SMC driver state is now managed internally

v2->v3:
- linflex-uart (Patch [v2,1/8] and [v2,2/8], now dropped):
- Patches merged in v2, no longer re-submitted
- SCMI-SMC handling layer (Patch [v2,3/8], now [v3,1/6]):
- Changed occurrences of calls coming from "Dom0", to "hwdom" or "hardware domain"
- Made initialization part of initcall chain instead of presmp_initcall
- Changed occurrences related to "Dom0 DT", to "Host DT"
- Made scmi_support and scmi_smc_id variables __ro_after_init
- Used current->domain to print domain ID (with %pd formatter)
- Dropped usage of local string var smc_id_prop to store "arm,smc-id"
- Added usage of XENLOG_* levels to all prints
- Changed print in scmi_check_smccc_ver() to XENLOG_WARNING
- If scmi_check_smccc_ver() fails, initialization fails silently (only printing a warning regarding no SMCCC support) since it's optional
- Made scmi_is_valid_smc_id() private to the driver and used it in scmi_handle_smc() instead of requiring usage by its callers
- Created a 'firmware' folder in xen/arch/arm, to store the SCMI related code, and moved the SCMI-SMC layer implementation there
- Handling SiP as SCMI SMC (Patch [v2,4/8] now [v3,2/6]):
- Dropped implementation-specific details in commit message and code comments
- S32G3 platform config (Patch [v2,5/8] now [v3,3/6]):
- As motivated at the beginning of this cover letter, changed the config name and description from S32CC to S32G3
- Dropped the s32cc.c dummy platform code and the CONFIG_S32CC_PLATFORM used to enable its compilation
- Dropped Stefano's "Reviewed-by", since patch had non-trivial changes. Please re-approve.
- CHANGELOG.md (Patch [v2,6/8] now [v3,4/6]):
- Changed 'dom0' to 'hwdom'
- Changed S32CC to S32G3, as motivated at the beginning of the cover letter
- Rephrased to drop the 'Add' word since the entries are already part of the 'Added' category
- Dropped Stefano's and Oleksii's "Acked-by", since patch had non-trivial changes. Please re-approve.
- SUPPORT.md (Patch [v2,7/8] now [v3,5/6]):
- Changed 'dom0' to 'hwdom'
- Changed 'Dom0 DT' to 'Host DT'
- MAINTAINERS (Patch [v2,8/8] now [v3,6/6]):
- Dropped linflex-uart.c driver from ARM Architecture list
- Dropped s32cc.c platform file since it's been dropped from Patch [v3,3/6]
- Changed S32CC to S32G3, as motivated at the beginning of the cover letter
- Dropped Stefano's "Acked-by", since patch had non-trivial changes. Please re-approve.

v1->v2:
- linflex-uart:
- Addressed coding style comments from Julien:
- spaces vs. tabs
- indentation
- license issue
- comments format
- code reusage
- misplaced loop exit
- Made the pointer to struct linflex_uart const in most functions since it's not modified
- Added support for customizable baud rate through console options, parsing what Xen gets in its bootargs. other parameters following <baud> are discarded for the moment.
- SCMI SMC handling:
- Added a generic scmi-smc layer (enabled by CONFIG_SCMI_SMC) to enable forwarding SCMI requests over SMC to EL3 FW if issued by Dom0. If the SCMI firmware node is not found in Dom0's DT during initialization, it fails silently as it's not mandatory.
- Changed the handling for SiP SMCs in vsmc.c to firstly try the platform_smc() callback if implemented, then try to handle the SiP SMC as SCMI if enabled and SMC ID matches.
- S32CC Platform support:
- Added dependency on CONFIG_SCMI_SMC
- Removed the S32CC platform-specific forwarding to EL3 mechanism.
- Dropped unused headers
- CHANGELOG.md:
- Added mentions about S32CC support and SCMI-SMC layer.
- SUPPORT.md:
- Added SCMI over SMC forwarding to EL3 feature for Arm as supported.
- MAINTAINERS:
- Added myself as maintainer for S32CC platforms and NXP S32 Linux Team as reviewer list.

Andrei Cherechesu (6):
xen/arm: firmware: Add SCMI over SMC calls handling layer xen/arm: vsmc: Enable handling SiP-owned SCMI SMC calls xen/arm: platforms: Add NXP S32G3 Processors config CHANGELOG.md: Add NXP S32G3 and SCMI-SMC layer support mentions SUPPORT.md: Describe SCMI-SMC layer feature
MAINTAINERS: Add myself as maintainer for NXP S32G3

 CHANGELOG.md                                 |   3 +
 MAINTAINERS                                  |   6 +
 SUPPORT.md                                   |   8 +
 xen/arch/arm/Kconfig                         |   2 +
 xen/arch/arm/Makefile                        |   1 +
 xen/arch/arm/firmware/Kconfig                |  13 ++
 xen/arch/arm/firmware/Makefile               |   1 +
 xen/arch/arm/firmware/scmi-smc.c             | 162 +++++++++++++++++++
 xen/arch/arm/include/asm/firmware/scmi-smc.h |  41 +++++
 xen/arch/arm/platforms/Kconfig               |   8 +
 xen/arch/arm/vsmc.c                          |  13 +-
 11 files changed, 257 insertions(+), 1 deletion(-)
 create mode 100644 xen/arch/arm/firmware/Kconfig
 create mode 100644 xen/arch/arm/firmware/Makefile
 create mode 100644 xen/arch/arm/firmware/scmi-smc.c
 create mode 100644 xen/arch/arm/include/asm/firmware/scmi-smc.h
Signature · 1 line
2.45.2
#1 lore raw

PATCH v4 1/6 xen/arm: firmware: Add SCMI over SMC calls handling layer

From: Andrei Cherechesu <[email protected]>

Introduce the SCMI-SMC layer to have some basic degree of awareness about SCMI calls that are based on the ARM System Control and Management Interface (SCMI) specification (DEN0056E).

The SCMI specification includes various protocols for managing system-level resources, such as: clocks, pins, reset, system power, power domains, performance domains, etc. The clients are named "SCMI agents" and the server is named "SCMI platform".

Only support the shared-memory based transport with SMCs as the doorbell mechanism for notifying the platform. Also, this implementation only handles the "arm,scmi-smc" compatible, requiring the following properties:
- "arm,smc-id" (unique SMC ID)
- "shmem" (one or more phandles pointing to shmem zones for each channel)

The initialization is done as initcall, since we need SMCs, and PSCI should already probe EL3 FW for SMCCC support. If no "arm,scmi-smc" compatible node is found in the host DT, the initialization fails silently, as it's not mandatory. Otherwise, we get the 'arm,smc-id' DT property from the node, to know the SCMI SMC ID we handle. The 'shmem' memory ranges are not validated, as the SMC calls are only passed through to EL3 FW if coming from the hardware domain.

Create a new 'firmware' folder to keep the SCMI code separate from the generic ARM code.

---
 xen/arch/arm/Kconfig                         |   2 +
 xen/arch/arm/Makefile                        |   1 +
 xen/arch/arm/firmware/Kconfig                |  13 ++
 xen/arch/arm/firmware/Makefile               |   1 +
 xen/arch/arm/firmware/scmi-smc.c             | 162 +++++++++++++++++++
 xen/arch/arm/include/asm/firmware/scmi-smc.h |  41 +++++
 6 files changed, 220 insertions(+)
 create mode 100644 xen/arch/arm/firmware/Kconfig
 create mode 100644 xen/arch/arm/firmware/Makefile
 create mode 100644 xen/arch/arm/firmware/scmi-smc.c
 create mode 100644 xen/arch/arm/include/asm/firmware/scmi-smc.h
xen/arch/arm/Kconfig +2 -0
index 604aba4996..23dc7162a7 100644
@@ -271,6 +271,8 @@ config PARTIAL_EMULATION
 	  not been emulated to their complete functionality. Enabling this might
 	  result in unwanted/non-spec compliant behavior.
 
+source "arch/arm/firmware/Kconfig"
+
 endmenu
 
 menu "ARM errata workaround via the alternative framework"
xen/arch/arm/Makefile +1 -0
index e4ad1ce851..8c696c2011 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_HAS_PCI) += pci/
 ifneq ($(CONFIG_NO_PLAT),y)
 obj-y += platforms/
 endif
+obj-y += firmware/
 obj-$(CONFIG_TEE) += tee/
 obj-$(CONFIG_HAS_VPCI) += vpci.o
 
xen/arch/arm/firmware/Kconfig new file +13 -0
new file mode 100644
index 0000000000..817da745fd
@@ -0,0 +1,13 @@
+menu "Firmware Drivers"
+
+config SCMI_SMC
+	bool "Forward SCMI over SMC calls from hwdom to EL3 firmware"
+	default y
+	help
+	  This option enables basic awareness for SCMI calls using SMC as
+	  doorbell mechanism and Shared Memory for transport ("arm,scmi-smc"
+	  compatible only). The value of "arm,smc-id" DT property from SCMI
+	  firmware node is used to trap and forward corresponding SCMI SMCs
+	  to firmware running at EL3, for calls coming from the hardware domain.
+
+endmenu
xen/arch/arm/firmware/Makefile new file +1 -0
new file mode 100644
index 0000000000..a5e4542666
@@ -0,0 +1 @@
+obj-$(CONFIG_SCMI_SMC) += scmi-smc.o
xen/arch/arm/firmware/scmi-smc.c new file +162 -0

162 lines not on this page · raw message

xen/arch/arm/include/asm/firmware/scmi-smc.h new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
2.45.2
Acked-by on v4 1/6
#2 lore raw

Re: [PATCH v4 1/6] xen/arm: firmware: Add SCMI over SMC calls handling layer

Quoted 30 lines · Andrei Cherechesu (OSS)

From: Andrei Cherechesu <[email protected]>

Introduce the SCMI-SMC layer to have some basic degree of awareness about SCMI calls that are based on the ARM System Control and Management Interface (SCMI) specification (DEN0056E).

The SCMI specification includes various protocols for managing system-level resources, such as: clocks, pins, reset, system power, power domains, performance domains, etc. The clients are named "SCMI agents" and the server is named "SCMI platform".

Only support the shared-memory based transport with SMCs as the doorbell mechanism for notifying the platform. Also, this implementation only handles the "arm,scmi-smc" compatible, requiring the following properties:
- "arm,smc-id" (unique SMC ID)
- "shmem" (one or more phandles pointing to shmem zones for each channel)

The initialization is done as initcall, since we need SMCs, and PSCI should already probe EL3 FW for SMCCC support. If no "arm,scmi-smc" compatible node is found in the host DT, the initialization fails silently, as it's not mandatory. Otherwise, we get the 'arm,smc-id' DT property from the node, to know the SCMI SMC ID we handle. The 'shmem' memory ranges are not validated, as the SMC calls are only passed through to EL3 FW if coming from the hardware domain.

Quoted 5 lines

Create a new 'firmware' folder to keep the SCMI code separate from the generic ARM code.

NIT for the future. If there are changes in-between the revisions, in general you should drop the Rb/Ab tags. Here you incorporated my feedback, so:

The series is ready to go in. I'll commit it today or tomorrow as I'm waiting for staging to become "green" again. Thanks.

~Michal

#3 lore raw

PATCH v4 2/6 xen/arm: vsmc: Enable handling SiP-owned SCMI SMC calls

In reply to Andrei Cherechesu (OSS)

From: Andrei Cherechesu <[email protected]>

Change the handling of SiP SMC calls to be more generic, instead of directly relying on the platform_smc() callback implementation.

Try to handle the SiP SMC first through the platform_smc() callback (if implemented). Otherwise, try to handle it as SCMI message.

---
 xen/arch/arm/vsmc.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
xen/arch/arm/vsmc.c +12 -1
index f679cced7f..62d8117a12 100644
@@ -20,6 +20,7 @@
 #include <asm/traps.h>
 #include <asm/vpsci.h>
 #include <asm/platform.h>
+#include <asm/firmware/scmi-smc.h>
 
 /* Number of functions currently supported by Hypervisor Service. */
 #define XEN_SMCCC_FUNCTION_COUNT 3
@@ -224,6 +225,16 @@ static bool handle_sssc(struct cpu_user_regs *regs)
     }
 }
 
+/* Secure Calls defined by the Silicon Provider (SiP) */
+static bool handle_sip(struct cpu_user_regs *regs)
+{
+    /* Firstly, let each platform define custom handling for these SMCs */
+    if ( platform_smc(regs) )
+        return true;
+
+    return scmi_handle_smc(regs);
+}
+
 /*
  * vsmccc_handle_call() - handle SMC/HVC call according to ARM SMCCC.
  * returns true if that was valid SMCCC call (even if function number
@@ -288,7 +299,7 @@ static bool vsmccc_handle_call(struct cpu_user_regs *regs)
             handled = handle_sssc(regs);
             break;
         case ARM_SMCCC_OWNER_SIP:
-            handled = platform_smc(regs);
+            handled = handle_sip(regs);
             break;
         case ARM_SMCCC_OWNER_TRUSTED_APP ... ARM_SMCCC_OWNER_TRUSTED_APP_END:
         case ARM_SMCCC_OWNER_TRUSTED_OS ... ARM_SMCCC_OWNER_TRUSTED_OS_END:
Signature · 1 line
2.45.2
#4 lore raw

PATCH v4 3/6 xen/arm: platforms: Add NXP S32G3 Processors config

In reply to Andrei Cherechesu (OSS)

From: Andrei Cherechesu <[email protected]>

Platforms based on NXP S32G3 processors use the NXP LINFlexD UART driver for console by default, and rely on Dom0 having access to SCMI services for system-level resources from firmware at EL3.

---
 xen/arch/arm/platforms/Kconfig | 8 ++++++++
 1 file changed, 8 insertions(+)
xen/arch/arm/platforms/Kconfig +8 -0
index 02322c259c..6dbf6ec87b 100644
@@ -37,6 +37,14 @@ config MPSOC
 	help
 	Enable all the required drivers for Xilinx Ultrascale+ MPSoC
 
+config S32G3
+	bool "NXP S32G3 Processors support"
+	depends on ARM_64
+	select HAS_LINFLEX
+	select SCMI_SMC
+	help
+	Enable all the required drivers for NXP S32G3 Processors Family
+
 config NO_PLAT
 	bool "No Platforms"
 	help
Signature · 1 line
2.45.2
#5 lore raw

PATCH v4 4/6 CHANGELOG.md: Add NXP S32G3 and SCMI-SMC layer support mentions

In reply to Andrei Cherechesu (OSS)

From: Andrei Cherechesu <[email protected]>

---
 CHANGELOG.md | 3 +++
 1 file changed, 3 insertions(+)
CHANGELOG.md +3 -0
index 15f681459f..bda43b1efb 100644
@@ -16,6 +16,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
 ### Added
  - On Arm:
    - Experimental support for Armv8-R.
+   - Support for NXP S32G3 Processors Family and NXP LINFlexD UART driver.
+   - Basic handling for SCMI requests over SMC using Shared Memory, by allowing
+     forwarding the calls to EL3 FW if coming from hwdom.
  - On x86:
    - xl suspend/resume subcommands.
 
Signature · 1 line
2.45.2
#6 lore raw

PATCH v4 5/6 SUPPORT.md: Describe SCMI-SMC layer feature

In reply to Andrei Cherechesu (OSS)

From: Andrei Cherechesu <[email protected]>

Describe the layer which enables SCMI over SMC calls forwarding to EL3 FW if issued by the Hardware domain. If the SCMI firmware node is not found in the Host DT during initialization, it fails silently as it's not mandatory.

The SCMI SMCs trapping at EL2 now lets hwdom perform SCMI ops for interacting with system-level resources almost as if it would be running natively.

---
 SUPPORT.md | 8 ++++++++
 1 file changed, 8 insertions(+)
SUPPORT.md +8 -0
index 82239d0294..1f7867bd32 100644
@@ -928,6 +928,14 @@ Add/Remove device tree nodes using a device tree overlay binary (.dtbo).
 
     Status: Tech Preview
 
+### Arm: SCMI over SMC calls forwarding to EL3 Firmware
+
+Enable SCMI calls using SMC as doorbell mechanism and Shared Memory for
+transport ("arm,scmi-smc" compatible only) to reach EL3 Firmware if issued
+by hwdom. Some platforms use SCMI for access to system-level resources.
+
+    Status: Supported
+
 ## Virtual Hardware, QEMU
 
 This section describes supported devices available in HVM mode using a
Signature · 1 line
2.45.2
#7 lore raw

PATCH v4 6/6 MAINTAINERS: Add myself as maintainer for NXP S32G3

In reply to Andrei Cherechesu (OSS)

From: Andrei Cherechesu <[email protected]>

Add myself as maintainer for NXP S32G3 SoCs Family, and the S32 Linux Team as relevant reviewers list.

---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
index 34ad49bc39..392f780f76 100644
@@ -426,6 +426,12 @@ L:	[email protected]
 T:	git https://xenbits.xenproject.org/git-http/mini-os.git
 F:	config/MiniOS.mk
 
+NXP S32G3 PROCESSORS FAMILY SUPPORT
+M:	Andrei Cherechesu <[email protected]>
+L:	NXP S32 Linux Team <[email protected]>
+F:	xen/arch/arm/include/asm/linflex-uart.h
+F:	xen/drivers/char/linflex-uart.c
+
 OCAML TOOLS
 M:	Christian Lindig <[email protected]>
 M:	David Scott <[email protected]>
Signature · 1 line
2.45.2
#8 lore raw
In reply to Andrei Cherechesu (OSS)
Quoted 22 lines · Andrei Cherechesu (OSS)

From: Andrei Cherechesu <[email protected]>

Targeting: Xen 4.20
This v4 version of this patch series finishes the work left to support NXP S32G3 Processors [0], part of the NXP S32CC Family. The LINFlexD UART support patches have been merged in v2. Platforms using S32G3 Processors are not affected by the TLBI by VA erratum (discussed in v2), and are security supported without a workaround needed in Xen or guests. The workaround needed for S32G2 [1] / S32R45 [2] will be addressed in future series.

The 1st patch introduces a generic mechanism for forwarding SCMI over SMC calls to firmware running at EL3, selected via CONFIG_SCMI_SMC. The 2nd patch refactors the SiP SMC handling in vSMC mechanism, to rely firstly on platform_smc() if implemented, then on the previously introduced generic SCMI handling/forwarding mechanism.

The 3rd patch adds S32G3 platform config to enable the required drivers for S32G3-based platforms.

Quoted 9 lines

The 4th, 5th and 6th patches modify the CHANGELOG.md, SUPPORT.md and MAINTAINERS files, respectively, to add mentions about LINFlexD UART support, S32G3 Processors support, and the new SCMI-SMC layer introduced.

[0] https://www.nxp.com/products/S32G3
[1] https://www.nxp.com/products/S32G2
[2] https://www.nxp.com/products/S32R45

The series is now committed. Thanks.

~Michal

#9 lore raw

Hi,

Quoted 28 lines · Michal Orzel
Quoted 26 lines · Andrei Cherechesu (OSS)

From: Andrei Cherechesu <[email protected]>

Targeting: Xen 4.20
This v4 version of this patch series finishes the work left to support NXP S32G3 Processors [0], part of the NXP S32CC Family. The LINFlexD UART support patches have been merged in v2. Platforms using S32G3 Processors are not affected by the TLBI by VA erratum (discussed in v2), and are security supported without a workaround needed in Xen or guests. The workaround needed for S32G2 [1] / S32R45 [2] will be addressed in future series.

The 1st patch introduces a generic mechanism for forwarding SCMI over SMC calls to firmware running at EL3, selected via CONFIG_SCMI_SMC. The 2nd patch refactors the SiP SMC handling in vSMC mechanism, to rely firstly on platform_smc() if implemented, then on the previously introduced generic SCMI handling/forwarding mechanism.

The 3rd patch adds S32G3 platform config to enable the required drivers for S32G3-based platforms.

The 4th, 5th and 6th patches modify the CHANGELOG.md, SUPPORT.md and MAINTAINERS files, respectively, to add mentions about LINFlexD UART support, S32G3 Processors support, and the new SCMI-SMC layer introduced.

Quoted 7 lines
Quoted 4 lines

[0] https://www.nxp.com/products/S32G3
[1] https://www.nxp.com/products/S32G2
[2] https://www.nxp.com/products/S32R45

The series is now committed. Thanks.

~Michal

Thank you too, Michal, for all the quick feedback you provided! Glad we've been able to get this in despite the busy period right before FF for you guys.

I also wanted to thank Julien, Stefano, Grygorii, Oleksii, Bertrand, Andrew and everyone else who spent time and effort on this series :)

Wish you all relaxing and happy Holidays!

Best regards,
Andrei Cherechesu

Quoted 1 line