We developed a driver for a 1394/SBP2 storage device, we send the commands to the device through cdb in srb(the driver is above sbp2port driver). We found a strange problem that the lower driver(sbp2port or 1394bus?) pends certain IRP and never finishes it on vista platform.
In order to detect the media state in the storage device, we need to send a command to the device, we use a timer to send the command to the device periodically.
The process like this:
when received IRP_MN_START_DEVICE,
1 send the request to lower and wait to be finished successfully
2 then initialize the DPC(set the CustomDpc routine) and timer,then set the timer(5 seconds interval)
In the CustomDpc routine, i allocate a workitem and queue it.
In the workitem routine, i did the following:
1 allocate an irp ,
2 initialize it(note:i have set srb.TimeOutValue = 10)
3 set iocompletion routine for the irp
4 call the next lower driver.The code piece like the following:
status = IoCallDriver(fdoExtension->CommonExtension.LowerDeviceObject, irp);
if (status == STATUS_PENDING)
{
DbgPrintEx(DPFLTR_IHVDRIVER_ID,DPFLTR_ERROR_LEVEL,“*********** Wait IRP to finished \n”);
status = KeWaitForSingleObject(&event, Executive, KernelMode, FALSE,
NULL);//&WaitInterval);
DbgPrintEx(DPFLTR_IHVDRIVER_ID,DPFLTR_ERROR_LEVEL,“*********** Wait IRP success\n”);
status = ioStatus.Status;
}
Plug and unplug the device many times, in most case, the driver work well(that means at least i can get both the two output as a pair and system not be hung), but sometimes when plug the device in,the IRP was pending, i only got “*********** Wait IRP to finished” output, no “*********** Wait IRP success”(no matter how much time to wait)output. meanwhile, in the device manager, i right click on the device, chose “properties”, the device manager was hang too.
Because i serialize(use a Synchronization Event for this purpose) the command sent to the device,the pending lead other command cann’t be sent to the device later.
I try to find what leads the sbp2port, 1394bus or other lower driver doesn’t complete the irp sometimes, there is no answer, anyone can explain the reason? Any suggestion will be appreciated very much…