|
From: Stephan M. <ste...@we...> - 2006-06-06 16:29:08
|
Thanks for the patch, Dan. I'll apply it by adding a third parameter
to power_set_device_state():
void power_set_device_state(libusb_device_t *dev,
DEVICE_POWER_STATE device_state, bool_t block)
{
NTSTATUS status;
KEVENT event;
POWER_STATE power_state;
power_state.DeviceState = device_state;
if(block) /* wait for IRP to complete */
{
KeInitializeEvent(&event, NotificationEvent, FALSE);
/* set the device power state and wait for completion */
status = PoRequestPowerIrp(dev->physical_device_object,
IRP_MN_SET_POWER,
power_state,
on_power_set_device_state_complete,
&event, NULL);
if(status == STATUS_PENDING)
{
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
}
}
else
{
PoRequestPowerIrp(dev->physical_device_object, IRP_MN_SET_POWER,
power_state, NULL, NULL, NULL);
}
}
> After much exploration I've discovered the cause of the inability for
> some laptops to coming out of standby is.
>
> The power irp for changing device state is being issued in the
> completion routine for the system power irp, and then the thread is
> blocked waiting for the device power irp to complete.
>
> Before the blocking takes place, the power manager attempts to send the
> irp all the way, the power dispatcher sees the device power irp, and
> tries to send it down the stack, but the usbhub below returns status
> pending so the completion handler isn't called at that point.
>
> The libusb thread then blocks waiting for the irp to complete, but it
> never does because the thread which would go on to call the completion
> routing is being blocked!
>
> Replacing the call to on_power_set_device_state_complete with :
>
> power_state.DeviceState =
> dev->device_power_states[power_state.SystemState];
>
> /* set the device power state and don't wait for completion */
>
> (void) PoRequestPowerIrp(dev->physical_device_object,
> IRP_MN_SET_POWER,
> power_state,
> NULL,
> NULL, NULL);
>
> Seems to resolve the problem.
>
> I've attached this as a patch.
>
> Comments?
>
> Cheers,
>
> --
> Dan Ellis
> Newnham Research
>
>
> <hr>
>
> <hr>
> _______________________________________________
> Libusb-win32-devel mailing list
> Lib...@li...
> https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>
______________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193
|