[ros-diffs] [cgutman] 52071: [USBSTOR] - Don't leave DISPATCH_LEVEL while holding a spin lock acquired at DISPATCH_LEVEL - Synchronize cancellation checking by acquiring the cancel spin lock

cgutman at svn.reactos.org cgutman at svn.reactos.org
Fri Jun 3 05:38:31 UTC 2011


Author: cgutman
Date: Fri Jun  3 05:38:27 2011
New Revision: 52071

URL: http://svn.reactos.org/svn/reactos?rev=52071&view=rev
Log:
[USBSTOR]
- Don't leave DISPATCH_LEVEL while holding a spin lock acquired at DISPATCH_LEVEL
- Synchronize cancellation checking by acquiring the cancel spin lock

Modified:
    branches/usb-bringup/drivers/usb/usbstor/queue.c

Modified: branches/usb-bringup/drivers/usb/usbstor/queue.c
URL: http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor/queue.c?rev=52071&r1=52070&r2=52071&view=diff
==============================================================================
--- branches/usb-bringup/drivers/usb/usbstor/queue.c [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbstor/queue.c [iso-8859-1] Fri Jun  3 05:38:27 2011
@@ -56,19 +56,19 @@
     KeAcquireSpinLockAtDpcLevel(&FDODeviceExtension->IrpListLock);
 
     //
+    // remove the irp from the list
+    //
+    RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
+
+    //
+    // release irp list lock
+    //
+    KeReleaseSpinLockFromDpcLevel(&FDODeviceExtension->IrpListLock);    
+
+    //
     // now release the cancel lock
     //
     IoReleaseCancelSpinLock(Irp->CancelIrql);
-
-    //
-    // remove the irp from the list
-    //
-    RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
-
-    //
-    // release irp list lock
-    //
-    KeReleaseSpinLockFromDpcLevel(&FDODeviceExtension->IrpListLock);
 
     //
     // set cancel status
@@ -132,6 +132,21 @@
    FDODeviceExtension->IrpPendingCount++;
 
     //
+    // check if queue is freezed
+    //
+    IrpListFreeze = FDODeviceExtension->IrpListFreeze;
+
+    //
+    // release list lock
+    //
+    KeReleaseSpinLock(&FDODeviceExtension->IrpListLock, OldLevel);
+
+    //
+    // synchronize with cancellations by holding the cancel lock
+    //
+    IoAcquireCancelSpinLock(&Irp->CancelIrql);
+
+    //
     // now set the driver cancel routine
     //
     OldDriverCancel = IoSetCancelRoutine(Irp, USBSTOR_CancelIo);
@@ -142,16 +157,6 @@
     if (Irp->Cancel && OldDriverCancel == NULL)
     {
         //
-        // the irp has already been cancelled
-        //
-        KeReleaseSpinLock(&FDODeviceExtension->IrpListLock, OldLevel);
-
-        //
-        // cancel routine requires that cancel spinlock is held
-        //
-        IoAcquireCancelSpinLock(&Irp->CancelIrql);
-
-        //
         // cancel irp
         //
         USBSTOR_CancelIo(DeviceObject, Irp);
@@ -163,14 +168,9 @@
     }
 
     //
-    // check if queue is freezed
-    //
-    IrpListFreeze = FDODeviceExtension->IrpListFreeze;
-
-    //
-    // release list lock
-    //
-    KeReleaseSpinLock(&FDODeviceExtension->IrpListLock, OldLevel);
+    // release the cancel lock
+    //
+    IoReleaseCancelSpinLock(Irp->CancelIrql);
 
     //
     // if list is freezed, dont start this packet




More information about the Ros-diffs mailing list