Source-Changes-HG archive

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

[src/netbsd-1-5]: src/sys/dev/i2o Pull up revisions 1.19-1.23 (via patch, req...



details:   https://anonhg.NetBSD.org/src/rev/264da48a7f7d
branches:  netbsd-1-5
changeset: 492949:264da48a7f7d
user:      he <he%NetBSD.org@localhost>
date:      Sat Mar 09 19:38:16 2002 +0000

description:
Pull up revisions 1.19-1.23 (via patch, requested by ad):
  Use variable frame size to enable dpti firmware upgrades.
  Don't explode if the board doesn't respond during initialization.

diffstat:

 sys/dev/i2o/iop.c |  57 ++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 38 insertions(+), 19 deletions(-)

diffs (187 lines):

diff -r 35c8d2c452c9 -r 264da48a7f7d sys/dev/i2o/iop.c
--- a/sys/dev/i2o/iop.c Sat Mar 09 18:56:12 2002 +0000
+++ b/sys/dev/i2o/iop.c Sat Mar 09 19:38:16 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iop.c,v 1.19.4.3 2001/12/09 19:11:16 he Exp $  */
+/*     $NetBSD: iop.c,v 1.19.4.4 2002/03/09 19:38:16 he Exp $  */
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -288,7 +288,6 @@
                    sc->sc_dv.dv_xname);
                return;
        }
-       state++;
 
        if (bus_dmamem_alloc(sc->sc_dmat, NBPG, NBPG, 0,
            sc->sc_scr_seg, 1, &nsegs, BUS_DMA_NOWAIT) != 0) {
@@ -312,6 +311,11 @@
        }
        state++;
 
+#ifdef I2ODEBUG
+       /* So that our debug checks don't choke. */
+       sc->sc_framesize = 128;
+#endif
+
        /* Reset the adapter and request status. */
        if ((rv = iop_reset(sc)) != 0) {
                printf("%s: not responding (reset)\n", sc->sc_dv.dv_xname);
@@ -350,9 +354,25 @@
        sc->sc_maxib = le32toh(sc->sc_status.maxinboundmframes);
        if (sc->sc_maxib > IOP_MAX_INBOUND)
                sc->sc_maxib = IOP_MAX_INBOUND;
+       sc->sc_framesize = le16toh(sc->sc_status.inboundmframesize) << 2;
+       if (sc->sc_framesize > IOP_MAX_MSG_SIZE)
+               sc->sc_framesize = IOP_MAX_MSG_SIZE;
+
+#if defined(I2ODEBUG) || defined(DIAGNOSTIC)
+       if (sc->sc_framesize < IOP_MIN_MSG_SIZE) {
+               printf("%s: frame size too small (%d)\n",
+                   sc->sc_dv.dv_xname, sc->sc_framesize);
+               return;
+       }
+#endif
 
        /* Allocate message wrappers. */
        im = malloc(sizeof(*im) * sc->sc_maxib, M_DEVBUF, M_NOWAIT);
+       if (im == NULL) {
+               printf("%s: memory allocation failure\n", sc->sc_dv.dv_xname);
+               goto bail_out;
+       }
+       state++;
        memset(im, 0, sizeof(*im) * sc->sc_maxib);
        sc->sc_ims = im;
        SLIST_INIT(&sc->sc_im_freelist);
@@ -421,7 +441,6 @@
        if (state > 0)
                bus_dmamem_free(sc->sc_dmat, sc->sc_scr_seg, nsegs);
        bus_dmamap_destroy(sc->sc_dmat, sc->sc_scr_dmamap);
-
 }
 
 /*
@@ -930,9 +949,10 @@
                        tsleep(iop_status_get, PWAIT, "iopstat", hz / 10);
        }
 
-       if (st->syncbyte != 0xff)
+       if (st->syncbyte != 0xff) {
+               printf("%s: STATUS_GET timed out\n", sc->sc_dv.dv_xname);
                rv = EIO;
-       else {
+       } else {
                memcpy(&sc->sc_status, st, sizeof(sc->sc_status));
                rv = 0;
        }
@@ -960,7 +980,7 @@
        mf->msgictx = IOP_ICTX;
        mf->msgtctx = 0;
        mf->pagesize = NBPG;
-       mf->flags = IOP_INIT_CODE | ((IOP_MAX_MSG_SIZE >> 2) << 16);
+       mf->flags = IOP_INIT_CODE | ((sc->sc_framesize >> 2) << 16);
 
        /*
         * The I2O spec says that there are two SGLs: one for the status
@@ -994,7 +1014,7 @@
 
        /* Allocate DMA safe memory for the reply frames. */
        if (sc->sc_rep_phys == 0) {
-               sc->sc_rep_size = sc->sc_maxob * IOP_MAX_MSG_SIZE;
+               sc->sc_rep_size = sc->sc_maxob * sc->sc_framesize;
 
                rv = bus_dmamem_alloc(sc->sc_dmat, sc->sc_rep_size, NBPG,
                    0, &seg, 1, &rseg, BUS_DMA_NOWAIT);
@@ -1032,7 +1052,7 @@
        /* Populate the outbound FIFO. */
        for (i = sc->sc_maxob, addr = sc->sc_rep_phys; i != 0; i--) {
                iop_outl(sc, IOP_REG_OFIFO, (u_int32_t)addr);
-               addr += IOP_MAX_MSG_SIZE;
+               addr += sc->sc_framesize;
        }
 
        return (0);
@@ -1600,7 +1620,7 @@
 
        /* Perform reply queue DMA synchronisation. */
        bus_dmamap_sync(sc->sc_dmat, sc->sc_rep_dmamap, off,
-           IOP_MAX_MSG_SIZE, BUS_DMASYNC_POSTREAD);
+           sc->sc_framesize, BUS_DMASYNC_POSTREAD);
        if (--sc->sc_curib != 0)
                bus_dmamap_sync(sc->sc_dmat, sc->sc_rep_dmamap,
                    0, sc->sc_rep_size, BUS_DMASYNC_PREREAD);
