[IPoIB] Use regular mutex so PnP callback runs at PASSIVE to support MTHCA driver.
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 15 Mar 2006 01:00:08 +0000 (01:00 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 15 Mar 2006 01:00:08 +0000 (01:00 +0000)
Submitted by Leonid Keller (leonid@mellanox.co.il)

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

ulp/ipoib/kernel/ipoib_adapter.c
ulp/ipoib/kernel/ipoib_adapter.h

index 1ff47f5..e28aff2 100644 (file)
@@ -235,7 +235,8 @@ ipoib_destroy_adapter(
         * between destruction and AL callbacks (PnP, Query, Destruction).\r
         * The lock provides protection\r
         */\r
-       cl_mutex_acquire( &p_adapter->mutex );\r
+       KeWaitForMutexObject(\r
+               &p_adapter->mutex, Executive, KernelMode, FALSE, NULL );\r
        cl_obj_lock( &p_adapter->obj );\r
        p_adapter->state = IB_PNP_PORT_REMOVE;\r
 \r
@@ -248,7 +249,7 @@ ipoib_destroy_adapter(
 \r
        cl_obj_unlock( &p_adapter->obj );\r
 \r
-       cl_mutex_release( &p_adapter->mutex );\r
+       KeReleaseMutex( &p_adapter->mutex, FALSE );\r
 \r
        cl_obj_destroy( &p_adapter->obj );\r
 \r
@@ -264,7 +265,7 @@ adapter_construct(
        cl_spinlock_construct( &p_adapter->send_stat_lock );\r
        cl_spinlock_construct( &p_adapter->recv_stat_lock );\r
        cl_qpool_construct( &p_adapter->item_pool );\r
-       cl_mutex_construct( &p_adapter->mutex );\r
+       KeInitializeMutex( &p_adapter->mutex, 0 );\r
        cl_vector_construct( &p_adapter->ip_vector );\r
 \r
        cl_perf_construct( &p_adapter->perf );\r
@@ -316,13 +317,6 @@ adapter_init(
                return IB_ERROR;\r
        }\r
 \r
-       cl_status = cl_mutex_init( &p_adapter->mutex );\r
-       if( cl_status != CL_SUCCESS )\r
-       {\r
-               IPOIB_TRACE_EXIT( IPOIB_DBG_ERROR,\r
-                       ("cl_mutex_init returned %s\n", cl_status_text[cl_status]) );\r
-               return IB_ERROR;\r
-       }\r
 \r
        /* We manually manage the size and capacity of the vector. */\r
        cl_status = cl_vector_init( &p_adapter->ip_vector, 0,\r
@@ -468,7 +462,6 @@ __adapter_free(
        cl_qpool_destroy( &p_adapter->item_pool );\r
        cl_spinlock_destroy( &p_adapter->recv_stat_lock );\r
        cl_spinlock_destroy( &p_adapter->send_stat_lock );\r
-       cl_mutex_destroy( &p_adapter->mutex );\r
        cl_obj_deinit( p_obj );\r
 \r
        cl_perf_destroy( &p_adapter->perf, TRUE );\r
@@ -498,13 +491,14 @@ __ipoib_pnp_cb(
        CL_ASSERT( p_adapter );\r
 \r
        /* Synchronize with destruction */\r
-       cl_mutex_acquire( &p_adapter->mutex );\r
+       KeWaitForMutexObject(\r
+               &p_adapter->mutex, Executive, KernelMode, FALSE, NULL );\r
        cl_obj_lock( &p_adapter->obj );\r
        old_state = p_adapter->state;\r
        cl_obj_unlock( &p_adapter->obj );\r
        if( old_state == IB_PNP_PORT_REMOVE )\r
        {\r
-               cl_mutex_release( &p_adapter->mutex );\r
+               KeReleaseMutex( &p_adapter->mutex, FALSE );\r
                IPOIB_TRACE_EXIT( IPOIB_DBG_PNP,\r
                        ("Aborting - Adapter destroying.\n") );\r
                return IB_NOT_DONE;\r
@@ -646,7 +640,7 @@ __ipoib_pnp_cb(
                break;\r
        }\r
 \r
-       cl_mutex_release( &p_adapter->mutex );\r
+       KeReleaseMutex( &p_adapter->mutex, FALSE );\r
 \r
        IPOIB_EXIT( IPOIB_DBG_PNP );\r
        return status;\r
@@ -767,7 +761,8 @@ __ipoib_pnp_dereg(
        p_adapter = PARENT_STRUCT( context, ipoib_adapter_t, obj );\r
 \r
        /* Synchronize with destruction */\r
-       cl_mutex_acquire( &p_adapter->mutex );\r
+       KeWaitForMutexObject(\r
+               &p_adapter->mutex, Executive, KernelMode, FALSE, NULL );\r
 \r
        cl_obj_lock( &p_adapter->obj );\r
 \r
@@ -810,7 +805,7 @@ __ipoib_pnp_dereg(
        /* Dereference the adapter since the previous registration is now gone. */\r
        cl_obj_deref( &p_adapter->obj );\r
 \r
-       cl_mutex_release( &p_adapter->mutex );\r
+       KeReleaseMutex( &p_adapter->mutex, FALSE );\r
 \r
        IPOIB_EXIT( IPOIB_DBG_INIT );\r
 }\r
index d516c9d..066ce03 100644 (file)
@@ -164,7 +164,7 @@ typedef struct _ipoib_adapter
 \r
        cl_qpool_t                              item_pool;\r
 \r
-       cl_mutex_t                              mutex;\r
+       KMUTEX                                  mutex;\r
 \r
        cl_vector_t                             ip_vector;\r
 \r