Module Name: src
Committed By: mlelstv
Date: Wed Oct 17 17:05:16 UTC 2012
Modified Files:
src/sys/dev/usb: ucom.c
Log Message:
Don't rely on TS_BUSY to determine wether there is a buffer
available. Instead handle a possible buffer shortage.
Also aquire lock when modifying t_state.
To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/dev/usb/ucom.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/ucom.c
diff -u src/sys/dev/usb/ucom.c:1.99 src/sys/dev/usb/ucom.c:1.100
--- src/sys/dev/usb/ucom.c:1.99 Tue Mar 6 03:35:29 2012
+++ src/sys/dev/usb/ucom.c Wed Oct 17 17:05:15 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: ucom.c,v 1.99 2012/03/06 03:35:29 mrg Exp $ */
+/* $NetBSD: ucom.c,v 1.100 2012/10/17 17:05:15 mlelstv Exp $ */
/*
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.99 2012/03/06 03:35:29 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.100 2012/10/17 17:05:15 mlelstv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1002,7 +1002,10 @@ ucomstart(struct tty *tp)
goto out;
ub = SIMPLEQ_FIRST(&sc->sc_obuff_free);
- KASSERT(ub != NULL);
+ if (ub == NULL) {
+ SET(tp->t_state, TS_BUSY);
+ goto out;
+ }
SIMPLEQ_REMOVE_HEAD(&sc->sc_obuff_free, ub_link);
if (SIMPLEQ_FIRST(&sc->sc_obuff_free) == NULL)
@@ -1070,11 +1073,13 @@ ucom_write_status(struct ucom_softc *sc,
SIMPLEQ_INSERT_TAIL(&sc->sc_obuff_free, ub, ub_link);
cc -= sc->sc_opkthdrlen;
+ mutex_spin_enter(&tty_lock);
CLR(tp->t_state, TS_BUSY);
if (ISSET(tp->t_state, TS_FLUSH))
CLR(tp->t_state, TS_FLUSH);
else
ndflush(&tp->t_outq, cc);
+ mutex_spin_exit(&tty_lock);
if (err != USBD_CANCELLED && err != USBD_IOERROR &&
!sc->sc_dying) {