[ofw] [patch][IPoIB_NDIS6_CM] Shutter patch

Alex Naslednikov xalex at mellanox.co.il
Thu Feb 3 08:05:08 PST 2011


Changes at ipoib_adapter.cpp were applied at 3090

From: Alex Naslednikov
Sent: Monday, January 31, 2011 3:41 PM
To: Alex Naslednikov; ofw at lists.openfabrics.org
Subject: [ofw][patch][IPoIB_NDIS6_CM] Shutter patch

shutter_shut can't be called at DISPATCH_LEVEL
Signed off by: Alexander Naslednikov (xalex at mellanox.co.il)
Index: B:/users/xalex/MLNX_VPI_trunk/ulp/ipoib_NDIS6_CM/kernel/ipoib_adapter.cpp
===================================================================
--- B:/users/xalex/MLNX_VPI_trunk/ulp/ipoib_NDIS6_CM/kernel/ipoib_adapter.cpp   (revision 7173)
+++ B:/users/xalex/MLNX_VPI_trunk/ulp/ipoib_NDIS6_CM/kernel/ipoib_adapter.cpp                (revision 7174)
@@ -1018,7 +1018,6 @@
                ib_api_status_t                                status;
                ib_pnp_handle_t                             h_pnp;
                KLOCK_QUEUE_HANDLE              hdl;
-
                IPOIB_ENTER( IPOIB_DBG_INIT );

                if( p_adapter->reset )
@@ -1031,18 +1030,11 @@
                {
                                h_pnp = p_adapter->h_pnp;
                                p_adapter->h_pnp  = NULL;
-
-                              // Wait until NDIS will return all indicated NBLs that were received
-                              // Avoid shutting the shutter twice
-                              KeAcquireInStackQueuedSpinLock( &g_ipoib.lock, &hdl );
-                              if ( p_adapter->ipoib_state == IPOIB_RUNNING ) {
-                                              shutter_shut( &p_adapter->recv_shutter );
-                                              // Notify that reset started and disable other shutter_shut
-                                              p_adapter->ipoib_state |= IPOIB_RESET_OR_DOWN;
-                                              IPOIB_PRINT( TRACE_LEVEL_INFORMATION,  IPOIB_DBG_SHUTTER,
-                                              ("[%I64u] ipoib_state was IPOIB_RUNNING and IPOIB_RESET_OR_DOWN flag was set \n", cl_get_time_stamp()) );
-                              }
-                              KeReleaseInStackQueuedSpinLock( &hdl );
+
+                             // One can't call direclty to the shutter_shut() from this function, because
+                             // IRQL may be equal to DISPATCH_LEVEL while shutter_shut uses  KeWaitForSingleObject
+                             // Instead, __ipoib_adapter_reset() will be called by PASSIVE_LEVEL and
+                             // shutter_shut() will be called there.
                                status = p_adapter->p_ifc->dereg_pnp( h_pnp, __ipoib_pnp_dereg );

                                if( status == IB_SUCCESS )
@@ -1115,6 +1107,7 @@
                ipoib_port_t                      *p_port;
                ib_api_status_t                                status;
                ib_pnp_event_t                               state;
+             KLOCK_QUEUE_HANDLE              hdl;

                IPOIB_ENTER( IPOIB_DBG_INIT );
                IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
@@ -1123,6 +1116,22 @@
                                                                ("[%I64u] Got RESET\n", cl_get_time_stamp()) );

                p_adapter = (ipoib_adapter_t*)context;
