[openib-general] [PATCH] amso1100/c2_vq.c : Corrected vq_wait_for_reply function

Tom Tucker tom at opengridcomputing.com
Tue Apr 18 08:27:38 PDT 2006


Thanks for the patch! This is a nice cleanup...

The code does actually wait. If you go look at the implementation of
wait_event_timeout you will see that it essentially the same thing. At
the time this code was written, the wait_event_timeout function didn't
exist ...


On Tue, 2006-04-18 at 12:44 +0530, Pradipta Kumar Banerjee wrote:
> Hi
> 
> This patch corrects the vq_wait_for_reply function so that it actually waits
> for the reply till the timeout occurs.
> 
> Signed-off-by: Pradipta Kumar B <bpradip at in.ibm.com>
> Signed-off-by: Krishna Kumar <krkumar2 at in.ibm.com>
> 
> ---
> 
> Index: c2_vq.c
> =====================================================================
> --- c2_vq.c.org	2006-04-18 11:52:01.000000000 +0530
> +++ c2_vq.c	2006-04-18 12:20:42.000000000 +0530
> @@ -240,27 +240,12 @@ int vq_send_wr(struct c2_dev *c2dev, uni
>   */
>  int vq_wait_for_reply(struct c2_dev *c2dev, struct c2_vq_req *req)
>  {
> -	wait_queue_t __wait;
> -	int rc = 0;
> -
> -	/*
> -	 * Add this request to the wait queue.
> -	 */
> -	init_waitqueue_entry(&__wait, current);
> -	add_wait_queue(&req->wait_object, &__wait);
> -	for (;;) {
> -		set_current_state(TASK_UNINTERRUPTIBLE);
> -		if (atomic_read(&req->reply_ready)) {
> -			break;
> -		}
> -		if (schedule_timeout(60 * HZ) == 0) {
> -			rc = -ETIMEDOUT;
> -			break;
> -		}
> +	if (wait_event_timeout(req->wait_object,
> +		(atomic_read(&req->reply_ready) == 1), 60*HZ) == 0) {
> +		printk(KERN_ERR "Device timeout\n");
> +		return -ETIMEDOUT;
>  	}
> -	set_current_state(TASK_RUNNING);
> -	remove_wait_queue(&req->wait_object, &__wait);
> -	return rc;
> +	return 0;
>  }
>  
>  /*
> _______________________________________________
> openib-general mailing list
> openib-general at openib.org
> http://openib.org/mailman/listinfo/openib-general
> 
> To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general




More information about the general mailing list