Add CONFIG_SYSTEM_SUSPEND and SCIF UART suspend/resume handlers
v3 cover Add CONFIG_SYSTEM_SUSPEND and SCIF UART suspend/resume handlers
From: Mykola Kvach <[email protected]>
Hi all,
This patch series introduces CONFIG_SYSTEM_SUSPEND to Xen and implements suspend/resume handlers for the SCIF UART driver. These changes address feedback and discussions on the Xen-devel mailing list:
https://lists.xenproject.org/archives/html/xen-devel/2025-03/msg00169.html https://lists.xenproject.org/archives/html/xen-devel/2025-03/msg02188.html
I am marking this series as v2, as it is a logical continuation of the discussion linked above regarding the SCIF driver changes.
Patch 1:
Introduces the CONFIG_SYSTEM_SUSPEND infrastructure, which enables Xen to
support suspend-to-RAM functionality. It adds three new Kconfig options:
- HAS_SYSTEM_SUSPEND: Indicates whether the architecture supports suspend.
- SYSTEM_SUSPEND_ALWAYS_ON: Forces suspend support on platforms that require it (e.g., x86).
- SYSTEM_SUSPEND: The user-facing option to enable suspend support, enabled by default when SYSTEM_SUSPEND_ALWAYS_ON is set.
This approach is intended to be easily extendable to other architectures in
the future.
Patch 2:
Implements suspend/resume callbacks for the SCIF UART driver. These functions
ensure proper shutdown and reinitialization of the UART hardware across suspend/resume cycles. Their inclusion is gated by the CONFIG_SYSTEM_SUSPEND option.
The SCIF suspend/resume functionality has been tested on the Renesas R-Car H3
Starter Kit board.
Compared to v1, the main change in this version is the addition of aCONFIG_SYSTEM_SUSPEND check around the SCIF driver's suspend/resume logic.
Changes introduced in v3:
- select HAS_SYSTEM_SUSPEND from SYSTEM_SUSPEND_ALWAYS_ON
- drop selecting HAS_SYSTEM_SUSPEND from X86
- simplify default setting in SYSTEM_SUSPEND
- hide prompt of SYSTEM_SUSPEND when SYSTEM_SUSPEND_ALWAYS_ON is enabled
- move HAS_SYSTEM_SUSPEND alongside other HAS_* configs
Best regards,
Mykola Kvach
Mykyta Poturai (1):
xen: Introduce system suspend config option
Volodymyr Babchuk (1):
xen/char: implement suspend/resume calls for SCIF driver
xen/arch/x86/Kconfig | 1 + xen/common/Kconfig | 18 ++++++++++++++++ xen/drivers/char/scif-uart.c | 40 ++++++++++++++++++++++++++++++++++-- 3 files changed, 57 insertions(+), 2 deletions(-)
Signature · 1 line
2.48.1
PATCH v3 1/2 xen: Introduce system suspend config option
From: Mykyta Poturai <[email protected]>
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.
---
Changes introduced in v3:
- select HAS_SYSTEM_SUSPEND from SYSTEM_SUSPEND_ALWAYS_ON
- drop selecting HAS_SYSTEM_SUSPEND from X86
- simplify default setting in SYSTEM_SUSPEND
- hide prompt of SYSTEM_SUSPEND when SYSTEM_SUSPEND_ALWAYS_ON is enabled
- move HAS_SYSTEM_SUSPEND alongside other HAS_* configs
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 | 1 + xen/common/Kconfig | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+)
xen/arch/x86/Kconfig +1 -0
@@ -33,6 +33,7 @@ config X86 select HAS_VMAP select HAS_VPCI if HVM select NEEDS_LIBELF + select SYSTEM_SUSPEND_ALWAYS_ON config ARCH_DEFCONFIG string
xen/common/Kconfig +18 -0
@@ -122,6 +122,9 @@ config HAS_SCHED_GRANULARITY config HAS_STACK_PROTECTOR bool +config HAS_SYSTEM_SUSPEND + bool + config HAS_UBSAN bool
@@ -593,4 +596,19 @@ config BUDDY_ALLOCATOR_SIZE Amount of memory reserved for the buddy allocator to serve Xen heap, working alongside the colored one. +config SYSTEM_SUSPEND_ALWAYS_ON + bool + select HAS_SYSTEM_SUSPEND + +config SYSTEM_SUSPEND + bool "System suspend support" if !SYSTEM_SUSPEND_ALWAYS_ON + depends on HAS_SYSTEM_SUSPEND + default 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
Signature · 1 line
2.48.1
Re: [PATCH v3 1/2] xen: Introduce system suspend config option
Quoted 13 lines · Mykola Kvach
From: Mykyta Poturai <[email protected]>
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 ifSYSTEM_SUSPEND_ALWAYS_ONis set and depends onHAS_SYSTEM_SUSPEND.
Quoted 7 lines
On x86, both
HAS_SYSTEM_SUSPENDandSYSTEM_SUSPEND_ALWAYS_ONare 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 <[email protected]>Signed-off-by Mykola Kvach <[email protected]>
PATCH v3 2/2 xen/char: implement suspend/resume calls for SCIF driver
In reply to Mykola KvachFrom: Volodymyr Babchuk <[email protected]>
The changes have been tested only on the Renesas R-Car H3 Starter Kit board.
---
In patch v2, I just added a CONFIG_SYSTEM_SUSPEND check around the suspend/resume functions in the SCIF driver.
--- xen/drivers/char/scif-uart.c | 40 ++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-)
xen/drivers/char/scif-uart.c +38 -2
@@ -139,9 +139,8 @@ static void scif_uart_interrupt(int irq, void *data) } } -static void __init scif_uart_init_preirq (struct serial_port *port) +static void scif_uart_disable (struct scif_uart *uart) { -struct scif_uart *uart = port->uart;const struct port_params *params = uart->params;/*
@@ -155,6 +154,14 @@ static void __init scif_uart_init_preirq(struct serial_port *port)/* Reset TX/RX FIFOs */ scif_writew (uart,SCIF_SCFCR ,SCFCR_RFRST |SCFCR_TFRST ); +} + +static void scif_uart_init_preirq (struct serial_port *port) +{ +struct scif_uart *uart = port->uart; +const struct port_params *params = uart->params; + +scif_uart_disable (uart);/* Clear all errors and flags */ scif_readw (uart, params->status_reg);
@@ -271,6 +278,31 @@ static void scif_uart_stop_tx(struct serial_port *port)scif_writew (uart,SCIF_SCSCR ,scif_readw (uart,SCIF_SCSCR ) & ~SCSCR_TIE ); } +#ifdef CONFIG_SYSTEM_SUSPEND + +static void scif_uart_suspend (struct serial_port *port) +{ +struct scif_uart *uart = port->uart; + +scif_uart_stop_tx (port); +scif_uart_disable (uart); +} + +static void scif_uart_resume (struct serial_port *port) +{ +struct scif_uart *uart = port->uart; +const struct port_params *params = uart->params; +uint16_t ctrl; + +scif_uart_init_preirq (port); + +/* Enable TX/RX and Error Interrupts */ + ctrl =scif_readw (uart,SCIF_SCSCR ); +scif_writew (uart,SCIF_SCSCR , ctrl | params->irq_flags); +} + +#endif /* CONFIG_SYSTEM_SUSPEND */ +static struct uart_driver __read_mostly scif_uart_driver = { .init_preirq = scif_uart_init_preirq, .init_postirq = scif_uart_init_postirq,
@@ -281,6 +313,10 @@ static struct uart_driver __read_mostly scif_uart_driver = { .start_tx = scif_uart_start_tx, .stop_tx = scif_uart_stop_tx, .vuart_info = scif_vuart_info, +#ifdef CONFIG_SYSTEM_SUSPEND + .suspend = scif_uart_suspend, + .resume = scif_uart_resume, +#endif }; static const struct dt_device_match scif_uart_dt_match[] __initconst =
Signature · 1 line
2.48.1
Re: [PATCH v3 2/2] xen/char: implement suspend/resume calls for SCIF driver
Hi Mykola,
Quoted 6 lines · Mykola Kvach
CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.
From: Volodymyr Babchuk <[email protected]>
The changes have been tested only on the Renesas R-Car H3 Starter Kit board.
The commit message need to explain what the change is and why it is needed.
Also ...
Quoted 56 lines
Signed-off-by Volodymyr Babchuk <[email protected]>Signed-off-by Oleksandr Andrushchenko <[email protected]>Signed-off-by Mykola Kvach <[email protected]>---
In patch v2, I just added aCONFIG_SYSTEM_SUSPENDcheck around the suspend/resume functions in the SCIF driver.--- xen/drivers/char/scif-uart.c | 40 ++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-)xen/drivers/char/scif-uart.c +20
-2@@ -139,9 +139,8 @@ static void scif_uart_interrupt(int irq, void *data) } } -static void __init scif_uart_init_preirq (struct serial_port *port) +static void scif_uart_disable (struct scif_uart *uart) { -struct scif_uart *uart = port->uart;const struct port_params *params = uart->params;/* @@ -155,6 +154,14 @@ static void __init scif_uart_init_preirq(struct serial_port *port)/* Reset TX/RX FIFOs */ scif_writew (uart,SCIF_SCFCR ,SCFCR_RFRST |SCFCR_TFRST ); +} + +static void scif_uart_init_preirq (struct serial_port *port) +{ +struct scif_uart *uart = port->uart; +const struct port_params *params = uart->params; + +scif_uart_disable (uart);/* Clear all errors and flags */ scif_readw (uart, params->status_reg);@@ -271,6 +278,31 @@ static void scif_uart_stop_tx(struct serial_port *port)scif_writew (uart,SCIF_SCSCR ,scif_readw (uart,SCIF_SCSCR ) & ~SCSCR_TIE ); } +#ifdef CONFIG_SYSTEM_SUSPEND + +static void scif_uart_suspend (struct serial_port *port) +{ +struct scif_uart *uart = port->uart; + +scif_uart_stop_tx (port); +scif_uart_disable (uart); +} + +static void scif_uart_resume (struct serial_port *port)
xen/drivers/char/scif-uart.c static void scif_uart_stop_tx(struct serial_port *port) · line 301
Quoted 10 lines
xen/drivers/char/scif-uart.c +10
-0+{ +struct scif_uart *uart = port->uart; +const struct port_params *params = uart->params; +uint16_t ctrl; + +scif_uart_init_preirq (port); + +/* Enable TX/RX and Error Interrupts */ + ctrl =scif_readw (uart,SCIF_SCSCR ); +scif_writew (uart,SCIF_SCSCR , ctrl | params->irq_flags);
If you can give reference to a public doc which describe these registers, it will be great.
Otherwise, the changes look ok to me.
Quoted 8 lines
xen/drivers/char/scif-uart.c +4
-0+} + +#endif /* CONFIG_SYSTEM_SUSPEND */ +static struct uart_driver __read_mostly scif_uart_driver = { .init_preirq = scif_uart_init_preirq, .init_postirq = scif_uart_init_postirq,
xen/drivers/char/scif-uart.c static struct uart_driver __read_mostly scif_uart_driver = { · line 322
Quoted 10 lines
xen/drivers/char/scif-uart.c +4
-0@@ -281,6 +313,10 @@ static struct uart_driver __read_mostly scif_uart_driver = { .start_tx = scif_uart_start_tx, .stop_tx = scif_uart_stop_tx, .vuart_info = scif_vuart_info, +#ifdef CONFIG_SYSTEM_SUSPEND + .suspend = scif_uart_suspend, + .resume = scif_uart_resume, +#endif }; static const struct dt_device_match scif_uart_dt_match[] __initconst =
- Ayan
Quoted 4 lines
--
2.48.1
Re: [PATCH v3 2/2] xen/char: implement suspend/resume calls for SCIF driver
Hi Ayan
Quoted 4 lines · Ayan Kumar Halder
Hi Mykola,
On 06/06/2025 11:11, Mykola Kvach wrote:
Quoted 8 lines
Quoted 6 lines
CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.
From: Volodymyr Babchuk <[email protected]>
The changes have been tested only on the Renesas R-Car H3 Starter Kit board.
The commit message need to explain what the change is and why it is needed.
Thanks for the feedback. I thought the information from the commit message title would be enough.
I will add a few more words to clarify what the change is and why it's needed to the commit message body.
Quoted 64 lines
Also ...
Quoted 61 lines
Signed-off-by Volodymyr Babchuk <[email protected]>Signed-off-by Oleksandr Andrushchenko <[email protected]>Signed-off-by Mykola Kvach <[email protected]>---
In patch v2, I just added aCONFIG_SYSTEM_SUSPENDcheck around the suspend/resume functions in the SCIF driver.--- xen/drivers/char/scif-uart.c | 40 ++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-)xen/drivers/char/scif-uart.c +25
-2@@ -139,9 +139,8 @@ static void scif_uart_interrupt(int irq, void *data) } } -static void __init scif_uart_init_preirq (struct serial_port *port) +static void scif_uart_disable (struct scif_uart *uart) { -struct scif_uart *uart = port->uart;const struct port_params *params = uart->params;/* @@ -155,6 +154,14 @@ static void __init scif_uart_init_preirq(struct serial_port *port)/* Reset TX/RX FIFOs */ scif_writew (uart,SCIF_SCFCR ,SCFCR_RFRST |SCFCR_TFRST ); +} + +static void scif_uart_init_preirq (struct serial_port *port) +{ +struct scif_uart *uart = port->uart; +const struct port_params *params = uart->params; + +scif_uart_disable (uart);/* Clear all errors and flags */ scif_readw (uart, params->status_reg);@@ -271,6 +278,31 @@ static void scif_uart_stop_tx(struct serial_port *port)scif_writew (uart,SCIF_SCSCR ,scif_readw (uart,SCIF_SCSCR ) & ~SCSCR_TIE ); } +#ifdef CONFIG_SYSTEM_SUSPEND + +static void scif_uart_suspend (struct serial_port *port) +{ +struct scif_uart *uart = port->uart; + +scif_uart_stop_tx (port); +scif_uart_disable (uart); +} + +static void scif_uart_resume (struct serial_port *port) +{ +struct scif_uart *uart = port->uart; +const struct port_params *params = uart->params; +uint16_t ctrl; +
Quoted 8 lines
xen/drivers/char/scif-uart.c static void scif_uart_stop_tx(struct serial_port *port) · line 301
Quoted 5 lines
xen/drivers/char/scif-uart.c +5
-0+scif_uart_init_preirq (port); + +/* Enable TX/RX and Error Interrupts */ + ctrl =scif_readw (uart,SCIF_SCSCR ); +scif_writew (uart,SCIF_SCSCR , ctrl | params->irq_flags);If you can give reference to a public doc which describe these registers, it will be great.
I don't think I can share documentation for the board I used for testing this commit.
However, I searched for Linux boards that use the same driver and SCIF register set with available documentation, and I found a few boards with open documentation, for example, RZ/G1H or RZ/G1M:
Quoted 20 lines
Otherwise, the changes look ok to me.
Quoted 17 lines
xen/drivers/char/scif-uart.c +8
-0+} + +#endif /* CONFIG_SYSTEM_SUSPEND */ +static struct uart_driver __read_mostly scif_uart_driver = { .init_preirq = scif_uart_init_preirq, .init_postirq = scif_uart_init_postirq,@@ -281,6 +313,10 @@ static struct uart_driver __read_mostly scif_uart_driver = { .start_tx = scif_uart_start_tx, .stop_tx = scif_uart_stop_tx, .vuart_info = scif_vuart_info, +#ifdef CONFIG_SYSTEM_SUSPEND + .suspend = scif_uart_suspend, + .resume = scif_uart_resume, +#endif };
Quoted 6 lines
xen/drivers/char/scif-uart.c static struct uart_driver __read_mostly scif_uart_driver = { · line 322
Quoted 1 line
xen/drivers/char/scif-uart.c +0
-0static const struct dt_device_match scif_uart_dt_match[] __initconst =- Ayan
Quoted 4 lines
--
2.48.1
Best regards,
Mykola