Question on USB suspend functionality

Hello,

I have a small problem in implementing USB suspend mode.

On a test IBM thinkpad notepad am able to put the USB device into suspend mode and again wake him up. Works fine.

With the same notebook attached to a docking station, its not working.
When i submit “IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION” ioctl to bus driver…he(bus driver) doesnt call either callback function nor Completion Routine.

Have anyone seen any issues like this?

Thanks,
Mahee

Sample code
/***********/

nextStack = IoGetNextIrpStackLocation(SuspendCallbackIrp);
nextStack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
nextStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION;
nextStack->Parameters.DeviceIoControl.Type3InputBuffer = &DevExt->SuspendCallbackInfo;
nextStack->Parameters.DeviceIoControl.InputBufferLength = sizeof(USB_IDLE_CALLBACK_INFO);

IoSetCompletionRoutine(SuspendCallbackIrp,
USB_SuspendDeviceCompletionRoutine,
DevExt,
TRUE,
TRUE,
TRUE);

DbgPrint(“USB_SuspendDeviceWithCallback: Submitting idle IRP 0x%p.\n”, SuspendCallbackIrp);

DevExt->SuspendIrp = SuspendCallbackIrp;
status = IoCallDriver(DevExt->PhysicalDeviceObject, SuspendCallbackIrp);

if (NT_SUCCESS(status))
{
DbrPrint("USB_SuspendDeviceWithCallback: Waiting for suspend idle callback "\
“or completion routine to fire…\n”);

waitObjects[0] = &DevExt->SuspendCallbackCalled;
waitObjects[1] = &DevExt->SuspendCompletionRoutineCalled;

timeout.QuadPart = -5*10*1000*1000; // 5 seconds
status = KeWaitForMultipleObjects(2,
waitObjects,
WaitAny,
Executive,
KernelMode,
FALSE,
&timeout,
NULL);

if (status == STATUS_WAIT_0)
DbgPrint(“USB_SuspendDeviceWithCallback: Suspend callback fired!\n”);
else if (status == STATUS_WAIT_1)
DbgPrint(“USB_SuspendDeviceWithCallback: Completion routine fired!\n”);
else
{
DbgPrint("USB_SuspendDeviceWithCallback: KeWaitForMultipleObjects "\
“returned unknown status 0x%x.\n”, status);

/* I am timing out on the notebook mounted on a docking station else works fine*/

bCancelIrpFlag = IoCancelIrp(DevExt->SuspendIrp);

if (bCancelIrpFlag)
DbgPrint(“USB_SuspendDeviceWithCallback: Cancelled IRP!\n”);
else
DbgPrint(“USB_SuspendDeviceWithCallback: UNABLE to Cancel IRP\n”);

//KdBreakPoint();
}

Selective suspend is a controller wide activity, so any other device on the bus can prevent SS from occurring. Does the docking station have any embedded usb devices in it?

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Wednesday, August 06, 2008 6:56 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Question on USB suspend functionality

Hello,

I have a small problem in implementing USB suspend mode.

On a test IBM thinkpad notepad am able to put the USB device into suspend mode and again wake him up. Works fine.

With the same notebook attached to a docking station, its not working.
When i submit “IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION” ioctl to bus driver…he(bus driver) doesnt call either callback function nor Completion Routine.

Have anyone seen any issues like this?

Thanks,
Mahee

Sample code
/***********/

nextStack = IoGetNextIrpStackLocation(SuspendCallbackIrp);
nextStack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
nextStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION;
nextStack->Parameters.DeviceIoControl.Type3InputBuffer = &DevExt->SuspendCallbackInfo;
nextStack->Parameters.DeviceIoControl.InputBufferLength = sizeof(USB_IDLE_CALLBACK_INFO);

IoSetCompletionRoutine(SuspendCallbackIrp,
USB_SuspendDeviceCompletionRoutine,
DevExt,
TRUE,
TRUE,
TRUE);

DbgPrint(“USB_SuspendDeviceWithCallback: Submitting idle IRP 0x%p.\n”, SuspendCallbackIrp);

DevExt->SuspendIrp = SuspendCallbackIrp;
status = IoCallDriver(DevExt->PhysicalDeviceObject, SuspendCallbackIrp);

if (NT_SUCCESS(status))
{
DbrPrint("USB_SuspendDeviceWithCallback: Waiting for suspend idle callback "\
“or completion routine to fire…\n”);

waitObjects[0] = &DevExt->SuspendCallbackCalled;
waitObjects[1] = &DevExt->SuspendCompletionRoutineCalled;

timeout.QuadPart = -5*10*1000*1000; // 5 seconds
status = KeWaitForMultipleObjects(2,
waitObjects,
WaitAny,
Executive,
KernelMode,
FALSE,
&timeout,
NULL);

if (status == STATUS_WAIT_0)
DbgPrint(“USB_SuspendDeviceWithCallback: Suspend callback fired!\n”);
else if (status == STATUS_WAIT_1)
DbgPrint(“USB_SuspendDeviceWithCallback: Completion routine fired!\n”);
else
{
DbgPrint("USB_SuspendDeviceWithCallback: KeWaitForMultipleObjects "\
“returned unknown status 0x%x.\n”, status);

/* I am timing out on the notebook mounted on a docking station else works fine*/

bCancelIrpFlag = IoCancelIrp(DevExt->SuspendIrp);

if (bCancelIrpFlag)
DbgPrint(“USB_SuspendDeviceWithCallback: Cancelled IRP!\n”);
else
DbgPrint(“USB_SuspendDeviceWithCallback: UNABLE to Cancel IRP\n”);

//KdBreakPoint();
}


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Doron Holan wrote:

Selective suspend is a controller wide activity, so any other device
on the bus can prevent SS from occurring. Does the docking station
have any embedded usb devices in it?

The docking station itself is probably a USB hub…

Doron,
I couldnt find anything embedded USB on the docking station from the spec.
How does embedded USB will make a difference?

Chris,
My monitor also have some USB ports and acts as a hub. It works good with them.

Thanks Guys,
Mahee

The embedded usb device would just make it non obvious that there is something else on the bus that is now no longer allowing the entire bus to SS. Is your device the only device on the controller (outside of hubs) ?

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Thursday, August 07, 2008 9:17 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Question on USB suspend functionality

Doron,
I couldnt find anything embedded USB on the docking station from the spec.
How does embedded USB will make a difference?

Chris,
My monitor also have some USB ports and acts as a hub. It works good with them.

Thanks Guys,
Mahee


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Yes mine is the ONLY usb device connected to the syatem.
If docking station is connected, the laptops’s USB ports(USB ports outside docking station) also wont work, whereas same ports work when there is no docking station.

I tried to debug, i could see bus driver is the current owner of the IRP i sent…

Mahee

Is it Vista or XP?

Try to display devices by connection in the device manager. Then examine
all USB components in the tree to which is your device connected
(starting from HC). If any of them, includign HC, prevents SS, device
won’t be suspended. At Vista only HCs and hubs influence it, at XP all
devices connected to any of hub in the three.

Anyway, you don’t need to care. Your driver did its work and now it is
system decision when to call the callback. If ever. BTW, at Vista, you
can control device power states directly.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Thursday, August 07, 2008 7:19 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Question on USB suspend functionality

Yes mine is the ONLY usb device connected to the syatem.
If docking station is connected, the laptops’s USB ports(USB
ports outside docking station) also wont work, whereas same
ports work when there is no docking station.

I tried to debug, i could see bus driver is the current owner
of the IRP i sent…

Mahee


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online
at http://www.osronline.com/page.cfm?name=ListServer