[PATCH v2 1/2] xen: Introduce system suspend config option

Mykola Kvach posted 2 patches 6 months, 3 weeks ago
There is a newer version of this series
[PATCH v2 1/2] xen: Introduce system suspend config option
Posted by Mykola Kvach 6 months, 3 weeks ago
From: Mykola Kvach <mykola_kvach@epam.com>

This option enables the system suspend support. This is the mechanism that
allows the system to be suspended to RAM and later resumed.

The patch introduces three options:
- HAS_SYSTEM_SUSPEND: indicates suspend support is available on the platform.
- SYSTEM_SUSPEND_ALWAYS_ON: used for architectures where suspend must always
  be enabled.
- SYSTEM_SUSPEND: user-facing option to enable/disable suspend if supported.
  Defaults to enabled if SYSTEM_SUSPEND_ALWAYS_ON is set and depends on
  HAS_SYSTEM_SUSPEND.

On x86, both HAS_SYSTEM_SUSPEND and SYSTEM_SUSPEND_ALWAYS_ON are selected by
default, making suspend support always enabled. The options are designed to
be easily extensible to other architectures (e.g., PPC, RISC-V) as future
support is added.

Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
---
Discussion on adding the SYSTEM_SUSPEND config can be found here:
https://lists.xenproject.org/archives/html/xen-devel/2025-03/msg00169.html
---
 xen/arch/x86/Kconfig |  2 ++
 xen/common/Kconfig   | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig
index 7afe879710..f7c026b0aa 100644
--- a/xen/arch/x86/Kconfig
+++ b/xen/arch/x86/Kconfig
@@ -33,6 +33,8 @@ config X86
 	select HAS_VMAP
 	select HAS_VPCI if HVM
 	select NEEDS_LIBELF
+	select HAS_SYSTEM_SUSPEND
+	select SYSTEM_SUSPEND_ALWAYS_ON
 
 config ARCH_DEFCONFIG
 	string
diff --git a/xen/common/Kconfig b/xen/common/Kconfig
index 3d66d09397..3886a77e46 100644
--- a/xen/common/Kconfig
+++ b/xen/common/Kconfig
@@ -579,4 +579,21 @@ config BUDDY_ALLOCATOR_SIZE
 	  Amount of memory reserved for the buddy allocator to serve Xen heap,
 	  working alongside the colored one.
 
+config HAS_SYSTEM_SUSPEND
+	bool
+
+config SYSTEM_SUSPEND_ALWAYS_ON
+	bool
+
+config SYSTEM_SUSPEND
+	bool "System suspend support"
+	depends on HAS_SYSTEM_SUSPEND
+	default y if SYSTEM_SUSPEND_ALWAYS_ON
+	help
+	  This option enables the system suspend support. This is the
+	  mechanism that allows the system to be suspended to RAM and
+	  later resumed.
+
+	  If unsure, say N.
+
 endmenu
-- 
2.48.1
Re: [PATCH v2 1/2] xen: Introduce system suspend config option
Posted by Jan Beulich 6 months, 2 weeks ago
On 28.05.2025 10:05, Mykola Kvach wrote:
> --- a/xen/arch/x86/Kconfig
> +++ b/xen/arch/x86/Kconfig
> @@ -33,6 +33,8 @@ config X86
>  	select HAS_VMAP
>  	select HAS_VPCI if HVM
>  	select NEEDS_LIBELF
> +	select HAS_SYSTEM_SUSPEND
> +	select SYSTEM_SUSPEND_ALWAYS_ON

To avoid other architectures potentially also needing to select both, how about
moving the former one ...

> --- a/xen/common/Kconfig
> +++ b/xen/common/Kconfig
> @@ -579,4 +579,21 @@ config BUDDY_ALLOCATOR_SIZE
>  	  Amount of memory reserved for the buddy allocator to serve Xen heap,
>  	  working alongside the colored one.
>  
> +config HAS_SYSTEM_SUSPEND
> +	bool
> +
> +config SYSTEM_SUSPEND_ALWAYS_ON
> +	bool

... here?

> +config SYSTEM_SUSPEND
> +	bool "System suspend support"
> +	depends on HAS_SYSTEM_SUSPEND
> +	default y if SYSTEM_SUSPEND_ALWAYS_ON

Hmm, this way "always on" isn't achieved. Someone can still turn it off, likely
causing the build to fail (until it is properly made an optional feature). You
also need to make the prompt invisible (by attaching "if SYSTEM_SUSPEND_ALWAYS_ON").

Also the default line could be shorter as "default SYSTEM_SUSPEND_ALWAYS_ON";
aiui with modern kconfig there's no difference anymore between the two.

Jan