All of lore.kernel.org
 help / color / mirror / Atom feed
From: Haozhong Zhang <haozhong@zhan9.net>
To: qemu-devel@nongnu.org
Cc: mst@redhat.com, Haozhong Zhang <zhanghaozhong@bytedance.com>
Subject: Re: [PATCH] xio3130_downstream: Set the maximum link width and speed
Date: Wed, 2 Jun 2021 18:43:16 +0800	[thread overview]
Message-ID: <20210602104316.5wau5oe2zhvtq3cq@HZ-MBP-HOME.local> (raw)
In-Reply-To: <20210527170630.43458-1-haozhong@zhan9.net>

[-- Attachment #1: Type: text/plain, Size: 2079 bytes --]

On 05/28/21 01:06, Haozhong Zhang wrote:
> The current implementation leaves 0 in the maximum link width (MLW)
> and speed (MLS) fields of the PCI_EXP_LNKCAP register of a xio3130
> downstream port device. As a consequence, when that downstream port
> negotiates the link width and speed with its downstream device, 0 will
> be used and filled in the MLW and MLS fields of the PCI_EXP_LNKSTA
> register of that downstream port.
> 
> Normally, such 0 MLS and MLW in PCI_EXP_LNKSTA register only make the
> guest lspci output looks weird (like "speed unknown" and "x0 width").
> However, it also fails the hot-plug of device to the xio3130
> downstream port. The guest Linux kernel complains:
> 
>     pcieport 0000:01:00.0: pciehp: Slot(0): Cannot train link: status 0x2000
> 
> because the pciehp_hpc driver expects a read of valid (non-zero) MLW
> from PCI_EXP_LNKSTA register of that downstream port.
> 
> This patch addresses the above issue by setting MLW and MLS in
> PCI_EXP_LNKCAP of the xio3130 downstream port to values defined in its
> data manual, i.e., x1 and 2.5 GT respectively.
> 
> Signed-off-by: Haozhong Zhang <zhanghaozhong@bytedance.com>
> ---
>  hw/pci-bridge/xio3130_downstream.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/hw/pci-bridge/xio3130_downstream.c b/hw/pci-bridge/xio3130_downstream.c
> index 04aae72cd6..fbf9868ad7 100644
> --- a/hw/pci-bridge/xio3130_downstream.c
> +++ b/hw/pci-bridge/xio3130_downstream.c
> @@ -87,6 +87,13 @@ static void xio3130_downstream_realize(PCIDevice *d, Error **errp)
>          goto err_bridge;
>      }
>  
> +    /*
> +     * Following two fields must be set before calling pcie_cap_init() which
> +     * will fill them to MLS and MLW of PCI_EXP_LNKCAP register.
> +     */
> +    s->speed = QEMU_PCI_EXP_LNK_2_5GT;
> +    s->width = QEMU_PCI_EXP_LNK_X1;
> +
>      rc = pcie_cap_init(d, XIO3130_EXP_OFFSET, PCI_EXP_TYPE_DOWNSTREAM,
>                         p->port, errp);
>      if (rc < 0) {
> -- 
> 2.31.1
> 
>

Forgot to cc Marcel



[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2021-06-02 10:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-27 17:06 [PATCH] xio3130_downstream: Set the maximum link width and speed Haozhong Zhang
2021-06-02 10:43 ` Haozhong Zhang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210602104316.5wau5oe2zhvtq3cq@HZ-MBP-HOME.local \
    --to=haozhong@zhan9.net \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zhanghaozhong@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.