Queue DPC for ISR

Discussion in 'Windows Vista Drivers' started by dLopesp, Oct 8, 2008.

  1. dLopesp

    dLopesp Guest

    Hi,

    I'm working with a KMDF driver and found a problem when handling interrupts.

    In my ISR function, I save volatile information, schedule a DPC for this ISR
    and clear the interrupt.

    When reading WDF documentation, I found that only one DPC can be queue at
    time and my call to WdfInterruptQueueDpcForIsr will return false.

    My problem is that, this situation will probably happen and I don't know how
    to handle this failure, since I cann't loose that interrupt.

    Should I create a DPC object and enqueue it?

    I was unable to find any sample code on this.

    Thanks in advance.
    Douglas
     
    dLopesp, Oct 8, 2008
    #1
    1. Advertisements

  2. dLopesp

    Don Burn Guest

    This will happen even without WDF, a DPC can only be in the queue once at a
    time. The normal approach for this is to have a buffer for the information
    you need for the DPC, and design it to hold enough info to not loose an
    interrupt. You insert the data in the buffer in the ISR, then queue the
    interrupt. In the DPC you get the data out and process all the information.
    This does require some synchronization in the DPC using either
    WdfInterruptSynchronize or WdfInterruptAcquireLock.


    --
    Don Burn (MVP, Windows DDK)
    Windows Filesystem and Driver Consulting
    Website: http://www.windrvr.com
    Blog: http://msmvps.com/blogs/WinDrvr
    Remove StopSpam to reply
     
    Don Burn, Oct 8, 2008
    #2
    1. Advertisements

  3. The right way to handle interrupts is disable the device interrupts in the
    ISR, queue the DPC, then enable the device interrupts back in DPC. And MAKE
    SURE YOU CHECK THAT'S YOUR DEVICE'S INTERRUPT in ISR!
     
    Alexander Grigoriev, Oct 8, 2008
    #3
  4. dLopesp

    dLopesp Guest

    Hi Alexander,

    thanks for the quick reply.

    By doing that ("disable the device interrupts in the ISR") it is possible
    that I loose some important information from the board, since I have a lot of
    processing in my DPC. Is there a way to queue those adicional interrupts?

    Got that, I already checked and it is my device's interrupt.

    Thanks in advance.
     
    dLopesp, Oct 8, 2008
    #4
  5. In the DPC, you handle all information that you can get from the board. I
    suppose one processor is able to handle it, otherwise you'll have to spread
    the processing, which becomes very messy.

    You can also avoid disabling the board interrupts by making your own
    mechanism for queung a DPC only as necessary. If it's already running,
    you'll queue more information for it to process, without actually queuing
    it.
     
    Alexander Grigoriev, Oct 9, 2008
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.