linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: linux-pci@vger.kernel.org
Cc: KarimAllah Ahmed <karahmed@amazon.de>,
	Kuppuswamy Sathyanarayanan 
	<sathyanarayanan.kuppuswamy@linux.intel.com>,
	Hao Zheng <yinhe@linux.alibaba.com>,
	bhelgaas@google.com, linux-kernel@vger.kernel.org,
	nanhai.zou@linux.alibaba.com, quan.xu0@linux.alibaba.com,
	ashok.raj@intel.com, keith.busch@intel.com,
	mike.campin@intel.com
Subject: [PATCH 2/2] PCI/IOV: Assume SR-IOV VFs support extended config space.
Date: Thu, 13 Jun 2019 16:57:20 -0600	[thread overview]
Message-ID: <156046664016.29869.16676461736240878900.stgit@gimli.home> (raw)
In-Reply-To: <156046609596.29869.5839964168034189416.stgit@gimli.home>

The SR-IOV specification requires both PFs and VFs to implement a PCIe
capability.  Generally this is sufficient to assume extended config
space is present, but we generally also perform additional tests to
make sure the extended config space is reachable and not simply an
alias of standard config space.  For a VF to exist extended config
space must be accessible on the PF, therefore we can also assume it to
be accessible on the VF.  This enables a micro performance
optimization previously implemented in commit 975bb8b4dc93 ("PCI/IOV:
Use VF0 cached config space size for other VFs") to speed up probing
of VFs.

Cc: KarimAllah Ahmed <karahmed@amazon.de>
Cc: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Cc: Hao Zheng <yinhe@linux.alibaba.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 drivers/pci/probe.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index a3a3c6b28343..439244ff8f09 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1561,6 +1561,21 @@ int pci_cfg_space_size(struct pci_dev *dev)
 	u32 status;
 	u16 class;
 
+#ifdef CONFIG_PCI_IOV
+	/*
+	 * Per the SR-IOV specification (rev 1.1, sec 3.5), VFs are required to
+	 * implement a PCIe capability and therefore must implement extended
+	 * config space.  We can skip the NO_EXTCFG test below and the
+	 * reachability/aliasing test in pci_cfg_space_size_ext() by virtue of
+	 * the fact that the SR-IOV capability on the PF resides in extended
+	 * config space and must be accessible and non-aliased to have enabled
+	 * support for this VF.  This is a micro performance optimization for
+	 * systems supporting many VFs.
+	 */
+	if (dev->is_virtfn)
+		return PCI_CFG_SPACE_EXP_SIZE;
+#endif
+
 	if (dev->bus->bus_flags & PCI_BUS_FLAGS_NO_EXTCFG)
 		return PCI_CFG_SPACE_SIZE;
 


  parent reply	other threads:[~2019-06-13 22:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-13 22:56 [PATCH 0/2] PCI/IOV: Resolve regression in SR-IOV VF cfg_size Alex Williamson
2019-06-13 22:57 ` [PATCH 1/2] Revert: PCI/IOV: Use VF0 cached config space size for other VFs Alex Williamson
2019-06-13 22:57 ` Alex Williamson [this message]
2019-06-19 19:54   ` [PATCH 2/2] PCI/IOV: Assume SR-IOV VFs support extended config space sathyanarayanan kuppuswamy
2019-07-03 13:59 ` [PATCH 0/2] PCI/IOV: Resolve regression in SR-IOV VF cfg_size 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=156046664016.29869.16676461736240878900.stgit@gimli.home \
    --to=alex.williamson@redhat.com \
    --cc=ashok.raj@intel.com \
    --cc=bhelgaas@google.com \
    --cc=karahmed@amazon.de \
    --cc=keith.busch@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mike.campin@intel.com \
    --cc=nanhai.zou@linux.alibaba.com \
    --cc=quan.xu0@linux.alibaba.com \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=yinhe@linux.alibaba.com \
    /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).