Skip to content

Commit 4110080

Browse files
sumitsemwalgregkh
authored andcommitted
PCI: Do any VF BAR updates before enabling the BARs
From: Gavin Shan <gwshan@linux.vnet.ibm.com> [ Upstream commit f40ec3c748c6912f6266c56a7f7992de61b255ed ] Previously we enabled VFs and enable their memory space before calling pcibios_sriov_enable(). But pcibios_sriov_enable() may update the VF BARs: for example, on PPC PowerNV we may change them to manage the association of VFs to PEs. Because 64-bit BARs cannot be updated atomically, it's unsafe to update them while they're enabled. The half-updated state may conflict with other devices in the system. Call pcibios_sriov_enable() before enabling the VFs so any BAR updates happen while the VF BARs are disabled. [bhelgaas: changelog] Tested-by: Carol Soto <clsoto@us.ibm.com> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bcbdcf4 commit 4110080

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

drivers/pci/iov.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,6 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
303303
return rc;
304304
}
305305

306-
pci_iov_set_numvfs(dev, nr_virtfn);
307-
iov->ctrl |= PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE;
308-
pci_cfg_access_lock(dev);
309-
pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl);
310-
msleep(100);
311-
pci_cfg_access_unlock(dev);
312-
313306
iov->initial_VFs = initial;
314307
if (nr_virtfn < initial)
315308
initial = nr_virtfn;
@@ -320,6 +313,13 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
320313
goto err_pcibios;
321314
}
322315

316+
pci_iov_set_numvfs(dev, nr_virtfn);
317+
iov->ctrl |= PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE;
318+
pci_cfg_access_lock(dev);
319+
pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl);
320+
msleep(100);
321+
pci_cfg_access_unlock(dev);
322+
323323
for (i = 0; i < initial; i++) {
324324
rc = virtfn_add(dev, i, 0);
325325
if (rc)

0 commit comments

Comments
 (0)