+
+             // Wait until NDIS will return all indicated NBLs that were received
+             // Avoid shutting the shutter twice
+             KeAcquireInStackQueuedSpinLock( &g_ipoib.lock, &hdl );
+             if ( p_adapter->ipoib_state == IPOIB_RUNNING ) {
+                             p_adapter->ipoib_state |= IPOIB_RESET_OR_DOWN;
+                             KeReleaseInStackQueuedSpinLock( &hdl );
+                             shutter_shut( &p_adapter->recv_shutter );
+                             // Notify that reset started and disable other shutter_shut
+                             IPOIB_PRINT( TRACE_LEVEL_INFORMATION,  IPOIB_DBG_SHUTTER,
+                             ("ipoib_state was IPOIB_RUNNING and IPOIB_RESET_OR_DOWN flag was set \n") );
+             }
+             else
+             {
+                             KeReleaseInStackQueuedSpinLock( &hdl );
+             }

                /* Synchronize with destruction */
                KeWaitForMutexObject(
Index: B:/users/xalex/MLNX_VPI_trunk/ulp/ipoib_NDIS6_CM/kernel/ipoib_driver.cpp
===================================================================
--- B:/users/xalex/MLNX_VPI_trunk/ulp/ipoib_NDIS6_CM/kernel/ipoib_driver.cpp       (revision 7173)
+++ B:/users/xalex/MLNX_VPI_trunk/ulp/ipoib_NDIS6_CM/kernel/ipoib_driver.cpp    (revision 7174)
@@ -2111,7 +2111,6 @@

                CL_ASSERT( adapter_context );
                p_adapter = (ipoib_adapter_t*)adapter_context;
-
                if( p_adapter->reset )
                {
                                IPOIB_EXIT( IPOIB_DBG_INIT );
@@ -2995,7 +2994,7 @@
 /*          Tear down the connection and start over again.                This is only called when there is a problem.
 For example, if a send, query info, or set info had a time out.  MiniportCheckForHang will
 be called first.
-IRQL = DISPATCH_LEVEL
+IRQL <= DISPATCH_LEVEL

 @param p_addr_resetPointer to BOOLLEAN that is set to TRUE if the NDIS
 library should call MiniportSetInformation to restore addressing information to the current values.
@@ -3014,9 +3013,11 @@
                CL_ASSERT( p_addr_reset );
                CL_ASSERT( adapter_context );
                p_adapter = (ipoib_adapter_t*)adapter_context;
+
                ++g_reset;

-              switch( ipoib_reset_adapter( p_adapter ) )
+             ib_api_status_t status = ipoib_reset_adapter( p_adapter );
+             switch( status )
                {
                case IB_NOT_DONE:
                                IPOIB_EXIT( IPOIB_DBG_INIT );
@@ -3578,21 +3579,25 @@
                                // Wait until NDIS will return all indicated NBLs that were received
                                // Avoid shutting the shutter twice
                                KeAcquireInStackQueuedSpinLock( &g_ipoib.lock, &hdl );
-
-                              if ( p_adapter->ipoib_state & IPOIB_RESET_OR_DOWN )
-                              {
-                                              IPOIB_PRINT( TRACE_LEVEL_WARNING, IPOIB_DBG_ALL,
-                                              ("Shutdown occured while reset process wasn't completed yet\n") );
-                              }

-                              if ( p_adapter->ipoib_state == IPOIB_RUNNING ) { //ensure that there was no active reset
+                             if ( p_adapter->ipoib_state == IPOIB_RUNNING )
+                             { //ensure that there was no active reset
+                                             p_adapter->ipoib_state |= IPOIB_RESET_OR_DOWN;
+                                             KeReleaseInStackQueuedSpinLock( &hdl );
                                                shutter_shut( &p_adapter->recv_shutter );
                                                // Notify that shutter was already shut
-                                              p_adapter->ipoib_state |= IPOIB_RESET_OR_DOWN;
                                                IPOIB_PRINT( TRACE_LEVEL_INFORMATION,  IPOIB_DBG_SHUTTER,
                                                                ("ipoib_state was IPOIB_RUNNING and IPOIB_RESET_OR_DOWN flag was set\n") );
                                }
-                              KeReleaseInStackQueuedSpinLock( &hdl );
+                             else
+                             {
+                                             if ( p_adapter->ipoib_state & IPOIB_RESET_OR_DOWN )
+                                             {
+                                                             IPOIB_PRINT( TRACE_LEVEL_WARNING, IPOIB_DBG_ALL,
+                                                             ("Shutdown occured while reset process wasn't completed yet\n") );
+                                             }
+                                             KeReleaseInStackQueuedSpinLock( &hdl );
+                             }
                }

                IPOIB_EXIT( IPOIB_DBG_INIT );
Index: B:/users/xalex/MLNX_VPI_trunk/inc/kernel/shutter.h
===================================================================
--- B:/users/xalex/MLNX_VPI_trunk/inc/kernel/shutter.h           (revision 7173)
+++ B:/users/xalex/MLNX_VPI_trunk/inc/kernel/shutter.h        (revision 7174)
@@ -104,6 +104,7 @@
                ASSERT(res >= 0);
                if (res)
                                // We are now waiting for the object to reach -MAX_OPERATIONS
+                             ASSERT( KeGetCurrentIrql() < DISPATCH_LEVEL );
                                KeWaitForSingleObject( &p_shutter->event, Executive, KernelMode, FALSE, NULL );
 }

Alexander (XaleX) Naslednikov
SW Networking Team
Mellanox Technologies

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20110203/6c98b2dd/attachment.html>


More information about the ofw mailing list