From: Zhenyu Zhang <zhenyzha12@gmail.com>
To: Sebastian Ott <sebott@redhat.com>, qemu-devel@nongnu.org
Cc: Alex Williamson <alex.williamson@redhat.com>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
zhenyzha@redhat.com
Subject: Re: [PATCH] pci: ensure valid link status bits for downstream ports
Date: Fri, 15 Nov 2024 20:42:54 +0800 [thread overview]
Message-ID: <e9392f4d-71a6-4909-bfb1-fc2d15e1ef96@gmail.com> (raw)
In-Reply-To: <20241111123756.18393-1-sebott@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2717 bytes --]
On 2024/11/11 20:37, Sebastian Ott wrote:
> PCI hotplug for downstream endpoints on arm fails because Linux'
> PCIe hotplug driver doesn't like the QEMU provided LNKSTA:
>
> pcieport 0000:08:01.0: pciehp: Slot(2): Card present
> pcieport 0000:08:01.0: pciehp: Slot(2): Link Up
> pcieport 0000:08:01.0: pciehp: Slot(2): Cannot train link: status 0x2000
>
> There's 2 cases where LNKSTA isn't setup properly:
> * the downstream device has no express capability
> * max link width of the bridge is 0
>
> Fix these by making the LNKSTA modifications independent of each other.
>
> Signed-off-by: Sebastian Ott<sebott@redhat.com>
> ---
> hw/pci/pcie.c | 28 ++++++++++++++--------------
> 1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
> index 0b455c8654..f714f4fb7c 100644
> --- a/hw/pci/pcie.c
> +++ b/hw/pci/pcie.c
> @@ -1109,20 +1109,20 @@ void pcie_sync_bridge_lnk(PCIDevice *bridge_dev)
> lnksta = target->config_read(target,
> target->exp.exp_cap + PCI_EXP_LNKSTA,
> sizeof(lnksta));
> -
> - if ((lnksta & PCI_EXP_LNKSTA_NLW) > (lnkcap & PCI_EXP_LNKCAP_MLW)) {
> - lnksta &= ~PCI_EXP_LNKSTA_NLW;
> - lnksta |= lnkcap & PCI_EXP_LNKCAP_MLW;
> - } else if (!(lnksta & PCI_EXP_LNKSTA_NLW)) {
> - lnksta |= QEMU_PCI_EXP_LNKSTA_NLW(QEMU_PCI_EXP_LNK_X1);
> - }
> -
> - if ((lnksta & PCI_EXP_LNKSTA_CLS) > (lnkcap & PCI_EXP_LNKCAP_SLS)) {
> - lnksta &= ~PCI_EXP_LNKSTA_CLS;
> - lnksta |= lnkcap & PCI_EXP_LNKCAP_SLS;
> - } else if (!(lnksta & PCI_EXP_LNKSTA_CLS)) {
> - lnksta |= QEMU_PCI_EXP_LNKSTA_CLS(QEMU_PCI_EXP_LNK_2_5GT);
> - }
> + }
> + if ((lnksta & PCI_EXP_LNKSTA_NLW) > (lnkcap & PCI_EXP_LNKCAP_MLW)) {
> + lnksta &= ~PCI_EXP_LNKSTA_NLW;
> + lnksta |= lnkcap & PCI_EXP_LNKCAP_MLW;
> + }
> + if (!(lnksta & PCI_EXP_LNKSTA_NLW)) {
> + lnksta |= QEMU_PCI_EXP_LNKSTA_NLW(QEMU_PCI_EXP_LNK_X1);
> + }
> + if ((lnksta & PCI_EXP_LNKSTA_CLS) > (lnkcap & PCI_EXP_LNKCAP_SLS)) {
> + lnksta &= ~PCI_EXP_LNKSTA_CLS;
> + lnksta |= lnkcap & PCI_EXP_LNKCAP_SLS;
> + }
> + if (!(lnksta & PCI_EXP_LNKSTA_CLS)) {
> + lnksta |= QEMU_PCI_EXP_LNKSTA_CLS(QEMU_PCI_EXP_LNK_2_5GT);
> }
>
> pci_word_test_and_clear_mask(exp_cap + PCI_EXP_LNKSTA,
|[PATCH] pci: ensure valid link status bits for downstream ports
Test on aarch64 host(v9.2.0-rc0-1-gbde0d70333)
PCI hotplug for downstream endpoints on arm succeed
The test results are as expected.
|
|Tested-by: Zhenyu Zhang <zhenyzha@redhat.com> |
[-- Attachment #2: Type: text/html, Size: 3329 bytes --]
next prev parent reply other threads:[~2024-11-15 14:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-11 12:37 [PATCH] pci: ensure valid link status bits for downstream ports Sebastian Ott
2024-11-11 12:40 ` Sebastian Ott
2024-11-15 12:42 ` Zhenyu Zhang [this message]
2024-11-21 11:08 ` Sebastian Ott
2024-12-02 19:03 ` Alex Williamson
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=e9392f4d-71a6-4909-bfb1-fc2d15e1ef96@gmail.com \
--to=zhenyzha12@gmail.com \
--cc=alex.williamson@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sebott@redhat.com \
--cc=zhenyzha@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).