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.
This commit is contained in:
rin 2019-02-17 04:17:52 +00:00
parent 05f24ca45b
commit fcb6b46ef6
8 changed files with 37 additions and 28 deletions

View File

@ -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 usbd_xfer *xfer)
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;

View File

@ -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 usbd_xfer *xfer)
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);

View File

@ -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 usbd_xfer *xfer)
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;

View File

@ -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 usbd_xfer *xfer)
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);
}

View File

@ -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 usbd_xfer *xfer)
{
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;

View File

@ -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 usbd_xfer *xfer)
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

View File

@ -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 usbd_xfer *xfer)
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);
}

View File

@ -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 usbd_xfer *xfer)
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;