@@ -1690,7 +1710,7 @@
                if (im->im_rb != NULL) {
                        size = (le32toh(rb->msgflags) >> 14) & ~3;
 #ifdef I2ODEBUG
-                       if (size > IOP_MAX_MSG_SIZE)
+                       if (size > sc->sc_framesize)
                                panic("iop_handle_reply: reply too large");
 #endif
                        memcpy(im->im_rb, rb, size);
@@ -1864,7 +1884,7 @@
         */
        off = mb[0] >> 16;
        p = mb + off;
-       nsegs = ((IOP_MAX_MSG_SIZE / 4) - off) >> 1;
+       nsegs = ((sc->sc_framesize >> 2) - off) >> 1;
 
        if (dm->dm_nsegs > nsegs) {
                bus_dmamap_unload(sc->sc_dmat, ix->ix_map);
@@ -1950,7 +1970,7 @@
                return (rv);
 
        off = mb[0] >> 16;
-       nsegs = ((IOP_MAX_MSG_SIZE / 4) - off) >> 1;
+       nsegs = ((sc->sc_framesize >> 2) - off) >> 1;
 
        /*
         * If the transfer is highly fragmented and won't fit using SIMPLE
@@ -2054,7 +2074,7 @@
        int s;
 
 #ifdef I2ODEBUG
-       if ((mb[0] >> 16) > IOP_MAX_MSG_SIZE / 4)
+       if ((mb[0] >> 16) > (sc->sc_framesize >> 2))
                panic("iop_post: frame too large");
 #endif
 
@@ -2267,7 +2287,7 @@
 
        printf("%s: WARNING: transport failure:\n", sc->sc_dv.dv_xname);
 
-       printf("%s:   ictx=0x%08x tctx=0x%08x\n", sc->sc_dv.dv_xname,
+       printf("%s:  ictx=0x%08x tctx=0x%08x\n", sc->sc_dv.dv_xname,
            le32toh(fn->msgictx), le32toh(fn->msgtctx));
        printf("%s:  failurecode=0x%02x severity=0x%02x\n",
            sc->sc_dv.dv_xname, fn->failurecode, fn->severity);
@@ -2521,8 +2541,7 @@
        im = NULL;
        mapped = 1;
 
-       if (pt->pt_msglen > IOP_MAX_MSG_SIZE ||
-           pt->pt_msglen > (le16toh(sc->sc_status.inboundmframesize) << 2) ||
+       if (pt->pt_msglen > sc->sc_framesize ||
            pt->pt_msglen < sizeof(struct i2o_msg) ||
            pt->pt_nbufs > IOP_MAX_MSG_XFERS ||
            pt->pt_nbufs < 0 || pt->pt_replylen < 0 ||
@@ -2535,7 +2554,7 @@
                        goto bad;
                }
 
-       mf = malloc(IOP_MAX_MSG_SIZE, M_DEVBUF, M_WAITOK);
+       mf = malloc(sc->sc_framesize, M_DEVBUF, M_WAITOK);
        if (mf == NULL)
                return (ENOMEM);
 
@@ -2560,8 +2579,8 @@
                goto bad;
 
        i = (le32toh(im->im_rb->msgflags) >> 14) & ~3;
-       if (i > IOP_MAX_MSG_SIZE)
-               i = IOP_MAX_MSG_SIZE;
+       if (i > sc->sc_framesize)
+               i = sc->sc_framesize;
        if (i > pt->pt_replylen)
                i = pt->pt_replylen;
        rv = copyout(im->im_rb, pt->pt_reply, i);



Home | Main Index | Thread Index | Old Index