public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Huang Rui <ray.huang@amd.com>
To: Roger Quadros <rogerq@ti.com>
Cc: <gregkh@linuxfoundation.org>, <stern@rowland.harvard.edu>,
	<balbi@ti.com>, <linux-usb@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] usb: usbtest: Add timetout to simple_io()
Date: Wed, 18 Dec 2013 22:46:03 +0800	[thread overview]
Message-ID: <20131218144603.GA19091@hr-dev.amd.com> (raw)
In-Reply-To: <1387361411-15139-1-git-send-email-rogerq@ti.com>

Hi Roger,

On Wed, Dec 18, 2013 at 03:40:10PM +0530, Roger Quadros wrote:
> Without a timetout some tests e.g. test_halt() can remain stuck forever.
> 
> Signed-off-by: Roger Quadros <rogerq@ti.com>
> Reviewed-by: Felipe Balbi <balbi@ti.com>
> ---
>  drivers/usb/misc/usbtest.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
> index b415282..6294e1b 100644
> --- a/drivers/usb/misc/usbtest.c
> +++ b/drivers/usb/misc/usbtest.c
> @@ -10,6 +10,7 @@
>  
>  #include <linux/usb.h>
>  
> +#define SIMPLE_IO_TIMEOUT	10000	/* in milliseconds */
>  

Only one question, how do you confirm the timeout value?

Thanks,
Rui

>  /*-------------------------------------------------------------------------*/
>  
> @@ -366,6 +367,7 @@ static int simple_io(
>  	int			max = urb->transfer_buffer_length;
>  	struct completion	completion;
>  	int			retval = 0;
> +	unsigned long		expire;
>  
>  	urb->context = &completion;
>  	while (retval == 0 && iterations-- > 0) {
> @@ -378,9 +380,15 @@ static int simple_io(
>  		if (retval != 0)
>  			break;
>  
> -		/* NOTE:  no timeouts; can't be broken out of by interrupt */
> -		wait_for_completion(&completion);
> -		retval = urb->status;
> +		expire = msecs_to_jiffies(SIMPLE_IO_TIMEOUT);
> +		if (!wait_for_completion_timeout(&completion, expire)) {
> +			usb_kill_urb(urb);
> +			retval = (urb->status == -ENOENT ?
> +				  -ETIMEDOUT : urb->status);
> +		} else {
> +			retval = urb->status;
> +		}
> +
>  		urb->dev = udev;
>  		if (retval == 0 && usb_pipein(urb->pipe))
>  			retval = simple_check_buf(tdev, urb);
> -- 
> 1.8.3.2
> 
> 


  parent reply	other threads:[~2013-12-18 15:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-18 10:10 [PATCH 1/2] usb: usbtest: Add timetout to simple_io() Roger Quadros
2013-12-18 10:10 ` [PATCH 2/2] usb: usbtest: Always clear halt else further tests will fail Roger Quadros
2013-12-19  4:01   ` Huang Rui
2013-12-19  5:46     ` Huang Rui
2013-12-19  6:21       ` Roger Quadros
2013-12-19  6:35         ` Greg KH
2013-12-18 14:46 ` Huang Rui [this message]
2013-12-18 16:37   ` [PATCH 1/2] usb: usbtest: Add timetout to simple_io() Felipe Balbi
2013-12-19  4:00     ` Huang Rui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131218144603.GA19091@hr-dev.amd.com \
    --to=ray.huang@amd.com \
    --cc=balbi@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=rogerq@ti.com \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox