Thu Aug 22 20:00:43 2013 UTC ()
Check that the xfer we are about to abort didn't finish yet since abort
methods fail in this case (at least ehci's one).


(aymeric)
diff -r1.154 -r1.155 src/sys/dev/usb/usbdi.c

cvs diff -r1.154 -r1.155 src/sys/dev/usb/usbdi.c (expand / switch to unified diff)

--- src/sys/dev/usb/usbdi.c 2013/07/11 19:46:44 1.154
+++ src/sys/dev/usb/usbdi.c 2013/08/22 20:00:43 1.155
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: usbdi.c,v 1.154 2013/07/11 19:46:44 aymeric Exp $ */ 1/* $NetBSD: usbdi.c,v 1.155 2013/08/22 20:00:43 aymeric Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart@augustsson.net) at 8 * by Lennart Augustsson (lennart@augustsson.net) at
9 * Carlstedt Research & Technology and Matthew R. Green (mrg@eterna.com.au). 9 * Carlstedt Research & Technology and Matthew R. Green (mrg@eterna.com.au).
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE. 30 * POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.154 2013/07/11 19:46:44 aymeric Exp $"); 34__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.155 2013/08/22 20:00:43 aymeric Exp $");
35 35
36#ifdef _KERNEL_OPT 36#ifdef _KERNEL_OPT
37#include "opt_compat_netbsd.h" 37#include "opt_compat_netbsd.h"
38#endif 38#endif
39 39
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/systm.h> 41#include <sys/systm.h>
42#include <sys/kernel.h> 42#include <sys/kernel.h>
43#include <sys/device.h> 43#include <sys/device.h>
44#include <sys/malloc.h> 44#include <sys/malloc.h>
45#include <sys/proc.h> 45#include <sys/proc.h>
46#include <sys/bus.h> 46#include <sys/bus.h>
47#include <sys/cpu.h> 47#include <sys/cpu.h>
@@ -327,27 +327,28 @@ usbd_transfer(usbd_xfer_handle xfer) @@ -327,27 +327,28 @@ usbd_transfer(usbd_xfer_handle xfer)
327 err = 0; 327 err = 0;
328 if ((flags & USBD_SYNCHRONOUS_SIG) != 0) { 328 if ((flags & USBD_SYNCHRONOUS_SIG) != 0) {
329 if (pipe->device->bus->lock) 329 if (pipe->device->bus->lock)
330 err = cv_wait_sig(&xfer->cv, pipe->device->bus->lock); 330 err = cv_wait_sig(&xfer->cv, pipe->device->bus->lock);
331 else 331 else
332 err = tsleep(xfer, PZERO|PCATCH, "usbsyn", 0); 332 err = tsleep(xfer, PZERO|PCATCH, "usbsyn", 0);
333 } else { 333 } else {
334 if (pipe->device->bus->lock) 334 if (pipe->device->bus->lock)
335 cv_wait(&xfer->cv, pipe->device->bus->lock); 335 cv_wait(&xfer->cv, pipe->device->bus->lock);
336 else 336 else
337 err = tsleep(xfer, PRIBIO, "usbsyn", 0); 337 err = tsleep(xfer, PRIBIO, "usbsyn", 0);
338 } 338 }
339 if (err) { 339 if (err) {
340 pipe->methods->abort(xfer); 340 if (!xfer->done)
 341 pipe->methods->abort(xfer);
341 break; 342 break;
342 } 343 }
343 } 344 }
344 usbd_unlock_pipe(pipe); 345 usbd_unlock_pipe(pipe);
345 return (xfer->status); 346 return (xfer->status);
346} 347}
347 348
348/* Like usbd_transfer(), but waits for completion. */ 349/* Like usbd_transfer(), but waits for completion. */
349usbd_status 350usbd_status
350usbd_sync_transfer(usbd_xfer_handle xfer) 351usbd_sync_transfer(usbd_xfer_handle xfer)
351{ 352{
352 xfer->flags |= USBD_SYNCHRONOUS; 353 xfer->flags |= USBD_SYNCHRONOUS;
353 return (usbd_transfer(xfer)); 354 return (usbd_transfer(xfer));