From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sn1nam01on0094.outbound.protection.outlook.com ([104.47.32.94]:45235 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1031942AbeCAPYX (ORCPT ); Thu, 1 Mar 2018 10:24:23 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Stuart Hayes , Bjorn Helgaas , Sasha Levin Subject: [added to the 4.1 stable tree] PCI: Create SR-IOV virtfn/physfn links before attaching driver Date: Thu, 1 Mar 2018 15:22:56 +0000 Message-ID: <20180301152116.1486-49-alexander.levin@microsoft.com> References: <20180301152116.1486-1-alexander.levin@microsoft.com> In-Reply-To: <20180301152116.1486-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: Stuart Hayes This patch has been added to the 4.1 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 27d6162944b9b34c32cd5841acd21786637ee743 ] When creating virtual functions, create the "virtfn%u" and "physfn" links in sysfs *before* attaching the driver instead of after. When we attach the driver to the new virtual network interface first, there is a race when the driver attaches to the new sends out an "add" udev event, and the network interface naming software (biosdevname or systemd, for example) tries to look at these links. Signed-off-by: Stuart Hayes Signed-off-by: Bjorn Helgaas Signed-off-by: Sasha Levin --- drivers/pci/iov.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 089a1f41e44e..95db37cf5f08 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -156,7 +156,6 @@ static int virtfn_add(struct pci_dev *dev, int id, int = reset) pci_device_add(virtfn, virtfn->bus); mutex_unlock(&iov->dev->sriov->lock); =20 - pci_bus_add_device(virtfn); sprintf(buf, "virtfn%u", id); rc =3D sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf); if (rc) @@ -167,6 +166,8 @@ static int virtfn_add(struct pci_dev *dev, int id, int = reset) =20 kobject_uevent(&virtfn->dev.kobj, KOBJ_CHANGE); =20 + pci_bus_add_device(virtfn); + return 0; =20 failed2: --=20 2.14.1