NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/53447: usb lock problem, mutex_enter



On Jul 12,  9:25pm, phil%netbsd.org@localhost (phil%netbsd.org@localhost) wrote:
-- Subject: kern/53447: usb lock problem, mutex_enter

| >Number:         53447
| >Category:       kern
| >Synopsis:       usb lock problem, mutex_enter
| >Confidential:   no
| >Severity:       serious
| >Priority:       medium
| >Responsible:    kern-bug-people
| >State:          open
| >Class:          sw-bug
| >Submitter-Id:   net
| >Arrival-Date:   Thu Jul 12 21:25:00 +0000 2018
| >Originator:     Phil Nelson
| >Release:        NetBSD HEAD 8.99.21
| >Organization:
| >Environment:
| 8.99.21 NetBSD 8.99.21 (STEELHEAD) #8: Thu Jul 12 13:34:13 PDT 2018 amd64
| >Description:
| When asking for the root device using a USB console keyboard, typing a character to answer the root device name causes a Mutex_error, mutex_vector_enter 528: spin lock held.

Try this:

Index: xhci.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/xhci.c,v
retrieving revision 1.93
diff -u -u -r1.93 xhci.c
--- xhci.c	29 Jun 2018 17:48:24 -0000	1.93
+++ xhci.c	12 Jul 2018 21:50:51 -0000
@@ -1206,7 +1206,7 @@
 static inline bool
 xhci_polling_p(struct xhci_softc * const sc)
 {
-	return sc->sc_bus.ub_usepolling || sc->sc_bus2.ub_usepolling;
+	return cold || sc->sc_bus.ub_usepolling || sc->sc_bus2.ub_usepolling;
 }
 
 int
@@ -3983,6 +3983,7 @@
 	struct xhci_ring * const tr = &xs->xs_ep[dci].xe_tr;
 	struct xhci_xfer * const xx = XHCI_XFER2XXFER(xfer);
 	const uint32_t len = xfer->ux_length;
+	const bool polling = xhci_polling_p(sc);
 	usb_dma_t * const dma = &xfer->ux_dmabuf;
 	uint64_t parameter;
 	uint32_t status;
@@ -4009,13 +4010,15 @@
 	    XHCI_TRB_3_IOC_BIT;
 	xhci_trb_put(&xx->xx_trb[i++], parameter, status, control);
 
-	mutex_enter(&tr->xr_lock);
+	if (!polling)
+		mutex_enter(&tr->xr_lock);
 	xhci_ring_put(sc, tr, xfer, xx->xx_trb, i);
-	mutex_exit(&tr->xr_lock);
+	if (!polling)
+		mutex_exit(&tr->xr_lock);
 
 	xhci_db_write_4(sc, XHCI_DOORBELL(xs->xs_idx), dci);
 
-	if (xfer->ux_timeout && !xhci_polling_p(sc)) {
+	if (xfer->ux_timeout && !polling) {
 		callout_reset(&xfer->ux_callout, mstohz(xfer->ux_timeout),
 		    xhci_timeout, xfer);
 	}


Home | Main Index | Thread Index | Old Index