Tue Jan 22 20:50:04 2013 UTC ()
need to protect complete tailq with intr lock


(jmcneill)
diff -r1.35 -r1.36 src/sys/dev/usb/dwc_otg.c

cvs diff -r1.35 -r1.36 src/sys/dev/usb/Attic/dwc_otg.c (expand / switch to unified diff)

--- src/sys/dev/usb/Attic/dwc_otg.c 2013/01/22 15:19:48 1.35
+++ src/sys/dev/usb/Attic/dwc_otg.c 2013/01/22 20:50:04 1.36
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: dwc_otg.c,v 1.35 2013/01/22 15:19:48 jmcneill Exp $ */ 1/* $NetBSD: dwc_otg.c,v 1.36 2013/01/22 20:50:04 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2012 Hans Petter Selasky. All rights reserved. 4 * Copyright (c) 2012 Hans Petter Selasky. All rights reserved.
5 * Copyright (c) 2010-2011 Aleksandr Rybalko. All rights reserved. 5 * Copyright (c) 2010-2011 Aleksandr Rybalko. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -50,27 +50,27 @@ @@ -50,27 +50,27 @@
50 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 50 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
51 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 51 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
52 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 52 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
53 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 53 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
54 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 54 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
55 * POSSIBILITY OF SUCH DAMAGE. 55 * POSSIBILITY OF SUCH DAMAGE.
56 */ 56 */
57 57
58/* 58/*
59 * Designware USB 2.0 OTG 59 * Designware USB 2.0 OTG
60 */ 60 */
61 61
62#include <sys/cdefs.h> 62#include <sys/cdefs.h>
63__KERNEL_RCSID(0, "$NetBSD: dwc_otg.c,v 1.35 2013/01/22 15:19:48 jmcneill Exp $"); 63__KERNEL_RCSID(0, "$NetBSD: dwc_otg.c,v 1.36 2013/01/22 20:50:04 jmcneill Exp $");
64 64
65#include <sys/param.h> 65#include <sys/param.h>
66#include <sys/systm.h> 66#include <sys/systm.h>
67#include <sys/kmem.h> 67#include <sys/kmem.h>
68#include <sys/kernel.h> 68#include <sys/kernel.h>
69#include <sys/device.h> 69#include <sys/device.h>
70#include <sys/select.h> 70#include <sys/select.h>
71#include <sys/proc.h> 71#include <sys/proc.h>
72#include <sys/queue.h> 72#include <sys/queue.h>
73#include <sys/cpu.h> 73#include <sys/cpu.h>
74 74
75#include <machine/endian.h> 75#include <machine/endian.h>
76 76
@@ -410,31 +410,35 @@ dwc_otg_get_lock(struct usbd_bus *bus, k @@ -410,31 +410,35 @@ dwc_otg_get_lock(struct usbd_bus *bus, k
410 410
411Static void 411Static void
412dwc_otg_softintr(void *v) 412dwc_otg_softintr(void *v)
413{ 413{
414 struct usbd_bus *bus = v; 414 struct usbd_bus *bus = v;
415 struct dwc_otg_softc *sc = bus->hci_private; 415 struct dwc_otg_softc *sc = bus->hci_private;
416 struct dwc_otg_xfer *dxfer, *tmp; 416 struct dwc_otg_xfer *dxfer, *tmp;
417 417
418 KASSERT(sc->sc_bus.use_polling || mutex_owned(&sc->sc_lock)); 418 KASSERT(sc->sc_bus.use_polling || mutex_owned(&sc->sc_lock));
419 419
420 DOTG_EVCNT_INCR(sc->sc_ev_soft_intr); 420 DOTG_EVCNT_INCR(sc->sc_ev_soft_intr);
421 421
422 DPRINTF("\n"); 422 DPRINTF("\n");
 423
 424 mutex_spin_enter(&sc->sc_intr_lock);
423 TAILQ_FOREACH_SAFE(dxfer, &sc->sc_complete, xnext, tmp) { 425 TAILQ_FOREACH_SAFE(dxfer, &sc->sc_complete, xnext, tmp) {
424 TAILQ_REMOVE(&sc->sc_complete, dxfer, xnext); 426 TAILQ_REMOVE(&sc->sc_complete, dxfer, xnext);
425 427 mutex_spin_exit(&sc->sc_intr_lock);
426 usb_transfer_complete(&dxfer->xfer); 428 usb_transfer_complete(&dxfer->xfer);
 429 mutex_spin_enter(&sc->sc_intr_lock);
427 } 430 }
 431 mutex_spin_exit(&sc->sc_intr_lock);
428} 432}
429 433
430Static void 434Static void
431dwc_otg_waitintr(struct dwc_otg_softc *sc, usbd_xfer_handle xfer) 435dwc_otg_waitintr(struct dwc_otg_softc *sc, usbd_xfer_handle xfer)
432{ 436{
433 int timo; 437 int timo;
434 uint32_t intrs; 438 uint32_t intrs;
435 439
436 xfer->status = USBD_IN_PROGRESS; 440 xfer->status = USBD_IN_PROGRESS;
437 for (timo = xfer->timeout; timo >= 0; timo--) { 441 for (timo = xfer->timeout; timo >= 0; timo--) {
438 usb_delay_ms(&sc->sc_bus, 1); 442 usb_delay_ms(&sc->sc_bus, 1);
439 if (sc->sc_dying) 443 if (sc->sc_dying)
440 break; 444 break;