Driver Problems? Questions? Issues?
Put OSR's experience to work for you! Contact us for assistance with:
  • Creating the right design for your requirements
  • Reviewing your existing driver code
  • Analyzing driver reliability/performance issues
  • Custom training mixed with consulting and focused directly on your specific areas of interest/concern.
Check us out. OSR, the Windows driver experts.

OSR Seminars


Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 6  
13 Jul 18 12:43
Mukesh Kumar
xxxxxx@gmail.com
Join Date: 05 Dec 2016
Posts To This List: 14
AddDevice getting called while Surpriseremoval is still getting processed

Hi team, We have a USB Bus driver and a Function driver. During SurpriseRemoval, Function driver disable its interface, so that OS Services can close the Open Handle to the driver. WDF calls the D0Exit and ReleaseHardware of Function driver, and the calls EvtDeviceFileClose. The delay in WDF callback EvtDeviceFileClose, doesnt allow the filter driver to unload. Meanwhile, even though the Bus driver is in Releasehardware. Meanwhile OS calls a AddDevice to the BusDriver, which cant be handled as this stage as we have already started the cleanup, and we have to return a error for Adddevice. Is there a way, we can ask Framework not to do a Addevice, until the driver unloads completely ? or can EvtDeviceFileClose on Function driver be called before ReleaseHardware callback on Function driver ?
  Message 2 of 6  
13 Jul 18 13:55
Peter Viscarola
xxxxxx@osr.com
Join Date:
Posts To This List: 6243
List Moderator
AddDevice getting called while Surpriseremoval is still getting processed

<quote> Is there a way, we can ask Framework not to do a Addevice, until the driver unloads completely? </quote> I'm not sure I understand why this is a race condition for you. Each device instance is separate, right? So, while one instance is being "cleaned up" (I'm not sure *exactly* what you mean by this, but...) another instance can *always* arrive, right? Sorry... I guess I don't understand the basic issue, Peter OSR @OSRDrivers
  Message 3 of 6  
13 Jul 18 15:06
Mukesh Kumar
xxxxxx@gmail.com
Join Date: 05 Dec 2016
Posts To This List: 14
AddDevice getting called while Surpriseremoval is still getting processed

Hi Peter, the driver doesnt support Multi instance, as there are few globals and Hardware config params which needs to be cleaned before re-instanced.
  Message 4 of 6  
13 Jul 18 15:07
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 12008
AddDevice getting called while Surpriseremoval is still getting processed

xxxxx@gmail.com wrote: > We have a USB Bus driver and a Function driver. During SurpriseRemoval, Function driver disable its interface, so that OS Services can close the Open Handle to the driver. So, you have a USB device.  The driver for that device creates a PDO, for which you have another function driver, and you have an app opening a handle to that driver.  Is that right?  So, in surprise removal, that whole stack is going to get torn down.  Or have I misinterpreted? > WDF calls the D0Exit and ReleaseHardware of Function driver, and the calls EvtDeviceFileClose. The delay in WDF callback EvtDeviceFileClose, doesnt allow the filter driver to unload. Meanwhile, even though the Bus driver is in Releasehardware. What filter driver?  What that a typo? I'm not sure why this should be a problem.   > Meanwhile OS calls a AddDevice to the BusDriver, which cant be handled as this stage as we have already started the cleanup, and we have to return a error for Adddevice. This is a design flaw in your drivers.  The AddDevice in the bus driver is trying to create a brand-new device instance for the newly reinserted hardware, which should be totally independent of the old device instance.  What kind of global state are you tracking that causes you to return an error?  And why are you doing so? > Is there a way, we can ask Framework not to do a Addevice, until the driver unloads completely ? or can EvtDeviceFileClose on Function driver be called before ReleaseHardware callback on Function driver ? The order shouldn't matter. -- Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
  Message 5 of 6  
13 Jul 18 15:10
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 12008
AddDevice getting called while Surpriseremoval is still getting processed

xxxxx@gmail.com wrote: > the driver doesnt support Multi instance, as there are few globals and Hardware config params which needs to be cleaned before re-instanced. Then your driver is broken.  It's just that simple.  There is NO excuse for having a USB driver that does not support multi-instance.  Your hardware config is not global, it is specific to a single device instance.  When you get a new instance, then you have to reset the hardware config, whether or not there is another device already configured. You need to fix it. -- Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
  Message 6 of 6  
13 Jul 18 21:51
Peter Viscarola
xxxxxx@osr.com
Join Date:
Posts To This List: 6243
List Moderator
AddDevice getting called while Surpriseremoval is still getting processed

> your driver is broken ... > You need to fix it This. Peter OSR @OSRDrivers
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 19:20.


Copyright ©2015, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license