Current-Users archive

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

Re: DDB not working with USB keyboard at xhci port



On 08/16/17 06:42, sc dying wrote:
When ukbd(4) is a console and connected to USB3 port, you can enter
into DDB by pressing ALT+CTRL+ESC but console freezes.
(on HEAD, netbsd-7, netbsd-8)

xhci has two buses, sc->sc_bus is for usb3 and sc->sc_bus2 is for
usb2.  ukbd is usually connected at Low-Speed, so usbd_set_polling
sets sc->sc_bus2->ub_usepolling.
However, xhci.c checks only sc->sc_bus->ub_usepolling, that's why
xhci_poll does not call xhci_softintr.

I can show a quick dirty patch.
It assumes ub_usepolling is always set by ukbd at LS/FS/HS.
Can you test this patch please?

Thanks,
Nick
Index: sys/dev/usb/xhci.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/xhci.c,v
retrieving revision 1.72
diff -u -p -r1.72 xhci.c
--- sys/dev/usb/xhci.c	1 Jun 2017 02:45:12 -0000	1.72
+++ sys/dev/usb/xhci.c	21 Aug 2017 11:03:44 -0000
@@ -1211,6 +1212,12 @@ xhci_init(struct xhci_softc *sc)
 	return rv;
 }
 
+static inline bool
+xhci_polling_p(struct xhci_softc * const sc)
+{
+	return sc->sc_bus.ub_usepolling || sc->sc_bus2.ub_usepolling;
+}
+
 int
 xhci_intr(void *v)
 {
@@ -1228,7 +1235,7 @@ xhci_intr(void *v)
 		goto done;
 
 	/* If we get an interrupt while polling, then just ignore it. */
-	if (sc->sc_bus.ub_usepolling) {
+	if (xhci_polling_p(sc)) {
 #ifdef DIAGNOSTIC
 		DPRINTFN(16, "ignored interrupt while polling", 0, 0, 0, 0);
 #endif
@@ -2106,7 +2113,7 @@ xhci_softintr(void *v)
 
 	XHCIHIST_FUNC(); XHCIHIST_CALLED();
 
-	KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(&sc->sc_lock));
+	KASSERT(xhci_polling_p(sc) || mutex_owned(&sc->sc_lock));
 
 	i = er->xr_ep;
 	j = er->xr_cs;
@@ -3771,7 +3778,7 @@ xhci_device_ctrl_start(struct usbd_xfer 
 
 	xhci_db_write_4(sc, XHCI_DOORBELL(xs->xs_idx), dci);
 
-	if (xfer->ux_timeout && !sc->sc_bus.ub_usepolling) {
+	if (xfer->ux_timeout && !xhci_polling_p(sc)) {
 		callout_reset(&xfer->ux_callout, mstohz(xfer->ux_timeout),
 		    xhci_timeout, xfer);
 	}
@@ -3887,7 +3894,7 @@ xhci_device_bulk_start(struct usbd_xfer 
 
 	xhci_db_write_4(sc, XHCI_DOORBELL(xs->xs_idx), dci);
 
-	if (xfer->ux_timeout && !sc->sc_bus.ub_usepolling) {
+	if (xfer->ux_timeout && !xhci_polling_p(sc)) {
 		callout_reset(&xfer->ux_callout, mstohz(xfer->ux_timeout),
 		    xhci_timeout, xfer);
 	}
@@ -3993,7 +4000,7 @@ xhci_device_intr_start(struct usbd_xfer 
 
 	xhci_db_write_4(sc, XHCI_DOORBELL(xs->xs_idx), dci);
 
-	if (xfer->ux_timeout && !sc->sc_bus.ub_usepolling) {
+	if (xfer->ux_timeout && !xhci_polling_p(sc)) {
 		callout_reset(&xfer->ux_callout, mstohz(xfer->ux_timeout),
 		    xhci_timeout, xfer);
 	}
@@ -4015,7 +4022,7 @@ xhci_device_intr_done(struct usbd_xfer *
 
 	DPRINTFN(15, "%p slot %u dci %u", xfer, xs->xs_idx, dci, 0);
 
-	KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(&sc->sc_lock));
+	KASSERT(xhci_polling_p(sc) || mutex_owned(&sc->sc_lock));
 
 	usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length,
 	    isread ? BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);


Home | Main Index | Thread Index | Old Index