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

RE: [PATCH v8 2/2] drivers/char: suspend handling in XHCI console driver


  • To: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Henry Wang <Henry.Wang@xxxxxxx>
  • Date: Fri, 4 Nov 2022 02:39:26 +0000
  • Accept-language: zh-CN, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=uKLhjeN6o45WTc5+DVVRmL+vTCD6wVUety8LtgAKsn4=; b=JMwm+9rpSccCwaE7NTUklSX/XzVwLd6VXYBuBZ4mm8OSR9NFghsyNKx/5AGWHH6WJ82w6JlpT+Kx3ZTasgERUiSCnMLFc5QhBOboorrvBomA0bqUfkyEBYINGUblkzcL8GTyp/YC2t25rsw0XiTANBXwZcmrdwxiarIoiIpRXtDTnDnh5jwhGvhtUMFF8WtHvPRdFyGWBGAPFXvV/UOUvk8iirXtc+7ODzTkobwsy5lT7dLmTFfHNOh4e7Q2v3gj7nGKGxCBJzY7oRot2e8sUB2GdS9ApMU2fajKZvMglAMXKeDnF5cuszStYgeiuKR+6Ano4urIDMwEKk2C0yGi8Q==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=uKLhjeN6o45WTc5+DVVRmL+vTCD6wVUety8LtgAKsn4=; b=BhvCNIYWi92knEbK5R0c+RdHbay8D3F96yi3NHJNf72JmTI91LvHdNMUUuLEFNa/lJcz/q3ZRzHjHDMWKByc8IASQeHb6Ltz7GKTKvp+GVkgbdWHCjn5x+QOEysy3xjBCCale3Nd6xyJoVkvF1/pX/M5Va28uJ8bskFWcyPLgbUpkqBdE8Jdqu0ektG93AwTZjVCIO3Rdy3M1Rq1/kaDuQdq8fpOMBEt+72W6ttHzlQxhLywSXyhc/gKMTo8NNNjhdSvej2Hpcq5fGXnfCYzpUqU3elF+Tma5yx33CGqOHpD/Bj+S6RvkFuXeirnv9sPVAWvFWKc2ayPDSjg6z2QFA==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=hPuDz7v8XI82wbDP2bNNucO3b8Px8nAjSkzyprxVkQOWgd1op1DvcmR0ZL2r0EYKK0T/4qSnDSMmYaUc6xX8EYt49zFYTHImMQa+rtld5DXMNp4FtbX8YKVgQuHlsesht5FLBBQGNISbmTd0KsG2ETdwHXAdE98Wr0qxmJizhqpUsoH/jsUF3wM6/IQtPpToMciMxT3NFYP3bv8UFGsekS2t9MYB2U2DxtNrmIOProVE4JdbdbJzX5OpoVBFjiI68A8dD2/++T8BPwSCzIaeQUO0OjqT6LZ99Z7MvGsDtcAdSpEDXXCWEQk01M/oGp5fzoXSPUdf422qnt6FZJnCRg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JF3V/OSXKNeRKTDwFM/JL4DzAYD7ovpGlx1JMrJe1iGl+skP1BXf3KhkR2eZPEhQiCyvhhHASzm3yifm6CQYL9MTc+iiBoeEHQVCnMjkx6/C1CKbAEfZjC7rieRBIO8ECu0mMignfznVQLcmnb5dSd6dU6sJAAH77Ryx1T114XJA7eFuzs1TJoFX1F5XWXewm3Ikyw/lJdCdeS9MUIoL81Ye5Khpy1UEtTT1tdtcmV/8DDkcwi9z68U7aEGyGg5gjTOfOBuoKLAhuERIMjWfWtjtCBCIDNwDSe2is304ixizfA+W9VAqP1z4at1Ze0cIPK7xCSbi05Q43mVqRRiBQg==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Fri, 04 Nov 2022 02:39:52 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHY1Agq3zcKCbhszkCMLD93E3RjZK4uRM4g
  • Thread-topic: [PATCH v8 2/2] drivers/char: suspend handling in XHCI console driver

Hi Marek,

> -----Original Message-----
> From: Xen-devel <xen-devel-bounces@xxxxxxxxxxxxxxxxxxxx> On Behalf Of
> Subject: [PATCH v8 2/2] drivers/char: suspend handling in XHCI console
> driver
> 
> Similar to the EHCI driver - save/restore relevant BAR and command
> register, re-configure DbC on resume and stop/start timer.
> On resume trigger sending anything that was queued in the meantime.
> Save full BAR value, instead of just the address part, to ease restoring
> on resume.
> 
> Signed-off-by: Marek Marczykowski-Górecki
> <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
> Acked-by: Jan Beulich <jbeulich@xxxxxxxx>

As per Matrix discussion, this is the only one left in this series and
according to Andrew, this patch was already acked and entirely
contained within the new driver itself, fixing a real bug, so if no
objections from other maintainers:

Release-acked-by: Henry Wang <Henry.Wang@xxxxxxx>

Kind regards,
Henry


