I’m brand new to Windows and Windows Driver development so please forgive any oversights…
I’m working with a few other developers on an XP embedded design where developing a driver and application. We’ve been occasionally seeing our DeviceIoControl() calls to our driver never return, although all our debugging seems to show the driver doing everything it needs to complete the call. I’ve accidentally stumbled upon reproduceable sequence that causes the DeviceIoControl() call to always hang.
I’m including the WDF trace with my explaination of events as I can understand them…
My application thread sends a request to our driver via DeviceIoControl().
During this request, the driver sends messages to custom hardware that will eventually create an interrupt, causing the driver to send a response buffer up to the application message thread.
Here is the driver request fromt he application thread…
00002818 io 860 872 0 1458 07\31\2007-10:22:03:432 WDFDEVICE 0x7B2B23C8 !devobj 0x84DB1630 0x0000000e(IRP_MJ_DEVICE_CONTROL), IRP_MN 0, IRP 0x85FB0F48
00002819 core 860 872 0 1459 07\31\2007-10:22:03:432 Allocating FxRequest* 84ACBE78, WDFREQUEST 7B534180
00002820 io 860 872 0 1460 07\31\2007-10:22:03:432 Queuing WDFREQUEST 0x7B534180 on WDFQUEUE 0x7B2BC8D8
00002821 io 860 872 0 1461 07\31\2007-10:22:03:432 Thread 84C0C980 is processing WDFQUEUE 0x7B2BC8D8
00002822 io 860 872 0 1462 07\31\2007-10:22:03:432 Calling driver EvtIoDeviceControl for WDFREQUEST 0x7B534180
00002823 core 860 872 0 1463 07\31\2007-10:22:03:443 Enter: WDFREQUEST 0x7B534180
00002824 core 860 872 0 1464 07\31\2007-10:22:03:464 Enter: WDFREQUEST 0x7B534180, Information 0x00000000
00002825 core 860 872 0 1465 07\31\2007-10:22:03:464 Completing WDFREQUEST 0x7B534180, STATUS_SUCCESS
00002826 core 860 872 0 1466 07\31\2007-10:22:03:464 Completing WDFREQUEST 0x7B534180 for IRP 0x85FB0F48 with Information 0x0, STATUS_SUCCESS
00002827 io 860 872 0 1467 07\31\2007-10:22:03:464 Enter: WDFQUEUE 0x7B2BC8D8, WDFREQUEST 0x7B534180
Now the custom hardware interrupts the driver, which creates a DPC to handle it. The DPC sends a response buffer up to the application’s message thread, and receives a replacement response buffer.
00002828 core 860 872 0 1468 07\31\2007-10:22:03:474 Enter: WDFREQUEST 0x7B429E38
00002829 core 860 872 0 1469 07\31\2007-10:22:03:505 Completing WDFREQUEST 0x7B429E38, STATUS_SUCCESS
00002830 core 860 872 0 1470 07\31\2007-10:22:03:505 Completing WDFREQUEST 0x7B429E38 for IRP 0x85538F48 with Information 0x1, STATUS_SUCCESS
00002831 io 860 872 0 1471 07\31\2007-10:22:03:505 Enter: WDFQUEUE 0x7B25F448, WDFREQUEST 0x7B429E38
00002832 io 860 872 0 1472 07\31\2007-10:22:03:505 Presentation lock for WDFQUEUE 0x7B25F448 is already held, deferring to dpc or workitem
00002833 core 860 872 0 1473 07\31\2007-10:22:03:505 Free FxRequest* 84BD61C0 memory
00002834 io 860 872 0 1474 07\31\2007-10:22:03:505 Dispatching requests from DPC
00002835 io 860 872 0 1475 07\31\2007-10:22:03:505 Thread 84C0C980 is processing WDFQUEUE 0x7B25F448
00002836 io 860 872 0 1476 07\31\2007-10:22:03:505 Driver has configured WDFQUEUE 0x7B25F448 for WdfIoQueueDispatchManual
00002837 io 860 1480 0 1477 07\31\2007-10:22:03:505 WDFDEVICE 0x7B2B23C8 !devobj 0x84DB1630 0x0000000e(IRP_MJ_DEVICE_CONTROL), IRP_MN 0, IRP 0x856AAF48
00002838 core 860 1480 0 1478 07\31\2007-10:22:03:505 Allocating FxRequest* 84BD61C0, WDFREQUEST 7B429E38
00002839 io 860 1480 0 1479 07\31\2007-10:22:03:505 Queuing WDFREQUEST 0x7B429E38 on WDFQUEUE 0x7B2BC8D8
00002840 io 860 1480 0 1480 07\31\2007-10:22:03:505 Thread 845A7A90 is processing WDFQUEUE 0x7B2BC8D8
00002841 io 860 1480 0 1481 07\31\2007-10:22:03:505 Calling driver EvtIoDeviceControl for WDFREQUEST 0x7B429E38
00002842 core 860 1480 0 1482 07\31\2007-10:22:03:515 Enter: WDFREQUEST 0x7B429E38
00002843 io 860 1480 0 1483 07\31\2007-10:22:03:515 Queuing WDFREQUEST 0x7B429E38 on WDFQUEUE 0x7B25F448
00002844 io 860 1480 0 1484 07\31\2007-10:22:03:515 Presentation lock for WDFQUEUE 0x7B25F448 is already held, deferring to dpc or workitem
00002845 io 860 1480 0 1485 07\31\2007-10:22:03:515 Dispatching requests from DPC
00002846 io 860 1480 0 1486 07\31\2007-10:22:03:515 Thread 845A7A90 is processing WDFQUEUE 0x7B25F448
00002847 io 860 1480 0 1487 07\31\2007-10:22:03:515 Driver has configured WDFQUEUE 0x7B25F448 for WdfIoQueueDispatchManual
00002848 io 860 1480 0 1488 07\31\2007-10:22:03:515 WDFREQUEST 0x7B429E38 dispatched to driver
00002849 io 860 1480 0 1489 07\31\2007-10:22:03:515 No requests on WDFQUEUE 0x7B2BC8D8
Now there seems to be some cleanup from my original DeviceIoControl() call.
00002850 io 860 872 0 1490 07\31\2007-10:22:03:515 WDFREQUEST 0x7B534180 dispatched to driver
00002851 core 860 872 0 1491 07\31\2007-10:22:03:515 Free FxRequest* 84ACBE78 memory
00002852 io 860 872 0 1492 07\31\2007-10:22:03:515 No requests on WDFQUEUE 0x7B2BC8D8
After this, my application thread is stopped, waiting for DeviceIoControl() to return, although the driver and message threads are still active.
If I alter the system hardware to not respond with the interrupt, the DeviceIoControl() completes.
Obviously the interrupt and DPC play some part in the problem, but I’m not sure I what is actually going wrong.
TIA
BK