From: Stan Smith Date: Thu, 7 Oct 2010 19:51:42 +0000 (+0000) Subject: [IPoIB_NDIS6_CM] The patch prevents race with BSOD when NDIS call receive callback... X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=b068faad3bef52f8e2b58038a2ef8a4320621daf;p=~shefty%2Frdma-win.git [IPoIB_NDIS6_CM] The patch prevents race with BSOD when NDIS call receive callback of ipoib while some ipoib global objects are under destruction (like p_adapter ->p_port). It was tested by night regression run on IPoIB driver Adding shutter_shut for Adapter Reset flow Signed-off by: Alexander Naslednikov (xalex at mellanox.co.il) git-svn-id: svn://openib.tc.cornell.edu/gen1@2963 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- diff --git a/branches/WOF2-3/ulp/ipoib_NDIS6_CM/kernel/ipoib_adapter.cpp b/branches/WOF2-3/ulp/ipoib_NDIS6_CM/kernel/ipoib_adapter.cpp index 217b8df7..a7f846c3 100644 --- a/branches/WOF2-3/ulp/ipoib_NDIS6_CM/kernel/ipoib_adapter.cpp +++ b/branches/WOF2-3/ulp/ipoib_NDIS6_CM/kernel/ipoib_adapter.cpp @@ -992,6 +992,8 @@ ipoib_reset_adapter( h_pnp = p_adapter->h_pnp; p_adapter->h_pnp = NULL; status = p_adapter->p_ifc->dereg_pnp( h_pnp, __ipoib_pnp_dereg ); + // Wait until NDIS will return all indicated NBLs that were received + shutter_shut( &p_adapter->recv_shutter ); if( status == IB_SUCCESS ) status = IB_NOT_DONE; } diff --git a/branches/WOF2-3/ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp b/branches/WOF2-3/ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp index 1b7a37b3..db092b70 100644 --- a/branches/WOF2-3/ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp +++ b/branches/WOF2-3/ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp @@ -830,11 +830,15 @@ __port_init( IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_OBJ, ("ref type %d ref_cnt %d\n", ref_init, p_port->obj.ref_cnt) ); #endif - // The port is started as paused and NDIS calls latter to ipoib_restart. We - // shut the recv_shuter for now and alive it on ipoib_restart. We did - // it in this way since MpInitializeInternal also calls in reset and than - // we need to set the rec ref count to 1 //TODO !!!!!!!!!!1 - // + /* The steps of the initialization are as depicted below: + I. adapter_init() calls shutter_init(), the shutter counter is set to 0 + II. ipoib_pnp_cb() calls to ipoib_port_init() that calls to __port_init() that SHOULD set shutter counter to -MAX_OPERATIONS + That is, the code below should call to shutter_shut() + III.NDIS calls to ipoib_restart() that calls to shutter_alive. Now, shutter_counter is again 0. + IV. NDIS call to ipoib_pause() that sets the adapter to pause state, calls to shutter_shut. + Now, the counter is again equals to -MAX_OPERATIONS + V. NDIS calls to ipoib_restart that calls to shutter_alive. Shutter counter is 0 and we can start working + */ if ( p_adapter->ipoib_state == IPOIB_INIT) { IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_RECV, diff --git a/trunk/ulp/ipoib_NDIS6_CM/kernel/ipoib_adapter.cpp b/trunk/ulp/ipoib_NDIS6_CM/kernel/ipoib_adapter.cpp index 217b8df7..a7f846c3 100644 --- a/trunk/ulp/ipoib_NDIS6_CM/kernel/ipoib_adapter.cpp +++ b/trunk/ulp/ipoib_NDIS6_CM/kernel/ipoib_adapter.cpp @@ -992,6 +992,8 @@ ipoib_reset_adapter( h_pnp = p_adapter->h_pnp; p_adapter->h_pnp = NULL; status = p_adapter->p_ifc->dereg_pnp( h_pnp, __ipoib_pnp_dereg ); + // Wait until NDIS will return all indicated NBLs that were received + shutter_shut( &p_adapter->recv_shutter ); if( status == IB_SUCCESS ) status = IB_NOT_DONE; } diff --git a/trunk/ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp b/trunk/ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp index 1b7a37b3..db092b70 100644 --- a/trunk/ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp +++ b/trunk/ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp @@ -830,11 +830,15 @@ __port_init( IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_OBJ, ("ref type %d ref_cnt %d\n", ref_init, p_port->obj.ref_cnt) ); #endif - // The port is started as paused and NDIS calls latter to ipoib_restart. We - // shut the recv_shuter for now and alive it on ipoib_restart. We did - // it in this way since MpInitializeInternal also calls in reset and than - // we need to set the rec ref count to 1 //TODO !!!!!!!!!!1 - // + /* The steps of the initialization are as depicted below: + I. adapter_init() calls shutter_init(), the shutter counter is set to 0 + II. ipoib_pnp_cb() calls to ipoib_port_init() that calls to __port_init() that SHOULD set shutter counter to -MAX_OPERATIONS + That is, the code below should call to shutter_shut() + III.NDIS calls to ipoib_restart() that calls to shutter_alive. Now, shutter_counter is again 0. + IV. NDIS call to ipoib_pause() that sets the adapter to pause state, calls to shutter_shut. + Now, the counter is again equals to -MAX_OPERATIONS + V. NDIS calls to ipoib_restart that calls to shutter_alive. Shutter counter is 0 and we can start working + */ if ( p_adapter->ipoib_state == IPOIB_INIT) { IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_RECV,