> ---
> Changes in v8:
>  - move 'bool suspended' to other bools
> New in v7
> 
> Without this patch, the console is broken after S3, and in some cases
> the suspend doesn't succeed at all (when xhci console is enabled).
> 
> Very similar (if not the same) functions might be used for coordinated
> reset handling. I tried to include it in this patch too, but it's a bit
> more involved, mostly due to share=yes case (PHYSDEVOP_dbgp_op can be
> called by the hardware domain only).
> ---
>  xen/drivers/char/xhci-dbc.c | 55 +++++++++++++++++++++++++++++++++-----
>  1 file changed, 49 insertions(+), 6 deletions(-)
> 
> diff --git a/xen/drivers/char/xhci-dbc.c b/xen/drivers/char/xhci-dbc.c
> index 43ed64a004e2..86f6df6bef67 100644
> --- a/xen/drivers/char/xhci-dbc.c
> +++ b/xen/drivers/char/xhci-dbc.c
> @@ -251,14 +251,17 @@ struct dbc {
>      struct xhci_string_descriptor *dbc_str;
> 
>      pci_sbdf_t sbdf;
> -    uint64_t xhc_mmio_phys;
> +    uint64_t bar_val;
>      uint64_t xhc_dbc_offset;
>      void __iomem *xhc_mmio;
> 
>      bool enable; /* whether dbgp=xhci was set at all */
>      bool open;
> +    bool suspended;
>      enum xhci_share share;
>      unsigned int xhc_num; /* look for n-th xhc */
> +    /* state saved across suspend */
> +    uint16_t pci_cr;
>  };
> 
>  static void *dbc_sys_map_xhc(uint64_t phys, size_t size)
> @@ -358,8 +361,9 @@ static bool __init dbc_init_xhc(struct dbc *dbc)
> 
>      pci_conf_write16(dbc->sbdf, PCI_COMMAND, cmd);
> 
> -    dbc->xhc_mmio_phys = (bar0 & PCI_BASE_ADDRESS_MEM_MASK) | (bar1
> << 32);
> -    dbc->xhc_mmio = dbc_sys_map_xhc(dbc->xhc_mmio_phys,
> xhc_mmio_size);
> +    dbc->bar_val = bar0 | (bar1 << 32);
> +    dbc->xhc_mmio = dbc_sys_map_xhc(dbc->bar_val &
> PCI_BASE_ADDRESS_MEM_MASK,
> +                                    xhc_mmio_size);
> 
>      if ( dbc->xhc_mmio == NULL )
>          return false;
> @@ -979,6 +983,9 @@ static bool dbc_ensure_running(struct dbc *dbc)
>      uint32_t ctrl;
>      uint16_t cmd;
> 
> +    if ( dbc->suspended )
> +        return false;
> +
>      if ( dbc->share != XHCI_SHARE_NONE )
>      {
>          /*
> @@ -1213,9 +1220,11 @@ static void __init cf_check
> dbc_uart_init_postirq(struct serial_port *port)
>       * page, so keep it simple.
>       */
>      if ( rangeset_add_range(mmio_ro_ranges,
> -                PFN_DOWN(uart->dbc.xhc_mmio_phys + uart-
> >dbc.xhc_dbc_offset),
> -                PFN_UP(uart->dbc.xhc_mmio_phys + uart->dbc.xhc_dbc_offset +
> -                       sizeof(*uart->dbc.dbc_reg)) - 1) )
> +                PFN_DOWN((uart->dbc.bar_val &
> PCI_BASE_ADDRESS_MEM_MASK) +
> +                         uart->dbc.xhc_dbc_offset),
> +                PFN_UP((uart->dbc.bar_val & PCI_BASE_ADDRESS_MEM_MASK) +
> +                       uart->dbc.xhc_dbc_offset +
> +                sizeof(*uart->dbc.dbc_reg)) - 1) )
>          printk(XENLOG_INFO
>                 "Error while adding MMIO range of device to 
> mmio_ro_ranges\n");
>  #endif
> @@ -1255,6 +1264,38 @@ static void cf_check dbc_uart_flush(struct
> serial_port *port)
>          set_timer(&uart->timer, goal);
>  }
> 
> +static void cf_check dbc_uart_suspend(struct serial_port *port)
> +{
> +    struct dbc_uart *uart = port->uart;
> +    struct dbc *dbc = &uart->dbc;
> +
> +    dbc_pop_events(dbc);
> +    stop_timer(&uart->timer);
> +    dbc->pci_cr = pci_conf_read16(dbc->sbdf, PCI_COMMAND);
> +    dbc->suspended = true;
> +}
> +
> +static void cf_check dbc_uart_resume(struct serial_port *port)
> +{
> +    struct dbc_uart *uart = port->uart;
> +    struct dbc *dbc = &uart->dbc;
> +
> +    pci_conf_write32(dbc->sbdf, PCI_BASE_ADDRESS_0, dbc->bar_val &
> 0xFFFFFFFF);
> +    pci_conf_write32(dbc->sbdf, PCI_BASE_ADDRESS_1, dbc->bar_val >> 32);
> +    pci_conf_write16(dbc->sbdf, PCI_COMMAND, dbc->pci_cr);
> +
> +    if ( !dbc_init_dbc(dbc) )
> +    {
> +        dbc_error("resume failed\n");
> +        return;
> +    }
> +
> +    dbc_enable_dbc(dbc);
> +    dbc->suspended = false;
> +    dbc_flush(dbc, &dbc->dbc_oring, &dbc->dbc_owork);
> +    set_timer(&uart->timer, NOW() + MICROSECS(DBC_POLL_INTERVAL));
> +}
> +
>  static struct uart_driver dbc_uart_driver = {
>      .init_preirq = dbc_uart_init_preirq,
>      .init_postirq = dbc_uart_init_postirq,
> @@ -1262,6 +1303,8 @@ static struct uart_driver dbc_uart_driver = {
>      .putc = dbc_uart_putc,
>      .getc = dbc_uart_getc,
>      .flush = dbc_uart_flush,
> +    .suspend = dbc_uart_suspend,
> +    .resume = dbc_uart_resume,
>  };
> 
>  /* Those are accessed via DMA. */
> --
> git-series 0.9.1


 


Rackspace

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