Module Name: src Committed By: rin Date: Sun Feb 17 04:17:52 UTC 2019
Modified Files: src/sys/arch/mips/adm5120/dev: ahci.c src/sys/dev/ic: sl811hs.c src/sys/dev/usb: ehci.c motg.c ohci.c uhci.c xhci.c src/sys/external/bsd/dwc2: dwc2.c Log Message: Fix assertion failures triggered by usbdi.c,v 1.182, when devices are detached. This is because xfers of USBD_NOT_STARTED can be removed from queue in an invisible way to host controller drivers. Discussed on tech-kern. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/mips/adm5120/dev/ahci.c cvs rdiff -u -r1.100 -r1.101 src/sys/dev/ic/sl811hs.c cvs rdiff -u -r1.265 -r1.266 src/sys/dev/usb/ehci.c cvs rdiff -u -r1.24 -r1.25 src/sys/dev/usb/motg.c cvs rdiff -u -r1.287 -r1.288 src/sys/dev/usb/ohci.c src/sys/dev/usb/uhci.c cvs rdiff -u -r1.105 -r1.106 src/sys/dev/usb/xhci.c cvs rdiff -u -r1.57 -r1.58 src/sys/external/bsd/dwc2/dwc2.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/arch/mips/adm5120/dev/ahci.c diff -u src/sys/arch/mips/adm5120/dev/ahci.c:1.16 src/sys/arch/mips/adm5120/dev/ahci.c:1.17 --- src/sys/arch/mips/adm5120/dev/ahci.c:1.16 Mon Sep 3 16:29:25 2018 +++ src/sys/arch/mips/adm5120/dev/ahci.c Sun Feb 17 04:17:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ahci.c,v 1.16 2018/09/03 16:29:25 riastradh Exp $ */ +/* $NetBSD: ahci.c,v 1.17 2019/02/17 04:17:52 rin Exp $ */ /*- * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko. @@ -64,7 +64,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.16 2018/09/03 16:29:25 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.17 2019/02/17 04:17:52 rin Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -491,7 +491,8 @@ ahci_freex(struct usbd_bus *bus, struct DPRINTF(D_MEM, ("SLfreex")); #ifdef DIAGNOSTIC - if (xfer->ux_state != XFER_BUSY) { + if (xfer->ux_state != XFER_BUSY && + xfer->ux_status != USBD_NOT_STARTED) { printf("ahci_freex: xfer=%p not busy, 0x%08x\n", xfer, xfer->ux_state); return; Index: src/sys/dev/ic/sl811hs.c diff -u src/sys/dev/ic/sl811hs.c:1.100 src/sys/dev/ic/sl811hs.c:1.101 --- src/sys/dev/ic/sl811hs.c:1.100 Mon Sep 3 16:29:31 2018 +++ src/sys/dev/ic/sl811hs.c Sun Feb 17 04:17:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sl811hs.c,v 1.100 2018/09/03 16:29:31 riastradh Exp $ */ +/* $NetBSD: sl811hs.c,v 1.101 2019/02/17 04:17:52 rin Exp $ */ /* * Not (c) 2007 Matthew Orgass @@ -68,7 +68,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.100 2018/09/03 16:29:31 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.101 2019/02/17 04:17:52 rin Exp $"); #ifdef _KERNEL_OPT #include "opt_slhci.h" @@ -811,7 +811,8 @@ slhci_freex(struct usbd_bus *bus, struct slhci_mem_use(bus, -1); #endif #ifdef DIAGNOSTIC - if (xfer->ux_state != XFER_BUSY) { + if (xfer->ux_state != XFER_BUSY && + xfer->ux_status != USBD_NOT_STARTED) { struct slhci_softc *sc = SLHCI_BUS2SC(bus); printf("%s: slhci_freex: xfer=%p not busy, %#08x halted\n", SC_NAME(sc), xfer, xfer->ux_state); Index: src/sys/dev/usb/ehci.c diff -u src/sys/dev/usb/ehci.c:1.265 src/sys/dev/usb/ehci.c:1.266 --- src/sys/dev/usb/ehci.c:1.265 Tue Sep 18 02:00:06 2018 +++ src/sys/dev/usb/ehci.c Sun Feb 17 04:17:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ehci.c,v 1.265 2018/09/18 02:00:06 mrg Exp $ */ +/* $NetBSD: ehci.c,v 1.266 2019/02/17 04:17:52 rin Exp $ */ /* * Copyright (c) 2004-2012 The NetBSD Foundation, Inc. @@ -53,7 +53,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.265 2018/09/18 02:00:06 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.266 2019/02/17 04:17:52 rin Exp $"); #include "ohci.h" #include "uhci.h" @@ -1562,9 +1562,10 @@ ehci_freex(struct usbd_bus *bus, struct struct ehci_softc *sc = EHCI_BUS2SC(bus); struct ehci_xfer *ex __diagused = EHCI_XFER2EXFER(xfer); - KASSERTMSG(xfer->ux_state == XFER_BUSY, "xfer %p state %d\n", xfer, - xfer->ux_state); - KASSERT(ex->ex_isdone); + KASSERTMSG(xfer->ux_state == XFER_BUSY || + xfer->ux_status == USBD_NOT_STARTED, + "xfer %p state %d\n", xfer, xfer->ux_state); + KASSERT(ex->ex_isdone || xfer->ux_status == USBD_NOT_STARTED); #ifdef DIAGNOSTIC xfer->ux_state = XFER_FREE; Index: src/sys/dev/usb/motg.c diff -u src/sys/dev/usb/motg.c:1.24 src/sys/dev/usb/motg.c:1.25 --- src/sys/dev/usb/motg.c:1.24 Tue Jan 22 06:39:24 2019 +++ src/sys/dev/usb/motg.c Sun Feb 17 04:17:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: motg.c,v 1.24 2019/01/22 06:39:24 skrll Exp $ */ +/* $NetBSD: motg.c,v 1.25 2019/02/17 04:17:52 rin Exp $ */ /* * Copyright (c) 1998, 2004, 2011, 2012, 2014 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.24 2019/01/22 06:39:24 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.25 2019/02/17 04:17:52 rin Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -760,7 +760,8 @@ motg_freex(struct usbd_bus *bus, struct struct motg_softc *sc = MOTG_BUS2SC(bus); #ifdef DIAGNOSTIC - if (xfer->ux_state != XFER_BUSY) { + if (xfer->ux_state != XFER_BUSY && + xfer->ux_status != USBD_NOT_STARTED) { printf("motg_freex: xfer=%p not busy, 0x%08x\n", xfer, xfer->ux_state); } Index: src/sys/dev/usb/ohci.c diff -u src/sys/dev/usb/ohci.c:1.287 src/sys/dev/usb/ohci.c:1.288 --- src/sys/dev/usb/ohci.c:1.287 Sun Sep 16 20:21:56 2018 +++ src/sys/dev/usb/ohci.c Sun Feb 17 04:17:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ohci.c,v 1.287 2018/09/16 20:21:56 mrg Exp $ */ +/* $NetBSD: ohci.c,v 1.288 2019/02/17 04:17:52 rin Exp $ */ /* * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.287 2018/09/16 20:21:56 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.288 2019/02/17 04:17:52 rin Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1083,7 +1083,8 @@ ohci_freex(struct usbd_bus *bus, struct { ohci_softc_t *sc = OHCI_BUS2SC(bus); - KASSERTMSG(xfer->ux_state == XFER_BUSY, + KASSERTMSG(xfer->ux_state == XFER_BUSY || + xfer->ux_status == USBD_NOT_STARTED, "xfer=%p not busy, 0x%08x\n", xfer, xfer->ux_state); #ifdef DIAGNOSTIC xfer->ux_state = XFER_FREE; Index: src/sys/dev/usb/uhci.c diff -u src/sys/dev/usb/uhci.c:1.287 src/sys/dev/usb/uhci.c:1.288 --- src/sys/dev/usb/uhci.c:1.287 Thu Feb 7 12:35:43 2019 +++ src/sys/dev/usb/uhci.c Sun Feb 17 04:17:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: uhci.c,v 1.287 2019/02/07 12:35:43 skrll Exp $ */ +/* $NetBSD: uhci.c,v 1.288 2019/02/17 04:17:52 rin Exp $ */ /* * Copyright (c) 1998, 2004, 2011, 2012 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.287 2019/02/07 12:35:43 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.288 2019/02/17 04:17:52 rin Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -675,9 +675,11 @@ uhci_freex(struct usbd_bus *bus, struct struct uhci_softc *sc = UHCI_BUS2SC(bus); struct uhci_xfer *uxfer __diagused = UHCI_XFER2UXFER(xfer); - KASSERTMSG(xfer->ux_state == XFER_BUSY, "xfer %p state %d\n", xfer, - xfer->ux_state); - KASSERTMSG(uxfer->ux_isdone, "xfer %p not done\n", xfer); + KASSERTMSG(xfer->ux_state == XFER_BUSY || + xfer->ux_status == USBD_NOT_STARTED, + "xfer %p state %d\n", xfer, xfer->ux_state); + KASSERTMSG(uxfer->ux_isdone || xfer->ux_status == USBD_NOT_STARTED, + "xfer %p not done\n", xfer); #ifdef DIAGNOSTIC xfer->ux_state = XFER_FREE; #endif Index: src/sys/dev/usb/xhci.c diff -u src/sys/dev/usb/xhci.c:1.105 src/sys/dev/usb/xhci.c:1.106 --- src/sys/dev/usb/xhci.c:1.105 Tue Jan 22 15:02:33 2019 +++ src/sys/dev/usb/xhci.c Sun Feb 17 04:17:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: xhci.c,v 1.105 2019/01/22 15:02:33 skrll Exp $ */ +/* $NetBSD: xhci.c,v 1.106 2019/02/17 04:17:52 rin Exp $ */ /* * Copyright (c) 2013 Jonathan A. Kollasch @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.105 2019/01/22 15:02:33 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.106 2019/02/17 04:17:52 rin Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -2284,7 +2284,8 @@ xhci_freex(struct usbd_bus *bus, struct XHCIHIST_FUNC(); XHCIHIST_CALLED(); #ifdef DIAGNOSTIC - if (xfer->ux_state != XFER_BUSY) { + if (xfer->ux_state != XFER_BUSY && + xfer->ux_status != USBD_NOT_STARTED) { DPRINTFN(0, "xfer=%#jx not busy, 0x%08jx", (uintptr_t)xfer, xfer->ux_state, 0, 0); } Index: src/sys/external/bsd/dwc2/dwc2.c diff -u src/sys/external/bsd/dwc2/dwc2.c:1.57 src/sys/external/bsd/dwc2/dwc2.c:1.58 --- src/sys/external/bsd/dwc2/dwc2.c:1.57 Tue Jan 22 15:02:34 2019 +++ src/sys/external/bsd/dwc2/dwc2.c Sun Feb 17 04:17:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dwc2.c,v 1.57 2019/01/22 15:02:34 skrll Exp $ */ +/* $NetBSD: dwc2.c,v 1.58 2019/02/17 04:17:52 rin Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.57 2019/01/22 15:02:34 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.58 2019/02/17 04:17:52 rin Exp $"); #include "opt_usb.h" @@ -235,7 +235,8 @@ dwc2_freex(struct usbd_bus *bus, struct DPRINTFN(10, "\n"); #ifdef DIAGNOSTIC - if (xfer->ux_state != XFER_BUSY) { + if (xfer->ux_state != XFER_BUSY && + xfer->ux_status != USBD_NOT_STARTED) { DPRINTF("xfer=%p not busy, 0x%08x\n", xfer, xfer->ux_state); } xfer->ux_state = XFER_FREE;