Module Name:    src
Committed By:   skrll
Date:           Tue May 10 10:40:33 UTC 2016

Modified Files:
        src/sys/dev/usb: ucom.c

Log Message:
Fixup ucom_cleanup to not forget our pipe handles.

Simplify ucomreadcb by dealing with the USBD_CANCELLED separately and
not taking sc_lock.  We can't hold sc_lock while aborting now.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 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.111 src/sys/dev/usb/ucom.c:1.112
--- src/sys/dev/usb/ucom.c:1.111	Sat Apr 23 10:15:32 2016
+++ src/sys/dev/usb/ucom.c	Tue May 10 10:40:33 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucom.c,v 1.111 2016/04/23 10:15:32 skrll Exp $	*/
+/*	$NetBSD: ucom.c,v 1.112 2016/05/10 10:40:33 skrll 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.111 2016/04/23 10:15:32 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.112 2016/05/10 10:40:33 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1396,25 +1396,25 @@ ucomreadcb(struct usbd_xfer *xfer, void 
 
 	UCOMHIST_FUNC(); UCOMHIST_CALLED();
 
-	mutex_enter(&sc->sc_lock);
-	ub = SIMPLEQ_FIRST(&sc->sc_ibuff_empty);
-	SIMPLEQ_REMOVE_HEAD(&sc->sc_ibuff_empty, ub_link);
+	if (status == USBD_CANCELLED)
+		return;
 
-	if (status == USBD_CANCELLED || status == USBD_IOERROR ||
+	mutex_enter(&sc->sc_lock);
+	if (status == USBD_IOERROR ||
 	    sc->sc_dying) {
 		DPRINTF("dying", 0, 0, 0, 0);
-		ub->ub_index = ub->ub_len = 0;
 		/* Send something to wake upper layer */
-		if (status != USBD_CANCELLED) {
-			(tp->t_linesw->l_rint)('\n', tp);
-			mutex_spin_enter(&tty_lock);	/* XXX */
-			ttwakeup(tp);
-			mutex_spin_exit(&tty_lock);	/* XXX */
-		}
+		(tp->t_linesw->l_rint)('\n', tp);
+		mutex_spin_enter(&tty_lock);	/* XXX */
+		ttwakeup(tp);
+		mutex_spin_exit(&tty_lock);	/* XXX */
 		mutex_exit(&sc->sc_lock);
 		return;
 	}
 
+	ub = SIMPLEQ_FIRST(&sc->sc_ibuff_empty);
+	SIMPLEQ_REMOVE_HEAD(&sc->sc_ibuff_empty, ub_link);
+
 	if (status == USBD_STALLED) {
 		usbd_clear_endpoint_stall_async(sc->sc_bulkin_pipe);
 		ucomsubmitread(sc, ub);
@@ -1474,18 +1474,10 @@ ucom_cleanup(struct ucom_softc *sc)
 
 	ucom_shutdown(sc);
 	if (sc->sc_bulkin_pipe != NULL) {
-		struct usbd_pipe *bulkin_pipe = sc->sc_bulkin_pipe;
-		sc->sc_bulkin_pipe = NULL;
-		mutex_exit(&sc->sc_lock);
-		usbd_abort_pipe(bulkin_pipe);
-		mutex_enter(&sc->sc_lock);
+		usbd_abort_pipe(sc->sc_bulkin_pipe);
 	}
 	if (sc->sc_bulkout_pipe != NULL) {
-		struct usbd_pipe *bulkout_pipe = sc->sc_bulkout_pipe;
-		sc->sc_bulkout_pipe = NULL;
-		mutex_exit(&sc->sc_lock);
-		usbd_abort_pipe(bulkout_pipe);
-		mutex_enter(&sc->sc_lock);
+		usbd_abort_pipe(sc->sc_bulkout_pipe);
 	}
 }
 

Reply via email to