Return-Path: Received: from mail-by2nam01on0104.outbound.protection.outlook.com ([104.47.34.104]:11884 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754843AbeARVBU (ORCPT ); Thu, 18 Jan 2018 16:01:20 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Sumit Semwal , Gavin Shan , Bjorn Helgaas , Sasha Levin Subject: [added to the 4.1 stable tree] PCI: Do any VF BAR updates before enabling the BARs Date: Thu, 18 Jan 2018 21:00:05 +0000 Message-ID: <20180118205908.3220-79-alexander.levin@microsoft.com> References: <20180118205908.3220-1-alexander.levin@microsoft.com> In-Reply-To: <20180118205908.3220-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Sumit Semwal This patch has been added to the stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ 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 Signed-off-by: Gavin Shan Signed-off-by: Bjorn Helgaas Signed-off-by: Sasha Levin --- drivers/pci/iov.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 846d4f604ebd..089a1f41e44e 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -302,13 +302,6 @@ static int sriov_enable(struct pci_dev *dev, int nr_vi= rtfn) return rc; } =20 - pci_iov_set_numvfs(dev, nr_virtfn); - iov->ctrl |=3D PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE; - pci_cfg_access_lock(dev); - pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl); - msleep(100); - pci_cfg_access_unlock(dev); - iov->initial_VFs =3D initial; if (nr_virtfn < initial) initial =3D nr_virtfn; @@ -319,6 +312,13 @@ static int sriov_enable(struct pci_dev *dev, int nr_vi= rtfn) return retval; } =20 + pci_iov_set_numvfs(dev, nr_virtfn); + iov->ctrl |=3D PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE; + pci_cfg_access_lock(dev); + pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl); + msleep(100); + pci_cfg_access_unlock(dev); + for (i =3D 0; i < initial; i++) { rc =3D virtfn_add(dev, i, 0); if (rc) --=20 2.11.0