diff options
author | Xudong Hao <xudong.hao@intel.com> | 2013-05-31 00:21:29 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2013-05-31 17:30:02 -0400 |
commit | fbf33f516bdbcc2ab1ba1e54dfb720b0cfaa6874 (patch) | |
tree | e9fae8a71b38e6cb5bf27d1ccef89a11e7bb3b9c | |
parent | f722406faae2d073cc1d01063d1123c35425939e (diff) |
PCI: Finish SR-IOV VF setup before adding the device
Commit 4f535093cf "PCI: Put pci_dev in device tree as early as possible"
moves device registering from pci_bus_add_devices() to pci_device_add().
That causes problems for virtual functions because device_add(&virtfn->dev)
is called before setting the virtfn->is_virtfn flag, which then causes Xen
to report PCI virtual functions as PCI physical functions.
Fix it by setting virtfn->is_virtfn before calling pci_device_add().
[Jiang Liu]: Move the setting of virtfn->is_virtfn ahead further for better
readability and modify changelog.
Signed-off-by: Xudong Hao <xudong.hao@intel.com>
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable@vger.kernel.org # v3.9+
-rw-r--r-- | drivers/pci/iov.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index c93071d428f5..a971a6f6268d 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c | |||
@@ -92,6 +92,8 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset) | |||
92 | pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_DID, &virtfn->device); | 92 | pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_DID, &virtfn->device); |
93 | pci_setup_device(virtfn); | 93 | pci_setup_device(virtfn); |
94 | virtfn->dev.parent = dev->dev.parent; | 94 | virtfn->dev.parent = dev->dev.parent; |
95 | virtfn->physfn = pci_dev_get(dev); | ||
96 | virtfn->is_virtfn = 1; | ||
95 | 97 | ||
96 | for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) { | 98 | for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) { |
97 | res = dev->resource + PCI_IOV_RESOURCES + i; | 99 | res = dev->resource + PCI_IOV_RESOURCES + i; |
@@ -113,9 +115,6 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset) | |||
113 | pci_device_add(virtfn, virtfn->bus); | 115 | pci_device_add(virtfn, virtfn->bus); |
114 | mutex_unlock(&iov->dev->sriov->lock); | 116 | mutex_unlock(&iov->dev->sriov->lock); |
115 | 117 | ||
116 | virtfn->physfn = pci_dev_get(dev); | ||
117 | virtfn->is_virtfn = 1; | ||
118 | |||
119 | rc = pci_bus_add_device(virtfn); | 118 | rc = pci_bus_add_device(virtfn); |
120 | sprintf(buf, "virtfn%u", id); | 119 | sprintf(buf, "virtfn%u", id); |
121 | rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf); | 120 | rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf); |