All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: bhelgaas@google.com
Cc: linux-pci@vger.kernel.org, joro@8bytes.org,
	andihartmann@01019freenet.de, linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/3] pci: Differentiate ACS controllable from enabled
Date: Thu, 27 Jun 2013 16:39:54 -0600	[thread overview]
Message-ID: <20130627223954.16564.78400.stgit@bling.home> (raw)
In-Reply-To: <20130627222159.16564.38166.stgit@bling.home>

We currently misinterpret that in order for an ACS feature to be
enabled it must be set in the control field.  In reality, this means
that the feature is not only enabled, but controllable.  Many of the
ACS capability bits are not required if the device behaves by default
in the way specified when both the capability and control bit are set
and does not support or allow the alternate mode.  We therefore need
to check the capabilities and mask out flags that are enabled but not
controllable.  Egress control seems to be the only flag which is
purely optional.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 drivers/pci/pci.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index d0c2b35..ae372ca 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2352,12 +2352,20 @@ void pci_enable_acs(struct pci_dev *dev)
 static bool pci_acs_flags_enabled(struct pci_dev *pdev, u16 acs_flags)
 {
 	int pos;
-	u16 ctrl;
+	u16 cap, ctrl;
 
 	pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ACS);
 	if (!pos)
 		return false;
 
+	/*
+	 * Except for egress control, capabilities are either required
+	 * or only required if controllable.  Features missing from the
+	 * capability field can therefore be assumed as hard-wired enabled.
+	 */
+	pci_read_config_word(pdev, pos + PCI_ACS_CAP, &cap);
+	acs_flags &= (cap | PCI_ACS_EC);
+
 	pci_read_config_word(pdev, pos + PCI_ACS_CTRL, &ctrl);
 	return (ctrl & acs_flags) == acs_flags;
 }
@@ -2432,9 +2440,6 @@ bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags)
 		if (!pdev->multifunction)
 			break;
 
-		acs_flags &= (PCI_ACS_RR | PCI_ACS_CR |
-			      PCI_ACS_EC | PCI_ACS_DT);
-
 		return pci_acs_flags_enabled(pdev, acs_flags);
 	}
 


  parent reply	other threads:[~2013-06-27 22:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-27 22:39 [PATCH v2 0/3] pci: ACS fixes & quirks Alex Williamson
2013-06-27 22:39 ` [PATCH v2 1/3] pci: Fix flaw in pci_acs_enabled() Alex Williamson
2013-06-27 22:39 ` Alex Williamson [this message]
2013-06-27 22:40 ` [PATCH v2 3/3] pci: ACS quirk for AMD southbridge Alex Williamson
2013-07-08 16:17 ` [PATCH v2 0/3] pci: ACS fixes & quirks Alex Williamson
2013-07-12  7:01   ` Don Dutile
2013-07-23 15:47   ` Alex Williamson
2013-07-23 20:19 ` Bjorn Helgaas

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=20130627223954.16564.78400.stgit@bling.home \
    --to=alex.williamson@redhat.com \
    --cc=andihartmann@01019freenet.de \
    --cc=bhelgaas@google.com \
    --cc=joro@8bytes.org \
    --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 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.