[openib-general] [PATCH][kdapl] resend patch of clean up async evd

Itamar itamar at mellanox.co.il
Wed May 11 00:41:14 PDT 2005


Clean up async evd flow.
Clean up init module.

Signed-off-by: Itamar Rabenstein <itamar at mellanox.co.il>


Index: dapl_module.c
===================================================================
--- dapl_module.c	(revision 2302)
+++ dapl_module.c	(working copy)
@@ -147,6 +147,28 @@
 		goto bail;
 	}
 
+	dat_status = dapl_ib_open_hca(hca_ptr->name, hca_ptr);
+
+	if (dat_status != DAT_SUCCESS) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+					 "dapl_ib_open_hca failed %x\n",
+					 dat_status);
+		goto bail;
+	}
+	/*
+	 * Obtain IA attributes from the HCA to limit certain
+	 * operations.
+	 */
+	dat_status = dapl_ib_query_hca(hca_ptr,
+								   &hca_ptr->ia_attr,
+								   NULL, &hca_ptr->hca_address);
+	if (dat_status != DAT_SUCCESS) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+					 "dapl_ib_query_hca failed %x\n",
+					 dat_status);
+		goto bail;
+	}
+
 	provider->extension = hca_ptr;
 
 	/* register providers with dat_registry */
Index: dapl_ia_util.c
===================================================================
--- dapl_ia_util.c	(revision 2302)
+++ dapl_ia_util.c	(working copy)
@@ -468,13 +468,6 @@
 {
 	spin_lock(&hca_ptr->lock);
 	atomic_dec(&hca_ptr->handle_ref_count);
-	if (atomic_read(&hca_ptr->handle_ref_count) == 0) {
-		dapl_ib_close_hca(hca_ptr);
-#if 0
-		hca_ptr->ib_hca_handle = IB_INVALID_HANDLE;
-#endif
-                hca_ptr->async_evd = NULL;
-	}
 	spin_unlock(&hca_ptr->lock);
 }
 
Index: dapl_ia_open.c
===================================================================
--- dapl_ia_open.c	(revision 2302)
+++ dapl_ia_open.c	(working copy)
@@ -44,12 +44,6 @@
 #include "dapl_adapter_util.h"
 
 /*
- * LOCAL PROTOTYPES
- */
-
-void dapl_hca_cleanup(DAPL_HCA * hca_ptr, DAT_BOOLEAN dec_ref);
-
-/*
  * Open a provider and return a handle. The handle enables the user
  * to invoke operations on this provider.
  *
@@ -99,37 +93,7 @@
 	/* get the hca_ptr */
 	hca_ptr = (DAPL_HCA *) provider->extension;
 
-	/*
-	 * Open the HCA if it has not been done before.
-	 */
 	spin_lock(&hca_ptr->lock);
-	/* register with the HW */
-	dat_status = dapl_ib_open_hca(hca_ptr->name, hca_ptr);
-
-	if (dat_status != DAT_SUCCESS) {
-		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-			     "dapl_ib_open_hca failed %x\n",
-			     dat_status);
-		spin_unlock(&hca_ptr->lock);
-		goto bail;
-	}
-
-	/*
-	 * Obtain IA attributes from the HCA to limit certain
-	 * operations.
-	 * If using DAPL_ATS naming, ib_query_hca will also set the ip
-	 * address.
-	 */
-	dat_status = dapl_ib_query_hca(hca_ptr,
-				       &hca_ptr->ia_attr,
-				       NULL, &hca_ptr->hca_address);
-	if (dat_status != DAT_SUCCESS) {
-		dapl_hca_cleanup(hca_ptr, DAT_FALSE);
-		spin_unlock(&hca_ptr->lock);
-		goto bail;
-	}
-
-	/* Take a reference on the hca_handle */
 	atomic_inc(&hca_ptr->handle_ref_count);
 	spin_unlock(&hca_ptr->lock);
 
@@ -137,7 +101,7 @@
 	ia_ptr = dapl_ia_alloc(provider, hca_ptr);
 	if (!ia_ptr) {
 		spin_lock(&hca_ptr->lock);
-		dapl_hca_cleanup(hca_ptr, DAT_TRUE);
+		atomic_dec(&hca_ptr->handle_ref_count);
 		spin_unlock(&hca_ptr->lock);
 		dat_status =
 		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
@@ -157,14 +121,6 @@
 				      DAT_INVALID_HANDLE_EVD_ASYNC);
 			goto bail;
 		}
