Tech Support > Microsoft Windows > Drivers > usb bulk transfer driver crash
usb bulk transfer driver crash
Posted by jasonlue on June 2nd, 2005


Hi, all,

I create a usb bulk transfer driver based on the example in DDK. It normally
works greate except:

1. When driver has to split a big data into small transfers usbd can accept
(4K on my computer). I continue the next small transfers in
ReadWriteCompletion just like the example. After transfering a big file
around 500M for 1M packet each to eventually split into 4k's in driver, the
driver crashes. I understand most likely it's caused by virtual memory
mapping. Where on Completion function (running DISPATCH_LEVEL), access to
user memory is not safe. (although I create a internal MDL to map to that
memory). Am I correct here?

I rewote my code to split the packet from user mode in Read/Write Irp
function and set a loop there to complete until all data are transfered.
Surprisingly enough, the driver still crashes. What could be possible reason
here?

Anybody writing usb bulk drivers, how do you handle big data and split them?

thanks for all comments.

Posted by jasonlue on June 10th, 2005


Seems to me this forum is not as helpful as others.

Anyway, after a long while, now I figured out a solution based on Walter
Oney's usb driver example.

Quote:
// Reader Peter Diaconesco ran across an apparent bug in the Win2K version
of UHCD.SYS. Under
// heavy load conditions, UHCD was bug-checking because its internal call
to MmGetSystemAddressForMdl
// was apparently returning NULL (even though it's not supposed to). We can
prevent that problem
// by mapping the pages in the following "safe" manner:

calling this in both OnRead/OnWrite and OnReadWriteComplete() before passing
the MDL down:

GENERICAPI PVOID GENERIC_EXPORT GenericGetSystemAddressForMdl(PMDL mdl)
{ // GenericGetSystemAddressForMdl
if (!mdl)
return NULL;

CSHORT oldfail = mdl->MdlFlags & MDL_MAPPING_CAN_FAIL;
mdl->MdlFlags |= MDL_MAPPING_CAN_FAIL;

PVOID address = MmMapLockedPages(mdl, KernelMode);

if (!oldfail)
mdl->MdlFlags &= ~MDL_MAPPING_CAN_FAIL;

return address;
} // GenericGetSystemAddressForMdl


"jasonlue" wrote:


Similar Posts