[openib-general] [PATCH 1 of 4] RFC: revert module ref counting patches
Michael S. Tsirkin
mst at mellanox.co.il
Mon Apr 10 04:17:30 PDT 2006
Revert module ref counting patch for CMA.
Index: linux-2.6.16/drivers/infiniband/core/cma.c
===================================================================
--- linux-2.6.16/drivers/infiniband/core/cma.c (revision 6333)
+++ linux-2.6.16/drivers/infiniband/core/cma.c (revision 6332)
@@ -96,7 +96,6 @@
*/
struct rdma_id_private {
struct rdma_cm_id id;
- struct module *owner;
struct list_head list;
struct list_head listen_list;
@@ -280,9 +279,8 @@
wake_up(&id_priv->wait_remove);
}
-struct rdma_cm_id* __rdma_create_id(rdma_cm_event_handler event_handler,
- void *context, enum rdma_port_space ps,
- struct module *owner)
+struct rdma_cm_id* rdma_create_id(rdma_cm_event_handler event_handler,
+ void *context, enum rdma_port_space ps)
{
struct rdma_id_private *id_priv;
@@ -293,7 +291,6 @@
id_priv->state = CMA_IDLE;
id_priv->id.context = context;
id_priv->id.event_handler = event_handler;
- id_priv->owner = owner;
id_priv->id.ps = ps;
spin_lock_init(&id_priv->lock);
init_waitqueue_head(&id_priv->wait);
@@ -305,7 +302,7 @@
return &id_priv->id;
}
-EXPORT_SYMBOL(__rdma_create_id);
+EXPORT_SYMBOL(rdma_create_id);
static int cma_init_ib_qp(struct rdma_id_private *id_priv, struct ib_qp *qp)
{
@@ -545,18 +542,6 @@
}
}
-static int invoke_event_handler(struct rdma_id_private *id_priv,
- struct rdma_cm_event *event)
-{
- int ret;
-
- BUG_ON(!try_module_get(id_priv->owner));
- ret = id_priv->id.event_handler(&id_priv->id, event);
- module_put(id_priv->owner);
-
- return ret;
-}
-
static int cma_notify_user(struct rdma_id_private *id_priv,
enum rdma_cm_event_type type, int status,
void *data, u8 data_len)
@@ -568,7 +553,7 @@
event.private_data = data;
event.private_data_len = data_len;
- return invoke_event_handler(id_priv, &event);
+ return id_priv->id.event_handler(&id_priv->id, &event);
}
static void cma_cancel_route(struct rdma_id_private *id_priv)
@@ -785,7 +770,7 @@
return ret;
}
-static struct rdma_id_private* cma_new_id(struct rdma_id_private *listen_id,
+static struct rdma_id_private* cma_new_id(struct rdma_cm_id *listen_id,
struct ib_cm_event *ib_event)
{
struct rdma_id_private *id_priv;
@@ -795,8 +780,8 @@
__u16 port;
u8 ip_ver;
- id = __rdma_create_id(listen_id->id.event_handler, listen_id->id.context,
- listen_id->id.ps, listen_id->owner);
+ id = rdma_create_id(listen_id->event_handler, listen_id->context,
+ listen_id->ps);
if (IS_ERR(id))
return NULL;
@@ -806,11 +791,11 @@
if (!rt->path_rec)
goto err;
- if (cma_get_net_info(ib_event->private_data, listen_id->id.ps,
+ if (cma_get_net_info(ib_event->private_data, listen_id->ps,
&ip_ver, &port, &src, &dst))
goto err;
- cma_save_net_info(&id->route.addr, &listen_id->id.route.addr,
+ cma_save_net_info(&id->route.addr, &listen_id->route.addr,
ip_ver, port, src, dst);
rt->path_rec[0] = *ib_event->param.req_rcvd.primary_path;
if (rt->num_paths == 2)
@@ -841,7 +826,7 @@
goto out;
}
- conn_id = cma_new_id(listen_id, ib_event);
+ conn_id = cma_new_id(&listen_id->id, ib_event);
if (!conn_id) {
ret = -ENOMEM;
goto out;
@@ -958,13 +943,11 @@
static int cma_listen_handler(struct rdma_cm_id *id,
struct rdma_cm_event *event)
{
- struct rdma_id_private *listen_id = id->context;
- struct rdma_id_private *id_priv;
+ struct rdma_id_private *id_priv = id->context;
- id_priv = container_of(id, struct rdma_id_private, id);
- id->context = listen_id->id.context;
- id->event_handler = listen_id->id.event_handler;
- return invoke_event_handler(id_priv, event);
+ id->context = id_priv->id.context;
+ id->event_handler = id_priv->id.event_handler;
+ return id_priv->id.event_handler(id, event);
}
static void cma_listen_on_dev(struct rdma_id_private *id_priv,
@@ -974,8 +957,7 @@
struct rdma_cm_id *id;
int ret;
- id = __rdma_create_id(cma_listen_handler, id_priv, id_priv->id.ps,
- id_priv->owner);
+ id = rdma_create_id(cma_listen_handler, id_priv, id_priv->id.ps);
if (IS_ERR(id))
return;
@@ -1098,7 +1080,7 @@
if (!cma_comp_exch(id_priv, work->old_state, work->new_state))
goto out;
- if (invoke_event_handler(id_priv, &work->event)) {
+ if (id_priv->id.event_handler(&id_priv->id, &work->event)) {
cma_exch(id_priv, CMA_DESTROYING);
destroy = 1;
}
Index: linux-2.6.16/drivers/infiniband/include/rdma/rdma_cm.h
===================================================================
--- linux-2.6.16/drivers/infiniband/include/rdma/rdma_cm.h (revision 6333)
+++ linux-2.6.16/drivers/infiniband/include/rdma/rdma_cm.h (revision 6332)
@@ -106,10 +106,6 @@
u8 port_num;
};
-struct rdma_cm_id *__rdma_create_id(rdma_cm_event_handler event_handler,
- void *context, enum rdma_port_space ps,
- struct module *owner);
-
/**
* rdma_create_id - Create an RDMA identifier.
*
@@ -118,12 +114,8 @@
* @context: User specified context associated with the id.
* @ps: RDMA port space.
*/
-static inline struct rdma_cm_id *
-rdma_create_id(rdma_cm_event_handler event_handler,
- void *context, enum rdma_port_space ps)
-{
- return __rdma_create_id(event_handler, context, ps, THIS_MODULE);
-}
+struct rdma_cm_id *rdma_create_id(rdma_cm_event_handler event_handler,
+ void *context, enum rdma_port_space ps);
void rdma_destroy_id(struct rdma_cm_id *id);
--
MST
More information about the general
mailing list