Skip to content

Commit c8de8ed

Browse files
committed
PCI: Make ACS quirk implementations more uniform
The ACS quirks differ in needless ways, which makes them look more different than they really are. Reorder the ACS flags in order of definitions in the spec: PCI_ACS_SV Source Validation PCI_ACS_TB Translation Blocking PCI_ACS_RR P2P Request Redirect PCI_ACS_CR P2P Completion Redirect PCI_ACS_UF Upstream Forwarding PCI_ACS_EC P2P Egress Control PCI_ACS_DT Direct Translated P2P (PCIe r5.0, sec 7.7.8.2) and use similar code structure in all. No functional change intended. Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Logan Gunthorpe <[email protected]> Reviewed-by: Alex Williamson <[email protected]>
1 parent f338bb9 commit c8de8ed

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

drivers/pci/quirks.c

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4366,18 +4366,18 @@ static bool pci_quirk_cavium_acs_match(struct pci_dev *dev)
43664366

43674367
static int pci_quirk_cavium_acs(struct pci_dev *dev, u16 acs_flags)
43684368
{
4369+
if (!pci_quirk_cavium_acs_match(dev))
4370+
return -ENOTTY;
4371+
43694372
/*
4370-
* Cavium root ports don't advertise an ACS capability. However,
4373+
* Cavium Root Ports don't advertise an ACS capability. However,
43714374
* the RTL internally implements similar protection as if ACS had
4372-
* Request Redirection, Completion Redirection, Source Validation,
4375+
* Source Validation, Request Redirection, Completion Redirection,
43734376
* and Upstream Forwarding features enabled. Assert that the
43744377
* hardware implements and enables equivalent ACS functionality for
43754378
* these flags.
43764379
*/
4377-
acs_flags &= ~(PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_SV | PCI_ACS_UF);
4378-
4379-
if (!pci_quirk_cavium_acs_match(dev))
4380-
return -ENOTTY;
4380+
acs_flags &= ~(PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF);
43814381

43824382
return acs_flags ? 0 : 1;
43834383
}
@@ -4395,7 +4395,7 @@ static int pci_quirk_xgene_acs(struct pci_dev *dev, u16 acs_flags)
43954395
}
43964396

43974397
/*
4398-
* Many Intel PCH root ports do provide ACS-like features to disable peer
4398+
* Many Intel PCH Root Ports do provide ACS-like features to disable peer
43994399
* transactions and validate bus numbers in requests, but do not provide an
44004400
* actual PCIe ACS capability. This is the list of device IDs known to fall
44014401
* into that category as provided by Intel in Red Hat bugzilla 1037684.
@@ -4443,37 +4443,34 @@ static bool pci_quirk_intel_pch_acs_match(struct pci_dev *dev)
44434443
return false;
44444444
}
44454445

4446-
#define INTEL_PCH_ACS_FLAGS (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_SV)
4446+
#define INTEL_PCH_ACS_FLAGS (PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF)
44474447

44484448
static int pci_quirk_intel_pch_acs(struct pci_dev *dev, u16 acs_flags)
44494449
{
4450-
u16 flags = dev->dev_flags & PCI_DEV_FLAGS_ACS_ENABLED_QUIRK ?
4451-
INTEL_PCH_ACS_FLAGS : 0;
4452-
44534450
if (!pci_quirk_intel_pch_acs_match(dev))
44544451
return -ENOTTY;
44554452

4456-
return acs_flags & ~flags ? 0 : 1;
4453+
if (dev->dev_flags & PCI_DEV_FLAGS_ACS_ENABLED_QUIRK)
4454+
acs_flags &= ~(INTEL_PCH_ACS_FLAGS);
4455+
4456+
return acs_flags ? 0 : 1;
44574457
}
44584458

44594459
/*
4460-
* These QCOM root ports do provide ACS-like features to disable peer
4460+
* These QCOM Root Ports do provide ACS-like features to disable peer
44614461
* transactions and validate bus numbers in requests, but do not provide an
44624462
* actual PCIe ACS capability. Hardware supports source validation but it
44634463
* will report the issue as Completer Abort instead of ACS Violation.
4464-
* Hardware doesn't support peer-to-peer and each root port is a root
4465-
* complex with unique segment numbers. It is not possible for one root
4466-
* port to pass traffic to another root port. All PCIe transactions are
4467-
* terminated inside the root port.
4464+
* Hardware doesn't support peer-to-peer and each Root Port is a Root
4465+
* Complex with unique segment numbers. It is not possible for one Root
4466+
* Port to pass traffic to another Root Port. All PCIe transactions are
4467+
* terminated inside the Root Port.
44684468
*/
44694469
static int pci_quirk_qcom_rp_acs(struct pci_dev *dev, u16 acs_flags)
44704470
{
4471-
u16 flags = (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_SV);
4472-
int ret = acs_flags & ~flags ? 0 : 1;
4473-
4474-
pci_info(dev, "Using QCOM ACS Quirk (%d)\n", ret);
4471+
acs_flags &= ~(PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF);
44754472

4476-
return ret;
4473+
return acs_flags ? 0 : 1;
44774474
}
44784475

44794476
static int pci_quirk_al_acs(struct pci_dev *dev, u16 acs_flags)

0 commit comments

Comments
 (0)