Blob Blame History Raw
From e42d042736cc8d856cb4e87fd1d5e2f13448d308 Mon Sep 17 00:00:00 2001
From: "Bryant G. Ly" <bryantly@linux.vnet.ibm.com>
Date: Thu, 9 Nov 2017 08:00:35 -0600
Subject: [PATCH 04/11] PCI/IOV: Add pci_vf_drivers_autoprobe() interface

References: FATE#324970, bsc#1078720
Patch-mainline: v4.16-rc1
Git-commit: 608c0d8804ef3ca4cda8ec6ad914e47deb283d7b

Add a pci_vf_drivers_autoprobe() interface. Setting autoprobe to false
on the PF prevents drivers from binding to VFs when they are enabled.

Signed-off-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com>
Signed-off-by: Juan J. Alvarez <jjalvare@linux.vnet.ibm.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Russell Currey <ruscur@russell.cc>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Acked-by: Michal Suchanek <msuchanek@suse.de>
---
 arch/powerpc/platforms/pseries/pci.c |  2 ++
 drivers/pci/iov.c                    | 11 +++++++++++
 include/linux/pci.h                  |  2 ++
 3 files changed, 15 insertions(+)

diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index 14a90cf471cc..48d3af026f90 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -63,6 +63,7 @@ int pseries_pcibios_sriov_enable(struct pci_dev *pdev, u16 num_vfs)
 {
 	/* Allocate PCI data */
 	add_dev_pci_data(pdev);
+	pci_vf_drivers_autoprobe(pdev, false);
 	return 0;
 }
 
@@ -70,6 +71,7 @@ int pseries_pcibios_sriov_disable(struct pci_dev *pdev)
 {
 	/* Release PCI data */
 	remove_dev_pci_data(pdev);
+	pci_vf_drivers_autoprobe(pdev, true);
 	return 0;
 }
 #endif
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 12c9779e02a0..04cacdc7c916 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -629,6 +629,17 @@ void pci_restore_iov_state(struct pci_dev *dev)
 }
 
 /**
+ * pci_vf_drivers_autoprobe - set PF property drivers_autoprobe for VFs
+ * @dev: the PCI device
+ * @auto_probe: set VF drivers auto probe flag
+ */
+void pci_vf_drivers_autoprobe(struct pci_dev *dev, bool auto_probe)
+{
+	if (dev->is_physfn)
+		dev->sriov->drivers_autoprobe = auto_probe;
+}
+
+/**
  * pci_iov_bus_range - find bus range used by Virtual Function
  * @bus: the PCI bus
  *
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 8ae0fd23cb30..25880ca7cc78 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1909,6 +1909,7 @@ int pci_vfs_assigned(struct pci_dev *dev);
 int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs);
 int pci_sriov_get_totalvfs(struct pci_dev *dev);
 resource_size_t pci_iov_resource_size(struct pci_dev *dev, int resno);
+void pci_vf_drivers_autoprobe(struct pci_dev *dev, bool probe);
 #else
 static inline int pci_iov_virtfn_bus(struct pci_dev *dev, int id)
 {
@@ -1936,6 +1937,7 @@ static inline int pci_sriov_get_totalvfs(struct pci_dev *dev)
 { return 0; }
 static inline resource_size_t pci_iov_resource_size(struct pci_dev *dev, int resno)
 { return 0; }
+static inline void pci_vf_drivers_autoprobe(struct pci_dev *dev, bool probe) { }
 #endif
 
 #if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE)
-- 
2.13.6