[IBAL] make IBBUS start up synchronous. event-based implementation.
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Sun, 29 Mar 2009 15:27:25 +0000 (15:27 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Sun, 29 Mar 2009 15:27:25 +0000 (15:27 +0000)
IBBUS start up was two-phased by design, because HCA, sitting in another stack, could have come later them IBAL.
Now it can't happen. So i added a wait on event at the end of the first phase, which is posted at the end of the second phase - PnP notification on arrival of HCA.

git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@2062 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

core/al/al_ci_ca.h
core/al/al_ci_ca_shared.c
core/al/kernel/al_ci_ca.c
core/al/kernel/al_pnp.c

index aaa39d9..a75e59b 100644 (file)
@@ -56,7 +56,9 @@ typedef ci_interface_t                        verbs_interface_t;
 ib_api_status_t\r
 create_ci_ca(\r
        IN                              al_obj_t                                        *p_parent_obj,\r
-       IN              const   ci_interface_t*                         p_ci );\r
+       IN              const   ci_interface_t*                         p_ci,\r
+       IN              const   PDEVICE_OBJECT                          p_hca_dev\r
+       );\r
 \r
 DEVICE_OBJECT*\r
 get_ca_dev(\r
@@ -101,6 +103,9 @@ typedef struct _al_ci_ca
        /* Array of port GUIDs on this CI CA. */\r
        ib_net64_t                                      *port_array;\r
 \r
+       /* "end of PnP handling" event */\r
+       cl_event_t                                      event;\r
+\r
 }      al_ci_ca_t;\r
 \r
 \r
index 759f0cd..6271c4b 100644 (file)
@@ -74,6 +74,7 @@ free_ci_ca(
 \r
        cl_spinlock_destroy( &p_ci_ca->attr_lock );\r
        cl_qpool_destroy( &p_ci_ca->event_pool );\r
+       cl_event_destroy( &p_ci_ca->event );\r
 \r
        if( p_ci_ca->port_array )\r
                cl_free( p_ci_ca->port_array );\r
index 221d484..979c9ec 100644 (file)
@@ -84,7 +84,9 @@ ci_ca_async_event_cb(
 ib_api_status_t\r
 create_ci_ca(\r
        IN                              al_obj_t                                        *p_parent_obj,\r
-       IN              const   ci_interface_t*                         p_ci )\r
+       IN              const   ci_interface_t*                         p_ci,\r
+       IN              const   PDEVICE_OBJECT                          p_hca_dev\r
+       )\r
 {\r
        ib_api_status_t                 status;\r
        cl_status_t                             cl_status;\r
@@ -110,6 +112,8 @@ create_ci_ca(
        cl_qlist_init( &p_ci_ca->shmid_list );\r
        cl_qpool_construct( &p_ci_ca->event_pool );\r
        p_ci_ca->verbs = *p_ci;\r
+       cl_event_construct( &p_ci_ca->event );\r
+       cl_event_init( &p_ci_ca->event, FALSE );\r
 \r
        cl_status = cl_spinlock_init( &p_ci_ca->attr_lock );\r
        if( cl_status != CL_SUCCESS )\r
@@ -185,6 +189,9 @@ create_ci_ca(
                return status;\r
        }\r
 \r
+       /* store HCA device object into CA object */\r
+       p_ci_ca->h_ca->p_hca_dev = p_hca_dev;\r
+       \r
        /* Get a list of the port GUIDs on this CI CA. */\r
        status = get_port_info( p_ci_ca );\r
        if( status != IB_SUCCESS )\r
@@ -516,6 +523,6 @@ get_ca_dev(
 {\r
        ASSERT( h_ca );\r
 \r
-       ObReferenceObject( h_ca->obj.p_ci_ca->verbs.p_hca_dev );\r
-       return h_ca->obj.p_ci_ca->verbs.p_hca_dev;\r
-}
\ No newline at end of file
+       ObReferenceObject( h_ca->p_hca_dev );\r
+       return h_ca->p_hca_dev;\r
+}\r
index 757090a..0c34647 100644 (file)
@@ -994,6 +994,7 @@ __pnp_process_add_ca(
 \r
        /* Cleanup the event record. */\r
        deref_al_obj( &gp_pnp->obj );\r
+       cl_event_signal( &p_event_rec->p_ci_ca->event );\r
        cl_free( p_event_rec );\r
 \r
        AL_EXIT( AL_DBG_PNP );\r
@@ -1137,6 +1138,7 @@ __pnp_process_remove_ca(
 \r
        /* Cleanup the event record. */\r
        deref_al_obj( &gp_pnp->obj );\r
+       cl_event_signal( &p_event_rec->p_ci_ca->event );\r
        cl_free( p_event_rec );\r
 \r
        AL_EXIT( AL_DBG_PNP );\r
@@ -1235,6 +1237,13 @@ pnp_ca_event(
        ref_al_obj( &gp_pnp->obj );\r
        cl_async_proc_queue( gp_async_pnp_mgr, &p_event_rec->async_item );\r
 \r
+       /* wait for the end of event propagation \r
+       It is needed for enabling quick HCA disable/enable scenarios. */\r
+       cl_status = cl_event_wait_on( &p_ci_ca->event, \r
+               EVENT_NO_TIMEOUT, AL_WAIT_ALERTABLE );\r
+       if (cl_status != CL_SUCCESS)\r
+               return IB_ERROR;\r
+\r
        AL_EXIT( AL_DBG_PNP );\r
        return IB_SUCCESS;\r
 }\r