<!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.6000.16705" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=455225316-27102008><FONT face=Arial color=#0000ff size=2>Hello 
Tzachi,</FONT></SPAN></DIV>
<DIV><SPAN class=455225316-27102008><FONT face=Arial color=#0000ff size=2>  
My intent on using ExAcquireFastMutexUnsafe() was a debug technique copied from 
a Microsoft KMDF driver example. The debug plan was intended to 'blow up' 
if/when the ExAcquireFastMutexUnsafe() call was invoked at an incorrect 
IRQL level. </FONT></SPAN></DIV>
<DIV><SPAN class=455225316-27102008><FONT face=Arial color=#0000ff size=2>I 
never did see an example of the code 'blowing up', hence did not worry about 
it.  Seems I trusted the MS example code and did not completely read the 
ExAcquireFastMutexUnsafe() documentation.</FONT></SPAN></DIV>
<DIV><SPAN class=455225316-27102008><FONT face=Arial color=#0000ff 
size=2>ExAcquireFastMutex() is a better way to go.</FONT></SPAN></DIV>
<DIV><SPAN class=455225316-27102008><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=455225316-27102008><FONT face=Arial color=#0000ff 
size=2>stan.</FONT></SPAN></DIV>
<DIV><SPAN class=455225316-27102008><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=455225316-27102008><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> ofw-bounces@lists.openfabrics.org 
[mailto:ofw-bounces@lists.openfabrics.org] <B>On Behalf Of </B>Tzachi 
Dar<BR><B>Sent:</B> Monday, October 27, 2008 7:58 AM<BR><B>To:</B> 
ofw@lists.openfabrics.org<BR><B>Subject:</B> [ofw] patch: [ibal] use safe 
function for working on mutex.<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><FONT face=Arial size=2><SPAN class=842535614-27102008>The unsafe functions 
can only be used from apc level. We call them from passive level, so we use the 
safe functions.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Index: 
Q:/projinf3/trunk/core/bus/kernel/bus_port_mgr.c<BR>===================================================================<BR>--- 
Q:/projinf3/trunk/core/bus/kernel/bus_port_mgr.c (revision 3372)<BR>+++ 
Q:/projinf3/trunk/core/bus/kernel/bus_port_mgr.c (revision 3373)<BR>@@ 
-483,12 +483,12 @@<BR>   */<BR>  if ( 
!bus_globals.h_pnp_port 
)<BR>  {<BR>-  ExAcquireFastMutexUnsafe(&g_ControlMutex);<BR>+  ExAcquireFastMutex(&g_ControlMutex);<BR>   if 
( !bus_globals.h_pnp_port ) {<BR>    bus_globals.h_pnp_port 
= (ib_pnp_handle_t)1; /* block others */<BR>    need_pnp_reg 

TRUE;<BR>   }<BR>-  ExReleaseFastMutexUnsafe(&g_ControlMutex);<BR>+  ExReleaseFastMutex(&g_ControlMutex);<BR> <BR>   if 
( need_pnp_reg )<BR>   {<BR>@@ -1005,10 +1005,10 
@@<BR>   if ( !p_bfi->p_bus_ext 
)<BR>    continue;<BR>   GO = 
FALSE;<BR>-  ExAcquireFastMutexUnsafe(&g_ControlMutex);<BR>+  ExAcquireFastMutex(&g_ControlMutex);<BR>   if 
( p_bfi->ca_guid && p_bfi->p_port_mgr 
)<BR>    GO = 
TRUE;<BR>-  ExReleaseFastMutexUnsafe(&g_ControlMutex);<BR>+  ExReleaseFastMutex(&g_ControlMutex);<BR>   if 
( GO == FALSE )<BR>    continue;<BR>   status 
= _port_mgr_pkey_rem( pkeys, p_bfi->p_port_mgr );<BR>@@ -1149,10 +1149,10 
@@<BR>   if ( !p_bfi->p_bus_ext 
)<BR>    continue;<BR>   GO = 
FALSE;<BR>-  ExAcquireFastMutexUnsafe(&g_ControlMutex);<BR>+  ExAcquireFastMutex(&g_ControlMutex);<BR>   if 
( p_bfi->ca_guid && p_bfi->p_port_mgr 
)<BR>    GO = 
TRUE;<BR>-  ExReleaseFastMutexUnsafe(&g_ControlMutex);<BR>+  ExReleaseFastMutex(&g_ControlMutex);<BR>   if 
( GO == FALSE )<BR>    continue;<BR>   status 
= _port_mgr_pkey_add( pkeys, p_bfi, p_bfi->p_port_mgr );<BR>Index: 
Q:/projinf3/trunk/core/bus/kernel/bus_pnp.c<BR>===================================================================<BR>--- 
Q:/projinf3/trunk/core/bus/kernel/bus_pnp.c (revision 3372)<BR>+++ 
Q:/projinf3/trunk/core/bus/kernel/bus_pnp.c (revision 3373)<BR>@@ -334,7 
+334,7 @@<BR>   return 
status;<BR>  }<BR> <BR>- ExAcquireFastMutexUnsafe(&g_ControlMutex);<BR>+ ExAcquireFastMutex(&g_ControlMutex);<BR>  if 
( !gh_al ) {<BR>   /* Initialize AL 
*/<BR>   ib_status = al_initialize();<BR>@@ -343,12 +343,12 
@@<BR>    al_cleanup();<BR>    BUS_TRACE_EXIT( 
BUS_DBG_ERROR, ("al_initialize returned 
%s.\n",<BR>        ib_get_err_str(ib_status)) 
);<BR>-   ExReleaseFastMutexUnsafe(&g_ControlMutex);<BR>+   ExReleaseFastMutex(&g_ControlMutex);<BR>    return 
STATUS_UNSUCCESSFUL;<BR>   }<BR>   AL_init_here = 
TRUE;<BR>  }<BR>- ExReleaseFastMutexUnsafe(&g_ControlMutex);<BR>+ ExReleaseFastMutex(&g_ControlMutex);<BR> <BR>  /* 
Initialize the port manager. */<BR>  ib_status = create_port_mgr( 
p_ext->bus_filter, &p_ext->p_port_mgr );<BR>@@ -1252,7 +1252,7 
@@<BR> <BR>  CL_ASSERT((obj_type == BFI_PORT_MGR_OBJ) || 
(obj_type == BFI_IOU_MGR_OBJ));<BR> <BR>-    
ExAcquireFastMutexUnsafe(&g_ControlMutex);<BR>+    
ExAcquireFastMutex(&g_ControlMutex);<BR> <BR>  for(p_bfi=g_bus_filters; 
p_bfi < &g_bus_filters[MAX_BUS_FILTERS]; p_bfi++) {<BR> <BR>@@ 
-1272,7 +1272,7 
@@<BR>    }<BR>   }<BR>  }<BR>- ExReleaseFastMutexUnsafe(&g_ControlMutex);<BR>+ ExReleaseFastMutex(&g_ControlMutex);<BR> <BR>  BUS_PRINT( 
BUS_DBG_PNP,<BR>     ("%s() cl_obj %p type %s_MGR_OBJ 
--> bfi[%d] %p\n",<BR>@@ -1302,7 +1302,7 @@<BR>   return 
matched;<BR>  }<BR> <BR>- ExAcquireFastMutexUnsafe(&g_ControlMutex);<BR>+ ExAcquireFastMutex(&g_ControlMutex);<BR> <BR>  for(p_bfi=g_bus_filters; 
p_bfi < &g_bus_filters[MAX_BUS_FILTERS]; p_bfi++)<BR>  {<BR>@@ 
-1315,7 +1315,7 
@@<BR>    break;<BR>   }<BR>  }<BR>- ExReleaseFastMutexUnsafe(&g_ControlMutex);<BR>+ ExReleaseFastMutex(&g_ControlMutex);<BR> <BR> #if 
DBG<BR>  if ( !matched )<BR>@@ -1376,7 +1376,7 @@<BR>   
*/<BR>  if ( !matched 
)<BR>  {<BR>-  ExAcquireFastMutexUnsafe(&g_ControlMutex);<BR>+  ExAcquireFastMutex(&g_ControlMutex);<BR> <BR>   for(p_bfi=g_bus_filters; 
p_bfi < &g_bus_filters[MAX_BUS_FILTERS]; 
p_bfi++)<BR>   {<BR>@@ -1391,7 +1391,7 
@@<BR>     break;<BR>    }<BR>   }<BR>-  ExReleaseFastMutexUnsafe(&g_ControlMutex);<BR>+  ExReleaseFastMutex(&g_ControlMutex);<BR>  }<BR> <BR>  BUS_PRINT( 
BUS_DBG_PNP,<BR>@@ -1413,7 +1413,7 @@<BR>      * 
IoCreateDeviceSecure & IoCreateSymbolicLink must be called 
at<BR>      * PASSIVE_LEVEL.<BR>   
*/<BR>- ExAcquireFastMutexUnsafe(&g_ControlMutex);<BR>+ ExAcquireFastMutex(&g_ControlMutex);<BR> <BR>  // 
find 1st unused bfi slot.<BR>  for(p_bfi=g_bus_filters; p_bfi < 
&g_bus_filters[MAX_BUS_FILTERS]; p_bfi++)<BR>@@ -1430,7 +1430,7 
@@<BR>    break;<BR>   }<BR>  }<BR>- ExReleaseFastMutexUnsafe(&g_ControlMutex);<BR>+ ExReleaseFastMutex(&g_ControlMutex);<BR> <BR> #if 
DBG<BR>  RtlStringCbPrintfA ( p_bfi->whoami,<BR>@@ -1453,11 
+1453,11 
@@<BR> {<BR>  int remaining;<BR> <BR>- ExAcquireFastMutexUnsafe(&g_ControlMutex);<BR>+ ExAcquireFastMutex(&g_ControlMutex);<BR>  p_bfi->p_bus_ext 
= NULL;<BR>  p_bfi->ca_guid = 0ULL;<BR>  remaining = 
--g_bfi_InstanceCount; // one less bfi 
in-use<BR>- ExReleaseFastMutexUnsafe(&g_ControlMutex);<BR>+ ExReleaseFastMutex(&g_ControlMutex);<BR> <BR>  return 
remaining;<BR> }<BR>@@ -1467,9 +1467,9 
@@<BR> {<BR>  int ic;<BR> <BR>- ExAcquireFastMutexUnsafe(&g_ControlMutex);<BR>+ ExAcquireFastMutex(&g_ControlMutex);<BR>  ic 

g_bfi_InstanceCount;<BR>- ExReleaseFastMutexUnsafe(&g_ControlMutex);<BR>+ ExReleaseFastMutex(&g_ControlMutex);<BR> <BR>  return 
ic;<BR> }<BR>Index: 
Q:/projinf3/trunk/core/bus/kernel/bus_iou_mgr.c<BR>===================================================================<BR>--- 
Q:/projinf3/trunk/core/bus/kernel/bus_iou_mgr.c (revision 3372)<BR>+++ 
Q:/projinf3/trunk/core/bus/kernel/bus_iou_mgr.c (revision 3373)<BR>@@ 
-483,13 +483,13 @@<BR>   */<BR>  if ( !bus_globals.h_pnp_iou 
)<BR>  {<BR>-  ExAcquireFastMutexUnsafe(&g_ControlMutex);<BR>+  ExAcquireFastMutex(&g_ControlMutex);<BR>   if 
( !bus_globals.h_pnp_iou 
)<BR>   {<BR>    bus_globals.h_pnp_iou = 
(ib_pnp_handle_t)1; /* block others */ <BR>    need_pnp_reg 

TRUE;<BR>   }<BR>-  ExReleaseFastMutexUnsafe(&g_ControlMutex);<BR>+  ExReleaseFastMutex(&g_ControlMutex);<BR> <BR>   if 
( need_pnp_reg )<BR>   {<BR></DIV></FONT>
<DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>