Author: vmikayelyan
Date: Fri Aug 19 16:20:32 2016
New Revision: 72378
URL: http://svn.reactos.org/svn/reactos?rev=72378&view=rev
Log:
usb: libusb: hub_controller: Fix PnP handler
In some cases our driver was changing IRP status in places where it
shouldn't.
Modified:
branches/GSoC_2016/USB/sdk/lib/drivers/libusb/hub_controller.cpp
Modified: branches/GSoC_2016/USB/sdk/lib/drivers/libusb/hub_controller.cpp
URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2016/USB/sdk/lib/drivers/l…
==============================================================================
--- branches/GSoC_2016/USB/sdk/lib/drivers/libusb/hub_controller.cpp [iso-8859-1] (original)
+++ branches/GSoC_2016/USB/sdk/lib/drivers/libusb/hub_controller.cpp [iso-8859-1] Fri Aug 19 16:20:32 2016
@@ -568,7 +568,8 @@
break;
}
}
- Status = STATUS_SUCCESS;
+ // Here we should leave Status as is.
+ Status = Irp->IoStatus.Status;
break;
}
case IRP_MN_QUERY_CAPABILITIES:
@@ -611,6 +612,14 @@
// handle device interface requests
//
Status = HandleQueryInterface(IoStack);
+
+ //
+ // If a bus driver does not export the requested interface, it
+ // should leave Status as is.
+ //
+ if (Status == STATUS_NOT_SUPPORTED)
+ Status = Irp->IoStatus.Status;
+
break;
}
case IRP_MN_REMOVE_DEVICE:
Author: vmikayelyan
Date: Fri Aug 19 15:50:18 2016
New Revision: 72373
URL: http://svn.reactos.org/svn/reactos?rev=72373&view=rev
Log:
usb: hub: PDO: Fix in IRP_MN_QUERY_DEVICE_RELATIONS
Here we shouldn't modify information field of IRP, because for example
in case of bus relations IRP must reach the stack's PDO collecting on
its way all relations.
This was the one of the causes of MS's usbccgp fail. usbccgp was not
able to report to PnP manager about it's child devices.
There is also another issues in usbuhci, which prevents usbccgp from
normal operation.
[THIS PATCH SHULD NOT BE MERGED WITH TRUNK UNTIL UHCI BUGS ARE NOT FIXED]
Modified:
branches/GSoC_2016/USB/drivers/usb/usbhub/pdo.c
Modified: branches/GSoC_2016/USB/drivers/usb/usbhub/pdo.c
URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2016/USB/drivers/usb/usbhu…
==============================================================================
--- branches/GSoC_2016/USB/drivers/usb/usbhub/pdo.c [iso-8859-1] (original)
+++ branches/GSoC_2016/USB/drivers/usb/usbhub/pdo.c [iso-8859-1] Fri Aug 19 15:50:18 2016
@@ -711,6 +711,7 @@
{
/* not supported */
Status = Irp->IoStatus.Status;
+ Information = Irp->IoStatus.Information;
break;
}
Author: vmikayelyan
Date: Fri Aug 19 15:47:45 2016
New Revision: 72372
URL: http://svn.reactos.org/svn/reactos?rev=72372&view=rev
Log:
usb: hub: FDO: Rework IRP_MN_QUERY_DEVICE_RELATIONS
First of all we should keep in account that there might be device
relations below and above this FDO, so we should save previous relations
coming from top object and shuld pass this IRP down to stack after
adding our relations. In case of success query devcie relations must be
completed in the PDO.
As MSDN requires, if the upper layer provided this IRP with initialized
DeviceRelation, then we should replace that relation with another one
which will contain our child PDOs too. And after replacement we should
free the recources allocated for previous relation structure.
If there is relations coming from upper layer, we shuldn't complete this
IRP with fail, because that will bring upper layer into unstabile state,
it will 'think' that succesfully reported it's relations.
Modified:
branches/GSoC_2016/USB/drivers/usb/usbhub/fdo.c
Modified: branches/GSoC_2016/USB/drivers/usb/usbhub/fdo.c
URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2016/USB/drivers/usb/usbhu…
==============================================================================
--- branches/GSoC_2016/USB/drivers/usb/usbhub/fdo.c [iso-8859-1] (original)
+++ branches/GSoC_2016/USB/drivers/usb/usbhub/fdo.c [iso-8859-1] Fri Aug 19 15:47:45 2016
@@ -1387,11 +1387,13 @@
NTSTATUS
USBHUB_FdoQueryBusRelations(
IN PDEVICE_OBJECT DeviceObject,
+ IN PDEVICE_RELATIONS RelationsFromTop,
OUT PDEVICE_RELATIONS* pDeviceRelations)
{
PHUB_DEVICE_EXTENSION HubDeviceExtension;
PDEVICE_RELATIONS DeviceRelations;
ULONG i;
+ ULONG ChildrenFromTop = 0;
ULONG Children = 0;
ULONG NeededSize;
@@ -1410,9 +1412,18 @@
Children++;
}
- NeededSize = sizeof(DEVICE_RELATIONS);
- if (Children > 1)
- NeededSize += (Children - 1) * sizeof(PDEVICE_OBJECT);
+ if (RelationsFromTop)
+ {
+ ChildrenFromTop = RelationsFromTop->Count;
+ if (!Children)
+ {
+ // We have nothing to add
+ *pDeviceRelations = RelationsFromTop;
+ return STATUS_SUCCESS;
+ }
+ }
+
+ NeededSize = sizeof(DEVICE_RELATIONS) + (Children + ChildrenFromTop - 1) * sizeof(PDEVICE_OBJECT);
//
// Allocate DeviceRelations
@@ -1421,9 +1432,21 @@
NeededSize);
if (!DeviceRelations)
- return STATUS_INSUFFICIENT_RESOURCES;
- DeviceRelations->Count = Children;
- Children = 0;
+ {
+ if (!RelationsFromTop)
+ return STATUS_INSUFFICIENT_RESOURCES;
+ else
+ return STATUS_NOT_SUPPORTED;
+ }
+ // Copy the objects coming from top
+ if (ChildrenFromTop)
+ {
+ RtlCopyMemory(DeviceRelations->Objects, RelationsFromTop->Objects,
+ ChildrenFromTop * sizeof(PDEVICE_OBJECT));
+ }
+
+ DeviceRelations->Count = Children + ChildrenFromTop;
+ Children = ChildrenFromTop;
//
// Fill in return structure
@@ -1438,6 +1461,10 @@
DeviceRelations->Objects[Children++] = HubDeviceExtension->ChildDeviceObject[i];
}
}
+
+ // We should do this, because replaced this with our's one
+ if (RelationsFromTop)
+ ExFreePool(RelationsFromTop);
ASSERT(Children == DeviceRelations->Count);
*pDeviceRelations = DeviceRelations;
@@ -1976,7 +2003,6 @@
{
PIO_STACK_LOCATION Stack;
NTSTATUS Status = STATUS_SUCCESS;
- ULONG_PTR Information = 0;
PHUB_DEVICE_EXTENSION HubDeviceExtension;
HubDeviceExtension = (PHUB_DEVICE_EXTENSION) DeviceObject->DeviceExtension;
@@ -2007,12 +2033,28 @@
case BusRelations:
{
PDEVICE_RELATIONS DeviceRelations = NULL;
+ PDEVICE_RELATIONS RelationsFromTop = (PDEVICE_RELATIONS)Irp->IoStatus.Information;
DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations\n");
- Status = USBHUB_FdoQueryBusRelations(DeviceObject, &DeviceRelations);
-
- Information = (ULONG_PTR)DeviceRelations;
- break;
+ Status = USBHUB_FdoQueryBusRelations(DeviceObject, RelationsFromTop, &DeviceRelations);
+
+ if (!NT_SUCCESS(Status))
+ {
+ if (Status == STATUS_NOT_SUPPORTED)
+ {
+ // We should process this to not lose relations from top.
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
+ }
+ // We should fail an IRP
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return Status;
+ }
+
+ Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
+ Irp->IoStatus.Status = Status;
+ return ForwardIrpAndForget(DeviceObject, Irp);
}
case RemovalRelations:
{
@@ -2066,7 +2108,6 @@
}
}
- Irp->IoStatus.Information = Information;
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
Author: vmikayelyan
Date: Fri Aug 19 15:37:57 2016
New Revision: 72369
URL: http://svn.reactos.org/svn/reactos?rev=72369&view=rev
Log:
usb: hub: PDO: Fail IRP_MN_QUERY_STOP_DEVICE.
We should fail this request, because we're not handling
IRP_MN_STOP_DEVICE for now. On systems above win2000 we'll
receive this IRP ONLY when the PnP manager rebalances resources.
Modified:
branches/GSoC_2016/USB/drivers/usb/usbhub/pdo.c
Modified: branches/GSoC_2016/USB/drivers/usb/usbhub/pdo.c
URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2016/USB/drivers/usb/usbhu…
==============================================================================
--- branches/GSoC_2016/USB/drivers/usb/usbhub/pdo.c [iso-8859-1] (original)
+++ branches/GSoC_2016/USB/drivers/usb/usbhub/pdo.c [iso-8859-1] Fri Aug 19 15:37:57 2016
@@ -729,6 +729,14 @@
break;
}
case IRP_MN_QUERY_STOP_DEVICE:
+ {
+ //
+ // We should fail this request, because we're not handling IRP_MN_STOP_DEVICE for now.
+ // We'll receive this IRP ONLY when the PnP manager rebalances resources.
+ //
+ Status = STATUS_NOT_SUPPORTED;
+ break;
+ }
case IRP_MN_QUERY_REMOVE_DEVICE:
{
// HERE SHOULD BE CHECKED INTERFACE COUNT PROVIED TO UPPER LAYER TO BE ZERO, AS WE ARE HANDLING