From 6146a233016213d42d04ce8eead8d60d0a21d582 Mon Sep 17 00:00:00 2001 From: tzachid Date: Thu, 30 Oct 2008 10:28:29 +0000 Subject: [PATCH] [ipoix] Fix two races where ipoib_port_up was called twice. git-svn-id: svn://openib.tc.cornell.edu/gen1@1712 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- trunk/ulp/ipoib/kernel/ipoib_port.c | 41 ++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/trunk/ulp/ipoib/kernel/ipoib_port.c b/trunk/ulp/ipoib/kernel/ipoib_port.c index fd82966e..77131498 100644 --- a/trunk/ulp/ipoib/kernel/ipoib_port.c +++ b/trunk/ulp/ipoib/kernel/ipoib_port.c @@ -5136,14 +5136,24 @@ ipoib_port_up( IPOIB_ENTER( IPOIB_DBG_INIT ); + cl_obj_lock( &p_port->obj ); + if ((p_port->state == IB_QPS_INIT) || + (p_port->state == IB_QPS_RTS)){ + cl_obj_unlock( &p_port->obj ); + status = STATUS_SUCCESS; + IPOIB_PRINT_EXIT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT, + ("p_port->state = %d - Aborting.\n", p_port->state) ); + goto up_done; + } + p_port->state = IB_QPS_INIT; + cl_obj_unlock( &p_port->obj ); + + /* Wait for all work requests to get flushed. */ while( p_port->recv_mgr.depth || p_port->send_mgr.depth ) cl_thread_suspend( 0 ); - cl_obj_lock( &p_port->obj ); - p_port->state = IB_QPS_INIT; KeResetEvent( &p_port->sa_event ); - cl_obj_unlock( &p_port->obj ); mad_out = (ib_mad_t*)cl_zalloc(256); if(! mad_out) @@ -5203,6 +5213,8 @@ up_done: ipoib_set_inactive( p_port->p_adapter ); __endpt_mgr_reset_all( p_port ); } + ASSERT(p_port->state == IB_QPS_INIT || p_port->state == IB_QPS_ERROR); + p_port->state = IB_QPS_ERROR; KeSetEvent( &p_port->sa_event, EVENT_INCREMENT, FALSE ); } @@ -5344,14 +5356,20 @@ __bcast_get_cb( cl_obj_lock( &p_port->obj ); p_port->ib_mgr.h_query = NULL; + + CL_ASSERT(p_port->state == IB_QPS_INIT || p_port->state == IB_QPS_ERROR); if( p_port->state != IB_QPS_INIT ) { status = IB_CANCELED; goto done; } - + status = p_query_rec->status; + IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT, + ("status of request %s\n", + p_port->p_adapter->p_ifc->get_err_str( status )) ); + switch( status ) { case IB_SUCCESS: @@ -5380,7 +5398,6 @@ __bcast_get_cb( NdisWriteErrorLogEntry( p_port->p_adapter->h_adapter, EVENT_IPOIB_BCAST_GET, 1, p_query_rec->status ); } - done: cl_obj_unlock( &p_port->obj ); @@ -5391,6 +5408,7 @@ done: ipoib_set_inactive( p_port->p_adapter ); __endpt_mgr_reset_all( p_port ); } + p_port->state = IB_QPS_ERROR; KeSetEvent( &p_port->sa_event, EVENT_INCREMENT, FALSE ); } @@ -5621,11 +5639,12 @@ __bcast_cb( p_port = (ipoib_port_t*)p_mcast_rec->mcast_context; cl_obj_lock( &p_port->obj ); + + ASSERT(p_port->state == IB_QPS_INIT || p_port->state == IB_QPS_ERROR); if( p_port->state != IB_QPS_INIT ) { cl_obj_unlock( &p_port->obj ); if( p_mcast_rec->status == IB_SUCCESS ) - { ipoib_port_ref(p_port, ref_leave_mcast); p_port->p_adapter->p_ifc->leave_mcast( p_mcast_rec->h_mcast, __leave_error_mcast_cb ); @@ -5636,9 +5655,7 @@ __bcast_cb( ("Invalid state - Aborting.\n") ); return; } - status = p_mcast_rec->status; - if( status != IB_SUCCESS ) { IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR, @@ -5684,6 +5701,8 @@ __bcast_cb( { ipoib_set_inactive( p_port->p_adapter ); __endpt_mgr_reset_all( p_port ); + ASSERT(p_port->state == IB_QPS_INIT || p_port->state == IB_QPS_ERROR); + p_port->state = IB_QPS_ERROR; KeSetEvent( &p_port->sa_event, EVENT_INCREMENT, FALSE ); } ipoib_port_deref( p_port, ref_bcast_req_failed ); @@ -5729,6 +5748,8 @@ __bcast_cb( err: /* Flag the adapter as hung. */ p_port->p_adapter->hung = TRUE; + ASSERT(p_port->state == IB_QPS_INIT || p_port->state == IB_QPS_ERROR); + p_port->state = IB_QPS_ERROR; KeSetEvent( &p_port->sa_event, EVENT_INCREMENT, FALSE ); ipoib_port_deref( p_port, ref_bcast_error ); IPOIB_EXIT( IPOIB_DBG_INIT ); @@ -5737,8 +5758,10 @@ err: cl_obj_lock( &p_port->obj ); /* Only change the state if we're still in INIT. */ - if( p_port->state == IB_QPS_INIT ) + ASSERT( p_port->state == IB_QPS_INIT || p_port->state == IB_QPS_ERROR); + if (p_port->state == IB_QPS_INIT) { p_port->state = IB_QPS_RTS; + } cl_obj_unlock( &p_port->obj ); /* Prepost receives. */ -- 2.46.0