<!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.16587" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=207471417-27102008><FONT face=Arial color=#0000ff 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.</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></BODY></HTML>