Module Name: src Committed By: jmcneill Date: Mon Jan 9 10:57:35 UTC 2012
Modified Files: src/sys/dev/usb: auvitek.c auvitek_dtv.c Log Message: make sure kernel lock is held when calling into usb stack To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/dev/usb/auvitek.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/usb/auvitek_dtv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/usb/auvitek.c diff -u src/sys/dev/usb/auvitek.c:1.7 src/sys/dev/usb/auvitek.c:1.8 --- src/sys/dev/usb/auvitek.c:1.7 Sun Oct 2 19:15:39 2011 +++ src/sys/dev/usb/auvitek.c Mon Jan 9 10:57:34 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: auvitek.c,v 1.7 2011/10/02 19:15:39 jmcneill Exp $ */ +/* $NetBSD: auvitek.c,v 1.8 2012/01/09 10:57:34 jmcneill Exp $ */ /*- * Copyright (c) 2010 Jared D. McNeill <jmcne...@invisible.ca> @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: auvitek.c,v 1.7 2011/10/02 19:15:39 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: auvitek.c,v 1.8 2012/01/09 10:57:34 jmcneill Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -359,8 +359,11 @@ auvitek_read_1(struct auvitek_softc *sc, USETW(req.wIndex, reg); USETW(req.wLength, sizeof(data)); + KERNEL_LOCK(1, curlwp); err = usbd_do_request_flags(sc->sc_udev, &req, &data, 0, &actlen, USBD_DEFAULT_TIMEOUT); + KERNEL_UNLOCK_ONE(curlwp); + if (err) printf("%s: read failed: %s\n", device_xname(sc->sc_dev), usbd_errstr(err)); @@ -381,8 +384,11 @@ auvitek_write_1(struct auvitek_softc *sc USETW(req.wIndex, reg); USETW(req.wLength, 0); + KERNEL_LOCK(1, curlwp); err = usbd_do_request_flags(sc->sc_udev, &req, NULL, 0, &actlen, USBD_DEFAULT_TIMEOUT); + KERNEL_UNLOCK_ONE(curlwp); + if (err) printf("%s: write failed: %s\n", device_xname(sc->sc_dev), usbd_errstr(err)); Index: src/sys/dev/usb/auvitek_dtv.c diff -u src/sys/dev/usb/auvitek_dtv.c:1.4 src/sys/dev/usb/auvitek_dtv.c:1.5 --- src/sys/dev/usb/auvitek_dtv.c:1.4 Sun Oct 2 19:15:40 2011 +++ src/sys/dev/usb/auvitek_dtv.c Mon Jan 9 10:57:34 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: auvitek_dtv.c,v 1.4 2011/10/02 19:15:40 jmcneill Exp $ */ +/* $NetBSD: auvitek_dtv.c,v 1.5 2012/01/09 10:57:34 jmcneill Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill <jmcne...@invisible.ca> @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: auvitek_dtv.c,v 1.4 2011/10/02 19:15:40 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: auvitek_dtv.c,v 1.5 2012/01/09 10:57:34 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -257,8 +257,11 @@ auvitek_dtv_init_pipes(struct auvitek_so { usbd_status err; + KERNEL_LOCK(1, curlwp); err = usbd_open_pipe(sc->sc_bulk_iface, sc->sc_ab.ab_endpt, USBD_EXCLUSIVE_USE, &sc->sc_ab.ab_pipe); + KERNEL_UNLOCK_ONE(curlwp); + if (err) { aprint_error_dev(sc->sc_dev, "couldn't open bulk-in pipe: %s\n", usbd_errstr(err)); @@ -272,8 +275,10 @@ static int auvitek_dtv_close_pipes(struct auvitek_softc *sc) { if (sc->sc_ab.ab_pipe != NULL) { + KERNEL_LOCK(1, curlwp); usbd_abort_pipe(sc->sc_ab.ab_pipe); usbd_close_pipe(sc->sc_ab.ab_pipe); + KERNEL_UNLOCK_ONE(curlwp); sc->sc_ab.ab_pipe = NULL; } @@ -348,7 +353,11 @@ auvitek_dtv_bulk_start1(struct auvitek_b //USBD_SHORT_XFER_OK|USBD_NO_COPY, USBD_NO_TIMEOUT, USBD_NO_COPY, 100, auvitek_dtv_bulk_cb); + + KERNEL_LOCK(1, curlwp); err = usbd_transfer(bx->bx_xfer); + KERNEL_UNLOCK_ONE(curlwp); + if (err != USBD_IN_PROGRESS) { aprint_error_dev(sc->sc_dev, "USB error: %s\n", usbd_errstr(err));