[openib-general] [PATCH 2 of 4] RFC: revert module ref counting patches

Michael S. Tsirkin mst at mellanox.co.il
Mon Apr 10 04:17:55 PDT 2006


Revert module ref counting patch for CM. I expect the same to
apply to for-2.6.17.

Index: linux-2.6.16/drivers/infiniband/core/cm.c
===================================================================
--- linux-2.6.16/drivers/infiniband/core/cm.c	(revision 6324)
+++ linux-2.6.16/drivers/infiniband/core/cm.c	(revision 6323)
@@ -118,7 +118,6 @@
 
 struct cm_id_private {
 	struct ib_cm_id	id;
-	struct module *owner;
 
 	struct rb_node service_node;
 	struct rb_node sidr_id_node;
@@ -591,9 +590,9 @@
 	ib_send_cm_sidr_rep(&cm_id_priv->id, &param);
 }
 
-struct ib_cm_id *__ib_create_cm_id(struct ib_device *device,
+struct ib_cm_id *ib_create_cm_id(struct ib_device *device,
 				 ib_cm_handler cm_handler,
-				 void *context, struct module *owner)
+				 void *context)
 {
 	struct cm_id_private *cm_id_priv;
 	int ret;
@@ -602,7 +601,6 @@
 	if (!cm_id_priv)
 		return ERR_PTR(-ENOMEM);
 
-	cm_id_priv->owner = owner;
 	cm_id_priv->id.state = IB_CM_IDLE;
 	cm_id_priv->id.device = device;
 	cm_id_priv->id.cm_handler = cm_handler;
@@ -623,7 +621,7 @@
 	kfree(cm_id_priv);
 	return ERR_PTR(-ENOMEM);
 }
-EXPORT_SYMBOL(__ib_create_cm_id);
+EXPORT_SYMBOL(ib_create_cm_id);
 
 static struct cm_work * cm_dequeue_work(struct cm_id_private *cm_id_priv)
 {
@@ -1153,18 +1151,6 @@
 	work->cm_event.private_data = &req_msg->private_data;
 }
 
-static int invoke_cm_handler(struct cm_id_private *cm_id_priv,
-			     struct ib_cm_event *event)
-{
-	int ret;
-
-	BUG_ON(!try_module_get(cm_id_priv->owner));
-	ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, event);
-	module_put(cm_id_priv->owner);
-
-	return ret;
-}
-
 static void cm_process_work(struct cm_id_private *cm_id_priv,
 			    struct cm_work *work)
 {
@@ -1172,7 +1158,7 @@
 	int ret;
 
 	/* We will typically only have the current event to report. */
-	ret = invoke_cm_handler(cm_id_priv, &work->cm_event);
+	ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, &work->cm_event);
 	cm_free_work(work);
 
 	while (!ret && !atomic_add_negative(-1, &cm_id_priv->work_count)) {
@@ -1180,7 +1166,8 @@
 		work = cm_dequeue_work(cm_id_priv);
 		spin_unlock_irqrestore(&cm_id_priv->lock, flags);
 		BUG_ON(!work);
-		ret = invoke_cm_handler(cm_id_priv, &work->cm_event);
+		ret = cm_id_priv->id.cm_handler(&cm_id_priv->id,
+						&work->cm_event);
 		cm_free_work(work);
 	}
 	cm_deref_id(cm_id_priv);
@@ -1370,7 +1357,6 @@
 		goto error2;
 	}
 
-	cm_id_priv->owner = listen_cm_id_priv->owner;
 	cm_id_priv->id.cm_handler = listen_cm_id_priv->id.cm_handler;
 	cm_id_priv->id.context = listen_cm_id_priv->id.context;
 	cm_id_priv->id.service_id = req_msg->service_id;
@@ -2743,7 +2729,6 @@
 	atomic_inc(&cur_cm_id_priv->refcount);
 	spin_unlock_irqrestore(&cm.lock, flags);
 
-	cm_id_priv->owner = cur_cm_id_priv->owner;
 	cm_id_priv->id.cm_handler = cur_cm_id_priv->id.cm_handler;
 	cm_id_priv->id.context = cur_cm_id_priv->id.context;
 	cm_id_priv->id.service_id = sidr_req_msg->service_id;
@@ -2912,7 +2897,7 @@
 	cm_event.param.send_status = wc_status;
 
 	/* No other events can occur on the cm_id at this point. */
-	ret = invoke_cm_handler(cm_id_priv, &cm_event);
+	ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, &cm_event);
 	cm_free_msg(msg);
 	if (ret)
 		ib_destroy_cm_id(&cm_id_priv->id);
Index: linux-2.6.16/drivers/infiniband/include/rdma/ib_cm.h
===================================================================
--- linux-2.6.16/drivers/infiniband/include/rdma/ib_cm.h	(revision 6324)
+++ linux-2.6.16/drivers/infiniband/include/rdma/ib_cm.h	(revision 6323)
@@ -292,10 +292,6 @@
 	u32			remote_cm_qpn;  /* 1 unless redirected */
 };
 
-struct ib_cm_id *__ib_create_cm_id(struct ib_device *device,
-				   ib_cm_handler cm_handler,
-				   void *context, struct module *owner);
-
 /**
  * ib_create_cm_id - Allocate a communication identifier.
  * @device: Device associated with the cm_id.  All related communication will
@@ -307,12 +303,9 @@
  * Communication identifiers are used to track connection states, service
  * ID resolution requests, and listen requests.
  */
-static inline struct ib_cm_id *ib_create_cm_id(struct ib_device *device,
-					       ib_cm_handler cm_handler,
-					       void *context)
-{
-	return __ib_create_cm_id(device, cm_handler, context, THIS_MODULE);
-}
+struct ib_cm_id *ib_create_cm_id(struct ib_device *device,
+				 ib_cm_handler cm_handler,
+				 void *context);
 
 /**
  * ib_destroy_cm_id - Destroy a connection identifier.


-- 
MST



More information about the general mailing list