Commit b9af0e2d authored by Shay Drory's avatar Shay Drory Committed by Jason Gunthorpe

IB/mad: Issue complete whenever decrements agent refcount

Replace calls of atomic_dec() to mad_agent_priv->refcount with calls to
deref_mad_agent() in order to issue complete. Most likely the refcount is
> 1 at these points, but it is difficult to prove. Performance is not
important on these paths, so be obviously correct.

Link: https://lore.kernel.org/r/20200621104738.54850-3-leon@kernel.orgSigned-off-by: default avatarShay Drory <shayd@mellanox.com>
Reviewed-by: default avatarMaor Gottlieb <maorg@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent 95a5631f
...@@ -1148,7 +1148,7 @@ int ib_post_send_mad(struct ib_mad_send_buf *send_buf, ...@@ -1148,7 +1148,7 @@ int ib_post_send_mad(struct ib_mad_send_buf *send_buf,
spin_lock_irqsave(&mad_agent_priv->lock, flags); spin_lock_irqsave(&mad_agent_priv->lock, flags);
list_del(&mad_send_wr->agent_list); list_del(&mad_send_wr->agent_list);
spin_unlock_irqrestore(&mad_agent_priv->lock, flags); spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
atomic_dec(&mad_agent_priv->refcount); deref_mad_agent(mad_agent_priv);
goto error; goto error;
} }
} }
...@@ -1831,7 +1831,7 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv, ...@@ -1831,7 +1831,7 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,
mad_agent_priv->agent.recv_handler( mad_agent_priv->agent.recv_handler(
&mad_agent_priv->agent, NULL, &mad_agent_priv->agent, NULL,
mad_recv_wc); mad_recv_wc);
atomic_dec(&mad_agent_priv->refcount); deref_mad_agent(mad_agent_priv);
} else { } else {
/* not user rmpp, revert to normal behavior and /* not user rmpp, revert to normal behavior and
* drop the mad */ * drop the mad */
...@@ -1848,7 +1848,7 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv, ...@@ -1848,7 +1848,7 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,
&mad_agent_priv->agent, &mad_agent_priv->agent,
&mad_send_wr->send_buf, &mad_send_wr->send_buf,
mad_recv_wc); mad_recv_wc);
atomic_dec(&mad_agent_priv->refcount); deref_mad_agent(mad_agent_priv);
mad_send_wc.status = IB_WC_SUCCESS; mad_send_wc.status = IB_WC_SUCCESS;
mad_send_wc.vendor_err = 0; mad_send_wc.vendor_err = 0;
...@@ -2438,7 +2438,7 @@ static void cancel_mads(struct ib_mad_agent_private *mad_agent_priv) ...@@ -2438,7 +2438,7 @@ static void cancel_mads(struct ib_mad_agent_private *mad_agent_priv)
list_del(&mad_send_wr->agent_list); list_del(&mad_send_wr->agent_list);
mad_agent_priv->agent.send_handler(&mad_agent_priv->agent, mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
&mad_send_wc); &mad_send_wc);
atomic_dec(&mad_agent_priv->refcount); deref_mad_agent(mad_agent_priv);
} }
} }
...@@ -2572,7 +2572,7 @@ static void local_completions(struct work_struct *work) ...@@ -2572,7 +2572,7 @@ static void local_completions(struct work_struct *work)
&local->mad_send_wr->send_buf, &local->mad_send_wr->send_buf,
&local->mad_priv->header.recv_wc); &local->mad_priv->header.recv_wc);
spin_lock_irqsave(&recv_mad_agent->lock, flags); spin_lock_irqsave(&recv_mad_agent->lock, flags);
atomic_dec(&recv_mad_agent->refcount); deref_mad_agent(recv_mad_agent);
spin_unlock_irqrestore(&recv_mad_agent->lock, flags); spin_unlock_irqrestore(&recv_mad_agent->lock, flags);
} }
...@@ -2585,7 +2585,7 @@ static void local_completions(struct work_struct *work) ...@@ -2585,7 +2585,7 @@ static void local_completions(struct work_struct *work)
&mad_send_wc); &mad_send_wc);
spin_lock_irqsave(&mad_agent_priv->lock, flags); spin_lock_irqsave(&mad_agent_priv->lock, flags);
atomic_dec(&mad_agent_priv->refcount); deref_mad_agent(mad_agent_priv);
if (free_mad) if (free_mad)
kfree(local->mad_priv); kfree(local->mad_priv);
kfree(local); kfree(local);
...@@ -2671,7 +2671,7 @@ static void timeout_sends(struct work_struct *work) ...@@ -2671,7 +2671,7 @@ static void timeout_sends(struct work_struct *work)
mad_agent_priv->agent.send_handler(&mad_agent_priv->agent, mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
&mad_send_wc); &mad_send_wc);
atomic_dec(&mad_agent_priv->refcount); deref_mad_agent(mad_agent_priv);
spin_lock_irqsave(&mad_agent_priv->lock, flags); spin_lock_irqsave(&mad_agent_priv->lock, flags);
} }
spin_unlock_irqrestore(&mad_agent_priv->lock, flags); spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment