linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: quirks: update cavium ACS quirk implementation
@ 2017-09-12 11:55 Vadim Lomovtsev
  2017-09-12 16:15 ` Alex Williamson
  2017-09-15 12:57 ` [PATCH v3] PCI: quirks: update Cavium ThunderX " Vadim Lomovtsev
  0 siblings, 2 replies; 30+ messages in thread
From: Vadim Lomovtsev @ 2017-09-12 11:55 UTC (permalink / raw)
  To: bhelgaas, linux-pci, linux-kernel
  Cc: David.Daney, jcm, Robert.Richter, Wilson.Snyder, Vadim Lomovtsev

This commit makes PIC ACS quirk applicable only to Cavium PCIE devices
and Cavium PCIE Root Ports which has limited PCI capabilities in terms
of no ACS support. Match function checks for ACS support and exact ACS
bits set at the device capabilities.
Also by this commit we get rid off device ID range values checkings.

Signed-off-by: Vadim Lomovtsev <Vadim.Lomovtsev@caviumnetworks.com>
---
 drivers/pci/quirks.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index a4d3361..11ca951 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -4211,6 +4211,29 @@ static int pci_quirk_amd_sb_acs(struct pci_dev *dev, u16 acs_flags)
 #endif
 }
 
+#define CAVIUM_ACS_FLAGS (PCI_ACS_SV | PCI_ACS_TB | PCI_ACS_RR | \
+			  PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_DT)
+
+static __inline__  bool pci_quirk_cavium_acs_match(struct pci_dev *dev)
+{
+	int pos = 0;
+	u32 caps = 0;
+
+	/* Filter out a few obvious non-matches first */
+	if (!pci_is_pcie(dev) || pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT)
+		return false;
+
+	/* Get the ACS caps offset */
+	pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS);
+	if (pos) {
+		pci_read_config_dword(dev, pos + PCI_ACS_CAP, &caps);
+		/* If we have no such bits set, then we will need a quirk */
+		return ((caps & CAVIUM_ACS_FLAGS) != CAVIUM_ACS_FLAGS);
+	}
+
+	return true;
+}
+
 static int pci_quirk_cavium_acs(struct pci_dev *dev, u16 acs_flags)
 {
 	/*
@@ -4218,13 +4241,10 @@ static int pci_quirk_cavium_acs(struct pci_dev *dev, u16 acs_flags)
 	 * with other functions, allowing masking out these bits as if they
 	 * were unimplemented in the ACS capability.
 	 */
-	acs_flags &= ~(PCI_ACS_SV | PCI_ACS_TB | PCI_ACS_RR |
-		       PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_DT);
-
-	if (!((dev->device >= 0xa000) && (dev->device <= 0xa0ff)))
+	if (!pci_quirk_cavium_acs_match(dev))
 		return -ENOTTY;
 
-	return acs_flags ? 0 : 1;
+	return acs_flags & ~(CAVIUM_ACS_FLAGS) ? 0 : 1;
 }
 
 static int pci_quirk_xgene_acs(struct pci_dev *dev, u16 acs_flags)
-- 
2.9.5

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

end of thread, other threads:[~2017-10-20 10:44 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-12 11:55 [PATCH] PCI: quirks: update cavium ACS quirk implementation Vadim Lomovtsev
2017-09-12 16:15 ` Alex Williamson
2017-09-13 11:37   ` Vadim Lomovtsev
2017-09-13 12:01   ` Vadim Lomovtsev
2017-09-15 12:57 ` [PATCH v3] PCI: quirks: update Cavium ThunderX " Vadim Lomovtsev
2017-09-15 19:20   ` Lomovtsev, Vadim
2017-09-18  8:48   ` [PATCH v4] " Vadim Lomovtsev
2017-09-20 11:33     ` Vadim Lomovtsev
2017-09-20 16:31     ` Alex Williamson
2017-09-21  8:39       ` Vadim Lomovtsev
2017-09-25 13:08     ` [PATCH v5] " Vadim Lomovtsev
2017-09-26 15:23       ` Vadim Lomovtsev
2017-09-26 15:43       ` Alex Williamson
2017-09-26 16:00         ` Vadim Lomovtsev
2017-09-27 18:03           ` Vadim Lomovtsev
2017-09-27 18:20       ` [PATCH v6] " Vadim Lomovtsev
2017-09-27 20:03         ` Vadim Lomovtsev
2017-09-27 20:18         ` Alex Williamson
2017-09-29 12:22           ` Vadim Lomovtsev
2017-10-09 16:14           ` Vadim Lomovtsev
2017-10-12 13:27         ` Robert Richter
2017-10-16 21:23         ` Bjorn Helgaas
2017-10-17 11:29           ` Vadim Lomovtsev
2017-10-17 12:47         ` [PATCH v7 0/2] PCI: quirks: Cavium ThunderX ACS quirk update Vadim Lomovtsev
2017-10-17 12:47           ` [PATCH v7 1/2] PCI: quirks: Set Cavium ACS capability quirk flags to assert RR/CR/SV/UF Vadim Lomovtsev
2017-10-17 12:47           ` [PATCH v7 2/2] PCI: quirks: Apply Cavium ThunderX ACS quirk only to Root Ports Vadim Lomovtsev
2017-10-19 11:26           ` [PATCH v7 0/2] PCI: quirks: Cavium ThunderX ACS quirk update Bjorn Helgaas
2017-10-19 11:59             ` Vadim Lomovtsev
2017-10-19 18:50               ` Bjorn Helgaas
2017-10-20 10:44                 ` Vadim Lomovtsev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).