diff mbox series

PCI: Create iov virtfn/physfn links before attaching driver

Message ID 45746aaf-656c-3ca7-9c11-55607a8154d2@gmail.com
State Accepted
Headers show
Series PCI: Create iov virtfn/physfn links before attaching driver | expand

Commit Message

Stuart Hayes Oct. 4, 2017, 3:57 p.m. UTC
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 <stuart.w.hayes@gmail.com>
---


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Comments

Bjorn Helgaas Oct. 4, 2017, 7:44 p.m. UTC | #1
On Wed, Oct 04, 2017 at 10:57:52AM -0500, Stuart Hayes wrote:
> 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 <stuart.w.hayes@gmail.com>

Applied to pci/virtualization for v4.15, thanks!

> ---
> 
> --- 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:
> 
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
diff mbox series

Patch

--- 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: