tech-kern archive

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

Re: USB error checking



On 28/12/2018 17:38, Robert Swindells wrote:

I posted a few weeks ago that I could reboot my Pinebook by doing:

% cat /dev/video0 > foo.jpg

I have now got it to drop into DDB and found that it is triggering an
assertion in sys/arch/arm/arm32/bus_dma.c:_bus_dmamap_sync().

         KASSERTMSG(len > 0 && offset + len <= map->dm_mapsize,
             "len %lu offset %lu mapsize %lu",
             len, offset, map->dm_mapsize);

with len = 0.


The attached should avoid the KASSERT. It's interesting as something must be requesting a ZLP (or there's a bug). An ECHI_DEBUG/ehcidebug=1 log when it happens would be interesting.

Thanks,
Nick

Index: sys/dev/usb/ehci.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/ehci.c,v
retrieving revision 1.265
diff -u -p -r1.265 ehci.c
--- sys/dev/usb/ehci.c	18 Sep 2018 02:00:06 -0000	1.265
+++ sys/dev/usb/ehci.c	29 Dec 2018 09:42:25 -0000
@@ -4025,8 +4025,9 @@ ehci_device_bulk_done(struct usbd_xfer *
 
 	KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(&sc->sc_lock));
 
-	usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length,
-	    rd ? BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
+	if (xfer->ux_length)
+		usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length,
+		    rd ? BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
 
 	DPRINTF("length=%jd", xfer->ux_actlen, 0, 0, 0);
 }
@@ -4242,8 +4243,9 @@ ehci_device_intr_done(struct usbd_xfer *
 
 	endpt = epipe->pipe.up_endpoint->ue_edesc->bEndpointAddress;
 	isread = UE_GET_DIR(endpt) == UE_DIR_IN;
-	usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length,
-	    isread ? BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
+	if (xfer->ux_length)
+		usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length,
+		    isread ? BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
 }
 
 /************************/
@@ -4608,8 +4610,9 @@ ehci_device_fs_isoc_done(struct usbd_xfe
 	epipe->isoc.cur_xfers--;
 	ehci_remove_sitd_chain(sc, exfer->ex_itdstart);
 
-	usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length,
-	    BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
+	if (xfer->ux_length)
+		usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length,
+		    BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
 }
 
 
@@ -5000,6 +5003,7 @@ ehci_device_isoc_done(struct usbd_xfer *
 
 	epipe->isoc.cur_xfers--;
 	ehci_remove_itd_chain(sc, exfer->ex_sitdstart);
-	usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length,
-	    BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
+	if (xfer->ux_length)
+		usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length,
+		    BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
 }


Home | Main Index | Thread Index | Old Index