1394 async callback(no back store)

Discussion in 'Windows Vista Drivers' started by Raj, Aug 6, 2003.

  1. Raj

    Raj Guest

    In 1394 device driver, I register callback for Async indication(Mdl =
    NULL
    FifoSListHead = NULL and FifoSpinLock = NULL). But I have questions on
    how I should handle callback function. Right now :

    1. Send response using data of NOTIFICATION received.

    2. Parse the packet and analyze what packet it is. ( "proprietary"
    protocol data of packet).

    3. Fill the driver buffers with NOTIFICATION data and dequeue and
    IoCompleteRequest the pended-Irp.

    4. Signal the event(passed by user program) so that App which has the
    buffers to driver will now receive the data.

    Now question is,

    (1) Will my callback can be called before I complete callback.
    If so, should I AcquireSpinLock soon after entering callback and
    ReleaseSpinLock before returning function. This way second call to the
    callback will be blocked. But I cannot do IoCompleteRequest when
    SpinLock is acquired.

    (2) Should I simply call workItem, each with NOTIFICATION pointer and
    return callback. NOTIFICATION pointer may be freed after I return from
    callback.
    I CANNOT queue NOTIFY and return. This is becoz my NOTIFICATION
    received may be freed by the time I execute work item after
    another(suppose there are two indications almost same time).

    (3)May be I can assume blindly my callback is not called before I
    complete the callback. Is it safe to assume this ? Since the bus
    driver calls this callback, I am not understanding whether the call is
    queued. How to understand this.

    What is best way to handle callback.
     
    Raj, Aug 6, 2003
    #1
    1. Advertisements

  2. (1) Will my callback can be called before I complete callback.
    I don't believe your notification routine needs to be written to be
    reentrant, but it isn't documented one way or another, and there are no
    samples that use this backing store technique anywhere that I have found.

    To provide synchronization, why not just have your own spinlock and use a
    DPC to complete your IRP? It is VERY likely that your notification routine
    is called under a bus driver held spinlock anyway.
     
    Bill McKenzie, Aug 7, 2003
    #2
    1. Advertisements

  3. Raj

    Raj Guest

    I don't believe your notification routine needs to be written to be
    I am thinking I will protect my global data with SpinLock and complete
    Irp in callback itself. Since my driver is the highest in chain and
    the Irp I am completing is original Irp of Dispatch routine, I am not
    having problems to complete in callback. Am I correct to assume so
    under given conditions.
     
    Raj, Aug 7, 2003
    #3
  4. I am thinking I will protect my global data with SpinLock and complete
    That should be fine. I was just giving you the ultimate paranoia version.
    Personally, I don't think you even have to provide synchronization for this
    routine, but I wish this was documented. I could easily verify that the bus
    does indeed synchronize around calling this routine already, but I could not
    guarantee that I can depend on this. Documentation of such would sure be
    *nice* <assume "Everybody Loves Raymond" inflection>.

    --
    Bill McKenzie
    Compuware Corporation
    Watch your IRPs/IRBs/URBs/SRBs/NDIS pkts with our free WDMSniffer tool:
    http://frontline.compuware.com/nashua/patches/utility.htm
     
    Bill McKenzie, Aug 7, 2003
    #4
  5. Raj

    Raj Guest

    If there is nested acquiring of Spinlocks ( acquire spinlock1, then
    acquire spinlock2) instead of acquiring one spinlock, will it change
    any performance other adding few more instructions for execution.
    Ofcourse acquiring spinklock should be for as short duration possible.
    But nested spinlock wouldn't hurt other than executing few more
    instructions. Am I right?
     
    Raj, Aug 8, 2003
    #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.