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

Re: [PATCH v2] ns16550: enable memory decoding on MMIO-based PCI console card


  • To: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 26 Apr 2023 09:48:04 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • 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=Zf2xenawkEDBzK8yC2XFCbJS8ncy2Q7HBlgb8stBePE=; b=Cjl8NjLrwrhM6tVBdewyy5MpncVSxGeRaujOzE2gTKfXTNKx5oozCa7KdswytnIQRy8r+jEn1KDPq8rAxxdxQxWsXmx1uDonRYqQcK2oes1ahBQRiiSZLHDwypieL0v3RYgxWeyL8YBZzG9HFf057cXKLfI+mHh9QeKgcL2yT6Dl9+Q7b9Dkn38ryrQ+plm6hf6FJTCqtMlf6ZODJ260nDbtpm4nc5js4brq35wdIfohG3P/Cd6G46nlFKwFCOQbh0Umz4Ahu+O1liyutAp7qFwT1PHQBQY+10lpm/OBUv7PP8EY6dgmTysMfI0WqJzmsABMvmmSPor/gPZYmDbanQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DXbvAfnkLubOwSTdTHuHYQ7Z69dv97zhDk0oD/nPJzvlnbjWEliYaoGSLm01gWJ8RJ9SDRBfkDo6yC8/IYli5QYxKfxXbhMsaQ3/PHiAVR4GQr7M5Bruqamv8IhbOxuTQaQkauqfz1LEqkIhY1odSOdsltPZzyHYYjjHZORX6mAnvxlKie3qUKCSuW78leNHRu5hxYsu+gdAdxkmkKhRdJzgClOZeSbT/nENFpYxhwrS7lw3B9mvF6EeO18eh6jQnueH/1RSwR0KmsFtVHO1nXGiyLpqT+NzErvc9BBkB+VbwjvxN732nMAIomrxZ4Pa9UdcE4HHMwX4xczsGM4rEg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Wed, 26 Apr 2023 07:48:35 +0000
  • Ironport-data: A9a23:EV5reaLr7sh5JvSnFE+RP5QlxSXFcZb7ZxGr2PjKsXjdYENS1mMPy zBJWzvQa6veNGDyLoola4y0/R5QvZaGxt8yT1ZlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHvykU7Ss1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpJrfPSwP9TlK6q4mhA4gZgPakjUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c5FBHoU9 MQxEgwOQUqJocac+q26VdBj05FLwMnDZOvzu1lG5BSBV7MMZ8mGRK/Ho9hFwD03m8ZCW+7EY NYUYiZuaxKGZABTPlAQC9Q1m+LAanvXKmUE7g7K4/dupTSIpOBy+OGF3N79YNuFSN8Thk+Fj mnH4374ElcRM9n3JT+tqyr93bSRw32qMG4UPLGBq6JpjkLN/WM4JyQyWln4ouiJ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rx5vmmaXoVczQOAdhfF/DKV 0+exW2DPl8zymQKw3FaV7qKj/QRnA=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, Apr 25, 2023 at 04:39:02PM +0200, Marek Marczykowski-Górecki wrote:
> pci_serial_early_init() enables PCI_COMMAND_IO for IO-based UART
> devices, add setting PCI_COMMAND_MEMORY for MMIO-based UART devices too.
> Note the MMIO-based devices in practice need a "pci" sub-option,
> otherwise a few parameters are not initialized (including bar_idx,
> reg_shift, reg_width etc). The "pci" is not supposed to be used with
> explicit BDF, so do not key setting PCI_COMMAND_MEMORY on explicit BDF
> being set. Contrary to the IO-based UART, pci_serial_early_init() will
> not attempt to set BAR0 address, even if user provided io_base manually
> - in most cases, those are with an offest and the current cmdline syntax
> doesn't allow expressing it. Due to this, enable PCI_COMMAND_MEMORY only
> if uart->bar is already populated. In similar spirit, this patch does
> not support setting BAR0 of the bridge.

FWIW (not that should be done here) but I think we also want to
disable memory decoding in pci_uart_config() while sizing the BAR.

> Signed-off-by: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
> ---
> This fixes the issue I was talking about on #xendevel. Thanks Roger for
> the hint.
> 
> Changes in v2:
>  - check if uart->bar instead of uart->io_base
>  - move it ahead of !uart->ps_bdf_enable return
>  - expand commit message.
> ---
>  xen/drivers/char/ns16550.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
> index 1b21eb93c45f..34231dcb23ea 100644
> --- a/xen/drivers/char/ns16550.c
> +++ b/xen/drivers/char/ns16550.c
> @@ -272,7 +272,15 @@ static int cf_check ns16550_getc(struct serial_port 
> *port, char *pc)
>  static void pci_serial_early_init(struct ns16550 *uart)
>  {
>  #ifdef NS16550_PCI
> -    if ( !uart->ps_bdf_enable || uart->io_base >= 0x10000 )
> +    if ( uart->bar )
> +    {
> +        pci_conf_write16(PCI_SBDF(0, uart->ps_bdf[0], uart->ps_bdf[1],
> +                                  uart->ps_bdf[2]),
> +                         PCI_COMMAND, PCI_COMMAND_MEMORY);

Don't you want to read the current command register first and just
or PCI_COMMAND_MEMORY?

I see that for IO decoding we already do it this way, but I'm not sure
whether it could cause issues down the road by unintentionally
disabling command flags.

Thanks, Roger.



 


Rackspace

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