[ofw][patch][IBBUS] Fix for a bug from Bugzilla 1367

Leonid Keller leonid at mellanox.co.il
Sun Apr 5 06:46:40 PDT 2009


Bugzilla 1367: If N cards are installed on a machine, a disabling of the
first one will
prevent the work of all applications with the rest cards.
 
Explanation:
   IBBUS driver creates only first instance of IBAL with a name. All the
rest
are unnamed. After removing the first card, the named instance is gone
and
applications, which are binding to IBAL by name, can't find it and can't
work.
 
Solution: The fix creates IBBUS Control Device of "
\\DosDevices\\Global\\ibal" name from IBBUS Driver Entry.
All other devices are created unnamed.
 
 
 
Index: bus/kernel/bus_driver.c
===================================================================
--- bus/kernel/bus_driver.c (revision 2076)
+++ bus/kernel/bus_driver.c (working copy)
@@ -60,6 +60,7 @@
 
 
 char node_desc[IB_NODE_DESCRIPTION_SIZE];
+PDEVICE_OBJECT g_ControlDeviceObject=NULL;
 
 bus_globals_t bus_globals = {
  BUS_DBG_ERROR,
@@ -981,6 +982,11 @@
  
  RtlInitUnicodeString( &dos_name, L"\\DosDevices\\Global\\ibal" );
  IoDeleteSymbolicLink( &dos_name );
+ if (g_ControlDeviceObject)
+ {
+  IoDeleteDevice(g_ControlDeviceObject);
+  g_ControlDeviceObject = NULL; 
+ }
  cur_conf = bus_globals.p_pkey_conf;
  while(cur_conf)
  {
@@ -1055,7 +1061,46 @@
  g_bfi_InstanceCount = 0;
  memset(  __out_bcount(sizeof(g_bus_filters)) (void*)g_bus_filters, 0,
    sizeof(g_bus_filters) );
+ 
+ {
+  UNICODE_STRING dev_name, dos_name;
+  bus_fdo_ext_t *p_ext=NULL;
 
+  RtlInitUnicodeString( &dev_name, AL_DEVICE_NAME );
+  RtlInitUnicodeString( &dos_name, L"\\DosDevices\\Global\\ibal" );
+
+  status = IoCreateDevice( p_driver_obj, sizeof(bus_fdo_ext_t),
+   &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) );
+  }
+  else {
+   IoDeleteSymbolicLink( &dos_name );
+   status = IoCreateSymbolicLink( &dos_name, &dev_name );
+   if( !NT_SUCCESS(status) )
+   {
+    IoDeleteDevice( g_ControlDeviceObject );
+    g_ControlDeviceObject = NULL;
+    BUS_PRINT( BUS_DBG_ERROR,
+     ("Failed to create symlink for dos name.\n") );
+   }
+   else {
+    BUS_PRINT( BUS_DBG_ERROR,
+     ("SUCCEEDED to create symlink for ControlDeviceObject.\n") );
+    
+    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: bus/kernel/bus_pnp.c
===================================================================
--- bus/kernel/bus_pnp.c (revision 2077)
+++ bus/kernel/bus_pnp.c (working copy)
@@ -60,6 +60,7 @@
 bus_filter_t   g_bus_filters[MAX_BUS_FILTERS];
 
 extern ib_al_handle_t gh_al; // NULL if AL needs init.
+extern PDEVICE_OBJECT g_ControlDeviceObject;
 
 
 static NTSTATUS
@@ -197,7 +198,7 @@
  /* 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 )
+ if ( ic == 1  && !g_ControlDeviceObject)
  {
   RtlInitUnicodeString( &dev_name, AL_DEVICE_NAME );
   RtlInitUnicodeString( &dos_name, L"\\DosDevices\\Global\\ibal" );

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20090405/4ee842f5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: create_ctrl_device.patch
Type: application/octet-stream
Size: 2924 bytes
Desc: create_ctrl_device.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20090405/4ee842f5/attachment.obj>


More information about the ofw mailing list