[openib-general] Re: [PATCH][26/26] IB: MAD cancel callbacks from thread

Jeff Garzik jgarzik at pobox.com
Thu Mar 3 16:07:43 PST 2005


Roland Dreier wrote:
> +void cancel_sends(void *data)
> +{
> +	struct ib_mad_agent_private *mad_agent_priv;
> +	struct ib_mad_send_wr_private *mad_send_wr;
> +	struct ib_mad_send_wc mad_send_wc;
> +	unsigned long flags;
> +
> +	mad_agent_priv = (struct ib_mad_agent_private *)data;

don't add casts to a void pointer, that's silly.



> +	mad_send_wc.status = IB_WC_WR_FLUSH_ERR;
> +	mad_send_wc.vendor_err = 0;
> +
> +	spin_lock_irqsave(&mad_agent_priv->lock, flags);
> +	while (!list_empty(&mad_agent_priv->canceled_list)) {
> +		mad_send_wr = list_entry(mad_agent_priv->canceled_list.next,
> +					 struct ib_mad_send_wr_private,
> +					 agent_list);
> +
> +		list_del(&mad_send_wr->agent_list);
> +		spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
> +
> +		mad_send_wc.wr_id = mad_send_wr->wr_id;
> +		mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
> +						   &mad_send_wc);
> +
> +		kfree(mad_send_wr);
> +		if (atomic_dec_and_test(&mad_agent_priv->refcount))
> +			wake_up(&mad_agent_priv->wait);
> +		spin_lock_irqsave(&mad_agent_priv->lock, flags);
> +	}
> +	spin_unlock_irqrestore(&mad_agent_priv->lock, flags);

dumb question... why is the lock dropped?  is it just for the 
send_handler(), or also for wr_id assigned, kfree, and wake_up() ?




More information about the general mailing list