<!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.2668" name=GENERATOR></HEAD>
<BODY>
<DIV>
<P><FONT face=Arial size=2>Hi Fab,</FONT></P>
<P><FONT face=Arial size=2>I'm sending you a patch, that gives a particular 
solution to one case of using fast mutexes, which increase IRQL and prevent 
using of AllocateBuffer .</FONT></P>
<P><SPAN class=355454811-12032006><FONT face=Arial size=2>To 
remind:</FONT></SPAN></P>
<P><FONT face=Arial size=2>> > > I come across the following problem: 
implementation of</FONT></P>
<P><FONT face=Arial size=2>> > > cl_mutex_acquire() via Fast Mutexes 
causes all the code </FONT></P>
<P><FONT face=Arial size=2>> in critical </FONT></P>
<P><FONT face=Arial size=2>> > > section to work at 
APC_LEVEL.</FONT></P>
<P><FONT face=Arial size=2>> > > </FONT></P>
<P><FONT face=Arial size=2>> > > The first case i saw, was at the 
start-up of IpoIb driver,</FONT></P>
<P><FONT face=Arial size=2>> > which takes</FONT></P>
<P><FONT face=Arial size=2>> > > mutex in __ipoib_pnp_cb and makes all 
MTHCA driver control</FONT></P>
<P><FONT face=Arial size=2>> > verbs to work</FONT></P>
<P><FONT face=Arial size=2>> > > at APC_LEVEL, which is 
troublesome.</FONT></P>
<P><FONT face=Arial size=2>> > > (e.g., create_cq calls 
AllocateCommonBuffer, which requires </FONT></P>
<P><FONT face=Arial size=2>> > > PASSIVE_LEVEL).</FONT></P>
<P><FONT face=Arial size=2>I've done that as you once suggested - by using usual 
mutexes (instead of cl_mutex) in the file in question.</FONT></P></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Index: 
E:/svn.openib/gen1/trunk/ulp/ipoib/kernel/ipoib_adapter.h<BR>===================================================================<BR>--- 
E:/svn.openib/gen1/trunk/ulp/ipoib/kernel/ipoib_adapter.h (revision 
230)<BR>+++ 
E:/svn.openib/gen1/trunk/ulp/ipoib/kernel/ipoib_adapter.h (working 
copy)<BR>@@ -161,9 +161,7 
@@<BR>  uint8_t     mcast_array_size;<BR> <BR>  cl_qpool_t    item_pool;<BR>-<BR>- cl_mutex_t    mutex;<BR>-<BR>+ KMUTEX     mutex;<BR>  cl_vector_t    ip_vector;<BR> <BR>  cl_perf_t    perf;<BR></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Index: 
E:/svn.openib/gen1/trunk/ulp/ipoib/kernel/ipoib_adapter.c<BR>===================================================================<BR>--- 
E:/svn.openib/gen1/trunk/ulp/ipoib/kernel/ipoib_adapter.c (revision 
230)<BR>+++ 
E:/svn.openib/gen1/trunk/ulp/ipoib/kernel/ipoib_adapter.c (working 
copy)<BR>@@ -234,7 +234,7 @@<BR>   * between destruction and AL 
callbacks (PnP, Query, Destruction).<BR>   * The lock provides 
protection<BR>   */<BR>- cl_mutex_acquire( 
&p_adapter->mutex );<BR>+ KeWaitForMutexObject( 
&p_adapter->mutex, Executive, KernelMode, FALSE,  NULL 
);<BR>  cl_obj_lock( &p_adapter->obj 
);<BR>  p_adapter->state = IB_PNP_PORT_REMOVE;<BR> <BR>@@ 
-247,7 +247,7 @@<BR> <BR>  cl_obj_unlock( &p_adapter->obj 
);<BR> <BR>- cl_mutex_release( &p_adapter->mutex 
);<BR>+ KeReleaseMutex( &p_adapter->mutex, FALSE 
);<BR> <BR>  cl_obj_destroy( &p_adapter->obj 
);<BR> <BR>@@ -263,7 +263,6 @@<BR>  cl_spinlock_construct( 
&p_adapter->send_stat_lock );<BR>  cl_spinlock_construct( 
&p_adapter->recv_stat_lock );<BR>  cl_qpool_construct( 
&p_adapter->item_pool );<BR>- cl_mutex_construct( 
&p_adapter->mutex );<BR>  cl_vector_construct( 
&p_adapter->ip_vector );<BR> <BR>  cl_perf_construct( 
&p_adapter->perf );<BR>@@ -315,13 +314,7 @@<BR>   return 
IB_ERROR;<BR>  }<BR> <BR>- cl_status = cl_mutex_init( 
&p_adapter->mutex );<BR>- if( cl_status != CL_SUCCESS 
)<BR>- {<BR>-  IPOIB_TRACE_EXIT( 
IPOIB_DBG_ERROR,<BR>-   ("cl_mutex_init returned %s\n", 
cl_status_text[cl_status]) );<BR>-  return 
IB_ERROR;<BR>- }<BR>+ KeInitializeMutex( &p_adapter->mutex, 0 
);<BR> <BR>  /* We manually manage the size and capacity of the 
vector. */<BR>  cl_status = cl_vector_init( 
&p_adapter->ip_vector, 0,<BR>@@ -463,7 +456,6 
@@<BR>  cl_qpool_destroy( &p_adapter->item_pool 
);<BR>  cl_spinlock_destroy( &p_adapter->recv_stat_lock 
);<BR>  cl_spinlock_destroy( &p_adapter->send_stat_lock 
);<BR>- cl_mutex_destroy( &p_adapter->mutex 
);<BR>  cl_obj_deinit( p_obj 
);<BR> <BR>  cl_perf_destroy( &p_adapter->perf, TRUE 
);<BR>@@ -493,13 +485,13 @@<BR>  CL_ASSERT( p_adapter 
);<BR> <BR>  /* Synchronize with destruction 
*/<BR>- cl_mutex_acquire( &p_adapter->mutex 
);<BR>+ KeWaitForMutexObject( &p_adapter->mutex, Executive, 
KernelMode, FALSE,  NULL );<BR>  cl_obj_lock( 
&p_adapter->obj );<BR>  old_state = 
p_adapter->state;<BR>  cl_obj_unlock( &p_adapter->obj 
);<BR>  if( old_state == IB_PNP_PORT_REMOVE 
)<BR>  {<BR>-  cl_mutex_release( &p_adapter->mutex 
);<BR>+  KeReleaseMutex( &p_adapter->mutex, FALSE 
);<BR>   IPOIB_TRACE_EXIT( 
IPOIB_DBG_PNP,<BR>    ("Aborting - Adapter destroying.\n") 
);<BR>   return IB_NOT_DONE;<BR>@@ -635,7 +627,7 
@@<BR>   break;<BR>  }<BR> <BR>- cl_mutex_release( 
&p_adapter->mutex );<BR>+ KeReleaseMutex( &p_adapter->mutex, 
FALSE );<BR> <BR>  IPOIB_EXIT( IPOIB_DBG_PNP 
);<BR>  return status;<BR>@@ -753,8 +745,7 @@<BR>  p_adapter 
= PARENT_STRUCT( context, ipoib_adapter_t, obj );<BR> <BR>  /* 
Synchronize with destruction */<BR>- cl_mutex_acquire( 
&p_adapter->mutex );<BR>-<BR>+ KeWaitForMutexObject( 
&p_adapter->mutex, Executive, KernelMode, FALSE,  NULL 
);<BR>  cl_obj_lock( &p_adapter->obj 
);<BR> <BR>  CL_ASSERT( !p_adapter->h_pnp );<BR>@@ -800,7 
+791,7 @@<BR>  /* Dereference the adapter since the previous 
registration is now gone. */<BR>  cl_obj_deref( &p_adapter->obj 
);<BR> <BR>- cl_mutex_release( &p_adapter->mutex 
);<BR>+ KeReleaseMutex( &p_adapter->mutex, FALSE 
);<BR> <BR>  IPOIB_EXIT( IPOIB_DBG_INIT );<BR> }<BR>@@ 
-923,7 +914,7 @@<BR>   NdisWriteErrorLogEntry( 
p_adapter->h_adapter,<BR>    EVENT_IPOIB_PORT_UP + 
(p_adapter->rate/ONE_X_IN_100BPS),<BR>    1, 
p_adapter->rate );<BR>-<BR>+ <BR>   NdisMIndicateStatus( 
p_adapter->h_adapter, 
NDIS_STATUS_MEDIA_CONNECT,<BR>    NULL, 0 
);<BR>   NdisMIndicateStatusComplete( p_adapter->h_adapter 
);<BR></DIV></FONT></BODY></HTML>