As a general rule, I agree with you. The USB core has been specifically
engineered to allow irp resends from a completion routine. IRPs are
usually completed from the DPC routine, so even if it is resent from
w/in the completion routine, the stack will unwind a bit before
recalling your CR.
Another thing to consider is total DPC time. If you are resending your
IRP in the CR and your device is constantly streaming data, you could
trigger the DPC is running for more then one second ASSERT b/c you are
not allowing the USB core’s DPC to return. In WDF, I always requeue to
my own DPC before resending, I figured it was middle ground between a
pure resend and queueing a work item.
In terms of stack space, you can figure out if your completion routine
has completed synchronously on you (ie consumed a bunch of stack space
and possibly more if it continues) or if it completed asynchronously
rather easily. Look at the sermouse example in the ddk, in particular,
1 the ReadInterlock field of the DeviceExtension
2 the values SERIAL_MOUSE_START_READ, SERIAL_MOUSE_END_READ,
SERIAL_MOUSE_IMMEDIATE_READ
3 the use of InterlockedXxx operations using the field and the values
This pattern can be applied to any stack where you are resending i/o
from the CR.
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of PeterGV (OSR)
Sent: Tuesday, May 10, 2005 6:08 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] USB client driver & IoCompletion
>
>>I want to know whether “submitting” URB request again in IoCompletion
>> routine of IRP/URB request to USBD is OK?
>>
No, it is NOT “OK”. Resubmitting an IRP from a completion routine is
almost NEVER OK, except in very rare and special circumstances.
Consider that your completion routine is called from IoCompleteRequest,
and that IoCompleteRequest could be called synchronously on the same
stack as your original call to IoCallDriver. Result? Very little stack
space.
Further, consider that your completion routine could be called from the
DCP of the device driver. Result? Your completion routine runs at IRQL
DISPATCH_LEVEL. It’s not polite, to say the very least, to call other’s
dispatch entry points at IRQL DISPATCH_LEVEL>
You probably want to read this month’s article on this topic in The NT
Insider: http://www.osronline.com/article.cfm?id=391
Peter
OSR
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com