Bewerken

Delen via


Reusing DMA Transaction Objects

[Applies to KMDF only]

After a driver processes all of the DMA transfers that are associated with a DMA transaction, the driver can delete or reuse the transaction object. Typically, the driver's EvtInterruptDpc callback function deletes the transaction object (by calling WdfObjectDelete). Subsequently, when the driver creates a new DMA transaction, it calls WdfDmaTransactionCreate to create a new transaction object.

However, sometimes it is beneficial for the driver to reuse transaction objects. In such cases, the driver calls WdfDmaTransactionRelease instead of WdfObjectDelete.

For example, suppose your driver and device must operate when computer memory resources are low. To handle this memory issue, your driver can use the following procedure:

  1. The driver's EvtDriverDeviceAdd callback function can call WdfDmaTransactionCreate to create one or more transaction objects. The driver saves the handles to these transaction objects.

  2. Each time the driver is ready to create and initialize a new transaction, it calls WdfDmaTransactionCreate. If this method returns STATUS_INSUFFICIENT_RESOURCES, the driver can use one of the stored transaction objects.

  3. If the driver uses one of its stored transaction objects, it should reuse the transaction object, instead of deleting it, when the transaction is completed. The driver sets up the transaction object for re-use by calling WdfDmaTransactionRelease instead of WdfObjectDelete.

The PLX9x5x sample reuses DMA transaction objects.