Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

One question about usb mass-storage lower filter driver

16 views
Skip to first unread message

caro...@gmail.com

unread,
Jun 28, 2009, 2:26:55 PM6/28/09
to
Dear all,
I got one problem on handling bulk transfer for mass-storage. I really
need a solution for this. Hope someone can answer my question. The
driver is under WDM.

For a certain IRP asking for bulk out transfer data is issued by upper
driver, the lower filter driver will send a return
STATUS_MORE_PROCESSING_REQUIRED to hold the IRP and build another bulk
transfer ,and complete the certain IRP.

So.. in the lower filter driver. It is like the following.
-----------------------------------------------------------------------
DispatchFromUppderDriver ( )
{
if (Irp type != the special irp type)
passIrp(pdx) ; // I only care a certain IRP.
....

Start_Bulk_Tansfer(pdx);

return STATUS_MORE_PROCESSING_REQUIRED;
}

Start_Bulk_Transfer( pdx )
{

....
IoSetCompletionRoutine ( .... , CompleteRoutine,..) ;
IoCallDriver(.., pdx->Hold_Irp) ;
}

CompleteRoutine(..)
{
SetIoCompleteRequest( Hold_Irp);
}
-----------------------------------------------------------------------

But, for some reason, I have to improve the response speed for the
certain Irp.
I just think that I can simply call the same Start_Bulk_Tansfer(pdx)
when the complete routine happen. And, in the meanwhile, lower filter
driver still response the irp with the data updated by previous
Start_Bulk_Tansfer(pdx)
So, in my imagnation, I can do something like the following..

-----------------------------------------------------------------------
AddDevice ()
{
pdx->data_exist = FALSE;
}
DispatchFromUppderDriver ( )
{
if (Irp type != the special irp type)
passIrp(pdx) ;

// I expect the data will be updated by Start_Bulk_Tansfer(pdx);
// The Irp will be complete by the lower filter driver with those
data.
if( pdx->data_exist)
{
//Copy the data to irp parameter and complete the irp.
return;
}

Start_Bulk_Tansfer(pdx); // Start_Bulk_Transfer will set complete
routine and do IoCallDriver( ) ;
return STATUS_MORE_PROCESSING_REQUIRED;
}

Start_Bulk_Transfer( pdx )
{
....
IoSetCompletionRoutine ( .... , CompleteRoutine,..) ;
IoCallDriver(.., pdx->Hold_Irp) ;
}

CompleteRoutine(..)
{

SetIoCompleteRequest( Hold_Irp);

Start_Bulk_Tansfer(pdx); <------ I call it again when the
complete routine happen.
}
-----------------------------------------------------------------------
But the true is that, ony first time Start_Bulk_Tansfer( ) and the
completeRoutine( ) actually happen. And, the 2nd Start_Bulk_Tansfer( )
won't get the complete routine. It looks like the completeRoutine has
been pending. So the certian Irp only can get the 1st time data and
the data won't be updated.

I also do a experimentation. I set a counter to ten, every time the
certain Irp arrived and been finish , the counter will decrease. When
it become zero, the certain Irp will not be complete immediately. The
lower filter driver will return STATUS_MORE_PROCESSING_REQUIRED; Then
the complete routine will happen right away. Just like the following..
if( pdx->data_exist)
{
if (pdx->count == 0)
return STATUS_MORE_PROCESSING_REQUIRED;
else
//Copy the data to irp parameter and complete the irp.
return;
}

I really don't know what mistakes I made. Could someone tell me the
reason of completeRoutine is pending ? or you have other suggestion?

PS : the certain Irp arrived in Dispatche_Level

Thanks,
by
Caro

caro...@gmail.com

unread,
Jul 2, 2009, 8:49:35 PM7/2/09
to
On 6月29日, 上午2時26分, "carosc...@gmail.com" <carosc...@gmail.com> wrote:
> Dear all,
> I got one problem on handling bulk transfer for mass-storage. I really
> need a solution for this. Hope someone can answer my question. The
> driver is under WDM.
>
> For a certain IRP asking for bulk out transfer data is issued by upper
> driver, thelowerfilterdriver will send a return

> STATUS_MORE_PROCESSING_REQUIRED to hold the IRP and build another bulk
> transfer ,and complete the certain IRP.
>
> So.. in thelowerfilterdriver. It is like the following.
>    // The Irp will be complete by thelowerfilterdriver with those

> data.
>    if( pdx->data_exist)
>    {
>       //Copy the data to irp parameter and complete the irp.
>       return;
>    }
>
>     Start_Bulk_Tansfer(pdx);  // Start_Bulk_Transfer will set complete
> routine and do IoCallDriver( ) ;
>     return STATUS_MORE_PROCESSING_REQUIRED;
>
> }
>
> Start_Bulk_Transfer( pdx )
> {
>   ....
>     IoSetCompletionRoutine ( .... , CompleteRoutine,..) ;
>     IoCallDriver(.., pdx->Hold_Irp) ;
>
> }
>
> CompleteRoutine(..)
> {
>
>       SetIoCompleteRequest( Hold_Irp);
>
>       Start_Bulk_Tansfer(pdx);   <------ I call it again when the
> complete routine happen.}
>
> -----------------------------------------------------------------------
>  But the true is that, ony first time Start_Bulk_Tansfer( ) and the
> completeRoutine( ) actually happen. And, the 2nd Start_Bulk_Tansfer( )
> won't get the complete routine. It looks like the completeRoutine has
> been pending. So the certian Irp only can get the 1st time data and
> the data won't be updated.
>
> I also do a experimentation. I set a counter to ten, every time the
> certain Irp arrived and been finish , the counter will decrease. When
> it become zero, the certain Irp will not be complete immediately. Thelowerfilterdriver will  return STATUS_MORE_PROCESSING_REQUIRED; Then

> the complete routine will happen right away. Just like the following..
>    if( pdx->data_exist)
>    {
>      if (pdx->count == 0)
>           return STATUS_MORE_PROCESSING_REQUIRED;
>      else
>       //Copy the data to irp parameter and complete the irp.
>       return;
>    }
>
> I really don't know what mistakes I made. Could someone tell me the
> reason of  completeRoutine is pending ? or you have other suggestion?
>
> PS : the certain Irp arrived in Dispatche_Level
>
> Thanks,
> by
> Caro

Oh ~ someone suggest me to markpending on Irp from dispach(). But the
situation is the same. I check the book " Programming the Microsoft
Windoes Driver Model". It looks like only issulate how to split one
Irp to severals Irp. So I just wonder if this issue is related multi-
thread. Could someone know how to handle Irp from uppder driver and
send self Irp to lower driver at the same times ? I hope the Irp from
upper driver won't be pending.


Regards,
Caro

Alexander Grigoriev

unread,
Jul 2, 2009, 9:58:06 PM7/2/09
to

If the device gets unplugged or fails, the request is completed immediately.
That will cause recursion in your CompleteRoutine and stack overflow.

<caro...@gmail.com> wrote in message
news:b2faa154-d135-488e...@i4g2000prm.googlegroups.com...

Doron Holan [MSFT]

unread,
Jul 10, 2009, 1:11:13 PM7/10/09
to
SMPR is not a valid return code for a dispatch routine, return
STATUS_PENDING and mark the irp as pending first. run your driver under
Driver Verifier, it will catch these types of errors

d

--

This posting is provided "AS IS" with no warranties, and confers no rights.


<caro...@gmail.com> wrote in message
news:446523c9-cbc4-4e96...@g1g2000yqh.googlegroups.com...

0 new messages