aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/misc
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2014-06-03 11:11:34 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-06-17 20:05:50 -0400
commit32b36eeae6a859670d2939a7d6136cb5e9ed64f8 (patch)
tree59a11c03171be8b514a7325f4fb971979a396014 /drivers/usb/misc
parentb0a50e92bda3c4aeb8017d4e6c6e92146ebd5c9b (diff)
USB: usbtest: add a timeout for scatter-gather tests
In usbtest, tests 5 - 8 use the scatter-gather library in usbcore without any sort of timeout. If there's a problem in the gadget or host controller being tested, the test can hang. This patch adds a 10-second timeout to the tests, so that they will fail gracefully with an ETIMEDOUT error instead of hanging. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Reported-by: Huang Rui <ray.huang@amd.com> Tested-by: Huang Rui <ray.huang@amd.com> CC: <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r--drivers/usb/misc/usbtest.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 51a6da256772..829f446064ea 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -7,7 +7,7 @@
7#include <linux/moduleparam.h> 7#include <linux/moduleparam.h>
8#include <linux/scatterlist.h> 8#include <linux/scatterlist.h>
9#include <linux/mutex.h> 9#include <linux/mutex.h>
10 10#include <linux/timer.h>
11#include <linux/usb.h> 11#include <linux/usb.h>
12 12
13#define SIMPLE_IO_TIMEOUT 10000 /* in milliseconds */ 13#define SIMPLE_IO_TIMEOUT 10000 /* in milliseconds */
@@ -484,6 +484,14 @@ alloc_sglist(int nents, int max, int vary)
484 return sg; 484 return sg;
485} 485}
486 486
487static void sg_timeout(unsigned long _req)
488{
489 struct usb_sg_request *req = (struct usb_sg_request *) _req;
490
491 req->status = -ETIMEDOUT;
492 usb_sg_cancel(req);
493}
494
487static int perform_sglist( 495static int perform_sglist(
488 struct usbtest_dev *tdev, 496 struct usbtest_dev *tdev,
489 unsigned iterations, 497 unsigned iterations,
@@ -495,6 +503,9 @@ static int perform_sglist(
495{ 503{
496 struct usb_device *udev = testdev_to_usbdev(tdev); 504 struct usb_device *udev = testdev_to_usbdev(tdev);
497 int retval = 0; 505 int retval = 0;
506 struct timer_list sg_timer;
507
508 setup_timer_on_stack(&sg_timer, sg_timeout, (unsigned long) req);
498 509
499 while (retval == 0 && iterations-- > 0) { 510 while (retval == 0 && iterations-- > 0) {
500 retval = usb_sg_init(req, udev, pipe, 511 retval = usb_sg_init(req, udev, pipe,
@@ -505,7 +516,10 @@ static int perform_sglist(
505 516
506 if (retval) 517 if (retval)
507 break; 518 break;
519 mod_timer(&sg_timer, jiffies +
520 msecs_to_jiffies(SIMPLE_IO_TIMEOUT));
508 usb_sg_wait(req); 521 usb_sg_wait(req);
522 del_timer_sync(&sg_timer);
509 retval = req->status; 523 retval = req->status;
510 524
511 /* FIXME check resulting data pattern */ 525 /* FIXME check resulting data pattern */