[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v5] xen/char: implement suspend/resume calls for SCIF driver


  • To: Mykola Kvach <xakep.amatop@xxxxxxxxx>
  • From: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • Date: Mon, 3 Nov 2025 09:21:01 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gmail.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EzpI4N0VoaKoDwPnKdSNJrSZNt2XpjQzIv/AeIVZz5c=; b=ITod/Sr08aH8E8yAdJMu5yy9AtMiFoqzw6fIbNQbOznBu3nwceuJwSdftVB+4bTQ5EZTf5gzMfthk2U3OSiC7Ver42rVaBqcuOz/1606rcV1EnBfxHxrRO6erAyd6HVpR0KBAmtr+yPGEupgDvaPBl7hEEaVfVPWOmX9sTn1LOCmLVWSoSvt3Y7SuKYYdCOKpKgbzmCbZtPtyPM5ePFBxOqw6cecdx2peq6VNvbt0X/cZXjw07ug3UqcFvZqg66LO9tkB9GDX5IBDxH48YPy6wBTBACykz2O7OD4c9yjqRlps9Wfk6ujpmFRUUFd3/KXe08Nm324MnccMUC2wHKQHA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CWzsFgeeeMZT+8gV0QfbnWLNyxhWodXmgYvZV87B8xH4v7G/oAK8CTEtojz78uaZl7hFcEEO+dCR+kn/ayvrGC4PnolL03LwXKiZmRQfZUn443umyGGeJrKaiEEms3ahb14Y7SYdzllLFLJbfmZ2sitNXEYZBljxa6PgI8HqjdfsAwQkUB+uEdjyf/wGSk7S11AHFIiqXrlZ/wEr9nVJb4BG2ecEN+NUL668I95x+fWNDjBYtOagUvUaf/MUoN80iQIGFUnN9r886AFd7PVhmvhL0oSjNo84DMjerGallWFdUV21hi6GiC6/S8y7/kkENoFCJHyoc+nvvjEwfUJRJw==
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>, Mykola Kvach <mykola_kvach@xxxxxxxx>
  • Delivery-date: Mon, 03 Nov 2025 08:21:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 03/11/2025 08:30, Mykola Kvach wrote:
> Hi Michal,
> 
> Thank you for the fast response and the review.
> 
> On Thu, Oct 30, 2025 at 10:41 AM Orzel, Michal <michal.orzel@xxxxxxx> wrote:
>>
>>
>>
>> On 30/10/2025 08:59, Mykola Kvach wrote:
>>> @Stefano Stabellini @Michal Orzel @Julien Grall @Bertrand Marquis ping
>>>
>>> On Thu, Aug 7, 2025 at 8:16 AM Mykola Kvach <xakep.amatop@xxxxxxxxx> wrote:
>>>>
>>>> From: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
>>>>
>>>> Implement suspend and resume callbacks for the SCIF UART driver,
>>>> enabled when CONFIG_SYSTEM_SUSPEND is set. This allows proper
>>>> handling of UART state across system suspend/resume cycles.
>>>>
>>>> Tested on Renesas R-Car H3 Starter Kit.
>>>>
>>>> Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
>>>> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
>>>> Signed-off-by: Mykola Kvach <mykola_kvach@xxxxxxxx>
>>>> ---
>>>> In patch v5, there are no changes at all;
>>>> it was done just to trigger a review.
>>>>
>>>> In patch v4, enhance commit message, no functional changes
>>>>
>>>> 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(-)
>>>>
>>>> diff --git a/xen/drivers/char/scif-uart.c b/xen/drivers/char/scif-uart.c
>>>> index 757793ca45..888821a3b8 100644
>>>> --- a/xen/drivers/char/scif-uart.c
>>>> +++ b/xen/drivers/char/scif-uart.c
>>>> @@ -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);
>> This will also call scif_uart_disable() that was already invoked during 
>> suspend.
>> Why do we need to re-disable it when resuming?
> 
> Thanks for the question.
> 
> Yes, resume calls scif_uart_init_preirq(), which in turn calls
> scif_uart_disable(). This is intentional.
> 
> - While Xen is suspended, EL3 firmware (e.g. TF-A) may use an early
>   or runtime console and reconfigure the SCIF, including enabling
>   TX. Re-disabling gives a quiescent baseline.
> 
> - PSCI does not guarantee device state across SYSTEM_SUSPEND; device
>   preconditions are outside PSCI's scope. We cannot rely on the state
>   Xen left before suspend.
> 
> - We reuse scif_uart_init_preirq() on resume to keep a single,
>   well-tested initialization path identical to cold boot. This avoids
>   split logic and keeps behavior consistent.
> 
> - The extra disable is idempotent and cheap (FIFO/status clear), while
>   preventing spurious data on bring-up.
> 
> I can add an inline comment to make this explicit:
> 
> /* On resume, EL3/firmware may have touched SCIF (early/runtime
>  * console). Disable again to start from a clean, quiescent state
>  * before reinit; reuse scif_uart_init_preirq() to keep the cold-boot
>  * sequence.
>  */
No need, your explanation makes sense. Thanks.

~Michal




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.