From: Feng Tang <feng.tang@linux.alibaba.com>
To: Christoph Hellwig <hch@infradead.org>,
Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Anju Zheng <zaj01616726@alibaba-inc.com>,
Niklas Cassel <cassel@kernel.org>
Subject: Re: [PATCH RFC] PCI: Add warning about possible danger for pcie_bus_perf mode
Date: Fri, 27 Nov 2026 21:24:30 +0800 [thread overview]
Message-ID: <awmEjs8VnJO5XIXd@U-2FWC9VHC-2323.local> (raw)
In-Reply-To: <awfv0WKc6iblVA9E@infradead.org>
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
---
From 829623aa7afa9e2e19a232d3968ef8c282cda3e4 Mon Sep 17 00:00:00 2001
From: Feng Tang <feng.tang@linux.alibaba.com>
Date: Thu, 26 Nov 2026 17:22:59 +0800
Subject: [PATCH] PCI: Quirk devices with broken MRRS function under
PCIE_BUS_PERFORMANCE mode
During stability test with "pci=pcie_bus_perf" cmdline parameter, there
was a bug that running 'mount' on one commercial NVMe disk failed on an
arm64 server, raised PCIe RAS error of "Malformed TLP", and panic the
kernel. The issue can't be reproduced after removing "pci=pcie_bus_perf".
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:
"
Max_Read_Request_Size - This field sets the maximum Read Request size
for the Function as a Requester. The Function must not generate Read
Requests with a size exceeding the set value
"
that it doesn't honor the MRRS setting, and sends out Memory Read request
with length of 512 bytes, and when root port replies CplD packet with 512
bytes payload which exceeds device's MPS, PCIe RAS error is issued.
The problem can be reproduced on some arm64 server and Intel server.
This caused some data damage, and there were quite a few NVMe cards of
the same type damaged (though we are not sure these are directly related).
So add a quirk for this kind of devices which don't honor MRRS part of
PCIe spec, and under PCIE_BUS_PERFORMANCE mode, set their corresponding
root ports' MPS/MRRS to match theirs.
Reported-by: Anju Zheng <zaj01616726@alibaba-inc.com>
Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Feng Tang <feng.tang@linux.alibaba.com>
---
drivers/pci/probe.c | 24 ++++++++++++++++++++++++
drivers/pci/quirks.c | 21 +++++++++++++++++++++
include/linux/pci.h | 1 +
3 files changed, 46 insertions(+)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 27008e2ea5af..9d8b2091cc46 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2932,11 +2932,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 &&
@@ -2956,6 +2959,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);
+ }
}
rc = pcie_set_mps(dev, mps);
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index de9bbccda21f..4560a116ae98 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -6423,3 +6423,24 @@ static void pci_mask_replay_timer_timeout(struct pci_dev *pdev)
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_GLI, 0x9750, pci_mask_replay_timer_timeout);
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_GLI, 0x9755, pci_mask_replay_timer_timeout);
#endif
+
+/*
+ * Some commercial NVMe controllers do not honor their Max_Read_Request_Size:
+ * they issue Memory Read Requests larger than the MRRS the kernel programmed
+ * (under pci=pcie_bus_perf the kernel sets MRRS == MPS). In PERFORMANCE mode
+ * the upstream Root Port may be left with a larger MPS than the device, so it
+ * may reply CplD packets with length larger than the device's MPS. The device
+ * then reports them as Malformed TLPs, raising PCIe RAS error or Machine Check
+ * Error(for x86).
+ *
+ * Flag such devices so that later on pcie_write_mps() can force the corresponding
+ * root port's MPS down to match the device, keeping CplD packet length within
+ * the device's MPS.
+ *
+ * This only affects PCIE_BUS_PERFORMANCE mode.
+ */
+static void quirk_broken_mrrs(struct pci_dev *dev)
+{
+ dev->broken_mrrs = 1;
+}
+DECLARE_PCI_FIXUP_HEADER(0x144d, 0xa80a, quirk_broken_mrrs);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index d31a8d107b1e..adeafed52ff6 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -504,6 +504,7 @@ struct pci_dev {
*/
unsigned int external_facing:1;
unsigned int broken_intx_masking:1; /* INTx masking can't be used */
+ unsigned int broken_mrrs:1; /* Issues read request with length > MRRS */
unsigned int io_window_1k:1; /* Intel bridge 1K I/O windows */
unsigned int irq_managed:1;
unsigned int non_compliant_bars:1; /* Broken BARs; ignore them */
--
2.39.5 (Apple Git-154)
next prev parent reply other threads:[~2026-11-27 13:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 15:58 Feng Tang
2026-11-26 8:37 ` Christoph Hellwig
2026-11-26 9:48 ` Feng Tang
2026-11-27 13:24 ` Feng Tang [this message]
2026-11-27 13:29 ` Niklas Cassel
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=awmEjs8VnJO5XIXd@U-2FWC9VHC-2323.local \
--to=feng.tang@linux.alibaba.com \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=zaj01616726@alibaba-inc.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
all inboxes | Powered by JetHome®