Any suggestions to find out the issue for Surprise Removal ?

Discussion in 'Windows Vista Drivers' started by bluestar, Mar 30, 2008.

  1. bluestar

    bluestar Guest

    Dear All:

    I am a newer for coding driver.
    I got a wdf source code from co-worker to solve one issue.

    I found when unplug unexpectedly(surprise removal), my driver
    can't
    not enter EvtDeviceD0Exit callback function. I would try to
    register
    EvtDeviceSurpriseRemoval callback function to debug. I found it
    doesn't enter EvtDeviceSurpriseRemoval, either.

    I would found when unplug unexpectedly, the device would
    disappear
    on the device management, but my driver can't enter
    EvtDeviceSurpriseRemoval,
    EvtDeviceD0Exit and EvtDeviceReleaseHardware callback functions
    to
    release all resources. It will happen errors when the device plug-
    in again
    into System.

    I know maybe it has more reasons, but could anyone tell me which
    ways
    or direction that i would do to find out the reason?

    Thanks for your kindly suggestions.
     
    bluestar, Mar 30, 2008
    #1
    1. Advertisements

  2. are you sure that you registered properly for these functions to begin with?
    are any other power down related functions called? Is the cleanup routine
    on your WDFDEVICE called?

    d
     
    Doron Holan [MSFT], Mar 31, 2008
    #2
    1. Advertisements

  3. bluestar

    bluestar Guest

    Dear Sir:

    My code inherits rom MS-Sample code(serial), so i registered
    properly for
    these functions on SerialEvtDeviceAdd. Like below,

    // Zero out the PnpPowerCallbacks structure.
    pnpPowerCallbacks.EvtDeviceSurpriseRemoval =
    SerialEvtDeviceSurpriseRemoval;

    Before run reading and writing function(user ap), my driver
    works well for plug&unplug.
    But after run reading and writing function, this condition will
    happen.

    Is it possible that device is halt?

    Thanks for your kindly help.
     
    bluestar, Apr 1, 2008
    #3
  4. i hope that you are calling WDF_PNPPOWER_EVENT_CALLBACKS_INIT to initialize
    pnpPowerCallbacks and not zeroing it yourself. i would attach a kernel
    debugger and see what the state of your device is when you surprise remove
    the device. perhaps there is io stuck in a power managed queue and
    preventing the power down. what happens when you close the app which has an
    open handle against the surprise removed device?
     
    Doron Holan [MSFT], Apr 1, 2008
    #4
  5. bluestar

    bluestar Guest

    I will try it by using your method.
    Thanks for your kindly suggestion.
     
    bluestar, Apr 1, 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.