From patchwork Wed Oct 4 15:57:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stuart hayes X-Patchwork-Id: 9985003 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A22876028E for ; Wed, 4 Oct 2017 15:58:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93EDE28B45 for ; Wed, 4 Oct 2017 15:58:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88B7428B4A; Wed, 4 Oct 2017 15:58:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39B8F28B45 for ; Wed, 4 Oct 2017 15:58:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751316AbdJDP56 (ORCPT ); Wed, 4 Oct 2017 11:57:58 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:48202 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751925AbdJDP54 (ORCPT ); Wed, 4 Oct 2017 11:57:56 -0400 Received: by mail-oi0-f66.google.com with SMTP id m198so7871218oig.5 for ; Wed, 04 Oct 2017 08:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=vXdmlvZMQjPum5FJvQjFAzozW7RH6lNxEGTsAkWUr6A=; b=D6wzn4v4BZPPZ36dAyt/FcD+F4zGic+uza/J77TwKN7OCRfxhiyJwE07aXWr1wU5qn eRFVNrINNPgv0CfWGDck2XIpabkloNKixkwm/O2W80Vos7xbSdCQRplkroRfPTH5nCF4 Pd/hy+9gvOQAsopNtmgcwlN6DPyOSF++itKxcgWsdrq7nLnjmCuz7cJPXSGZwnqh035k XaPukinnyo8UsfxBIh7/V0YeJV6SB5U6006H7YsAxlSelRrKe9WJKKE7M08cNwAai66R xwrAzYyTdMr2iwl9PMluA1VjRAOUyqVCSxgtzOKpOggcHeC27AhTZZa9ydmGf/ZE7+gp S4Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=vXdmlvZMQjPum5FJvQjFAzozW7RH6lNxEGTsAkWUr6A=; b=NGXW3Ol3aMUWShdXJ29c44GMfknqFV2vC0NCgM/+VlA8uHjQXLW1h1l0XsXZiuGUVY 8pW5GguCG2nqq0Zqrt4Ejce9pyyoa+qYdJry+uVW+vgHADR5a+PkQEuwJ0gX9y7GvIGz /vWh62vzVzh+IKVJf8zfKSDxcXzknFjS9q9p+XgIyLmEC5WoJo3DOg0EcTecovLBfD77 31A4dws5QBU/UcI9AQ4SZ0wVDwSKQkFCPMmP1dR5/jcHaAjJ4r/VoTZphrYb5rHpC4Zd oWNKydhwp/7JczyzNUjjKvHAN9+ZNntpjE8VbcUZPOSSCQPCkBWwyCkI/DT8gl4CkuIK S4rA== X-Gm-Message-State: AMCzsaUWw9/x0boLJbSxi3lR6igvP8X285oFZuYqbJ0O3AjtiMO6l/Lr wLTrsSPiSSDtYgoZSwXKcoq/+26E X-Google-Smtp-Source: AOwi7QDAU3/I0VHZL4wWQixbnXhSih/m8ONDVNhUwqqxkuKDWFYlBUYL40+jdivXAxWvlYaK74mPeA== X-Received: by 10.202.170.144 with SMTP id t138mr8403619oie.11.1507132675505; Wed, 04 Oct 2017 08:57:55 -0700 (PDT) Received: from [192.168.0.2] (cpe-24-27-59-32.austin.res.rr.com. [24.27.59.32]) by smtp.gmail.com with ESMTPSA id s14sm8552815ots.22.2017.10.04.08.57.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 08:57:54 -0700 (PDT) Subject: [PATCH] PCI: Create iov virtfn/physfn links before attaching driver To: Bjorn Helgaas Cc: bhelgaas@google.com, linux-pci@vger.kernel.org References: <20170926205745.GR15970@bhelgaas-glaptop.roam.corp.google.com> From: Stuart Hayes Message-ID: <45746aaf-656c-3ca7-9c11-55607a8154d2@gmail.com> Date: Wed, 4 Oct 2017 10:57:52 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170926205745.GR15970@bhelgaas-glaptop.roam.corp.google.com> Content-Language: en-US X-Antivirus: Avast (VPS 171004-0, 10/04/2017), Outbound message X-Antivirus-Status: Clean Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When creating virtual functions, create the "virtfn%u" and "physfn" links in sysfs before attaching the driver. Without this, there is a race when the driver attaches to the new virtual network interface and 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 --- --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus --- linux-4.14-rc1/drivers/pci/iov.c.orig 2017-09-18 15:00:43.168255665 -0500 +++ linux-4.14-rc1/drivers/pci/iov.c 2017-09-18 15:07:04.792280999 -0500 @@ -162,7 +162,6 @@ int pci_iov_add_virtfn(struct pci_dev *d pci_device_add(virtfn, virtfn->bus); - pci_bus_add_device(virtfn); sprintf(buf, "virtfn%u", id); rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf); if (rc) @@ -173,6 +172,8 @@ int pci_iov_add_virtfn(struct pci_dev *d kobject_uevent(&virtfn->dev.kobj, KOBJ_CHANGE); + pci_bus_add_device(virtfn); + return 0; failed2: