[PATCH] PCI: Cleanup SR-IOV state on unsuccessful PF driver probe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



During the probe, the PF driver might call pci_sriov_set_totalvfs()
to reduce the number of supported VFs. This will be restored later
by the PCI layer when the PF driver is detached.

In rare cases, when the PF driver fails the .probe routine after
it reduced the number of supported VFs, the value of TotalVFs will
not be restored automatically. This may impact subsequent probe
attempts as next calls to pci_sriov_get_totalvfs() will return an
already modified value.

To avoid this issue, either we should expect that all PF drivers
will restore TotalVFs on its own before failing the probe, or we
can do some explicit cleanup inside the PCI layer. Since the
latter case seems to be trivial to implement, let's start with it.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@xxxxxxxxx>
---
Cc: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
Cc: linux-pci@xxxxxxxxxxxxxxx
---
 drivers/pci/pci-driver.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index af2996d0d17f..c949fdd09f26 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -326,6 +326,7 @@ static long local_pci_probe(void *_ddi)
 		return rc;
 	if (rc < 0) {
 		pci_dev->driver = NULL;
+		pci_iov_remove(pci_dev);
 		pm_runtime_put_sync(dev);
 		return rc;
 	}
-- 
2.43.0





[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux