Module Name: src Committed By: skrll Date: Tue Jul 7 10:02:17 UTC 2020
Modified Files: src/sys/dev/usb: uhci.c Log Message: KASSERT polling or holding sc_lock in a few more places. kern/52569: Entering ddb using USB keyboard panics with "locking against myself" To generate a diff of this commit: cvs rdiff -u -r1.303 -r1.304 src/sys/dev/usb/uhci.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/uhci.c diff -u src/sys/dev/usb/uhci.c:1.303 src/sys/dev/usb/uhci.c:1.304 --- src/sys/dev/usb/uhci.c:1.303 Tue May 26 07:03:22 2020 +++ src/sys/dev/usb/uhci.c Tue Jul 7 10:02:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uhci.c,v 1.303 2020/05/26 07:03:22 skrll Exp $ */ +/* $NetBSD: uhci.c,v 1.304 2020/07/07 10:02:17 skrll Exp $ */ /* * Copyright (c) 1998, 2004, 2011, 2012, 2016, 2020 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.303 2020/05/26 07:03:22 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.304 2020/07/07 10:02:17 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1284,7 +1284,7 @@ uhci_add_bulk(uhci_softc_t *sc, uhci_sof { uhci_soft_qh_t *eqh; - KASSERT(mutex_owned(&sc->sc_lock)); + KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(&sc->sc_lock)); UHCIHIST_FUNC(); UHCIHIST_CALLED(); DPRINTFN(10, "sqh %#jx", (uintptr_t)sqh, 0, 0, 0); @@ -1310,7 +1310,7 @@ uhci_remove_bulk(uhci_softc_t *sc, uhci_ { uhci_soft_qh_t *pqh; - KASSERT(mutex_owned(&sc->sc_lock)); + KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(&sc->sc_lock)); UHCIHIST_FUNC(); UHCIHIST_CALLED(); DPRINTFN(10, "sqh %#jx", (uintptr_t)sqh, 0, 0, 0); @@ -1615,10 +1615,9 @@ uhci_idone(struct uhci_xfer *ux, ux_comp struct uhci_pipe *upipe = UHCI_PIPE2UPIPE(xfer->ux_pipe); uhci_soft_td_t *std; uint32_t status = 0, nstatus; - const bool polling __diagused = sc->sc_bus.ub_usepolling; int actlen; - KASSERT(polling || mutex_owned(&sc->sc_lock)); + KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(&sc->sc_lock)); DPRINTFN(12, "ux=%#jx", (uintptr_t)ux, 0, 0, 0); @@ -1753,7 +1752,7 @@ uhci_idone(struct uhci_xfer *ux, ux_comp if (cqp) TAILQ_INSERT_TAIL(cqp, ux, ux_list); - KASSERT(polling || mutex_owned(&sc->sc_lock)); + KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(&sc->sc_lock)); DPRINTFN(12, "ux=%#jx done", (uintptr_t)ux, 0, 0, 0); } @@ -3207,6 +3206,7 @@ uhci_setup_isoc(struct usbd_pipe *pipe) void uhci_device_isoc_done(struct usbd_xfer *xfer) { + uhci_softc_t *sc __diagused = UHCI_XFER2SC(xfer); struct uhci_pipe *upipe = UHCI_PIPE2UPIPE(xfer->ux_pipe); struct uhci_xfer *ux = UHCI_XFER2UXFER(xfer); int i, offs; @@ -3216,6 +3216,8 @@ uhci_device_isoc_done(struct usbd_xfer * DPRINTFN(4, "length=%jd, ux_state=0x%08jx", xfer->ux_actlen, xfer->ux_state, 0, 0); + KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(&sc->sc_lock)); + #ifdef DIAGNOSTIC if (ux->ux_stdend == NULL) { printf("%s: xfer=%p stdend==NULL\n", __func__, xfer); @@ -3285,10 +3287,9 @@ uhci_device_ctrl_done(struct usbd_xfer * int len = UGETW(xfer->ux_request.wLength); int isread = (xfer->ux_request.bmRequestType & UT_READ); - KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(&sc->sc_lock)); - UHCIHIST_FUNC(); UHCIHIST_CALLED(); + KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(&sc->sc_lock)); KASSERT(xfer->ux_rqflags & URQ_REQUEST); /* XXXNH move to uhci_idone??? */ @@ -3321,7 +3322,7 @@ uhci_device_bulk_done(struct usbd_xfer * DPRINTFN(5, "xfer=%#jx sc=%#jx upipe=%#jx", (uintptr_t)xfer, (uintptr_t)sc, (uintptr_t)upipe, 0); - KASSERT(mutex_owned(&sc->sc_lock)); + KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(&sc->sc_lock)); uhci_remove_bulk(sc, upipe->bulk.sqh);