From: Alex Williamson <alex.williamson@redhat.com>
To: bhelgaas@google.com
Cc: linux-pci@vger.kernel.org, ddutile@redhat.com,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 1/2] pci: Fix flaw in pci_acs_enabled()
Date: Fri, 07 Jun 2013 10:34:41 -0600 [thread overview]
Message-ID: <20130607163441.7733.23221.stgit@bling.home> (raw)
In-Reply-To: <20130607162732.7733.17758.stgit@bling.home>
Downstream ports support for all ACS flags supercedes multifunction
exclusion of some flags. The PCIe spec also fully specifies which
PCIe types are subject to the multifunction rules and excludes event
collectors and PCIe-to-PCI bridges entirely. Document each rule to
the section of the PCIe spec.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
drivers/pci/pci.c | 59 ++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 45 insertions(+), 14 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index b099e00..457ae51 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2354,6 +2354,19 @@ void pci_enable_acs(struct pci_dev *dev)
pci_write_config_word(dev, pos + PCI_ACS_CTRL, ctrl);
}
+static bool pci_acs_flags_enabled(struct pci_dev *pdev, u16 acs_flags)
+{
+ int pos;
+ u16 ctrl;
+
+ pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ACS);
+ if (!pos)
+ return false;
+
+ pci_read_config_word(pdev, pos + PCI_ACS_CTRL, &ctrl);
+ return (ctrl & acs_flags) == acs_flags;
+}
+
/**
* pci_acs_enabled - test ACS against required flags for a given device
* @pdev: device to test
@@ -2364,8 +2377,7 @@ void pci_enable_acs(struct pci_dev *dev)
*/
bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags)
{
- int pos, ret;
- u16 ctrl;
+ int ret;
ret = pci_dev_specific_acs_enabled(pdev, acs_flags);
if (ret >= 0)
@@ -2374,23 +2386,42 @@ bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags)
if (!pci_is_pcie(pdev))
return false;
- /* Filter out flags not applicable to multifunction */
- if (pdev->multifunction)
+ switch (pci_pcie_type(pdev)) {
+ /*
+ * PCIe 3.0, 6.12.1 excludes ACS on these devices. "Not applicable"
+ */
+ case PCI_EXP_TYPE_PCI_BRIDGE:
+ case PCI_EXP_TYPE_RC_EC:
+ break;
+ /*
+ * PCIe 3.0, 6.12.1.1 specifies full ACS capabilities on downstream
+ * ports, regardless of them being multifunction devices.
+ */
+ case PCI_EXP_TYPE_DOWNSTREAM:
+ case PCI_EXP_TYPE_ROOT_PORT:
+ return pci_acs_flags_enabled(pdev, acs_flags);
+ /*
+ * PCIe 3.0, 6.12.1.2 specifies unimplemented ACS capabilities on
+ * multifunction devices. 6.12 footnote identifies specifically
+ * which devices types this applies to.
+ */
+ case PCI_EXP_TYPE_ENDPOINT:
+ case PCI_EXP_TYPE_UPSTREAM:
+ case PCI_EXP_TYPE_LEG_END:
+ case PCI_EXP_TYPE_RC_END:
+ if (!pdev->multifunction)
+ break;
+
acs_flags &= (PCI_ACS_RR | PCI_ACS_CR |
PCI_ACS_EC | PCI_ACS_DT);
- if (pci_pcie_type(pdev) == PCI_EXP_TYPE_DOWNSTREAM ||
- pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT ||
- pdev->multifunction) {
- pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ACS);
- if (!pos)
- return false;
-
- pci_read_config_word(pdev, pos + PCI_ACS_CTRL, &ctrl);
- if ((ctrl & acs_flags) != acs_flags)
- return false;
+ return pci_acs_flags_enabled(pdev, acs_flags);
}
+ /*
+ * PCIe 3.0, 6.12.1.3 specifies no ACS capabilties are applicable
+ * to single function devices with the exception of downstream ports.
+ */
return true;
}
next prev parent reply other threads:[~2013-06-07 16:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-07 16:34 [PATCH v2 0/2] pci: ACS check fixes Alex Williamson
2013-06-07 16:34 ` Alex Williamson [this message]
2013-06-18 17:09 ` [PATCH v2 1/2] pci: Fix flaw in pci_acs_enabled() Bjorn Helgaas
2013-06-18 18:38 ` Alex Williamson
2013-06-18 22:10 ` Bjorn Helgaas
2013-06-18 22:47 ` Alex Williamson
2013-06-19 2:30 ` Bjorn Helgaas
2013-06-20 21:43 ` Alex Williamson
2013-06-24 17:27 ` Bjorn Helgaas
2013-06-07 16:34 ` [PATCH v2 2/2] pci: Differentiate ACS controllable from enabled Alex Williamson
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=20130607163441.7733.23221.stgit@bling.home \
--to=alex.williamson@redhat.com \
--cc=bhelgaas@google.com \
--cc=ddutile@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).