[PATCH 1/2] usb: usbtest: Add timetout to simple_io()
Without a timetout some tests e.g. test_halt() can remain stuck forever. Signed-off-by: Roger Quadros rog...@ti.com Reviewed-by: Felipe Balbi ba...@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 1 /* in milliseconds */ /*-*/ @@ -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 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] usb: usbtest: Add timetout to simple_io()
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 rog...@ti.com Reviewed-by: Felipe Balbi ba...@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_TIMEOUT1 /* 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 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] usb: usbtest: Add timetout to simple_io()
On Wed, Dec 18, 2013 at 10:46:03PM +0800, Huang Rui wrote: 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 rog...@ti.com Reviewed-by: Felipe Balbi ba...@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 1 /* in milliseconds */ Only one question, how do you confirm the timeout value? dude, it's just a timeout. It could be anything, really. 10 seconds is just large enough value that would allow even the slowest scenarios (host + device) to complete, while not being so slow that you would wanna kill yourself after waiting for such a long time ;-) -- balbi signature.asc Description: Digital signature
Re: [PATCH 1/2] usb: usbtest: Add timetout to simple_io()
On Wed, Dec 18, 2013 at 10:37:44AM -0600, Felipe Balbi wrote: On Wed, Dec 18, 2013 at 10:46:03PM +0800, Huang Rui wrote: 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 rog...@ti.com Reviewed-by: Felipe Balbi ba...@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_TIMEOUT1 /* in milliseconds */ Only one question, how do you confirm the timeout value? dude, it's just a timeout. It could be anything, really. 10 seconds is just large enough value that would allow even the slowest scenarios (host + device) to complete, while not being so slow that you would wanna kill yourself after waiting for such a long time ;-) OK. I've tested in my side. Acked-by: Huang Rui ray.hu...@amd.com -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html