[USBHUB]
authorCameron Gutman <aicommander@gmail.com>
Mon, 30 Jan 2012 22:45:16 +0000 (22:45 +0000)
committerCameron Gutman <aicommander@gmail.com>
Mon, 30 Jan 2012 22:45:16 +0000 (22:45 +0000)
- Missed a fix from last commit
- Wait for the device status change work item to complete
- The USB stack is now properly constructed for USB booting

svn path=/branches/usb-bringup-trunk/; revision=55339

drivers/usb/usbhub_new/fdo.c
drivers/usb/usbhub_new/usbhub.h

index 31c91ef..5497c3e 100644 (file)
@@ -260,8 +260,6 @@ DeviceStatusChangeThread(
     PORT_STATUS_CHANGE PortStatus;
     LONG PortId;
 
-    static LONG failsafe = 0;
-
     DPRINT1("Entered DeviceStatusChangeThread, Context %x\n", Context);
 
     WorkItemData = (PWORK_ITEM_DATA)Context;
@@ -408,20 +406,7 @@ DeviceStatusChangeThread(
         }
     }
 
-    //
-    // FIXME: Still in testing
-    //
-    failsafe++;
-    if (failsafe > 100)
-    {
-        DPRINT1("SCE completed over 100 times but no action has been taken to clear the Change of any ports.\n");
-        //
-        // Return and dont send any more SCE Requests
-        //
-        return;
-    }
-
-    ExFreePool(WorkItemData);
+    KeSetEvent(&WorkItemData->Event, IO_NO_INCREMENT, FALSE);
 
     //
     // Send another SCE Request
@@ -460,6 +445,7 @@ StatusChangeEndpointCompletion(
         return STATUS_INSUFFICIENT_RESOURCES;
     }
     WorkItemData->Context = RealDeviceObject;
+    KeInitializeEvent(&WorkItemData->Event, NotificationEvent, FALSE);
     DPRINT1("Initialize work item\n");
     ExInitializeWorkItem(&WorkItemData->WorkItem, DeviceStatusChangeThread, (PVOID)WorkItemData);
 
@@ -468,6 +454,16 @@ StatusChangeEndpointCompletion(
     //
     ExQueueWorkItem(&WorkItemData->WorkItem, DelayedWorkQueue);
 
+    //
+    // Wait for the work item
+    //
+    KeWaitForSingleObject(&WorkItemData->Event,
+                          Executive,
+                          KernelMode,
+                          FALSE,
+                          NULL);
+    ExFreePool(WorkItemData);
+
     //
     // Return more processing required so the IO Manger doesn’t try to mess with IRP just freed
     //
@@ -1823,6 +1819,11 @@ USBHUB_FdoHandlePnp(
             }
             else
             {
+                //
+                // Send the first SCE Request
+                //
+                QueryStatusChangeEndpoint(DeviceObject);
+
                 //
                 // reset ports
                 //
@@ -1848,11 +1849,6 @@ USBHUB_FdoHandlePnp(
                         }
                     }
                 }
-
-                //
-                // Send the first SCE Request
-                //
-                QueryStatusChangeEndpoint(DeviceObject);
             }
 
             ExFreePool(Urb);
index c163d92..7f57ddd 100644 (file)
@@ -44,6 +44,7 @@ typedef struct _PORT_STATUS_CHANGE
 typedef struct _WORK_ITEM_DATA
 {
     WORK_QUEUE_ITEM WorkItem;
+    KEVENT Event;
     PVOID Context;
 } WORK_ITEM_DATA, *PWORK_ITEM_DATA;