From: sashiko-bot@kernel.org
To: "Feng Tang" <feng.tang@linux.alibaba.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v2] PCI: Quirk devices with broken MRRS function under PCIE_BUS_PERFORMANCE mode
Date: Mon, 30 Nov 2026 15:54:40 +0000 [thread overview]
Message-ID: <sashiko-outbox-241520@kernel.org> (raw)
In-Reply-To: <20261130154317.69012-1-feng.tang@linux.alibaba.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] PCI: pcie_find_sbmps() ignores smaller MPSS on intermediate
bridges
--
commit 71fbc43c3b824c6971cd3594dc63449905c21a34
Author: Feng Tang <feng.tang@linux.alibaba.com>
PCI: Quirk devices with broken MRRS function under PCIE_BUS_PERFORMANCE mode
This commit adds a quirk flag for PCIe devices that issue read requests
exceeding their configured MRRS, and clamps the upstream Root Port's MPS
and MRRS to the smallest MPSS among broken devices under it when running
in PCIE_BUS_PERFORMANCE mode.
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 2e84fc3d5df96..6e4b78b156f17 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -3041,6 +3041,23 @@ static int pcie_bus_configure_set(struct pci_dev *dev, void *data)
> return 0;
> }
>
> +/*
> + * Find the smallest mps of devices with broken MRRS function
> + * under a Root Port, if they exist
> + */
> +static int pcie_find_sbmps(struct pci_dev *dev, void *data)
> +{
> + u8 *sbmps = data;
> +
> + if (!pci_is_pcie(dev))
> + return 0;
> +
> + if (dev->broken_mrrs && *sbmps > dev->pcie_mpss)
> + *sbmps = dev->pcie_mpss;
> +
> + return 0;
> +}
> +
> /*
> * pcie_bus_configure_settings() requires that pci_walk_bus work in a top-down,
> * parents then children fashion. If this changes, then this code will not
> @@ -3049,11 +3066,12 @@ static int pcie_bus_configure_set(struct pci_dev *dev, void *data)
> void pcie_bus_configure_settings(struct pci_bus *bus)
> {
> u8 smpss = 0;
> + struct pci_dev *bridge = bus->self;
>
> - if (!bus->self)
> + if (!bridge)
> return;
>
> - if (!pci_is_pcie(bus->self))
> + if (!pci_is_pcie(bridge))
> return;
>
> /*
> @@ -3065,13 +3083,39 @@ void pcie_bus_configure_settings(struct pci_bus *bus)
> smpss = 0;
>
> if (pcie_bus_config == PCIE_BUS_SAFE) {
> - smpss = bus->self->pcie_mpss;
> + smpss = bridge->pcie_mpss;
>
> - pcie_find_smpss(bus->self, &smpss);
> + pcie_find_smpss(bridge, &smpss);
> pci_walk_bus(bus, pcie_find_smpss, &smpss);
> }
>
> - pcie_bus_configure_set(bus->self, &smpss);
> + if (pcie_bus_config == PCIE_BUS_PERFORMANCE &&
> + pci_pcie_type(bridge) == PCI_EXP_TYPE_ROOT_PORT) {
> + u8 sbmps = bridge->pcie_mpss;
> +
> + /*
> + * There are devices with broken MRRS function, that they issue
> + * Memory Read Requests with length larger than their MRRS, and
> + * the corresponding Root Port may return CplD packet with
> + * length larger than device's MPS, triggering "Malformed TLP"
> + * AER error.
> + *
> + * Limit Root Port's MPS/MRRS down to the smallest mps of all
> + * broken devices under it to avoid such issue.
> + */
> + pci_walk_bus(bus, pcie_find_sbmps, &sbmps);
[Severity: Medium]
Does pcie_find_sbmps() leave the Root Port's MPS larger than the
endpoint's effective MPS when a broken_mrrs device sits behind an
intermediate switch or bridge with a smaller pcie_mpss?
pcie_find_sbmps() only checks dev->pcie_mpss on the broken_mrrs endpoint
itself, whereas the subsequent top-down walk in pcie_write_mps() clamps
each device's MPS to min(mps, pcie_get_mps(dev->bus->self)). If a Root
Port supports 512B, an intermediate switch supports 128B, and the
broken_mrrs endpoint supports 256B, the Root Port is set to 256B while
the switch and endpoint are clamped to 128B, so the Root Port can still
return 256B CplD packets that trigger Malformed TLP errors.
Also, gating this block on pci_pcie_type(bridge) == PCI_EXP_TYPE_ROOT_PORT
skips the clamp completely when pcie_bus_configure_settings() is called
during hotplug below a switch downstream port.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130154317.69012-1-feng.tang@linux.alibaba.com?part=1
prev parent reply other threads:[~2026-11-30 15:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 15:43 [PATCH v2] PCI: Quirk devices with broken MRRS function under PCIE_BUS_PERFORMANCE mode Feng Tang
2026-11-30 15:54 ` sashiko-bot [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=sashiko-outbox-241520@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=feng.tang@linux.alibaba.com \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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