<!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=057423223-27102008><FONT face=Arial color=#0000ff size=2>Thanks
for taking the time to explain.</FONT></SPAN></DIV>
<DIV><SPAN class=057423223-27102008><FONT face=Arial color=#0000ff size=2>See
comments inline.</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> Tzachi Dar [mailto:tzachid@mellanox.co.il]
<BR><B>Sent:</B> Monday, October 27, 2008 3:07 PM<BR><B>To:</B> Smith, Stan;
ofw@lists.openfabrics.org<BR><B>Subject:</B> RE: [ofw] patch: [ibal] use safe
function for working on mutex.<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial color=#0000ff
size=2>Hi,</FONT></SPAN></DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial color=#0000ff size=2>The
original code was talking about <FONT face="Times New Roman"
color=#000000>ExAcquireFastMutexUnsafe.</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial color=#0000ff size=2><FONT
face="Times New Roman" color=#000000>MSDN says: </FONT></FONT></SPAN></DIV>
<DIV><SPAN class=187165521-27102008><STRONG>ExAcquireFastMutexUnsafe</STRONG>
can be safely called only at IRQL = APC_LEVEL. Use <A
href="ms-help://MS.WDK.v10.6001.071220/Kernel_r/hh/Kernel_r/k102_5f581434-dda0-4560-8867-3fa7f590e447.xml.htm"><B>ExAcquireFastMutex</B></A>
if the caller might run at IRQL < APC_LEVEL.</SPAN></DIV>
<DIV><SPAN class=187165521-27102008>Since we are not running at IRQL = APC_LEVEL
it can not be used and we should move to <A
href="ms-help://MS.WDK.v10.6001.071220/Kernel_r/hh/Kernel_r/k102_5f581434-dda0-4560-8867-3fa7f590e447.xml.htm"><B>ExAcquireFastMutex</B></A>
.</SPAN></DIV>
<DIV><SPAN class=187165521-27102008></SPAN> </DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial color=#0000ff size=2>But <A
href="ms-help://MS.WDK.v10.6001.071220/Kernel_r/hh/Kernel_r/k102_5f581434-dda0-4560-8867-3fa7f590e447.xml.htm"><B><FONT
face="Times New Roman" size=3>ExAcquireFastMutex</FONT></B></A><FONT
face="Times New Roman" color=#000000 size=3> <FONT face=Arial color=#0000ff
size=2>indeed moves us to APC_LEVEL. Under this lock, we call <FONT
face="Times New Roman" color=#000000>PsCreateSystemThread which must be run at
</FONT> <FONT size=3><FONT color=#000000><FONT
face="Times New Roman"><STRONG>IRQL: </STRONG>PASSIVE_LEVEL. So again not
good.</FONT></FONT></FONT><FONT face=Arial color=#0000ff size=2><SPAN
class=057423223-27102008> </SPAN></FONT></FONT></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial color=#0000ff size=2><FONT
face="Times New Roman" color=#000000 size=3><FONT face=Arial color=#0000ff
size=2><FONT face=Arial color=#0000ff size=2><SPAN
class=057423223-27102008></SPAN></FONT></FONT></FONT></FONT></SPAN> </DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial color=#0000ff size=2><FONT
face="Times New Roman" color=#000000 size=3><FONT face=Arial color=#0000ff
size=2><FONT face=Arial color=#0000ff size=2><SPAN
class=057423223-27102008></SPAN></FONT></FONT></FONT></FONT></SPAN> </DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial color=#0000ff size=2><FONT
face="Times New Roman" color=#000000 size=3><FONT face=Arial color=#0000ff
size=2><FONT face=Arial color=#0000ff size=2><SPAN
class=057423223-27102008><FONT face="Times New Roman" color=#000000
size=3>stan> </FONT></SPAN></FONT></FONT></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial color=#0000ff size=2><FONT
face="Times New Roman" color=#000000 size=3><FONT face=Arial color=#0000ff
size=2><FONT face=Arial color=#0000ff size=2><SPAN
class=057423223-27102008><FONT face="Times New Roman" color=#000000
size=3>ExAcquireFastMutex() exclusion is only for a very short code path,
with the original level restored by
ExReleaseFastMutex. </FONT></SPAN></FONT></FONT></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial color=#0000ff size=2><FONT
face="Times New Roman" color=#000000 size=3><FONT face=Arial color=#0000ff
size=2><FONT face=Arial color=#0000ff size=2><SPAN
class=057423223-27102008><FONT face="Times New Roman" color=#000000 size=3>Then
it's the call to al_initialize() you are worried about. OK, I
understand.</FONT> </SPAN></FONT></FONT></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial color=#0000ff size=2>Please
also note that:</FONT></SPAN></DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial color=#0000ff size=2>"<FONT
size=3><FONT color=#000000><FONT
face="Times New Roman"><STRONG>ExAcquireFastMutex</STRONG> puts the caller into
a wait state if the given fast mutex cannot be acquired immediately. Otherwise,
the caller is given ownership of the fast mutex<FONT color=#ff0000> with APCs to
the current thread disabled until it releases the fast mutex</FONT>." Not that
bad, but not exactly the side affect we were thinking
about.</FONT></FONT></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=187165521-27102008></SPAN> </DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial color=#0000ff size=2>So, I
want to "normal mutex": (KeInitializeMutex) but then MSDN says: "<FONT
face="Times New Roman" color=#000000 size=3>Only highest-level drivers, such as
FSDs that use executive worker threads, are likely to use a mutex object.". This
is not our case.</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=187165521-27102008></SPAN><SPAN
class=187165521-27102008></SPAN>A<SPAN class=187165521-27102008>lso it says:
"Acquiring ownership of a mutex prevents the delivery of normal kernel-mode
asynchronous procedure calls (APCs). The thread will not be preempted by an APC
unless the kernel issues an APC_LEVEL software interrupt to run a special kernel
APC, such as the I/O manager's IRP completion routine that returns results to
the original requester of an I/O operation" Again a side affect not that
desired.</SPAN></DIV>
<DIV><SPAN class=187165521-27102008></SPAN> </DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial><FONT color=#0000ff><FONT
size=2>For this reasons I believe that events are the best choice.<SPAN
class=057423223-27102008> </SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN
class=057423223-27102008></SPAN></FONT></FONT></FONT></SPAN> </DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN class=057423223-27102008><FONT color=#000000>stan> Agreed -
thanks for working me thru
this.</FONT> </SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial color=#0000ff
size=2>Thanks</FONT></SPAN></DIV>
<DIV><SPAN class=187165521-27102008><FONT face=Arial color=#0000ff
size=2>Tzachi</FONT></SPAN></DIV>
<DIV><BR></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Smith, Stan
[mailto:stan.smith@intel.com] <BR><B>Sent:</B> Monday, October 27, 2008 10:03
PM<BR><B>To:</B> Tzachi Dar; ofw@lists.openfabrics.org<BR><B>Subject:</B> RE:
[ofw] patch: [ibal] use safe function for working on
mutex.<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </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 10:21 AM<BR><B>To:</B> Tzachi
Dar; ofw@lists.openfabrics.org<BR><B>Subject:</B> RE: [ofw] patch: [ibal] use
safe function for working on mutex.<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><SPAN class=207471417-27102008><FONT face=Arial><FONT color=#0000ff><FONT
size=2>After some more experiments I have realized that working with mutex is
not good enough as well since they tend to bring the user to APC_LEVEL.<SPAN
class=222495919-27102008> </SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=207471417-27102008><FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN
class=222495919-27102008></SPAN></FONT></FONT></FONT></SPAN> </DIV>
<DIV><SPAN class=207471417-27102008><FONT face=Arial><FONT size=+0><FONT
size=2><SPAN class=222495919-27102008>Could you explain why the mutex
is insufficient?</SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=207471417-27102008><FONT face=Arial><FONT size=+0><FONT
size=2><SPAN class=222495919-27102008>What is the behavior you see that makes
you believe the mutex is not providing mutual
exclusion?</SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=207471417-27102008><FONT face=Arial><FONT size=+0><FONT
size=2><SPAN class=222495919-27102008></SPAN></FONT></FONT></FONT></SPAN><SPAN
class=207471417-27102008><FONT face=Arial><FONT size=+0><FONT size=2><SPAN
class=222495919-27102008>At what code point is the IRQL @ dispatch and/or in
an interrupt service routine?</SPAN></FONT></FONT></FONT></SPAN><SPAN
class=207471417-27102008><FONT face=Arial><FONT size=+0><FONT size=2><SPAN
class=222495919-27102008> </SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=207471417-27102008><FONT face=Arial><FONT size=+0><FONT
size=2><SPAN class=222495919-27102008>PNP callbacks are in an AL thread
context (passive).</SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=207471417-27102008><FONT face=Arial><FONT size=+0><FONT
size=2><SPAN
class=222495919-27102008></SPAN></FONT></FONT></FONT></SPAN> </DIV>
<DIV><SPAN class=207471417-27102008><FONT face=Arial><FONT size=+0><FONT
size=2><SPAN
class=222495919-27102008>thanks,</SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=207471417-27102008><FONT face=Arial><FONT size=+0><FONT
size=2><SPAN
class=222495919-27102008></SPAN></FONT></FONT></FONT></SPAN> </DIV>
<DIV><SPAN class=207471417-27102008><FONT face=Arial><FONT size=+0><FONT
size=2><SPAN
class=222495919-27102008>stan.</SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=207471417-27102008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=207471417-27102008><FONT face=Arial color=#0000ff size=2>So I
suggest to replace them to events.</FONT></SPAN></DIV>
<DIV><SPAN class=207471417-27102008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=207471417-27102008><FONT face=Arial color=#0000ff size=2>The
following patch was generated (but not tested yet):</FONT></SPAN></DIV>
<DIV><SPAN class=207471417-27102008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=207471417-27102008><FONT face=Arial color=#0000ff
size=2>Thanks</FONT></SPAN></DIV>
<DIV><SPAN class=207471417-27102008><FONT face=Arial color=#0000ff
size=2>Tzachi</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2>Index:
bus_driver.c<BR>===================================================================<BR>---
bus_driver.c (revision 3372)<BR>+++ bus_driver.c (working
copy)<BR>@@ -799,7 +799,7 @@<BR> // Mutex to synchronize multiple
threads creating & deleting <BR> // control deviceobjects.
<BR> <BR>- ExInitializeFastMutex(&g_ControlMutex);<BR>+ KeInitializeEvent(&g_ControlEvent,
SynchronizationEvent, TRUE);<BR> g_bfi_InstanceCount =
0;<BR> memset( __out_bcount(sizeof(g_bus_filters))
(void*)g_bus_filters, 0,<BR> sizeof(g_bus_filters)
);<BR>Index:
bus_driver.h<BR>===================================================================<BR>---
bus_driver.h (revision 3372)<BR>+++ bus_driver.h (working
copy)<BR>@@ -255,7 +255,7 @@<BR> <BR> extern
bus_filter_t g_bus_filters[MAX_BUS_FILTERS];<BR> extern ULONG
g_bfi_InstanceCount;<BR>-extern FAST_MUTEX g_ControlMutex; // serializes
InstanceCount & g_bus_filters<BR>+extern KEVENT g_ControlEvent; //
serializes InstanceCount & g_bus_filters<BR> <BR> extern
bus_filter_t *alloc_bfi( IN DRIVER_OBJECT *, OUT int * );<BR> extern int
free_bfi( IN bus_filter_t *p_bfi );<BR>@@ -265,4 +265,12 @@<BR> extern
bus_filter_t *get_set_bfi_by_ca_guid( IN net64_t ca_guid );<BR> extern
char *get_obj_state_str(cl_state_t state);<BR> <BR>+inline VOID
lock_control_event() {<BR>+ KeWaitForSingleObject(&g_ControlEvent,
Executive, KernelMode , FALSE, NULL);<BR>+}<BR>+<BR>+inline VOID
unlock_control_event() {<BR>+ KeSetEvent(&g_ControlEvent, 0,
FALSE);<BR>+}<BR>+<BR> #endif /* !defined _BUS_DRIVER_H_
*/<BR>Index:
bus_iou_mgr.c<BR>===================================================================<BR>---
bus_iou_mgr.c (revision 3373)<BR>+++ bus_iou_mgr.c (working
copy)<BR>@@ -483,13 +483,13 @@<BR> */<BR> if (
!bus_globals.h_pnp_iou
)<BR> {<BR>- ExAcquireFastMutex(&g_ControlMutex);<BR>+ lock_control_event();<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>- ExReleaseFastMutex(&g_ControlMutex);<BR>+ unlock_control_event();<BR> <BR> if
( need_pnp_reg )<BR> {<BR>Index:
bus_pnp.c<BR>===================================================================<BR>---
bus_pnp.c (revision 3373)<BR>+++ bus_pnp.c (working copy)<BR>@@
-51,7 +51,7 @@<BR> static
UNICODE_STRING al_ifc_name;<BR> static
UNICODE_STRING ci_ifc_name;<BR> <BR>-FAST_MUTEX g_ControlMutex;<BR>+KEVENT g_ControlEvent;<BR> ULONG g_bfi_InstanceCount;<BR> bus_filter_t g_bus_filters[MAX_BUS_FILTERS];<BR> <BR>@@
-334,7 +334,7 @@<BR> return
status;<BR> }<BR> <BR>- ExAcquireFastMutex(&g_ControlMutex);<BR>+ lock_control_event();<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>- ExReleaseFastMutex(&g_ControlMutex);<BR>+ unlock_control_event();<BR> return
STATUS_UNSUCCESSFUL;<BR> }<BR> AL_init_here
=
TRUE;<BR> }<BR>- ExReleaseFastMutex(&g_ControlMutex);<BR>+ unlock_control_event();<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>-
ExAcquireFastMutex(&g_ControlMutex);<BR>+ lock_control_event();<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>- ExReleaseFastMutex(&g_ControlMutex);<BR>+ unlock_control_event();<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>- ExAcquireFastMutex(&g_ControlMutex);<BR>+ lock_control_event();<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>- ExReleaseFastMutex(&g_ControlMutex);<BR>+ unlock_control_event();<BR> <BR> #if
DBG<BR> if ( !matched )<BR>@@ -1376,7 +1376,7 @@<BR>
*/<BR> if ( !matched
)<BR> {<BR>- ExAcquireFastMutex(&g_ControlMutex);<BR>+ lock_control_event();<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>- ExReleaseFastMutex(&g_ControlMutex);<BR>+ unlock_control_event();<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>- ExAcquireFastMutex(&g_ControlMutex);<BR>+ lock_control_event();<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>- ExReleaseFastMutex(&g_ControlMutex);<BR>+ unlock_control_event();<BR> <BR> #if
DBG<BR> RtlStringCbPrintfA ( p_bfi->whoami,<BR>@@ -1453,12
+1453,12
@@<BR> {<BR> int remaining;<BR> <BR>- ExAcquireFastMutex(&g_ControlMutex);<BR>+ lock_control_event();<BR> p_bfi->p_bus_ext
= NULL;<BR> p_bfi->ca_guid = 0ULL;<BR> remaining =
--g_bfi_InstanceCount; // one less bfi
in-use<BR>- ExReleaseFastMutex(&g_ControlMutex);<BR>-<BR>+ unlock_control_event();<BR>+ <BR> return
remaining;<BR> }<BR> <BR>@@ -1467,10 +1467,10
@@<BR> {<BR> int ic;<BR> <BR>- ExAcquireFastMutex(&g_ControlMutex);<BR>+ lock_control_event();<BR> ic
=
g_bfi_InstanceCount;<BR>- ExReleaseFastMutex(&g_ControlMutex);<BR>-<BR>+ unlock_control_event();<BR>+ <BR> return
ic;<BR> }<BR> <BR>Index:
bus_port_mgr.c<BR>===================================================================<BR>---
bus_port_mgr.c (revision 3373)<BR>+++ bus_port_mgr.c (working
copy)<BR>@@ -483,12 +483,12 @@<BR> */<BR> if (
!bus_globals.h_pnp_port
)<BR> {<BR>- ExAcquireFastMutex(&g_ControlMutex);<BR>+ lock_control_event();<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>- ExReleaseFastMutex(&g_ControlMutex);<BR>+ unlock_control_event();<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>- ExAcquireFastMutex(&g_ControlMutex);<BR>+ lock_control_event();<BR> if
( p_bfi->ca_guid && p_bfi->p_port_mgr
)<BR> GO =
TRUE;<BR>- ExReleaseFastMutex(&g_ControlMutex);<BR>+ unlock_control_event();<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>- ExAcquireFastMutex(&g_ControlMutex);<BR>+ lock_control_event();<BR> if
( p_bfi->ca_guid && p_bfi->p_port_mgr
)<BR> GO =
TRUE;<BR>- ExReleaseFastMutex(&g_ControlMutex);<BR>+ unlock_control_event();<BR> if
( GO == FALSE
)<BR> continue;<BR> status =
_port_mgr_pkey_add( pkeys, p_bfi, p_bfi->p_port_mgr );<BR></FONT></DIV>
<DIV><BR></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<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 4:58 PM<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></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>