none
How to queue DPC for interrupt ISR of MiniPort drivers RRS feed

  • Question

  • Hi,

    WdfInterruptQueueDpcForIsr(Interrupt) can be used to queue interrupt ISR for afterward processing. How to queue the ISR in MiniPort driver for such processing, because the IO Queue calls are not allowed in the Mini Port Driver?

    Thank you,

    Tiger

     

    Wednesday, July 15, 2015 5:24 PM

Answers

  • You can use a WDFDPC or you can use the underlying WDM DPC associated with your PDEVICE_OBJECT (IoInitializeDpcRequest , IoRequestDpc). the KMDF version has the added benefit of rundown protection

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, July 15, 2015 9:13 PM

All replies

  • What are you trying to do?  WdfInterruptQueueDpcForIsr queues a DPC not an ISR.  IoQueue calls are not allowed in mini-ports, but they are independent of DPC routines, and would not be allowed in the driver period even in a DPC routine.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Wednesday, July 15, 2015 5:31 PM
  • Hi Don,

    In my Mini Port Driver, The interrupts are handled by an ISR. But for some cases, there are long processing. These can be processed outside the interrupt ISR(). Before, I made a call WdfInterruptQueueDpcForIsr(Interrupt) for the afterward processing in the ISR() routine. But now, in the mini port driver, this WdfInterruptQueueDpcForIsr call can not be made. What is the alternative?

    Thank you,

    Tiger

    Wednesday, July 15, 2015 5:38 PM
  • You did not say what kind of mini-port driver it is.  Most mini-port drivers have a set of DPC handling routines, for example StorPortIssueDpc, NdisMQueueDpc, or IPortDMus::Notify.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Wednesday, July 15, 2015 5:46 PM
  • It is based on the AvStream driver. In the DispatchCreate():

    WDF_OBJECT_ATTRIBUTES  attributes;
    WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
    Status = WdfDeviceMiniportCreate(WdfGetDriver(), &attributes, Device->FunctionalDeviceObject,
     Device->NextDeviceObject, Device->PhysicalDeviceObject, &CapDevice->m_WdfDevice);
    KsAcquireDevice(Device);
    Status = KsAddItemToObjectBag(Device->Bag, reinterpret_cast <PVOID> (CapDevice),
         reinterpret_cast <PFNKSFREE> (CCaptureDevice::Cleanup) );
    KsReleaseDevice (Device);

    I called WdfDeviceMiniportCreate() to get a handle of the WdfDevice, which is to be used to DMA processing and allocate virtual memory buffers by using

    WdfCommonBufferGetAlignedVirtualAddress();

    Thank you,

    Tiger

    Wednesday, July 15, 2015 6:01 PM
  • I'm not a AvStream expert but you may want to try WdfDpcCreate and WdfDpcEnqueue. 

      

    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Wednesday, July 15, 2015 6:15 PM
  • Thank you,

    Tiger

    Wednesday, July 15, 2015 6:18 PM
  • are you creating a WDFINTERRUPT to handle the interrupt or is there an avstream abstraction for interrupts that you are using? if avstream has an abstraction, use it for the DPC enqueue.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, July 15, 2015 6:45 PM
  • Hi Doron,

    The Interrupt is connected through:

    IO_CONNECT_INTERRUPT_PARAMETERSiip;

    RtlZeroMemory(&iip, sizeof(IO_CONNECT_INTERRUPT_PARAMETERS));

    iip.Version =

    CONNECT_MESSAGE_BASED;

    PKMESSAGE_SERVICE_ROUTINEmisr = NULL;

    PKSERVICE_ROUTINEisr = NULL;

    misr =

    reinterpret_cast<PKMESSAGE_SERVICE_ROUTINE> (CCaptureDevice::InterruptServiceMSI);

    isr =

    reinterpret_cast<PKSERVICE_ROUTINE> (CCaptureDevice::InterruptServiceISR);

    iip.MessageBased.PhysicalDeviceObject = (

    PDEVICE_OBJECT)m_Device->PhysicalDeviceObject;

    iip.MessageBased.ConnectionContext.Generic = (

    PVOID*)&p_msii;

    ///////////////////////////////////////////////////


    iip.MessageBased.ServiceContext = m_Device->Context;

    iip.MessageBased.MessageServiceRoutine = misr;

    iip.MessageBased.FallBackServiceRoutine = isr;

    iip.MessageBased.SynchronizeIrql =

    PASSIVE_LEVEL;

    //KeInitializeSpinLock(&devExt->IMSRLock);


    //iip.MessageBased.SpinLock = &devExt->IMSRLock;


    iip.MessageBased.SpinLock =

    NULL;

    iip.MessageBased.FloatingSave =

    FALSE;

    status = IoConnectInterruptEx(&iip);

    In the

    InterruptServiceMSI(

    IN struct _KINTERRUPT*Interrupt

    ,

    INPVOIDServiceContext,

    INULONGMessageID);

    The parameter Interrupt is _KINTERRUPT pointer, not a WdfInterrupt.

    Thank you,

    Tiger

    Wednesday, July 15, 2015 7:07 PM
  • You can use a WDFDPC or you can use the underlying WDM DPC associated with your PDEVICE_OBJECT (IoInitializeDpcRequest , IoRequestDpc). the KMDF version has the added benefit of rundown protection

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, July 15, 2015 9:13 PM