unsure about kmdf synchronization

Hi all,

I’m trying to set up my queues in a KMDF PCI driver and I’m not sure if I’ve got my synchronization setup the way I want it to be. What I want:

  1. queue for device io controls
  2. synchronous entry into the EvtIoDeviceControl callback
  3. some IOCTLs will create a work item that will complete the request i.e. EvtIoDeviceControl will return STATUS_PENDING and the work item will call WdfCompleteRequest; others will complete the request
  4. EvtIoDeviceControl and work item to run independent of each other (of course excluding whatever code I put in by hand to do any needed mutual exclusion)

Here’s what I’ve got in my EvtDeviceAdd:
Device Creation
WdfDeviceInitSetIoType (pDeviceInit, WdfDeviceIoDirect);
WdfDeviceInitSetExclusive (pDeviceInit, FALSE);



WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE (&objAttrib, DEVICE_EXTENSION);
objAttrib.SynchronizationScope = WdfSynchronizationScopeQueue;

status = WdfDeviceCreate (&pDeviceInit, &objAttrib, &device);

Queue Creation
WDF_IO_QUEUE_CONFIG_INIT (&ioQueueConfig, WdfIoQueueDispatchSequential);
ioQueueConfig.EvtIoDeviceControl = VpaPci9030EvtIoDeviceControl;
ioQueueConfig.AllowZeroLengthRequests = TRUE;
ioQueueConfig.PowerManaged = WdfTrue;

WDF_OBJECT_ATTRIBUTES_INIT (&objAttrib);
objAttrib.ParentObject = pDeviceExt->Device;
objAttrib.SynchronizationScope = WdfSynchronizationScopeInheritFromParent;

status = WdfIoQueueCreate (device, &ioQueueConfig,
&objAttrib, &pDeviceExt->IoctlQueue);
status = WdfDeviceConfigureRequestDispatching (device, pDeviceExt->IoctlQueue,
WdfRequestTypeDeviceControl);

Work Item
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE (&objAttrib,
WORKITEM_CONTEXT);
objAttrib.ParentObject = pDeviceExt->IoctlQueue;

WDF_WORKITEM_CONFIG_INIT (&workItemConfig, VpaPci9030EvtWorkItem);
workItemConfig.AutomaticSerialization = FALSE;

status = WdfWorkItemCreate (&workItemConfig, &objAttrib,
&pDeviceExt->WorkItem);

My question concerns the dispatching option when the queue is created. WdfIoQueueDispatchSequential says that the queue will wait until a request is completed before sending the next request. That’s not what I want - the next request is allowed to come through while the work item is waiting to run. However, WdfIoQueueDispatchParallel says the requests will be dispatched as soon as available. That’s also not what I want - the calls into the EvtIoDeviceControl callback should be synchronous. Will having SynchronizeScopeQueue override the DispatchParallel and give me synchronous EvtIoDeviceControl callbacks, while at the same time allowing the next request to come in before the work item has run?

Thanks!!
Judy