Problem with USB composite bus driver.

Hi all,

I am trying to write usb bus driver for my composite device. For that i am referring toaster bus static enumeration example. I could able to install my bus driver successfully , but when i was trying to install one more driver (Modem driver )over it it was showing blue screen.

If i call WdfFdoInitSetFilter(DeviceInit) inside Bus_EvtDeviceAdd of composite bus driver Modem driver is getting installed over it, but if i do not call WdfFdoInitSetFilter then the framework completes the request with a status value of STATUS_INVALID_DEVICE_REQUEST. Because of this blue screen is appearing in Modem Driver.

Can any one guide me in this issue?
Thanks in advance.

Amit Samel wrote:

Modem driver is getting installed over it, but if i do not call
WdfFdoInitSetFilter then the framework completes the request
with a status value of STATUS_INVALID_DEVICE_REQUEST.
Because of this blue screen is appearing in Modem Driver.

Sounds to me like your first problem is that your modem driver blue screens when its requests get failed. By the way, you don’t mention what “requests” you’re talking about. At any rate, your bus driver is going to the FDO for your USB device, so setting it as a filter isn’t the right thing to do anyway.

> -----Original Message-----

From: xxxxx@lists.osr.com [mailto:bounce-399173-
xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: 03 February 2010 11:40
To: Windows System Software Devs Interest List
Subject: [ntdev] Problem with USB composite bus driver.

Hi all,

I am trying to write usb bus driver for my composite device.

Is there a problem with the built-in composite USB driver from Microsoft?

Tim.

What request is failing? Marking the fdo as a filter does not effect the pdo’s io handling

d

tiny phone keyboard + fat thumbs = you do the muth

-----Original Message-----
From: xxxxx@gmail.com
Sent: Wednesday, February 03, 2010 3:39 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Problem with USB composite bus driver.

Hi all,

I am trying to write usb bus driver for my composite device. For that i am referring toaster bus static enumeration example. I could able to install my bus driver successfully , but when i was trying to install one more driver (Modem driver )over it it was showing blue screen.

If i call WdfFdoInitSetFilter(DeviceInit) inside Bus_EvtDeviceAdd of composite bus driver Modem driver is getting installed over it, but if i do not call WdfFdoInitSetFilter then the framework completes the request with a status value of STATUS_INVALID_DEVICE_REQUEST. Because of this blue screen is appearing in Modem Driver.

Can any one guide me in this issue?
Thanks in advance.


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

Tim Green wrote:

Is there a problem with the built-in composite USB driver
from Microsoft?

Yes (search the archives for more info).

Doron Holan wrote:

What request is failing? Marking the fdo as a filter does not effect the pdo’s io handling d tiny >phone keyboard + fat thumbs = you do the muth

Hi Doron and Chris ,
In bus driver i have created one default queue. In EvtIoDefault i am forwarding all request to the lower driver.

Major code of request is IRP_MJ_INTERNAL_DEVICE_REQUEST

Minor code is IRP_MN_START_DEVICE

Amit

Iocts do not have minor codes. What is the ioctl value ? Is the modem driver usbser or some other in box modem driver?

d

tiny phone keyboard + fat thumbs = you do the muth

-----Original Message-----
From: xxxxx@gmail.com
Sent: Thursday, February 04, 2010 3:02 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Problem with USB composite bus driver.

Doron Holan wrote:
>What request is failing? Marking the fdo as a filter does not effect the pdo’s io handling d tiny >phone keyboard + fat thumbs = you do the muth

Hi Doron and Chris ,
In bus driver i have created one default queue. In EvtIoDefault i am forwarding all request to the lower driver.

Major code of request is IRP_MJ_INTERNAL_DEVICE_REQUEST

Minor code is IRP_MN_START_DEVICE

Amit


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

Hi Doron,

Sorry actually i typed it in a wrong way.

Major code of request was IRP_MJ_INTERNAL_DEVICE_CONTROL, which is an ioctl.

To get that ioctl i was trying to print control code of it.
KdPrint((“IOCTL code is 0x%x”,current_stack->Parameters.DeviceIoControl.IoControlCode));

And that value was IOCTL VALUE (hex) 0x22003
That IOCTL decodes to:

Device: UNKNOWN (0x22)

Function: 0x0

Access: FILE_ANY_ACCESS

Method: METHOD_NEITHER

So i was searching for IOCTL wrt these values in Ntddser.h, but i could not find it.

Let’s see. You are a usb composite bus driver. What type of I/O do you think a USB function driver is sending to your driver’s PDO? It certainly is not ntddser.h defined I/O, that is what the driver receives, not what it sends.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Thursday, February 04, 2010 10:17 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Problem with USB composite bus driver.

Hi Doron,

Sorry actually i typed it in a wrong way.

Major code of request was IRP_MJ_INTERNAL_DEVICE_CONTROL, which is an ioctl.

To get that ioctl i was trying to print control code of it.
KdPrint((“IOCTL code is 0x%x”,current_stack->Parameters.DeviceIoControl.IoControlCode));

And that value was IOCTL VALUE (hex) 0x22003 That IOCTL decodes to:

Device: UNKNOWN (0x22)

Function: 0x0

Access: FILE_ANY_ACCESS

Method: METHOD_NEITHER

So i was searching for IOCTL wrt these values in Ntddser.h, but i could not find it.


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

Hi Doron,

Now modem driver is not getting crashed over my bus driver. Its getting installed .Previously in pdo(created by my bus driver.) i was forwarding request to lower driver in a wrong way. That issue is resolved now. But still i am receiving the same ioctl inside EvtIoDefault of pdo .(created by my bus driver.)

Amit

What do you think that IOCTL is? Hint: could it be USB related?

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Thursday, February 04, 2010 11:39 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Problem with USB composite bus driver.

Hi Doron,

Now modem driver is not getting crashed over my bus driver. Its getting installed .Previously in pdo(created by my bus driver.) i was forwarding request to lower driver in a wrong way. That issue is resolved now. But still i am receiving the same ioctl inside EvtIoDefault of pdo .(created by my bus driver.)

Amit


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

Hi Doron,

Thanks. I got it. In USB we submit USB request blocks (URBs) to the parent driver using an IRP with the major function code IRP_MJ_INTERNAL_DEVICE_CONTROL. That is what i was receiving.

Amit.

Are you handling the various select confit/select interface calls in your driver? Or is the driver you are sending all of the urbs to translating the select configs into select interfaces?

d

tiny phone keyboard + fat thumbs = you do the muth

-----Original Message-----
From: xxxxx@gmail.com
Sent: Friday, February 05, 2010 1:01 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Problem with USB composite bus driver.

Hi Doron,

Thanks. I got it. In USB we submit USB request blocks (URBs) to the parent driver using an IRP with the major function code IRP_MJ_INTERNAL_DEVICE_CONTROL. That is what i was receiving.

Amit.


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

Hi Doron,

Doron Holan wrote:

Are you handling the various select confit/select interface calls in your driver? Or is the driver you are >sending all of the urbs to translating the select configs into select interfaces?

I did not understand what you said. You meant selecting interfaces in composite driver. (The same way i did in upper driver(Modem driver))?
In My composite driver i am forwarding all the requests which i got in default queue to the lower driver i.e. usb hub.

I have one more doubt. It is related to selective suspend and remote wake up in composite driver.
i could able to put my composite driver and child driver (Modem Driver )in to sleep state by sending IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION to the parent driver (USB hub) and handling its call back routine.

But When i tried to wake up my driver its getting hung. As i have not handled IRP_MN_WAIT_WAKE yet.
actually i could not find IRP_MN_WAIT_WAKE in a default queue of composite driver.
Where can i receive this irp?

Amit

Are you exposing other usb functions other than a modem? Each one of the functions you expose will send down a select config to your driver. It is your responsibility in your generic parent driver to
1 present config descriptor that only contains the functions for a particular child. Basically you have to create a config descriptor per child you enumerate
2 when receiving the select config from the child, convert that to a select interface so that the child’s select config does not mess up the state of all of the other functions

You do not receive wait wake irps in a kmdf driver. I also think you are going about usb ss backwards. Each of your children need to register for idle, you notify them to go idle and once everyone is off, only then do you register for idle with the hub driver.

Both of these tasks are *not* easy, you have a few weeks of work ahead of you and then a lot of testing.

d

tiny phone keyboard + fat thumbs = you do the muth

-----Original Message-----
From: xxxxx@gmail.com
Sent: Tuesday, February 09, 2010 6:24 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Problem with USB composite bus driver.

Hi Doron,

Doron Holan wrote:
>Are you handling the various select confit/select interface calls in your driver? Or is the driver you are >sending all of the urbs to translating the select configs into select interfaces?

I did not understand what you said. You meant selecting interfaces in composite driver. (The same way i did in upper driver(Modem driver))?
In My composite driver i am forwarding all the requests which i got in default queue to the lower driver i.e. usb hub.

I have one more doubt. It is related to selective suspend and remote wake up in composite driver.
i could able to put my composite driver and child driver (Modem Driver )in to sleep state by sending IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION to the parent driver (USB hub) and handling its call back routine.

But When i tried to wake up my driver its getting hung. As i have not handled IRP_MN_WAIT_WAKE yet.
actually i could not find IRP_MN_WAIT_WAKE in a default queue of composite driver.
Where can i receive this irp?

Amit


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

Hi Doron ,

1 As of now i am exposing only modem to composite driver, no other functions. Once my composite is a bit stable with one function then i will expose other functions.
So in this case also is it mandatory for me to create a config descriptor per child i enumerate when receiving the select config from the child, convert that to a select interface.

2 As of now as only one child is there so it’s a bit easy as i do not have to wait for all children to go to suspend to put my bus driver in suspend state. So i could able to put both composite as well as modem in suspend. First Modem sends IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION request to my composite driver which i am pending first by putting it in my own manual queue.

Then from my composite i am manually sending IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION to usb hub by setting idle notification callback and completion routine for it.

Then idle callback of composite driver idle request is getting called by usb hub , in which i am calling idle callback of modem driver to put it in suspend state first.

After this i am calling PorequestpowerIrp with minor code IRP_MN_SET_POWER and power state PowerDeviceD2 in idle callback of composite driver to put it in suspend state.

In this way i could able to put both drivers in suspend state , but when i try to wake them up it is getting hung as i have not implemented wake up functionality.

So i was thinking of implementing it in same way as given in ddk docs by manually sending IRP_MN_WAIT_WAKE up lower driver and setting call back routine for it .

As you said we do not receive wait wake irps in a kmdf driver. So how will my composite driver get to know that upper driver (Modem driver has sent IRP_MN_WAIT_WAKE)

Amit.

You never *ever* call PoRequestPowerIrp in a KMDF driver that is the power policy owner. Turn on KMDF verifier and you will hit stops very quickly with your current scheme. Look at the PDO callbacks you can register for, one of them is to tell you about wake. What you want to do is register yourself for S0Idle (can wake from S0, not USBSelectiveSuspend) with a very short idle timeout (1ms) and then immediately call WdfDeviceStopIdle(). When the hub below you calls your idle routine, call WdfDeviceResumeIdle and let KMDF power you down. KMDF will send the wake and Dx IRPs.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Tuesday, February 09, 2010 9:43 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Problem with USB composite bus driver.

Hi Doron ,

1 As of now i am exposing only modem to composite driver, no other functions. Once my composite is a bit stable with one function then i will expose other functions.
So in this case also is it mandatory for me to create a config descriptor per child i enumerate when receiving the select config from the child, convert that to a select interface.

2 As of now as only one child is there so it’s a bit easy as i do not have to wait for all children to go to suspend to put my bus driver in suspend state. So i could able to put both composite as well as modem in suspend. First Modem sends IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION request to my composite driver which i am pending first by putting it in my own manual queue.

Then from my composite i am manually sending IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION to usb hub by setting idle notification callback and completion routine for it.

Then idle callback of composite driver idle request is getting called by usb hub , in which i am calling idle callback of modem driver to put it in suspend state first.

After this i am calling PorequestpowerIrp with minor code IRP_MN_SET_POWER and power state PowerDeviceD2 in idle callback of composite driver to put it in suspend state.

In this way i could able to put both drivers in suspend state , but when i try to wake them up it is getting hung as i have not implemented wake up functionality.

So i was thinking of implementing it in same way as given in ddk docs by manually sending IRP_MN_WAIT_WAKE up lower driver and setting call back routine for it .

As you said we do not receive wait wake irps in a kmdf driver. So how will my composite driver get to know that upper driver (Modem driver has sent IRP_MN_WAIT_WAKE)

Amit.


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

Hi Doron ,

I will try with the way you said.
Actually with out enabling driver verifier my driver was getting crashed when i was calling PoRequestPowerIrp in my bus driver. As by default all function drivers are power policy owner .
And my modem (upper driver in the stack )is also power policy owner. There can be only one power policy owner in a stack. So i set power policy ownership to False in bus driver. That time it was not crashing.

Amit.

Amit Samel wrote:

Actually with out enabling driver verifier my driver was getting
crashed when i was calling PoRequestPowerIrp in my bus driver.
As by default all function drivers are power policy owner . And
my modem (upper driver in the stack )is also power policy owner.
There can be only one power policy owner in a stack. So i set
power policy ownership to False in bus driver. That time it was
not crashing.

You’re pretty far off in the weeds so I don’t think I (or maybe anyone) totally understands your “design”, but I think your bus driver and modem drivers are on different “stacks” altogether, and have separate power policies … I think this is what Doron is trying to tell you…

Hi Chris Aseltine,

In my bus driver i am statically enumerating child devices and creating pdo fro them. I am referring static enumeration example given in ddk. As of now i am creating only one pdo for modem and installing Modem over my bus driver. Then how come modem and bus drivers are on different stacks. ?

Amit.