[ofw][patches][ibbus] IBBUS gets never unload

Leonid Keller leonid at mellanox.co.il
Thu Jun 11 09:23:52 PDT 2009


Committed in 2228.


________________________________

	From: ofw-bounces at lists.openfabrics.org
[mailto:ofw-bounces at lists.openfabrics.org] On Behalf Of Leonid Keller
	Sent: Monday, June 01, 2009 11:49 AM
	To: Smith, Stan
	Cc: ofw at lists.openfabrics.org
	Subject: [ofw][patches][ibbus] IBBUS gets never unload
	
	
	This problem was introduced by adding new Control Device
resposible for handling IOCTLs. [winof: 2147]
	This device was created in DriverEntry and supposed to be
removed in DriverUnload routine.
	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.
	This patch moves creation of the Control Device to
bus_add_device routine and moves its removal to fdo_release_resources
routine.
	 
	 
	Index: V:/svn/winib/trunk/core/bus/kernel/bus_driver.c
	
===================================================================
	--- V:/svn/winib/trunk/core/bus/kernel/bus_driver.c (revision
4395)
	+++ V:/svn/winib/trunk/core/bus/kernel/bus_driver.c (revision
4396)
	@@ -969,12 +969,6 @@
	 
	  BUS_ENTER( BUS_DBG_DRV );
	  
	- IoDeleteSymbolicLink( &g_CDO_dos_name );
	- if (g_ControlDeviceObject)
	- {
	-  IoDeleteDevice(g_ControlDeviceObject);
	-  g_ControlDeviceObject = NULL; 
	- }
	  cur_conf = bus_globals.p_pkey_conf;
	  while(cur_conf)
	  {
	@@ -1050,31 +1044,6 @@
	  memset(  __out_bcount(sizeof(g_bus_filters))
(void*)g_bus_filters, 0,
	    sizeof(g_bus_filters) );
	  
	- {
	-  bus_fdo_ext_t *p_ext=NULL;
	-
	-  RtlInitUnicodeString( &g_CDO_dev_name, AL_DEVICE_NAME );
	-  RtlInitUnicodeString( &g_CDO_dos_name,
L"\\DosDevices\\Global\\ibal" );
	-
	-  status = IoCreateDevice( p_driver_obj, sizeof(bus_fdo_ext_t),
	-   &g_CDO_dev_name, FILE_DEVICE_BUS_EXTENDER,
	-   FILE_DEVICE_SECURE_OPEN, FALSE, &g_ControlDeviceObject );
	-  if( !NT_SUCCESS(status) )
	-  {
	-   g_ControlDeviceObject = NULL;
	-   BUS_PRINT( BUS_DBG_ERROR, 
	-    ("Failed to create ControlDeviceObject, status
%x.\n",status) );
	-   /* failure is OK - retry in bus_add_device() */
	-  }
	-  else {
	-   p_ext = g_ControlDeviceObject->DeviceExtension;
	-   RtlZeroMemory(p_ext, sizeof *p_ext);
	-   cl_init_pnp_po_ext( g_ControlDeviceObject, NULL, 
	-        NULL, bus_globals.dbg_lvl, NULL, NULL );
	-   IoInitializeRemoveLock( &p_ext->cl_ext.stop_lock, 'dtci', 0,
1000 );
	-  }
	- }
	-
	  BUS_EXIT( BUS_DBG_DRV );
	  return STATUS_SUCCESS;
	 }
	Index: V:/svn/winib/trunk/core/bus/kernel/bus_pnp.c
	
===================================================================
	--- V:/svn/winib/trunk/core/bus/kernel/bus_pnp.c (revision 4395)
	+++ V:/svn/winib/trunk/core/bus/kernel/bus_pnp.c (revision 4396)
	@@ -195,45 +195,54 @@
	   return STATUS_UNSUCCESSFUL;
	  }
	 
	- /* Create the FDO device object to attach to the stack. */
	-
	  /* if 1st Bus Filter Instance, then create device names for
user ioctl */
	  if ( ic == 1  && !g_ControlDeviceObject)
	  {
	+  RtlInitUnicodeString( &g_CDO_dev_name, AL_DEVICE_NAME );
	+  RtlInitUnicodeString( &g_CDO_dos_name,
L"\\DosDevices\\Global\\ibal" );
	+ 
	   status = IoCreateDevice( p_driver_obj, sizeof(bus_fdo_ext_t),
	-         &g_CDO_dev_name, FILE_DEVICE_BUS_EXTENDER,
	-         FILE_DEVICE_SECURE_OPEN, FALSE, &p_dev_obj );
	+   &g_CDO_dev_name, FILE_DEVICE_BUS_EXTENDER,
	+   FILE_DEVICE_SECURE_OPEN, FALSE, &g_ControlDeviceObject );
	   if( !NT_SUCCESS(status) )
	   {
	+   g_ControlDeviceObject = NULL;
	    BUS_PRINT( BUS_DBG_ERROR, 
	     ("Failed to create ControlDeviceObject, status
%x.\n",status) );
	    goto err1;
	   }
	- }
	- else {
	-  status = IoCreateDevice( p_driver_obj, sizeof(bus_fdo_ext_t),
	-         NULL, FILE_DEVICE_BUS_EXTENDER,
	-         FILE_DEVICE_SECURE_OPEN, FALSE, &p_dev_obj );
	-  if( !NT_SUCCESS(status) )
	-  {
	-   BUS_PRINT( BUS_DBG_ERROR, 
	-    ("Failed to create bus root FDO device.\n") );
	-   goto err1;
	+  else {
	+   p_ext = g_ControlDeviceObject->DeviceExtension;
	+   RtlZeroMemory(p_ext, sizeof *p_ext);
	+   cl_init_pnp_po_ext( g_ControlDeviceObject, NULL, 
	+        NULL, bus_globals.dbg_lvl, NULL, NULL );
	+   IoInitializeRemoveLock( &p_ext->cl_ext.stop_lock, 'dtci', 0,
1000 );
	+
	+   /* enable user-mode access to IB stack */
	+   BUS_PRINT( BUS_DBG_PNP, ("Remove-n-reCreate dos_name
symlink\n") );
	+   IoDeleteSymbolicLink( &g_CDO_dos_name );
	+   status = IoCreateSymbolicLink( &g_CDO_dos_name,
&g_CDO_dev_name );
	+   if( !NT_SUCCESS(status) )
	+   {
	+    BUS_PRINT( BUS_DBG_ERROR,
	+     ("Failed to create symlink for dos name.\n") );
	+    IoDeleteDevice( g_ControlDeviceObject );
	+    g_ControlDeviceObject = NULL;
	+    goto err1;
	+   }
	+   BUS_TRACE( BUS_DBG_PNP, ("Created dos_name symlink\n") );
	   }
	  }
	 
	- if ( ic == 1 ) {
	-  /* enable user-mode access to IB stack */
	-  BUS_PRINT( BUS_DBG_PNP, ("Remove-n-reCreate dos_name
symlink\n") );
	-  IoDeleteSymbolicLink( &g_CDO_dos_name );
	-  status = IoCreateSymbolicLink( &g_CDO_dos_name,
&g_CDO_dev_name );
	-  if( !NT_SUCCESS(status) )
	-  {
	-   BUS_PRINT( BUS_DBG_ERROR,
	-    ("Failed to create symlink for dos name.\n") );
	-   goto err2;
	-  }
	-  BUS_TRACE( BUS_DBG_PNP, ("Created dos_name symlink\n") );
	+ /* Create the FDO device object to attach to the stack. */
	+ status = IoCreateDevice( p_driver_obj, sizeof(bus_fdo_ext_t),
	+        NULL, FILE_DEVICE_BUS_EXTENDER,
	+        FILE_DEVICE_SECURE_OPEN, FALSE, &p_dev_obj );
	+ if( !NT_SUCCESS(status) )
	+ {
	+  BUS_PRINT( BUS_DBG_ERROR, 
	+   ("Failed to create bus root FDO device.\n") );
	+  goto err1;
	  }
	 
	  p_ext = p_dev_obj->DeviceExtension;
	@@ -308,12 +317,6 @@
	 err1:
	  BUS_PRINT( BUS_DBG_PNP, ("%s exit status 0x%x\n",
p_bfi->whoami,status) );
	  ic = free_bfi(p_bfi);
	- /* if last Bus filter, then cleanup */
	- if ( ic == 0 )
	- {
	-  IoDeleteSymbolicLink( &g_CDO_dos_name );
	-  RtlFreeUnicodeString( &al_ifc_name );
	- }
	  BUS_EXIT( BUS_DBG_PNP );
	  return status;
	 }
	@@ -470,7 +473,7 @@
	  p_bfi->ca_guid = p_ext->hca_ifc.Verbs.guid;
	 
	  /* register HCA */
	- ib_status = ib_register_ca( &p_ext->hca_ifc.Verbs,
p_ext->cl_ext.p_pdo );
	+ ib_status = ib_register_ca( &p_ext->hca_ifc.Verbs,
p_ext->cl_ext.p_pdo, p_dev_obj );
	  if( ib_status != IB_SUCCESS )
	  {
	   BUS_TRACE_EXIT( BUS_DBG_ERROR, ("ib_register_ca returned
%s.\n",
	@@ -596,7 +599,12 @@
	   return;
	  }
	 
	- IoDeleteSymbolicLink( &g_CDO_dos_name );
	+ if (g_ControlDeviceObject)
	+ {
	+  IoDeleteSymbolicLink( &g_CDO_dos_name );
	+  IoDeleteDevice(g_ControlDeviceObject);
	+  g_ControlDeviceObject = NULL; 
	+ }
	 
	  /* Disable any exported interfaces. */
	  status = IoSetDeviceInterfaceState( &al_ifc_name, FALSE );
	

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20090611/e525a76f/attachment.html>


More information about the ofw mailing list