Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Feng Tang" <feng.tang@linux.alibaba.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH RFC] PCI: Add warning about possible danger for pcie_bus_perf mode
Date: Fri, 27 Nov 2026 13:34:57 +0000	[thread overview]
Message-ID: <sashiko-outbox-237497@kernel.org> (raw)
In-Reply-To: <awmEjs8VnJO5XIXd@U-2FWC9VHC-2323.local>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] PCI: missing Signed-off-by trailer and changelog due to leading
  --- separator
- [Medium] PCI: retroactive Root Port MPS limit in pcie_write_mps()
  misses switches
- [Low] PCI: raw vendor ID 0x144d used instead of PCI_VENDOR_ID_SAMSUNG
  in quirks.c
--

commit 4da6a5be70bc88f019059fbcf823ed6f76b2a353
Author: Feng Tang <feng.tang@linux.alibaba.com>

> PCI: Add warning about possible danger for pcie_bus_perf mode
>
> On Thu, Nov 26, 2026 at 12:37:37AM -0800, Christoph Hellwig wrote:
> > On Wed, Nov 25, 2026 at 11:58:29PM +0800, Feng Tang wrote:
> > > During stability test, there was a bug that running 'mount' on a type
> > > of commercial NVME disk failed on an arm64 server and raised PCIe RAS
> > > error and panic the kernel later, when using "pci=pcie_bus_perf" kernel
> > > cmdline parameter.
> > >
> > > The NVME device has MPS(Max Payload Size) capability of 256 bytes while
> > > its corresponding root port is capable of 512 bytes. When enabling
> > > PCIE_BUS_PERFORMANCE mode, its MPS and MRRS(Max Read Request Size) are
> > > both set to 256, while the root port's are both set to 512. But the
> > > NVME device doesn't comply with PCIe spec (v6.3), Section 7.5.3.4:
> >
> > Please add a quirk for these devices now that you have identified
> > this problem.
>
> Following is a draft patch as suggested, which can solve this issue. Please
> help to review, thanks!
>
> - Feng

[Severity: High]
Because the email reply precedes a "---" separator, git am strips the actual
patch subject, changelog, and Signed-off-by: trailer below it and records the
reply text above as the commit message.

> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 2e84fc3d5df96..a15e5a8ee284f 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -2948,11 +2948,14 @@ static int pcie_find_smpss(struct pci_dev *dev, void *data)
>  	return 0;
>  }
>  
> +static void pcie_write_mrrs(struct pci_dev *dev);
>  static void pcie_write_mps(struct pci_dev *dev, int mps)
>  {
>  	int rc;
>  
>  	if (pcie_bus_config == PCIE_BUS_PERFORMANCE) {
> +		struct pci_bus	*bus;
> +
>  		mps = 128 << dev->pcie_mpss;
>  
>  		if (pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT &&
> @@ -2972,6 +2975,27 @@ static void pcie_write_mps(struct pci_dev *dev, int mps)
>  			 * allowable MPS based on its parent bus).
>  			 */
>  			mps = min(mps, pcie_get_mps(dev->bus->self));
> +
> +		/*
> +		 * Quirk for devices that issue Memory Read Requests larger
> +		 * than their MRRS.  "Performance" only guarantees a child's MPS
> +		 * is <= its parent's, so the corresponding root port may have
> +		 * bigger MPS than the device. When such a device sends out a
> +		 * Memory Read request with length > MRRS, and the root port
> +		 * returns CplD packet with length larger than device's MPS,
> +		 * "Malformed TLP" AER error or Machine Check Error(x86) could
> +		 * be triggered. So decrease the root port's MPS/MRRS down to
> +		 * match device's.
> +		 */
> +		bus = dev->bus;
> +		if (dev->broken_mrrs && bus->self &&
> +		    pci_pcie_type(bus->self) == PCI_EXP_TYPE_ROOT_PORT &&
> +		    pcie_get_mps(bus->self) > mps) {
> +			pci_info(dev, "Device has broken MRRS function, limiting MPS of upstream %s to %d\n",
> +				 pci_name(bus->self), mps);
> +			pcie_set_mps(bus->self, mps);
> +			pcie_write_mrrs(bus->self);
> +		}
>  	}

[Severity: Medium]
Does checking only pci_pcie_type(bus->self) == PCI_EXP_TYPE_ROOT_PORT miss
broken_mrrs endpoints attached behind a PCIe switch?  When dev is behind a
switch, dev->bus->self is a Switch Downstream Port
(PCI_EXP_TYPE_DOWNSTREAM), so the Root Port's MPS is left at 512 bytes and a
512-byte Memory Read Request from the endpoint still draws a 512-byte CplD
that triggers the Malformed TLP error.

Lowering bus->self retroactively during the top-down pci_walk_bus() in
pcie_bus_configure_settings() also leaves any earlier-visited sibling
functions configured with an MPS larger than their upstream bridge.
Pre-scanning the hierarchy under the Root Port to cap the Root Port's MPS
before running the top-down pcie_bus_configure_set() walk would avoid both
issues.

> diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> index fff85df3c301c..de41e44778952 100644
> --- a/drivers/pci/quirks.c
> +++ b/drivers/pci/quirks.c
> @@ -6635,3 +6635,24 @@ static void pci_mask_replay_timer_timeout(struct pci_dev *pdev)

[ ... ]

> +static void quirk_broken_mrrs(struct pci_dev *dev)
> +{
> +	dev->broken_mrrs = 1;
> +}
> +DECLARE_PCI_FIXUP_HEADER(0x144d, 0xa80a, quirk_broken_mrrs);

[Severity: Low]
This isn't a bug, but PCI_VENDOR_ID_SAMSUNG can be used here instead of open
coding 0x144d, matching the other Samsung quirks in drivers/pci/quirks.c.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/awmEjs8VnJO5XIXd@U-2FWC9VHC-2323.local?part=1

  parent reply	other threads:[~2026-11-27 13:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 15:58 [PATCH RFC] PCI: Add warning about possible danger for pcie_bus_perf mode Feng Tang
2026-11-25 16:04 ` sashiko-bot
2026-11-26  8:37 ` Christoph Hellwig
2026-11-26  9:48   ` Feng Tang
2026-11-27 13:24   ` Feng Tang
2026-11-27 13:29     ` Niklas Cassel
2026-11-27 13:34     ` sashiko-bot [this message]
2026-11-26  8:39 ` Niklas Cassel
2026-11-26 11:03   ` Feng Tang
2026-11-26 11:56     ` Niklas Cassel

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-237497@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