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: 821370 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="D6wzn4v4"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3y6gXm4kYGz9t2Z for ; Thu, 5 Oct 2017 02:58:00 +1100 (AEDT) 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 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: