Author: cgutman Date: Wed Feb 8 15:50:52 2012 New Revision: 55493
URL: http://svn.reactos.org/svn/reactos?rev=55493&view=rev Log: [USBHUB] - Don't wait for the work item to complete in the SCE completion handler - Use an event to signal the completion of a reset and wait for that event during IRP_MN_START_DEVICE handling so devices are enumerated synchronously which allows USB boot devices to be enumerated
Modified: branches/usb-bringup-trunk/drivers/usb/usbhub_new/fdo.c branches/usb-bringup-trunk/drivers/usb/usbhub_new/usbhub.c branches/usb-bringup-trunk/drivers/usb/usbhub_new/usbhub.h
Modified: branches/usb-bringup-trunk/drivers/usb/usbhub_new/fdo.c URL: http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/us... ============================================================================== --- branches/usb-bringup-trunk/drivers/usb/usbhub_new/fdo.c [iso-8859-1] (original) +++ branches/usb-bringup-trunk/drivers/usb/usbhub_new/fdo.c [iso-8859-1] Wed Feb 8 15:50:52 2012 @@ -1,4 +1,4 @@ -/* +/* * PROJECT: ReactOS Universal Serial Bus Hub Driver * LICENSE: GPL - See COPYING in the top level directory * FILE: drivers/usb/usbhub/fdo.c @@ -260,6 +260,7 @@ PWORK_ITEM_DATA WorkItemData; PORT_STATUS_CHANGE PortStatus; LONG PortId; + BOOLEAN SignalResetComplete = FALSE;
DPRINT1("Entered DeviceStatusChangeThread, Context %x\n", Context);
@@ -404,16 +405,32 @@ // This is a new device // Status = CreateUsbChildDeviceObject(DeviceObject, PortId, NULL, PortStatus.Status); - } - } - - KeSetEvent(&WorkItemData->Event, IO_NO_INCREMENT, FALSE); + + // + // Request event signalling later + // + SignalResetComplete = TRUE; + } + } + + ExFreePool(WorkItemData);
// // Send another SCE Request // DPRINT1("Sending another SCE!\n"); QueryStatusChangeEndpoint(DeviceObject); + + // + // Check if a reset event was satisfied + // + if (SignalResetComplete) + { + // + // Signal anyone waiting on it + // + KeSetEvent(&HubDeviceExtension->ResetComplete, IO_NO_INCREMENT, FALSE); + } }
NTSTATUS @@ -446,24 +463,14 @@ return STATUS_INSUFFICIENT_RESOURCES; } WorkItemData->Context = RealDeviceObject; - KeInitializeEvent(&WorkItemData->Event, NotificationEvent, FALSE); - DPRINT1("Initialize work item\n"); + + DPRINT1("Queuing work item\n"); + + // + // Queue the work item to handle initializing the device + // ExInitializeWorkItem(&WorkItemData->WorkItem, DeviceStatusChangeThread, (PVOID)WorkItemData); - - // - // Queue the work item to handle initializing the device - // 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 @@ -1467,7 +1474,21 @@ // Status = SetPortFeature(HubDeviceExtension->RootHubPhysicalDeviceObject, PortId, PORT_RESET); if (!NT_SUCCESS(Status)) + { DPRINT1("Failed to reset on port %d\n", PortId); + } + else + { + // + // wait for the reset to be handled since we want to enumerate synchronously + // + KeWaitForSingleObject(&HubDeviceExtension->ResetComplete, + Executive, + KernelMode, + FALSE, + NULL); + KeClearEvent(&HubDeviceExtension->ResetComplete); + } } } } @@ -1807,7 +1828,7 @@ DPRINT1("RootHubInitNotification %x\n", HubDeviceExtension->HubInterface.RootHubInitNotification);
// - // init roo hub notification + // init root hub notification // if (HubDeviceExtension->HubInterface.RootHubInitNotification) { @@ -1847,7 +1868,21 @@ // Status = SetPortFeature(HubDeviceExtension->RootHubPhysicalDeviceObject, PortId, PORT_RESET); if (!NT_SUCCESS(Status)) + { DPRINT1("Failed to reset on port %d\n", PortId); + } + else + { + // + // wait for the reset to be handled since we want to enumerate synchronously + // + KeWaitForSingleObject(&HubDeviceExtension->ResetComplete, + Executive, + KernelMode, + FALSE, + NULL); + KeClearEvent(&HubDeviceExtension->ResetComplete); + } } } }
Modified: branches/usb-bringup-trunk/drivers/usb/usbhub_new/usbhub.c URL: http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/us... ============================================================================== --- branches/usb-bringup-trunk/drivers/usb/usbhub_new/usbhub.c [iso-8859-1] (original) +++ branches/usb-bringup-trunk/drivers/usb/usbhub_new/usbhub.c [iso-8859-1] Wed Feb 8 15:50:52 2012 @@ -90,6 +90,11 @@ DeviceObject->Flags |= DO_POWER_PAGABLE;
// + // initialize reset complete event + // + KeInitializeEvent(&HubDeviceExtension->ResetComplete, NotificationEvent, FALSE); + + // // Attached to lower device // //Status = IoAttachDeviceToDeviceStackSafe(Fdo, Pdo, &DeviceExtension->LowerDevice);
Modified: branches/usb-bringup-trunk/drivers/usb/usbhub_new/usbhub.h URL: http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/us... ============================================================================== --- branches/usb-bringup-trunk/drivers/usb/usbhub_new/usbhub.h [iso-8859-1] (original) +++ branches/usb-bringup-trunk/drivers/usb/usbhub_new/usbhub.h [iso-8859-1] Wed Feb 8 15:50:52 2012 @@ -44,7 +44,6 @@ typedef struct _WORK_ITEM_DATA { WORK_QUEUE_ITEM WorkItem; - KEVENT Event; PVOID Context; } WORK_ITEM_DATA, *PWORK_ITEM_DATA;
@@ -80,6 +79,7 @@ PDEVICE_OBJECT RootHubFunctionalDeviceObject;
ULONG NumberOfHubs; + KEVENT ResetComplete;
PORT_STATUS_CHANGE *PortStatusChange; URB PendingSCEUrb;