Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Fix thinko in the handling of FORCE_SHORT_XFER s...



details:   https://anonhg.NetBSD.org/src/rev/0beaecbb826a
branches:  trunk
changeset: 483689:0beaecbb826a
user:      augustss <augustss%NetBSD.org@localhost>
date:      Thu Mar 16 00:41:50 2000 +0000

description:
Fix thinko in the handling of FORCE_SHORT_XFER so that it actually
transfers a 0 length package instead on munging the whole transfer.
The aue driver works now.

diffstat:

 sys/dev/usb/ohci.c |  36 ++++++++++++++++++++++--------------
 1 files changed, 22 insertions(+), 14 deletions(-)

diffs (114 lines):

diff -r 829ff09233bb -r 0beaecbb826a sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c        Wed Mar 15 22:52:14 2000 +0000
+++ b/sys/dev/usb/ohci.c        Thu Mar 16 00:41:50 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ohci.c,v 1.74 2000/02/29 21:37:00 augustss Exp $       */
+/*     $NetBSD: ohci.c,v 1.75 2000/03/16 00:41:50 augustss Exp $       */
 /*     $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $       */
 
 /*
@@ -464,10 +464,10 @@
 }
 
 usbd_status
-ohci_alloc_std_chain(opipe, sc, len, rd, flags, dma, sp, ep)
+ohci_alloc_std_chain(opipe, sc, alen, rd, flags, dma, sp, ep)
        struct ohci_pipe *opipe;
        ohci_softc_t *sc;
-       int len, rd;
+       int alen, rd;
        u_int16_t flags;
        usb_dma_t *dma;
        ohci_soft_td_t *sp, **ep;
@@ -475,9 +475,11 @@
        ohci_soft_td_t *next, *cur;
        ohci_physaddr_t dataphys, dataphysend;
        u_int32_t intr, tdflags;
-       int curlen;
+       int len, curlen;
 
-       DPRINTFN(len < 4096,("ohci_alloc_std_chain: start len=%d\n", len));
+       DPRINTFN(alen < 4096,("ohci_alloc_std_chain: start len=%d\n", alen));
+
+       len = alen;
        cur = sp;
        dataphys = DMAADDR(dma);
        dataphysend = OHCI_PAGE(dataphys + len - 1);
@@ -488,7 +490,7 @@
 
        for (;;) {
                next = ohci_alloc_std(sc);
-               if (next == 0)
+               if (next == NULL)
                        goto nomem;
 
                /* The OHCI hardware can handle at most one page crossing. */
@@ -524,23 +526,26 @@
                cur = next;
        }
        if ((flags & USBD_FORCE_SHORT_XFER) &&
-           len % UGETW(opipe->pipe.endpoint->edesc->wMaxPacketSize) == 0) {
+           alen % UGETW(opipe->pipe.endpoint->edesc->wMaxPacketSize) == 0) {
                /* Force a 0 length transfer at the end. */
+
+               cur->td.td_flags = LE(tdflags | OHCI_TD_NOINTR);
+               cur = next;
+
                next = ohci_alloc_std(sc);
-               if (next == 0)
+               if (next == NULL)
                        goto nomem;
 
                cur->td.td_flags = LE(tdflags | OHCI_TD_SET_DI(1));
                cur->td.td_cbp = 0; /* indicate 0 length packet */
                cur->nexttd = next;
                cur->td.td_nexttd = LE(next->physaddr);
-               cur->td.td_be = LE(dataphys - 1);
+               cur->td.td_be = ~0;
                cur->len = 0;
                cur->flags = 0;
-               cur = next;
                DPRINTFN(2,("ohci_alloc_std_chain: add 0 xfer\n"));
        }
-       cur->flags = OHCI_CALL_DONE | OHCI_ADD_LEN;
+       cur->flags |= OHCI_CALL_DONE;
        *ep = next;
 
        return (USBD_NORMAL_COMPLETION);
@@ -1170,6 +1175,8 @@
                        if (std->td.td_cbp != 0)
                                len -= LE(std->td.td_be) -
                                       LE(std->td.td_cbp) + 1;
+                       DPRINTFN(10, ("ohci_process_done: len=%d, flags=0x%x\n",
+                                     len, std->flags));
                        if (std->flags & OHCI_ADD_LEN)
                                xfer->actlen += len;
                        if (std->flags & OHCI_CALL_DONE) {
@@ -2509,7 +2516,7 @@
                    (int)LE(data->td.td_cbp), (int)LE(data->td.td_be)));
 
 #ifdef OHCI_DEBUG
-       if (ohcidebug > 4) {
+       if (ohcidebug > 5) {
                ohci_dump_ed(sed);
                ohci_dump_tds(data);
        }
@@ -2531,8 +2538,8 @@
 
 #if 0
 /* This goes wrong if we are too slow. */
-       if (ohcidebug > 5) {
-               usb_delay_ms(&sc->sc_bus, 5);
+       if (ohcidebug > 10) {
+               delay(10000);
                DPRINTF(("ohci_device_intr_transfer: status=%x\n",
                         OREAD4(sc, OHCI_COMMAND_STATUS)));
                ohci_dump_ed(sed);
@@ -2826,6 +2833,7 @@
        sitd->itd.itd_bp0 = LE(buf & OHCI_ITD_PAGE_MASK);
        nframes = xfer->nframes;
        offs = buf & OHCI_ITD_OFFSET_MASK;
+       ncross = 0;
        for (i = ncur = 0; i < nframes; i++, ncur++) {
                if (ncur == OHCI_ITD_NOFFSET || /* all offsets used */
                    ncross > 1) {       /* too many page crossings */



Home | Main Index | Thread Index | Old Index