Linux-PCI Archive on
 help / color / Atom feed
From: Alex Williamson <>
Cc: KarimAllah Ahmed <>,,
Subject: [PATCH] PCI/IOV: Fix VF cfg_size
Date: Tue, 04 Jun 2019 11:26:42 -0600
Message-ID: <155966918965.10361.16228304474160813310.stgit@gimli.home> (raw)

Commit 975bb8b4dc93 ("PCI/IOV: Use VF0 cached config space size for
other VFs") attempts to cache the config space size of VF0 to re-use
for all other VFs, but the cache is setup before the call to
pci_setup_device(), where we use set_pcie_port_type() to setup the
pcie_cap field on the struct pci_dev.  Without pcie_cap configured,
pci_cfg_space_size() returns PCI_CFG_SPACE_SIZE for the size.  VF0
has a bypass through pci_cfg_space_size(), so its size is reported
correctly, but all subsequent VFs incorrectly report 256 bytes of
config space.

Resolve by delaying pci_read_vf_config_common() until after

Fixes: 975bb8b4dc93 ("PCI/IOV: Use VF0 cached config space size for other VFs")
Cc: KarimAllah Ahmed <>
Signed-off-by: Alex Williamson <>
 drivers/pci/iov.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 3aa115ed3a65..34b1f78f4d31 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -161,13 +161,13 @@ int pci_iov_add_virtfn(struct pci_dev *dev, int id)
 	virtfn->is_virtfn = 1;
 	virtfn->physfn = pci_dev_get(dev);
-	if (id == 0)
-		pci_read_vf_config_common(virtfn);
 	rc = pci_setup_device(virtfn);
 	if (rc)
 		goto failed1;
+	if (id == 0)
+		pci_read_vf_config_common(virtfn);
 	virtfn->dev.parent = dev->dev.parent;
 	virtfn->multifunction = 0;

             reply index

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-04 17:26 Alex Williamson [this message]
2019-06-04 20:36 ` Alex Williamson
2019-06-13 21:20   ` Bjorn Helgaas
2019-06-13 22:01     ` Alex Williamson

Reply instructions:

You may reply publically 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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=155966918965.10361.16228304474160813310.stgit@gimli.home \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-PCI Archive on

Archives are clonable:
	git clone --mirror linux-pci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-pci linux-pci/ \
	public-inbox-index linux-pci

Newsgroup available over NNTP:

AGPL code for this site: git clone public-inbox