Module Name: src
Committed By: jmcneill
Date: Mon Jan 9 11:02:19 UTC 2012
Modified Files:
src/sys/dev/usb: emdtv.c emdtv_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.6 -r1.7 src/sys/dev/usb/emdtv.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/usb/emdtv_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/emdtv.c
diff -u src/sys/dev/usb/emdtv.c:1.6 src/sys/dev/usb/emdtv.c:1.7
--- src/sys/dev/usb/emdtv.c:1.6 Fri Dec 23 00:51:43 2011
+++ src/sys/dev/usb/emdtv.c Mon Jan 9 11:02:18 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: emdtv.c,v 1.6 2011/12/23 00:51:43 jakllsch Exp $ */
+/* $NetBSD: emdtv.c,v 1.7 2012/01/09 11:02:18 jmcneill Exp $ */
/*-
* Copyright (c) 2008, 2011 Jared D. McNeill <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emdtv.c,v 1.6 2011/12/23 00:51:43 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emdtv.c,v 1.7 2012/01/09 11:02:18 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -319,7 +319,10 @@ emdtv_read_multi_1(struct emdtv_softc *s
USETW(request.wIndex, index);
USETW(request.wLength, count);
+ KERNEL_LOCK(1, curlwp);
status = usbd_do_request(sc->sc_udev, &request, datap);
+ KERNEL_UNLOCK_ONE(curlwp);
+
if (status != USBD_NORMAL_COMPLETION)
aprint_error_dev(sc->sc_dev, "couldn't read %x/%x: %s\n",
req, index, usbd_errstr(status));
@@ -347,7 +350,10 @@ emdtv_write_multi_1(struct emdtv_softc *
USETW(request.wIndex, index);
USETW(request.wLength, count);
+ KERNEL_LOCK(1, curlwp);
status = usbd_do_request(sc->sc_udev, &request, __UNCONST(datap));
+ KERNEL_UNLOCK_ONE(curlwp);
+
if (status != USBD_NORMAL_COMPLETION)
aprint_error_dev(sc->sc_dev, "couldn't read %x/%x: %s\n",
req, index, usbd_errstr(status));
Index: src/sys/dev/usb/emdtv_dtv.c
diff -u src/sys/dev/usb/emdtv_dtv.c:1.7 src/sys/dev/usb/emdtv_dtv.c:1.8
--- src/sys/dev/usb/emdtv_dtv.c:1.7 Fri Dec 23 00:51:43 2011
+++ src/sys/dev/usb/emdtv_dtv.c Mon Jan 9 11:02:18 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: emdtv_dtv.c,v 1.7 2011/12/23 00:51:43 jakllsch Exp $ */
+/* $NetBSD: emdtv_dtv.c,v 1.8 2012/01/09 11:02:18 jmcneill Exp $ */
/*-
* Copyright (c) 2008, 2011 Jared D. McNeill <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emdtv_dtv.c,v 1.7 2011/12/23 00:51:43 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emdtv_dtv.c,v 1.8 2012/01/09 11:02:18 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -306,6 +306,7 @@ emdtv_dtv_start_transfer(void *priv,
aprint_debug_dev(sc->sc_dev, "allocating isoc xfers (pktsz %d)\n",
sc->sc_isoc_maxpacketsize);
+ KERNEL_LOCK(1, curlwp);
for (i = 0; i < EMDTV_NXFERS; i++) {
sc->sc_ix[i].ix_xfer = usbd_alloc_xfer(sc->sc_udev);
sc->sc_ix[i].ix_buf = usbd_alloc_buffer(sc->sc_ix[i].ix_xfer,
@@ -313,6 +314,7 @@ emdtv_dtv_start_transfer(void *priv,
aprint_debug_dev(sc->sc_dev, " ix[%d] xfer %p buf %p\n",
i, sc->sc_ix[i].ix_xfer, sc->sc_ix[i].ix_buf);
}
+ KERNEL_UNLOCK_ONE(curlwp);
aprint_debug_dev(sc->sc_dev, "starting isoc transactions\n");
@@ -332,6 +334,7 @@ emdtv_dtv_stop_transfer(void *priv)
sc->sc_streaming = false;
+ KERNEL_LOCK(1, curlwp);
if (sc->sc_isoc_pipe != NULL)
usbd_abort_pipe(sc->sc_isoc_pipe);
@@ -341,6 +344,7 @@ emdtv_dtv_stop_transfer(void *priv)
sc->sc_ix[i].ix_xfer = NULL;
sc->sc_ix[i].ix_buf = NULL;
}
+ KERNEL_UNLOCK_ONE(curlwp);
sc->sc_dtvsubmitcb = NULL;
sc->sc_dtvsubmitarg = NULL;
@@ -378,7 +382,10 @@ emdtv_dtv_isoc_start(struct emdtv_softc
EMDTV_NFRAMES,
USBD_NO_COPY | USBD_SHORT_XFER_OK,
emdtv_dtv_isoc);
+
+ KERNEL_LOCK(1, curlwp);
usbd_transfer(ix->ix_xfer);
+ KERNEL_UNLOCK_ONE(curlwp);
return 0;
}