[IBAL] Fix locking around special QP service send and receive queues.
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 24 Jul 2006 19:39:17 +0000 (19:39 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 24 Jul 2006 19:39:17 +0000 (19:39 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@427 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

core/al/kernel/al_smi.c

index 6004e70..d863910 100644 (file)
@@ -725,7 +725,9 @@ create_spl_qp_svc(
        }\r
 \r
        /* Post receive buffers. */\r
+       cl_spinlock_acquire( &p_spl_qp_svc->obj.lock );\r
        status = spl_qp_svc_post_recvs( p_spl_qp_svc );\r
+       cl_spinlock_release( &p_spl_qp_svc->obj.lock );\r
        if( status != IB_SUCCESS )\r
        {\r
                p_spl_qp_svc->obj.pfn_destroy( &p_spl_qp_svc->obj, NULL );\r
@@ -927,9 +929,11 @@ destroying_spl_qp_svc(
                         p_list_item != cl_qlist_end( &p_spl_qp_svc->send_queue );\r
                         p_list_item = cl_qlist_remove_head( &p_spl_qp_svc->send_queue ) )\r
                {\r
+                       cl_spinlock_release( &p_spl_qp_svc->obj.lock );\r
                        p_mad_wr = PARENT_STRUCT( p_list_item, al_mad_wr_t, list_item );\r
                        __complete_send_mad( p_spl_qp_svc->h_mad_disp, p_mad_wr,\r
                                IB_WCS_WR_FLUSHED_ERR );\r
+                       cl_spinlock_acquire( &p_spl_qp_svc->obj.lock );\r
                }\r
 \r
                cl_spinlock_release( &p_spl_qp_svc->obj.lock );\r
@@ -2826,6 +2830,7 @@ spl_qp_svc_reset_cb(
        al_mad_element_t*               p_al_mad;\r
        ib_qp_mod_t                             qp_mod;\r
        ib_api_status_t                 status;\r
+       cl_qlist_t                              mad_wr_list;\r
 \r
        AL_ENTER( AL_DBG_SMI_CB );\r
 \r
@@ -2846,6 +2851,7 @@ spl_qp_svc_reset_cb(
        CL_ASSERT( status == IB_SUCCESS );\r
 \r
        /* Return receive MAD elements to the pool. */\r
+       cl_spinlock_acquire( &p_spl_qp_svc->obj.lock );\r
        for( p_list_item = cl_qlist_remove_head( &p_spl_qp_svc->recv_queue );\r
                 p_list_item != cl_qlist_end( &p_spl_qp_svc->recv_queue );\r
                 p_list_item = cl_qlist_remove_head( &p_spl_qp_svc->recv_queue ) )\r
@@ -2855,6 +2861,7 @@ spl_qp_svc_reset_cb(
                status = ib_put_mad( &p_al_mad->element );\r
                CL_ASSERT( status == IB_SUCCESS );\r
        }\r
+       cl_spinlock_release( &p_spl_qp_svc->obj.lock );\r
 \r
        /* Re-initialize the QP. */\r
        status = ib_init_dgrm_svc( p_spl_qp_svc->h_qp, NULL );\r
@@ -2870,15 +2877,17 @@ spl_qp_svc_reset_cb(
        } while( status == IB_SUCCESS );\r
 \r
        /* Post receive buffers. */\r
+       cl_spinlock_acquire( &p_spl_qp_svc->obj.lock );\r
        spl_qp_svc_post_recvs( p_spl_qp_svc );\r
 \r
-       /*\r
-        * Re-queue any outstanding MAD send operations.\r
-        * Work from tail to head to maintain the request order.\r
-        */\r
-       for( p_list_item = cl_qlist_remove_tail( &p_spl_qp_svc->send_queue );\r
-                p_list_item != cl_qlist_end( &p_spl_qp_svc->send_queue );\r
-                p_list_item = cl_qlist_remove_tail( &p_spl_qp_svc->send_queue ) )\r
+       /* Re-queue any outstanding MAD send operations. */\r
+       cl_qlist_init( &mad_wr_list );\r
+       cl_qlist_insert_list_tail( &mad_wr_list, &p_spl_qp_svc->send_queue );\r
+       cl_spinlock_release( &p_spl_qp_svc->obj.lock );\r
+\r
+       for( p_list_item = cl_qlist_remove_head( &mad_wr_list );\r
+                p_list_item != cl_qlist_end( &mad_wr_list );\r
+                p_list_item = cl_qlist_remove_head( &mad_wr_list ) )\r
        {\r
                p_mad_wr = PARENT_STRUCT( p_list_item, al_mad_wr_t, list_item );\r
                special_qp_queue_mad( p_spl_qp_svc->h_qp, p_mad_wr );\r