Skip to content

Commit b1c1381

Browse files
committed
usb: hub: FDO: Handle surprise removal, fail stop request.
svn path=/branches/GSoC_2016/USB/; revision=72387
1 parent 3b17e8f commit b1c1381

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

drivers/usb/usbhub/fdo.c

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,9 @@ USBHUB_FdoHandlePnp(
20302030
{
20312031
PIO_STACK_LOCATION Stack;
20322032
NTSTATUS Status = STATUS_SUCCESS;
2033+
PDEVICE_OBJECT ChildDeviceObject;
20332034
PHUB_DEVICE_EXTENSION HubDeviceExtension;
2035+
PHUB_CHILDDEVICE_EXTENSION ChildDeviceExtension;
20342036

20352037
HubDeviceExtension = (PHUB_DEVICE_EXTENSION) DeviceObject->DeviceExtension;
20362038

@@ -2098,10 +2100,49 @@ USBHUB_FdoHandlePnp(
20982100
}
20992101
break;
21002102
}
2101-
case IRP_MN_QUERY_REMOVE_DEVICE:
21022103
case IRP_MN_QUERY_STOP_DEVICE:
21032104
{
2104-
DPRINT("IRP_MN_QUERY_STOP_DEVICE\n");
2105+
//
2106+
// We should fail this request, because we're not handling
2107+
// IRP_MN_STOP_DEVICE for now.We'll receive this IRP ONLY when
2108+
// PnP manager rebalances resources.
2109+
//
2110+
Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
2111+
IoCompleteRequest(Irp, IO_NO_INCREMENT);
2112+
return STATUS_NOT_SUPPORTED;
2113+
}
2114+
case IRP_MN_QUERY_REMOVE_DEVICE:
2115+
{
2116+
// No action is required from FDO because it have nothing to free.
2117+
DPRINT("IRP_MN_QUERY_REMOVE_DEVICE\n");
2118+
2119+
Irp->IoStatus.Status = STATUS_SUCCESS;
2120+
break;
2121+
}
2122+
case IRP_MN_SURPRISE_REMOVAL:
2123+
{
2124+
//
2125+
// We'll receive this IRP on HUB unexpected removal, or on USB
2126+
// controller removal from PCI port. Here we should "let know" all
2127+
// our children that their parent is removed and on next removal
2128+
// they also can be removed.
2129+
//
2130+
2131+
KeAcquireGuardedMutex(&HubDeviceExtension->HubMutexLock);
2132+
2133+
for (int i = 0; i < USB_MAXCHILDREN; i++)
2134+
{
2135+
ChildDeviceObject = HubDeviceExtension->ChildDeviceObject[i];
2136+
if (ChildDeviceObject)
2137+
{
2138+
ChildDeviceExtension = (PHUB_CHILDDEVICE_EXTENSION)ChildDeviceObject->DeviceObjectExtension;
2139+
ChildDeviceExtension->ParentDeviceObject = NULL;
2140+
}
2141+
}
2142+
2143+
KeReleaseGuardedMutex(&HubDeviceExtension->HubMutexLock);
2144+
2145+
// This IRP can't be failed
21052146
Irp->IoStatus.Status = STATUS_SUCCESS;
21062147
break;
21072148
}

0 commit comments

Comments
 (0)