DeferredRequestCompleted rule (kmdf)

The DeferredRequestCompleted rule specifies that if an I/O request presented to a driver's default I/O queue is not completed in the callback function but is deferred for later processing, the request must be completed in a deferred processing callback function, unless the request is forwarded and delivered to the framework, or unless the WdfRequestStopAcknowledge method is called.

The DeferredRequestCompleted rule requires that you identify the deferred requests using the __sdv_save_request and __sdv_retrieve_request macros. For information about how to use these macros, see Using __sdv_save_request and __sdv_retrieve_request for Deferred Procedure Calls. The precondition rule AliasWithinTimerDpc checks for the presence of these macros.

A request presented to the driver's default queue through one of the queue callback functions and deferred, must be completed before it exits from the I/O request callback functions, except in the following cases:

  • The I/O request was forwarded to an I/O target or to another queue

  • The I/O request was delivered to the framework (by calling WdfDeviceEnqueueRequest)

  • The WdfRequestStopAcknowledge method was called

The rule is verified when the driver exits from the following callback functions:

  • EvtIoStop, EvtCleanupCallback or EvtDestroyCallback for the queue

  • EvtCleanupCallback or EvtDestroyCallback for the file object

  • EvtFileClose, EvtFileCleanup, EvtDeviceSelfManagedIoSuspend, EvtDeviceSelfManagedIoFlush, EvtDeviceSelfManagedIoCleanup, EvtDeviceShutdownNotification, EvtDeviceSurpriseRemoval, EvtCleanupCallback or EvtDestroyCallback for the device

  • EvtDriverUnload

The I/O queue callback functions for the I/O request presentation are EvtIoDefault, EvtIoRead, EvtIoWrite, EvtIoDeviceControl, and EvtIoInternalDeviceControl.

The deferred processing callback functions for an I/O request are EvtTimerFunc, EvtDpcFunc, EvtInterruptDpc, EvtInterruptEnable, EvtInterruptDisable, and EvtWorkItem.

The DeferredRequestCompleted rule uses calls to the WdfRequestMarkCancelable, WdfDmaTransactionInitializeUsingRequest, WdfDmaTransactionInitialize, or WdfWorkItemEnqueue methods to indicate that the I/O request is being deferred.

Driver model KMDF

How to test

At compile time

Run Static Driver Verifier and specify the DeferredRequestCompleted rule.

Use the following steps to run an analysis of your code:
  1. Prepare your code (use role type declarations).
  2. Run Static Driver Verifier.
  3. View and analyze the results.

For more information, see Using Static Driver Verifier to Find Defects in Drivers.

Applies to

WdfDeviceEnqueueRequest WdfDmaTransactionInitialize WdfDmaTransactionInitializeUsingRequest WdfIoTargetSendInternalIoctlOthersSynchronously WdfIoTargetSendInternalIoctlSynchronously WdfIoTargetSendIoctlSynchronously WdfIoTargetSendReadSynchronously WdfIoTargetSendWriteSynchronously WdfRequestComplete WdfRequestCompleteWithInformation WdfRequestCompleteWithPriorityBoost WdfRequestForwardToIoQueue WdfRequestMarkCancelable WdfRequestMarkCancelableEx WdfRequestSend WdfRequestStopAcknowledge WdfRequestUnmarkCancelable WdfWorkItemEnqueue