All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] PCI: DWC: meson: add 256 bytes MRRS quirk
@ 2021-07-27  2:30 ` Artem Lapkin
  0 siblings, 0 replies; 15+ messages in thread
From: Artem Lapkin @ 2021-07-27  2:30 UTC (permalink / raw)
  To: narmstrong
  Cc: yue.wang, khilman, lorenzo.pieralisi, robh, kw, jbrunet,
	christianshewitt, martin.blumenstingl, linux-pci,
	linux-arm-kernel, linux-amlogic, linux-kernel, art, nick, gouwa

256 bytes maximum read request size. They can't handle
anything larger than this. So force this limit on
any devices attached under these ports.

Come-from: https://lkml.org/lkml/2021/6/18/160
Come-from: https://lkml.org/lkml/2021/6/19/19

It only affects PCIe in P2P, in non-P2P is will certainly affect
transfers on the internal SoC/Processor/Chip internal bus/fabric.

These quirks are currently implemented in the
controller driver and only applies when the controller has been probed
and to each endpoint detected on this particular controller.

Continue having separate quirks for each controller if the core
isn't the right place to handle MPS/MRRS.

>> Neil

Signed-off-by: Artem Lapkin <art@khadas.com>
---
 drivers/pci/controller/dwc/pci-meson.c | 31 ++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/pci/controller/dwc/pci-meson.c b/drivers/pci/controller/dwc/pci-meson.c
index 686ded034..1498950de 100644
--- a/drivers/pci/controller/dwc/pci-meson.c
+++ b/drivers/pci/controller/dwc/pci-meson.c
@@ -466,6 +466,37 @@ static int meson_pcie_probe(struct platform_device *pdev)
 	return ret;
 }
 
+static void meson_mrrs_limit_quirk(struct pci_dev *dev)
+{
+	struct pci_bus *bus = dev->bus;
+	int mrrs, mrrs_limit = 256;
+	static const struct pci_device_id bridge_devids[] = {
+		{ PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS, PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3) },
+		{ 0, },
+	};
+
+	/* look for the matching bridge */
+	while (!pci_is_root_bus(bus)) {
+		/*
+		 * 256 bytes maximum read request size. They can't handle
+		 * anything larger than this. So force this limit on
+		 * any devices attached under these ports.
+		 */
+		if (!pci_match_id(bridge_devids, bus->self)) {
+			bus = bus->parent;
+			continue;
+		}
+
+		mrrs = pcie_get_readrq(dev);
+		if (mrrs > mrrs_limit) {
+			pci_info(dev, "limiting MRRS %d to %d\n", mrrs, mrrs_limit);
+			pcie_set_readrq(dev, mrrs_limit);
+		}
+		break;
+	}
+}
+DECLARE_PCI_FIXUP_ENABLE(PCI_ANY_ID, PCI_ANY_ID, meson_mrrs_limit_quirk);
+
 static const struct of_device_id meson_pcie_of_match[] = {
 	{
 		.compatible = "amlogic,axg-pcie",
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-07-29  2:23 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27  2:30 [PATCH v2] PCI: DWC: meson: add 256 bytes MRRS quirk Artem Lapkin
2021-07-27  2:30 ` Artem Lapkin
2021-07-27  2:30 ` Artem Lapkin
2021-07-27 19:43 ` Bjorn Helgaas
2021-07-27 19:43   ` Bjorn Helgaas
2021-07-27 19:43   ` Bjorn Helgaas
2021-07-28 15:08   ` Neil Armstrong
2021-07-28 15:08     ` Neil Armstrong
2021-07-28 15:08     ` Neil Armstrong
2021-07-29  2:06     ` Art Nikpal
2021-07-29  2:06       ` Art Nikpal
2021-07-29  2:06       ` Art Nikpal
2021-07-29  2:21   ` Art Nikpal
2021-07-29  2:21     ` Art Nikpal
2021-07-29  2:21     ` Art Nikpal

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.