On Fri, 2015-10-30 at 04:59 +0530, Shivaprasad G Bhat wrote:
The reprobe needs to be called multiple times for vfio devices for
each
device in the iommu group in future patch. So split the reprobe into a
new function. No functional change.
Signed-off-by: Shivaprasad G Bhat <sbhat(a)linux.vnet.ibm.com>
---
src/util/virpci.c | 54 +++++++++++++++++++++++++++++++----------------------
1 file changed, 32 insertions(+), 22 deletions(-)
diff --git a/src/util/virpci.c b/src/util/virpci.c
index eba285a..2709ddd 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1097,6 +1097,37 @@ static bool virPCIIsAKnownStub(char *driver)
return ret;
}
+static int virPCIDeviceReprobeHostDriver(virPCIDevicePtr dev, char *driver, char
*drvdir)
+{
+ char *path = NULL;
+ int result = -1;
+
+ if (!dev->reprobe)
+ return 0;
+
+ /* Trigger a re-probe of the device is not in the stub's dynamic
+ * ID table. If the stub is available, but 'remove_id' isn't
+ * available, then re-probing would just cause the device to be
+ * re-bound to the stub.
+ */
+ if (driver && !(path = virPCIDriverFile(driver, "remove_id")))
+ goto cleanup;
+
+ if (!driver || !virFileExists(drvdir) || virFileExists(path)) {
+ if (virFileWriteStr(PCI_SYSFS "drivers_probe", dev->name, 0) <
0) {
+ virReportSystemError(errno,
+ _("Failed to trigger a re-probe for PCI device
'%s'"),
+ dev->name);
+ goto cleanup;
+ }
+ }
+ result = 0;
+ cleanup:
+ VIR_FREE(path);
+ dev->reprobe = false;
+ return result;
+}
+
static int
virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
{
@@ -1144,28 +1175,8 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
dev->remove_slot = false;
reprobe:
- if (!dev->reprobe) {
- result = 0;
+ if (virPCIDeviceReprobeHostDriver(dev, driver, drvdir) < 0)
goto cleanup;
- }
This actually introduces a flow change in the function:
before this patch, when dev->reprobe is false we set
result = 0 and jumped to cleanup, while now
virPCIDeviceReprobeHostDriver() returns 0 and the rest
of virPCIDeviceUnbindFromStub() is executed.
I would leave the check for the value of dev->reprobe
and setting it to false in cleanup out of
virPCIDeviceReprobeHostDriver().
-
- /* Trigger a re-probe of the device is not in the stub's dynamic
- * ID table. If the stub is available, but 'remove_id' isn't
- * available, then re-probing would just cause the device to be
- * re-bound to the stub.
- */
- VIR_FREE(path);
- if (driver && !(path = virPCIDriverFile(driver, "remove_id")))
- goto cleanup;
-
- if (!driver || !virFileExists(drvdir) || virFileExists(path)) {
- if (virFileWriteStr(PCI_SYSFS "drivers_probe", dev->name, 0) <
0) {
- virReportSystemError(errno,
- _("Failed to trigger a re-probe for PCI device
'%s'"),
- dev->name);
- goto cleanup;
- }
- }
result = 0;
@@ -1173,7 +1184,6 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
/* do not do it again */
dev->unbind_from_stub = false;
dev->remove_slot = false;
- dev->reprobe = false;
VIR_FREE(drvdir);
VIR_FREE(path);
Cheers.
--
Andrea Bolognani
Software Engineer - Virtualization Team