All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI: Add ACS errata for Pericom PI7C9X2G404 switch
@ 2021-09-03  3:40 Nathan Rossi
  2021-09-03  6:18 ` Lukas Wunner
  0 siblings, 1 reply; 6+ messages in thread
From: Nathan Rossi @ 2021-09-03  3:40 UTC (permalink / raw)
  To: linux-pci; +Cc: Nathan Rossi, Nathan Rossi, Bjorn Helgaas

From: Nathan Rossi <nathan.rossi@digi.com>

The Pericom PI7C9X2G404 PCIe switch has an errata for ACS P2P Request
Redirect behaviour when used in the cut-through forwarding mode. The
recommended work around for this issue is to use the switch in store and
forward mode.

This change adds a fixup specific to this switch that when enabling the
downstream port it checks if it has enabled ACS P2P Request Redirect,
and if so changes the device (via the upstream port) to use the store
and forward operating mode.

Signed-off-by: Nathan Rossi <nathan.rossi@digi.com>
---
 drivers/pci/quirks.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index ab3de1551b..1ea6661d01 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -5704,3 +5704,45 @@ static void apex_pci_fixup_class(struct pci_dev *pdev)
 }
 DECLARE_PCI_FIXUP_CLASS_HEADER(0x1ac1, 0x089a,
 			       PCI_CLASS_NOT_DEFINED, 8, apex_pci_fixup_class);
+
+/*
+ * Pericom PI7C9X2G404 switch errata E5 - ACS P2P Request Redirect is not
+ * functional
+ *
+ * When ACS P2P Request Redirect is enabled and bandwidth is not balanced
+ * between upstream and downstream ports, packets are queued in an internal
+ * buffer until CPLD packet. The workaround is to use the switch in store and
+ * forward mode.
+ */
+#define PI7C9X2G404_MODE_REG		0x74
+#define PI7C9X2G404_STORE_FORWARD_MODE	BIT(0)
+static void pci_fixup_pericom_acs_store_forward(struct pci_dev *pdev)
+{
+	struct pci_dev *upstream;
+	u16 val;
+
+	/* Downstream ports only */
+	if (pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM)
+		return;
+
+	/* Check for ACS P2P Request Redirect use */
+	if (!pdev->acs_cap)
+		return;
+	pci_read_config_word(pdev, pdev->acs_cap + PCI_ACS_CTRL, &val);
+	if (!(val & PCI_ACS_RR))
+		return;
+
+	upstream = pci_upstream_bridge(pdev);
+	if (!upstream)
+		return;
+
+	pci_read_config_word(upstream, PI7C9X2G404_MODE_REG, &val);
+	if (!(val & PI7C9X2G404_STORE_FORWARD_MODE)) {
+		pci_info(upstream, "Setting PI7C9X2G404 store-forward mode\n");
+		/* Enable store-foward mode */
+		pci_write_config_word(upstream, PI7C9X2G404_MODE_REG, val |
+				      PI7C9X2G404_STORE_FORWARD_MODE);
+	}
+}
+DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_PERICOM, 0x2404,
+			 pci_fixup_pericom_acs_store_forward);
---
2.33.0

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

end of thread, other threads:[~2021-09-09 17:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03  3:40 [PATCH] PCI: Add ACS errata for Pericom PI7C9X2G404 switch Nathan Rossi
2021-09-03  6:18 ` Lukas Wunner
2021-09-06  6:01   ` Nathan Rossi
2021-09-08 22:24     ` Bjorn Helgaas
2021-09-09  8:08       ` Nathan Rossi
2021-09-09 17:52         ` Bjorn Helgaas

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.