On Sun, Apr 12, 2020 at 09:19:48AM +0200, Patrick Wildt wrote:
> On Sun, Apr 12, 2020 at 05:41:15AM +0000, Mikolaj Kucharski wrote:
> > On Sat, Apr 11, 2020 at 09:46:49PM +0200, Patrick Wildt wrote:
> > > > OpenBSD 6.7-beta (GENERIC.MP) #552: Fri Apr 10 20:48:05 MDT 2020
> > > >     [email protected]:/usr/src/sys/arch/arm64/compile/GENERIC.MP
> > > > 
> > > > panic: _dmamap_sync: ran off map!
> > > 
> > > Oh, wow!  That means that the DMA sync is using a longer length than the
> > > DMA buffer has segments for.  It's very plausible that this happens on
> > > the Pinebook, and not on an x86 machine, because on the Pinebook it has
> > > to do DMA syncs, while on x86 that's essentially a no-op.
> > > 
> > > > Stopped at      panic+0x150:
> > > > TID     PID     UID     PRFLAGS         PFLAGS  CPU     COMMAND
> > > > 242142  87433   0       0x100002        0       3       sha256
> > > > 192114  36379   0       0x14000         0x200   2K      sdmmc2
> > > > db_enter() at panic+0x14c
> > > > panic() at ehci_idone+0x1d4
> > > > ehci_idone() at ehci_softintr+0x158
> > > 
> > > I see!  This is the one.  I think I made a slight error in this
> > > function, since for all the other drivers I made sure to sync only
> > > on successful completions, while for ehci(4) I missed this for one.
> > > 
> > > I think this diff should fix it, can you give it a go?
> > 
> > Unfortunately kernel panics in very similar way:
> 
> Ok, too bad.  I'll reproduce this on my Pinebook and hopefully have an
> update for you soon.
> 
> Patrick

I'm now trying to reproduce it, running this diff.  I'm sure the printfs
will slow the system down, but it's one way to see what's going on.

If you can reproduce it easily, would you mind trying again, with the
debug printfs?

Patrick

diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c
index 41851defe4f..00a9af6903f 100644
--- a/sys/dev/usb/ehci.c
+++ b/sys/dev/usb/ehci.c
@@ -912,13 +912,18 @@ ehci_idone(struct usbd_xfer *xfer)
                        xfer->status = USBD_STALLED;
                else
                        xfer->status = USBD_IOERROR; /* more info XXX */
-       } else
+       } else {
+               if (xfer->actlen) {
+                       printf("ehci_idone: len=%d, actlen=%d, cerr=%d, "
+                           "status=0x%x type=0x%x\n", xfer->length, actlen, 
cerr,
+                           status, 
UE_GET_XFERTYPE(xfer->pipe->endpoint->edesc->bmAttributes));
+                       usb_syncmem(&xfer->dmabuf, 0, xfer->actlen,
+                           usbd_xfer_isread(xfer) ?
+                           BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
+               }
                xfer->status = USBD_NORMAL_COMPLETION;
+       }
 
-       if (xfer->actlen)
-               usb_syncmem(&xfer->dmabuf, 0, xfer->actlen,
-                   usbd_xfer_isread(xfer) ?
-                   BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
        usb_transfer_complete(xfer);
        DPRINTFN(/*12*/2, ("ehci_idone: ex=%p done\n", ex));
 }

Reply via email to