]> xenbits.xensource.com Git - pvdrivers/win/xenbus.git/commitdiff
Install filters on first FDO creation and remove on last deletion
authorPaul Durrant <paul.durrant@citrix.com>
Thu, 23 Jul 2015 10:53:22 +0000 (11:53 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Thu, 23 Jul 2015 14:12:15 +0000 (15:12 +0100)
When XENBUS binds to two devices (as it may when the vendor PCI device
is present) then installing/removing filters on a per-FDO basis does not
work properly.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
src/xenbus/driver.c
src/xenbus/fdo.c

index 3409270fac9ed0cb8970a6a14dd7af5fe65de62a..46712e3bc90f772c1673ba704d9195792249c9c3 100644 (file)
@@ -39,6 +39,7 @@
 #include "driver.h"
 #include "names.h"
 #include "mutex.h"
+#include "filters.h"
 #include "dbg_print.h"
 #include "assert.h"
 #include "util.h"
@@ -193,13 +194,17 @@ DriverAddFunctionDeviceObject(
 {
     PDEVICE_OBJECT  DeviceObject;
     PXENBUS_DX      Dx;
+    ULONG           References;
 
     DeviceObject = FdoGetDeviceObject(Fdo);
     Dx = (PXENBUS_DX)DeviceObject->DeviceExtension;
     ASSERT3U(Dx->Type, ==, FUNCTION_DEVICE_OBJECT);
 
     InsertTailList(&Driver.List, &Dx->ListEntry);
-    Driver.References++;
+    References = Driver.References++;
+
+    if (References == 1)
+        FiltersInstall();
 }
 
 VOID
@@ -209,6 +214,7 @@ DriverRemoveFunctionDeviceObject(
 {
     PDEVICE_OBJECT  DeviceObject;
     PXENBUS_DX      Dx;
+    ULONG           References;
 
     DeviceObject = FdoGetDeviceObject(Fdo);
     Dx = (PXENBUS_DX)DeviceObject->DeviceExtension;
@@ -216,7 +222,10 @@ DriverRemoveFunctionDeviceObject(
 
     RemoveEntryList(&Dx->ListEntry);
     ASSERT3U(Driver.References, !=, 0);
-    --Driver.References;
+    References = --Driver.References;
+
+    if (References == 1)
+        FiltersUninstall();
 }
 
 DRIVER_UNLOAD       DriverUnload;
index 5d03f8ca6f366fce92081170e899b76f4e155e93..1e5538177a9fd8ee2895de585d0b446d20deaa9d 100644 (file)
@@ -59,7 +59,6 @@
 #include "driver.h"
 #include "range_set.h"
 #include "unplug.h"
-#include "filters.h"
 #include "dbg_print.h"
 #include "assert.h"
 #include "util.h"
@@ -4837,7 +4836,6 @@ FdoCreate(
         goto fail8;
 
     if (Fdo->PvdeviceInterface.Interface.Context == NULL) {
-        (VOID) FiltersInstall();
         DriverRequestReboot();
         goto done;
     }
@@ -5148,8 +5146,6 @@ FdoDestroy(
         FdoClearActive(Fdo);
     }
 
-    (VOID) FiltersUninstall();
-
     RtlZeroMemory(&Fdo->PvdeviceInterface,
                   sizeof (XENFILT_PVDEVICE_INTERFACE));