[openib-general] [PATCH] ib_mad_recv_done_handler cleanup the locking area
Krishna Kumar
krkumar at us.ibm.com
Mon Nov 1 18:10:16 PST 2004
This is a minor cleanup/optimize in this area. No need to hold lock
for too long (for atomic_inc), no multiple unlocks and normal case
of finding mad_agent first.
Thanks,
- KK
-------------- next part --------------
--- mad.c.org 2004-11-01 17:41:09.000000000 -0800
+++ mad.c 2004-11-01 17:43:55.000000000 -0800
@@ -988,20 +988,19 @@ static void ib_mad_recv_done_handler(str
recv->header.recv_buf.mad))
goto out;
- spin_lock_irqsave(&port_priv->reg_lock, flags);
/* Determine corresponding MAD agent for incoming receive MAD */
+ spin_lock_irqsave(&port_priv->reg_lock, flags);
solicited = solicited_mad(recv->header.recv_buf.mad);
mad_agent = find_mad_agent(port_priv, recv->header.recv_buf.mad,
solicited);
- if (!mad_agent) {
- spin_unlock_irqrestore(&port_priv->reg_lock, flags);
- printk(KERN_NOTICE PFX "No matching mad agent found for "
- "received MAD on port %d\n", port_priv->port_num);
- } else {
+ spin_unlock_irqrestore(&port_priv->reg_lock, flags);
+
+ if (mad_agent) {
atomic_inc(&mad_agent->refcount);
- spin_unlock_irqrestore(&port_priv->reg_lock, flags);
ib_mad_complete_recv(mad_agent, recv, solicited);
- }
+ } else
+ printk(KERN_NOTICE PFX "No matching mad agent found for "
+ "received MAD on port %d\n", port_priv->port_num);
out:
if (!mad_agent) {
More information about the general
mailing list