On 25/07/17(Tue) 00:30, sc dying wrote:
> On 2017/07/24 14:35, Martin Pieuchot wrote:
> > [...]
> > Here's a diff to try and play with. I'd guess the problem is in
> > pipe_close(). Which state has the EP you're closing? Do we close
> > the EP correctly?
>
> EP 3 is RX pipe, EP 4 is TX pipe.
> Looks good to me.
Does that mean it works? Do you still see a RXERROR with it?
> > - /* Mask the endpoint */
> > + /* Stop the endpoint */
> > + bus_dmamap_sync(sdev->ictx_dma.tag, sdev->ictx_dma.map, 0,
> > + sc->sc_pagesize, BUS_DMASYNC_POSTREAD);
> > + state = letoh32(XHCI_EPCTX_STATE(sdev->ep_ctx[xp->dci - 1]->info_lo));
>
> Do you wanna see output context (device context, 6.2.1)?
I'm not sure why would I, could you elaborate?
I though the Endpoint Context, sec. 6.2.3, is enough. Updated diff with
a corrected letoh32().
Index: xhci.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/xhci.c,v
retrieving revision 1.73
diff -u -p -r1.73 xhci.c
--- xhci.c 22 Jun 2017 02:44:37 -0000 1.73
+++ xhci.c 27 Jul 2017 12:21:54 -0000
@@ -1251,13 +1251,22 @@ xhci_pipe_close(struct usbd_pipe *pipe)
struct xhci_softc *sc = (struct xhci_softc *)pipe->device->bus;
struct xhci_pipe *lxp, *xp = (struct xhci_pipe *)pipe;
struct xhci_soft_dev *sdev = &sc->sc_sdevs[xp->slot];
+ uint32_t state;
int i;
/* Root Hub */
if (pipe->device->depth == 0)
return;
- /* Mask the endpoint */
+ /* If required, stop the endpoint */
+ bus_dmamap_sync(sdev->ictx_dma.tag, sdev->ictx_dma.map, 0,
+ sc->sc_pagesize, BUS_DMASYNC_POSTREAD);
+ state = XHCI_EPCTX_STATE(letoh32(sdev->ep_ctx[xp->dci - 1]->info_lo));
+ printf("%s: EP %d state=%x\n", DEVNAME(sc), xp->dci, state);
+ if (state != XHCI_EP_STOPPED && xhci_cmd_stop_ep(sc, xp->slot, xp->dci))
+ DPRINTF(("%s: error stopping ep (%d)\n", DEVNAME(sc), xp->dci));
+
+ /* Mask it */
sdev->input_ctx->drop_flags = htole32(XHCI_INCTX_MASK_DCI(xp->dci));
sdev->input_ctx->add_flags = 0;