<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3243" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN class=526263808-01062009>This problem was 
introduced by adding new Control Device resposible for handling IOCTLs.  
[winof: 2147]</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=526263808-01062009>This device was 
created in DriverEntry and supposed to be removed in DriverUnload 
routine.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=526263808-01062009>But it turned out, 
that PnP manager doesn't call DriverUnload till all devices are deleted, so 
IBBUS gets never unloaded, even after removing all HCA driver 
stack.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=526263808-01062009>This patch moves 
creation of the Control Device to bus_add_device routine and moves its removal 
to fdo_release_resources routine.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=526263808-01062009></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Index: 
V:/svn/winib/trunk/core/bus/kernel/bus_driver.c<BR>===================================================================<BR>--- 
V:/svn/winib/trunk/core/bus/kernel/bus_driver.c (revision 4395)<BR>+++ 
V:/svn/winib/trunk/core/bus/kernel/bus_driver.c (revision 4396)<BR>@@ 
-969,12 +969,6 @@<BR> <BR>  BUS_ENTER( BUS_DBG_DRV 
);<BR>  <BR>- IoDeleteSymbolicLink( &g_CDO_dos_name 
);<BR>- if 
(g_ControlDeviceObject)<BR>- {<BR>-  IoDeleteDevice(g_ControlDeviceObject);<BR>-  g_ControlDeviceObject 
= NULL; <BR>- }<BR>  cur_conf = 
bus_globals.p_pkey_conf;<BR>  while(cur_conf)<BR>  {<BR>@@ 
-1050,31 +1044,6 @@<BR>  memset(  
__out_bcount(sizeof(g_bus_filters)) (void*)g_bus_filters, 
0,<BR>    sizeof(g_bus_filters) 
);<BR>  <BR>- {<BR>-  bus_fdo_ext_t *p_ext=NULL;<BR>-<BR>-  RtlInitUnicodeString( 
&g_CDO_dev_name, AL_DEVICE_NAME );<BR>-  RtlInitUnicodeString( 
&g_CDO_dos_name, L"<A 
href="file://\\DosDevices\\Global\\ibal">\\DosDevices\\Global\\ibal</A>" 
);<BR>-<BR>-  status = IoCreateDevice( p_driver_obj, 
sizeof(bus_fdo_ext_t),<BR>-   &g_CDO_dev_name, 
FILE_DEVICE_BUS_EXTENDER,<BR>-   FILE_DEVICE_SECURE_OPEN, FALSE, 
&g_ControlDeviceObject );<BR>-  if( !NT_SUCCESS(status) 
)<BR>-  {<BR>-   g_ControlDeviceObject = 
NULL;<BR>-   BUS_PRINT( BUS_DBG_ERROR, 
<BR>-    ("Failed to create ControlDeviceObject, status 
%x.\n",status) );<BR>-   /* failure is OK - retry in 
bus_add_device() */<BR>-  }<BR>-  else 
{<BR>-   p_ext = 
g_ControlDeviceObject->DeviceExtension;<BR>-   RtlZeroMemory(p_ext, 
sizeof *p_ext);<BR>-   cl_init_pnp_po_ext( g_ControlDeviceObject, 
NULL, <BR>-        NULL, 
bus_globals.dbg_lvl, NULL, NULL );<BR>-   IoInitializeRemoveLock( 
&p_ext->cl_ext.stop_lock, 'dtci', 0, 1000 
);<BR>-  }<BR>- }<BR>-<BR>  BUS_EXIT( BUS_DBG_DRV 
);<BR>  return STATUS_SUCCESS;<BR> }<BR>Index: 
V:/svn/winib/trunk/core/bus/kernel/bus_pnp.c<BR>===================================================================<BR>--- 
V:/svn/winib/trunk/core/bus/kernel/bus_pnp.c (revision 4395)<BR>+++ 
V:/svn/winib/trunk/core/bus/kernel/bus_pnp.c (revision 4396)<BR>@@ -195,45 
+195,54 @@<BR>   return 
STATUS_UNSUCCESSFUL;<BR>  }<BR> <BR>- /* Create the FDO 
device object to attach to the stack. */<BR>-<BR>  /* if 1st Bus 
Filter Instance, then create device names for user ioctl */<BR>  if ( 
ic == 1  && 
!g_ControlDeviceObject)<BR>  {<BR>+  RtlInitUnicodeString( 
&g_CDO_dev_name, AL_DEVICE_NAME );<BR>+  RtlInitUnicodeString( 
&g_CDO_dos_name, L"<A 
href="file://\\DosDevices\\Global\\ibal">\\DosDevices\\Global\\ibal</A>" 
);<BR>+ <BR>   status = IoCreateDevice( p_driver_obj, 
sizeof(bus_fdo_ext_t),<BR>-         
&g_CDO_dev_name, 
FILE_DEVICE_BUS_EXTENDER,<BR>-         
FILE_DEVICE_SECURE_OPEN, FALSE, &p_dev_obj 
);<BR>+   &g_CDO_dev_name, 
FILE_DEVICE_BUS_EXTENDER,<BR>+   FILE_DEVICE_SECURE_OPEN, FALSE, 
&g_ControlDeviceObject );<BR>   if( !NT_SUCCESS(status) 
)<BR>   {<BR>+   g_ControlDeviceObject = 
NULL;<BR>    BUS_PRINT( BUS_DBG_ERROR, 
<BR>     ("Failed to create ControlDeviceObject, status 
%x.\n",status) );<BR>    goto 
err1;<BR>   }<BR>- }<BR>- else {<BR>-  status 
= IoCreateDevice( p_driver_obj, 
sizeof(bus_fdo_ext_t),<BR>-         
NULL, 
FILE_DEVICE_BUS_EXTENDER,<BR>-         
FILE_DEVICE_SECURE_OPEN, FALSE, &p_dev_obj );<BR>-  if( 
!NT_SUCCESS(status) )<BR>-  {<BR>-   BUS_PRINT( 
BUS_DBG_ERROR, <BR>-    ("Failed to create bus root FDO 
device.\n") );<BR>-   goto err1;<BR>+  else 
{<BR>+   p_ext = 
g_ControlDeviceObject->DeviceExtension;<BR>+   RtlZeroMemory(p_ext, 
sizeof *p_ext);<BR>+   cl_init_pnp_po_ext( g_ControlDeviceObject, 
NULL, <BR>+        NULL, 
bus_globals.dbg_lvl, NULL, NULL );<BR>+   IoInitializeRemoveLock( 
&p_ext->cl_ext.stop_lock, 'dtci', 0, 1000 
);<BR>+<BR>+   /* enable user-mode access to IB stack 
*/<BR>+   BUS_PRINT( BUS_DBG_PNP, ("Remove-n-reCreate dos_name 
symlink\n") );<BR>+   IoDeleteSymbolicLink( &g_CDO_dos_name 
);<BR>+   status = IoCreateSymbolicLink( &g_CDO_dos_name, 
&g_CDO_dev_name );<BR>+   if( !NT_SUCCESS(status) 
)<BR>+   {<BR>+    BUS_PRINT( 
BUS_DBG_ERROR,<BR>+     ("Failed to create symlink for 
dos name.\n") );<BR>+    IoDeleteDevice( 
g_ControlDeviceObject );<BR>+    g_ControlDeviceObject = 
NULL;<BR>+    goto 
err1;<BR>+   }<BR>+   BUS_TRACE( BUS_DBG_PNP, 
("Created dos_name symlink\n") 
);<BR>   }<BR>  }<BR> <BR>- if ( ic == 1 ) 
{<BR>-  /* enable user-mode access to IB stack 
*/<BR>-  BUS_PRINT( BUS_DBG_PNP, ("Remove-n-reCreate dos_name 
symlink\n") );<BR>-  IoDeleteSymbolicLink( &g_CDO_dos_name 
);<BR>-  status = IoCreateSymbolicLink( &g_CDO_dos_name, 
&g_CDO_dev_name );<BR>-  if( !NT_SUCCESS(status) 
)<BR>-  {<BR>-   BUS_PRINT( 
BUS_DBG_ERROR,<BR>-    ("Failed to create symlink for dos 
name.\n") );<BR>-   goto 
err2;<BR>-  }<BR>-  BUS_TRACE( BUS_DBG_PNP, ("Created 
dos_name symlink\n") );<BR>+ /* Create the FDO device object to attach to 
the stack. */<BR>+ status = IoCreateDevice( p_driver_obj, 
sizeof(bus_fdo_ext_t),<BR>+        NULL, 
FILE_DEVICE_BUS_EXTENDER,<BR>+        
FILE_DEVICE_SECURE_OPEN, FALSE, &p_dev_obj );<BR>+ if( 
!NT_SUCCESS(status) )<BR>+ {<BR>+  BUS_PRINT( BUS_DBG_ERROR, 
<BR>+   ("Failed to create bus root FDO device.\n") 
);<BR>+  goto err1;<BR>  }<BR> <BR>  p_ext = 
p_dev_obj->DeviceExtension;<BR>@@ -308,12 +317,6 
@@<BR> err1:<BR>  BUS_PRINT( BUS_DBG_PNP, ("%s exit status 
0x%x\n", p_bfi->whoami,status) );<BR>  ic = 
free_bfi(p_bfi);<BR>- /* if last Bus filter, then cleanup */<BR>- if ( 
ic == 0 )<BR>- {<BR>-  IoDeleteSymbolicLink( &g_CDO_dos_name 
);<BR>-  RtlFreeUnicodeString( &al_ifc_name 
);<BR>- }<BR>  BUS_EXIT( BUS_DBG_PNP );<BR>  return 
status;<BR> }<BR>@@ -470,7 +473,7 @@<BR>  p_bfi->ca_guid = 
p_ext->hca_ifc.Verbs.guid;<BR> <BR>  /* register HCA 
*/<BR>- ib_status = ib_register_ca( &p_ext->hca_ifc.Verbs, 
p_ext->cl_ext.p_pdo );<BR>+ ib_status = ib_register_ca( 
&p_ext->hca_ifc.Verbs, p_ext->cl_ext.p_pdo, p_dev_obj 
);<BR>  if( ib_status != IB_SUCCESS 
)<BR>  {<BR>   BUS_TRACE_EXIT( BUS_DBG_ERROR, 
("ib_register_ca returned %s.\n",<BR>@@ -596,7 +599,12 
@@<BR>   return;<BR>  }<BR> <BR>- IoDeleteSymbolicLink( 
&g_CDO_dos_name );<BR>+ if 
(g_ControlDeviceObject)<BR>+ {<BR>+  IoDeleteSymbolicLink( 
&g_CDO_dos_name 
);<BR>+  IoDeleteDevice(g_ControlDeviceObject);<BR>+  g_ControlDeviceObject 
= NULL; <BR>+ }<BR> <BR>  /* Disable any exported 
interfaces. */<BR>  status = IoSetDeviceInterfaceState( 
&al_ifc_name, FALSE );<BR></FONT></DIV></BODY></HTML>