-
-		/* InfiniBand allows only 1 asychronous event handler per HCA */
-		/* (see InfiniBand Spec, release 1.1, vol I, section 11.5.2,  */
-		/*  page 559).                                                */
-		/*                                                            */
-		/* We only need to make sure that this EVD's CQ belongs to    */
-		/* the same HCA as is being opened.                           */
-
 		if (evd_ptr->header.owner_ia->hca_ptr->ib_hca_handle !=
 		    hca_ptr->ib_hca_handle) {
 			dat_status =
@@ -172,7 +128,6 @@
 				      DAT_INVALID_HANDLE_EVD_ASYNC);
 			goto bail;
 		}
-
 		ia_ptr->cleanup_async_error_evd = DAT_FALSE;
 		ia_ptr->async_error_evd = evd_ptr;
 	} else {
@@ -187,31 +142,17 @@
 						      async_evd_qlen,
 						      DAT_EVD_ASYNC_FLAG,
 						      &evd_ptr);
-		if (dat_status != DAT_SUCCESS) {
+		if (dat_status != DAT_SUCCESS) 
 			goto bail;
-		}
 
 		atomic_inc(&evd_ptr->evd_ref_count);
-
-		spin_lock(&hca_ptr->lock);
-		if (hca_ptr->async_evd != (DAPL_EVD *) 0) {
-			spin_unlock(&hca_ptr->lock);
-		} else {
-			hca_ptr->async_evd = evd_ptr;
-			spin_unlock(&hca_ptr->lock);
-
-			/* Register the handlers associated with the async EVD.  */
-			dat_status = dapl_ia_setup_callbacks(ia_ptr, evd_ptr);
-			if (dat_status != DAT_SUCCESS) {
-				/* Assign the EVD so it gets cleaned up */
-				ia_ptr->cleanup_async_error_evd = DAT_TRUE;
-				ia_ptr->async_error_evd = evd_ptr;
-				goto bail;
-			}
-		}
-
+		/* Register the handlers associated with the async EVD.  */
+		dat_status = dapl_ia_setup_callbacks(ia_ptr, evd_ptr);
+		/* Assign the EVD so it gets cleaned up */
 		ia_ptr->cleanup_async_error_evd = DAT_TRUE;
 		ia_ptr->async_error_evd = evd_ptr;
+		if (dat_status != DAT_SUCCESS)
+			goto bail;
 	}
 
 	dat_status = DAT_SUCCESS;
@@ -220,10 +161,8 @@
 
       bail:
 	if (dat_status != DAT_SUCCESS) {
-		if (ia_ptr) {
-			/* This will release the async EVD if needed.  */
+		if (ia_ptr)
 			dapl_ia_close(ia_ptr, DAT_CLOSE_ABRUPT_FLAG);
-		}
 	}
 
 	dapl_dbg_log(DAPL_DBG_TYPE_RTN,
@@ -231,15 +170,3 @@
 
 	return dat_status;
 }
-
-/*
- * Clean up partially allocated HCA stuff. Strictly to make cleanup
- * simple.
- */
-void dapl_hca_cleanup(DAPL_HCA * hca_ptr, DAT_BOOLEAN dec_ref)
-{
-	dapl_ib_close_hca(hca_ptr);
-	if (dec_ref == DAT_TRUE) {
-		atomic_dec(&hca_ptr->handle_ref_count);
-	}
-}
Index: dapl.h
===================================================================
--- dapl.h	(revision 2302)
+++ dapl.h	(working copy)
@@ -211,8 +211,6 @@
 	spinlock_t lock;
 	DAPL_LLIST_HEAD ia_list_head;	/* list of all open IAs */
 	atomic_t handle_ref_count;	/* count of ia_opens on handle */
-	DAPL_EVD *async_evd;
-	DAPL_EVD *async_error_evd;
 	struct sockaddr_in6 hca_address;	/* local address of HCA */
 	char *name;		/* provider name */
 	ib_hca_handle_t ib_hca_handle;

-- 
Itamar



More information about the general mailing list