this works
[unix-history] / usr / src / sys / vax / uba / up.c
index 301a889..d8aa654 100644 (file)
@@ -1,13 +1,4 @@
-int    trc = -1;
-int    trcw = 0;
-#define        D(i)    if (trc&(1<<i)) { if (trcw&(1<<i)) DELAY(1000); } else
-int    csdel0 = 30;
-int    csdel1 = 0;
-int    csdel2 = 0;
-int    asdel = 500;
-int    csdel3 = 100;
-int    softas;
-/*     %H%     3.8     %G%     */
+/*     %H%     3.11    %G%     */
 
 /*
  * Emulex UNIBUS disk driver with overlapped seeks and ECC recovery.
 
 /*
  * Emulex UNIBUS disk driver with overlapped seeks and ECC recovery.
@@ -91,6 +82,19 @@ struct       device
        ushort  upec2;          /* burst error bit pattern */
 };
 
        ushort  upec2;          /* burst error bit pattern */
 };
 
+/*
+ * Software extension to the upas register, so we can
+ * postpone starting SEARCH commands until the controller
+ * is not transferring.
+ */
+int    softas;
+
+/*
+ * If upseek then we don't issue SEARCH commands but rather just
+ * settle for a SEEK to the correct cylinder.
+ */
+int    upseek;
+
 #define        UPADDR  ((struct device *)(UBA0_DEV + 0176700))
 
 #define        NUP     2               /* Number of drives this installation */
 #define        UPADDR  ((struct device *)(UBA0_DEV + 0176700))
 
 #define        NUP     2               /* Number of drives this installation */
@@ -101,14 +105,21 @@ struct    device
 /*
  * Constants controlling on-cylinder SEARCH usage.
  *
 /*
  * Constants controlling on-cylinder SEARCH usage.
  *
- * We assume that it takes SDIST sectors of time to set up a transfer.
- * If a drive is on-cylinder, and between SDIST and SDIST+RDIST sectors
- * from the first sector to be transferred, then we just perform the
- * transfer.  SDIST represents interrupt latency, RDIST the amount
- * of rotation which is tolerable to avoid another interrupt.
+ *     SDIST/2 msec            time needed to start transfer
+ *     IDIST/2 msec            slop for interrupt latency
+ *     RDIST/2 msec            tolerable rotational latency when on-cylinder
+ *
+ * If we are no closer than SDIST sectors and no further than SDIST+RDIST
+ * and in the driver then we take it as it is.  Otherwise we do a SEARCH
+ * requesting an interrupt SDIST+IDIST sectors in advance.
  */
  */
-#define        SDIST   3               /* 2-3 sectors 1-1.5 msec */
-#define        RDIST   6               /* 5-6 sectors 2.5-3 msec */
+#define        _SDIST  6               /* 3.0 msec */
+#define        _RDIST  6               /* 2.5 msec */
+#define        _IDIST  1               /* 0.5 msec */
+
+int    SDIST = _SDIST;
+int    RDIST = _RDIST;
+int    IDIST = _IDIST;
 
 /*
  * To fill a 300M drive:
 
 /*
  * To fill a 300M drive:
@@ -181,6 +192,7 @@ struct      buf     rupbuf;                 /* Buffer for raw i/o */
 #define        OFFSET  014             /* Offset heads to try to recover error */
 #define        RTC     016             /* Return to center-line after OFFSET */
 #define        SEARCH  030             /* Search for cylinder+sector */
 #define        OFFSET  014             /* Offset heads to try to recover error */
 #define        RTC     016             /* Return to center-line after OFFSET */
 #define        SEARCH  030             /* Search for cylinder+sector */
+#define        SEEK    04              /* Seek to cylinder */
 #define        RECAL   06              /* Recalibrate, needed after seek error */
 #define        DCLR    010             /* Drive clear, after error */
 #define        WCOM    060             /* Write */
 #define        RECAL   06              /* Recalibrate, needed after seek error */
 #define        DCLR    010             /* Drive clear, after error */
 #define        WCOM    060             /* Write */
@@ -220,6 +232,10 @@ int        up_ubinfo;              /* Information about UBA usage saved here */
  */
 int    idelay = 500;           /* Delay after PRESET or DCLR */
 int    sdelay = 150;           /* Delay after selecting drive in upcs2 */
  */
 int    idelay = 500;           /* Delay after PRESET or DCLR */
 int    sdelay = 150;           /* Delay after selecting drive in upcs2 */
+int    rdelay = 100;           /* Delay after SEARCH */
+int    asdel = 100;            /* Delay after clearing bit in upas */
+
+int    csdel2 = 0;             /* ??? Delay in upstart ??? */
 
 #define        DELAY(N)                { register int d; d = N; while (--d > 0); }
  
 
 #define        DELAY(N)                { register int d; d = N; while (--d > 0); }
  
@@ -260,10 +276,6 @@ register struct buf *bp;
        dp = &uputab[unit];
        (void) spl5();
        disksort(dp, bp);
        dp = &uputab[unit];
        (void) spl5();
        disksort(dp, bp);
-#ifdef UTRACE
-D(1)   ttime();
-D(2)   trace("upstrat bn %d unit %d\n", bp->b_blkno, unit);
-#endif
        if (dp->b_active == 0) {
                (void) upustart(unit);
                if (uptab.b_actf && uptab.b_active == 0)
        if (dp->b_active == 0) {
                (void) upustart(unit);
                if (uptab.b_actf && uptab.b_active == 0)
@@ -286,26 +298,41 @@ register unit;
        int sn, cn, csn;
        int didie = 0;
 
        int sn, cn, csn;
        int didie = 0;
 
-       if (unit >= NUP)
-               goto out;
-       if (uptab.b_active) {
-               softas |= 1<<unit;
-               return;
-       }
-#ifdef UTRACE
-D(3)   ttime();
-D(4)   trace("upustart %d active %d", unit, uputab[unit].b_active);
-#endif
        /*
        /*
-        * Whether or not it was before, this unit is no longer busy.
-        * Check to see if there is (still or now) a request in this
-        * drives queue, and if there is, select this unit.
+        * Other drivers tend to say something like
+        *      upaddr->upcs1 = IE;
+        *      upaddr->upas = 1<<unit;
+        * here, but the SC-11B will cancel a command which
+        * happens to be sitting in the cs1 if you clear the go
+        * bit by storing there (so the first is not safe),
+        * and it also does not like being bothered with operations
+        * such as clearing upas when a transfer is active (as
+        * it may well be.)
+        *
+        * Thus we keep careful track of when we re-enable IE
+        * after an interrupt and do it only if we didn't issue
+        * a command which re-enabled it as a matter of course.
+        * We clear bits in upas in the interrupt routine, when
+        * no transfers are active.
         */
         */
+       if (unit >= NUP)
+               goto out;
        if (unit+DK_N <= DK_NMAX)
                dk_busy &= ~(1<<(unit+DK_N));
        dp = &uputab[unit];
        if ((bp = dp->b_actf) == NULL)
                goto out;
        if (unit+DK_N <= DK_NMAX)
                dk_busy &= ~(1<<(unit+DK_N));
        dp = &uputab[unit];
        if ((bp = dp->b_actf) == NULL)
                goto out;
+       /*
+        * The SC-11B doesn't start SEARCH commands when transfers are
+        * in progress.  In fact, it tends to get confused when given
+        * SEARCH'es during transfers, generating interrupts with neither
+        * RDY nor a bit in the upas register.  Thus we defer
+        * until an interrupt when a transfer is pending.
+        */
+       if (uptab.b_active) {
+               softas |= 1<<unit;
+               return (0);
+       }
        if ((upaddr->upcs2 & 07) != unit) {
                upaddr->upcs2 = unit;
                DELAY(sdelay);
        if ((upaddr->upcs2 & 07) != unit) {
                upaddr->upcs2 = unit;
                DELAY(sdelay);
@@ -314,57 +341,30 @@ D(4)      trace("upustart %d active %d", unit, uputab[unit].b_active);
                neasycs2++;
        /*
         * If we have changed packs or just initialized,
                neasycs2++;
        /*
         * If we have changed packs or just initialized,
-        * the the volume will not be valid; if so, clear
+        * then the volume will not be valid; if so, clear
         * the drive, preset it and put in 16bit/word mode.
         */
        if ((upaddr->upds & VV) == 0) {
         * the drive, preset it and put in 16bit/word mode.
         */
        if ((upaddr->upds & VV) == 0) {
-#ifdef UTRACE
-D(5)           trace(" not VV");
-#endif
                upaddr->upcs1 = IE|DCLR|GO;
                DELAY(idelay);
                upaddr->upcs1 = IE|PRESET|GO;
                DELAY(idelay);
                upaddr->upof = FMT22;
                upaddr->upcs1 = IE|DCLR|GO;
                DELAY(idelay);
                upaddr->upcs1 = IE|PRESET|GO;
                DELAY(idelay);
                upaddr->upof = FMT22;
+               printf("VV done ds %o, er? %o %o %o\n", upaddr->upds, upaddr->uper1, upaddr->uper2, upaddr->uper3);
                didie = 1;
        }
                didie = 1;
        }
-       /*
-        * We are called from upstrategy when a new request arrives
-        * if we are not already active (with dp->b_active == 0),
-        * and we then set dp->b_active to 1 if we are to SEARCH
-        * for the desired cylinder, or 2 if we are on-cylinder.
-        * If we SEARCH then we will later be called from upintr()
-        * when the search is complete, and will link this disk onto
-        * the uptab.  We then set dp->b_active to 2 so that upintr()
-        * will not call us again.
-        *
-        * NB: Other drives clear the bit in the attention status
-        * (i.e. upas) register corresponding to the drive when they
-        * place the drive on the ready (i.e. uptab) queue.  This does
-        * not work with the Emulex, as the controller hangs the UBA
-        * of the VAX shortly after the upas register is set, for
-        * reasons unknown.  This only occurs in multi-spindle configurations,
-        * but to avoid the problem we use the fact that dp->b_active is
-        * 2 to replace the clearing of the upas bit.
-        */
        if (dp->b_active)
                goto done;
        dp->b_active = 1;
        if ((upaddr->upds & (DPR|MOL)) != (DPR|MOL))
        if (dp->b_active)
                goto done;
        dp->b_active = 1;
        if ((upaddr->upds & (DPR|MOL)) != (DPR|MOL))
-               goto done;      /* Will redetect error in upstart() soon */
-
+               goto done;
        /*
         * Do enough of the disk address decoding to determine
         * which cylinder and sector the request is on.
        /*
         * Do enough of the disk address decoding to determine
         * which cylinder and sector the request is on.
-        * Then compute the number of the sector SDIST sectors before
-        * the one where the transfer is to start, this being the
-        * point where we wish to attempt to begin the transfer,
-        * allowing approximately SDIST/2 msec for interrupt latency
-        * and preparation of the request.
-        *
         * If we are on the correct cylinder and the desired sector
         * lies between SDIST and SDIST+RDIST sectors ahead of us, then
         * we don't bother to SEARCH but just begin the transfer asap.
         * If we are on the correct cylinder and the desired sector
         * lies between SDIST and SDIST+RDIST sectors ahead of us, then
         * we don't bother to SEARCH but just begin the transfer asap.
+        * Otherwise ask for a interrupt SDIST+IDIST sectors ahead.
         */
        bn = dkblock(bp);
        cn = bp->b_cylin;
         */
        bn = dkblock(bp);
        cn = bp->b_cylin;
@@ -373,6 +373,8 @@ D(5)                trace(" not VV");
 
        if (cn - upaddr->updc)
                goto search;            /* Not on-cylinder */
 
        if (cn - upaddr->updc)
                goto search;            /* Not on-cylinder */
+       else if (upseek)
+               goto done;              /* Ok just to be on-cylinder */
        csn = (upaddr->upla>>6) - sn - 1;
        if (csn < 0)
                csn += NSECT;
        csn = (upaddr->upla>>6) - sn - 1;
        if (csn < 0)
                csn += NSECT;
@@ -380,13 +382,13 @@ D(5)              trace(" not VV");
                goto done;
 
 search:
                goto done;
 
 search:
-#ifdef UTRACE
-D(6)   trace(" search %d@%d to %d@%d", upaddr->updc, (upaddr->upla>>6),
-           cn, sn);
-#endif
        upaddr->updc = cn;
        upaddr->updc = cn;
-       upaddr->upda = sn;
-       upaddr->upcs1 = IE|SEARCH|GO;
+       if (upseek)
+               upaddr->upcs1 = IE|SEEK|GO;
+       else {
+               upaddr->upda = sn;
+               upaddr->upcs1 = IE|SEARCH|GO;
+       }
        didie = 1;
        /*
         * Mark this unit busy.
        didie = 1;
        /*
         * Mark this unit busy.
@@ -396,19 +398,14 @@ D(6)      trace(" search %d@%d to %d@%d", upaddr->updc, (upaddr->upla>>6),
                dk_busy |= 1<<unit;
                dk_numb[unit]++;
        }
                dk_busy |= 1<<unit;
                dk_numb[unit]++;
        }
-       if (csdel0) DELAY(csdel0);
+       DELAY(rdelay);
        goto out;
 
 done:
        /*
        goto out;
 
 done:
        /*
-        * This unit is ready to go.  Make active == 2 so
-        * we won't get called again (by upintr() because upas&(1<<unit))
-        * and link us onto the chain of ready disks.
+        * This unit is ready to go so
+        * link it onto the chain of ready disks.
         */
         */
-#ifdef UTRACE
-D(7)   trace(" done");
-#endif
-       dp->b_active = 2;
        dp->b_forw = NULL;
        if (uptab.b_actf == NULL)
                uptab.b_actf = dp;
        dp->b_forw = NULL;
        if (uptab.b_actf == NULL)
                uptab.b_actf = dp;
@@ -417,10 +414,6 @@ D(7)       trace(" done");
        uptab.b_actl = dp;
 
 out:
        uptab.b_actl = dp;
 
 out:
-       if (csdel1) DELAY(csdel1);
-#ifdef UTRACE
-D(8)   trace("\n");
-#endif
        return (didie);
 }
 
        return (didie);
 }
 
@@ -437,10 +430,6 @@ upstart()
 
 loop:
        if (csdel2) DELAY(csdel2);
 
 loop:
        if (csdel2) DELAY(csdel2);
-#ifdef UTRACE
-D(9)   ttime();
-D(10)  trace("upstart");
-#endif
        /*
         * Pick a drive off the queue of ready drives, and
         * perform the first transfer on its queue.
        /*
         * Pick a drive off the queue of ready drives, and
         * perform the first transfer on its queue.
@@ -449,12 +438,8 @@ D(10)      trace("upstart");
         * are not present and on-line, for which we completely clear the
         * request queue.
         */
         * are not present and on-line, for which we completely clear the
         * request queue.
         */
-       if ((dp = uptab.b_actf) == NULL) {
-#ifdef UTRACE
-D(11)          trace("\n");
-#endif
+       if ((dp = uptab.b_actf) == NULL)
                return (0);
                return (0);
-       }
        if ((bp = dp->b_actf) == NULL) {
                uptab.b_actf = dp->b_forw;
                goto loop;
        if ((bp = dp->b_actf) == NULL) {
                uptab.b_actf = dp->b_forw;
                goto loop;
@@ -473,19 +458,13 @@ D(11)             trace("\n");
        tn = sn/NSECT;
        sn %= NSECT;
        upaddr = UPADDR;
        tn = sn/NSECT;
        sn %= NSECT;
        upaddr = UPADDR;
-#ifdef UTRACE
-D(12)  trace(" unit %d", dn);
-#endif
        if ((upaddr->upcs2 & 07) != dn) {
        if ((upaddr->upcs2 & 07) != dn) {
-#ifdef UTRACE
-D(13)          trace(" select");
-#endif
                upaddr->upcs2 = dn;
                upaddr->upcs2 = dn;
-               DELAY(sdelay);
+               /* DELAY(sdelay);               Provided by ubasetup() */
                nwaitcs2++;
        } else
                neasycs2++;
                nwaitcs2++;
        } else
                neasycs2++;
-       up_ubinfo = ubasetup(bp, 1);    /* In a funny place for delay... */
+       up_ubinfo = ubasetup(bp, 1);    /* Providing delay */
        /*
         * If drive is not present and on-line, then
         * get rid of this with an error and loop to get
        /*
         * If drive is not present and on-line, then
         * get rid of this with an error and loop to get
@@ -493,9 +472,7 @@ D(13)               trace(" select");
         * (Then on to any other ready drives.)
         */
        if ((upaddr->upds & (DPR|MOL)) != (DPR|MOL)) {
         * (Then on to any other ready drives.)
         */
        if ((upaddr->upds & (DPR|MOL)) != (DPR|MOL)) {
-#ifdef UTRACE
-D(14)          trace(" !(DPR && MOL)");
-#endif
+               printf("!DPR || !MOL, unit %d, ds %o\n", dn, upaddr->upds);
                uptab.b_active = 0;
                uptab.b_errcnt = 0;
                dp->b_actf = bp->av_forw;
                uptab.b_active = 0;
                uptab.b_errcnt = 0;
                dp->b_actf = bp->av_forw;
@@ -510,9 +487,6 @@ D(14)               trace(" !(DPR && MOL)");
         * begin to try offsetting the heads to recover the data.
         */
        if (uptab.b_errcnt >= 16) {
         * begin to try offsetting the heads to recover the data.
         */
        if (uptab.b_errcnt >= 16) {
-#ifdef UTRACE
-D(15)          trace(" offset");
-#endif
                upaddr->upof = up_offset[uptab.b_errcnt & 017] | FMT22;
                upaddr->upcs1 = IE|OFFSET|GO;
                DELAY(idelay);
                upaddr->upof = up_offset[uptab.b_errcnt & 017] | FMT22;
                upaddr->upcs1 = IE|OFFSET|GO;
                DELAY(idelay);
@@ -524,11 +498,6 @@ D(15)              trace(" offset");
         * 2 bits of the UNIBUS address from the information
         * returned by ubasetup() for the cs1 register bits 8 and 9.
         */
         * 2 bits of the UNIBUS address from the information
         * returned by ubasetup() for the cs1 register bits 8 and 9.
         */
-#ifdef UTRACE
-D(16)  trace(" %s %d.%d@%d cnt %d ba %x\n",
-           (bp->b_flags&B_READ) ? "read" : "write",
-           cn, tn, sn, bp->b_bcount, up_ubinfo & 0x3ffff);
-#endif
        upaddr->updc = cn;
        upaddr->upda = (tn << 8) + sn;
        upaddr->upba = up_ubinfo;
        upaddr->updc = cn;
        upaddr->upda = (tn << 8) + sn;
        upaddr->upba = up_ubinfo;
@@ -539,9 +508,6 @@ D(16)       trace(" %s %d.%d@%d cnt %d ba %x\n",
        else
                cmd |= IE|WCOM|GO;
        upaddr->upcs1 = cmd;
        else
                cmd |= IE|WCOM|GO;
        upaddr->upcs1 = cmd;
-#ifdef notdef
-       if (csdel3) DELAY(csdel3);
-#endif
        /*
         * This is a controller busy situation.
         * Record in dk slot NUP+DK_N (after last drive)
        /*
         * This is a controller busy situation.
         * Record in dk slot NUP+DK_N (after last drive)
@@ -578,10 +544,6 @@ upintr()
        int osoftas;
        int needie = 1;
 
        int osoftas;
        int needie = 1;
 
-#ifdef UTRACE
-D(17)  ttime();
-D(18)  trace("upintr as %d act %d %d %d;", as, uptab.b_active, uputab[0].b_active, uputab[1].b_active);
-#endif
        if (uptab.b_active) {
                /*
                 * The drive is transferring, thus the hardware
        if (uptab.b_active) {
                /*
                 * The drive is transferring, thus the hardware
@@ -589,9 +551,6 @@ D(18)       trace("upintr as %d act %d %d %d;", as, uptab.b_active, uputab[0].b_active
                 * completes; check for it anyways.
                 */
                if ((upaddr->upcs1 & RDY) == 0) {
                 * completes; check for it anyways.
                 */
                if ((upaddr->upcs1 & RDY) == 0) {
-#ifdef UTRACE
-D(19)                  trace(" !RDY");
-#endif
                        printf("!RDY: cs1 %o, ds %o, wc %d\n", upaddr->upcs1,
                            upaddr->upds, upaddr->upwc);
 printf("as=%d act %d %d %d\n", as, uptab.b_active, uputab[0].b_active, uputab[1].b_active);
                        printf("!RDY: cs1 %o, ds %o, wc %d\n", upaddr->upcs1,
                            upaddr->upds, upaddr->upwc);
 printf("as=%d act %d %d %d\n", as, uptab.b_active, uputab[0].b_active, uputab[1].b_active);
@@ -607,25 +566,20 @@ printf("as=%d act %d %d %d\n", as, uptab.b_active, uputab[0].b_active, uputab[1]
                        dk_busy &= ~(1<<(DK_N+NUP));
                else if (DK_N+unit <= DK_NMAX)
                        dk_busy &= ~(1<<(DK_N+unit));
                        dk_busy &= ~(1<<(DK_N+NUP));
                else if (DK_N+unit <= DK_NMAX)
                        dk_busy &= ~(1<<(DK_N+unit));
-               if (upaddr->upcs1 & TRE) {
-#ifdef UTRACE
-D(20)                  trace(" TRE");
-#endif
+               if ((upaddr->upcs2 & 07) != unit) {
+                       upaddr->upcs2 = unit;
+                       DELAY(sdelay);
+                       nwaitcs2++;
+               } else
+                       neasycs2++;
+               if (upaddr->upds & ERR) {
                        /*
                         * An error occurred, indeed.  Select this unit
                         * to get at the drive status (a SEARCH may have
                         * intervened to change the selected unit), and
                         * wait for the command which caused the interrupt
                         * to complete (DRY).
                        /*
                         * An error occurred, indeed.  Select this unit
                         * to get at the drive status (a SEARCH may have
                         * intervened to change the selected unit), and
                         * wait for the command which caused the interrupt
                         * to complete (DRY).
-                        *
-                        * WHY IS THE WAIT NECESSARY?
                         */
                         */
-                       if ((upaddr->upcs2 & 07) != unit) {
-                               upaddr->upcs2 = unit;
-                               DELAY(sdelay);
-                               nwaitcs2++;
-                       } else
-                               neasycs2++;
                        while ((upaddr->upds & DRY) == 0)
                                DELAY(25);
                        /*
                        while ((upaddr->upds & DRY) == 0)
                                DELAY(25);
                        /*
@@ -675,22 +629,13 @@ D(20)                     trace(" TRE");
                 * on this drive with the upustart routine (if any).
                 */
                if (uptab.b_active) {
                 * on this drive with the upustart routine (if any).
                 */
                if (uptab.b_active) {
-#ifdef UTRACE
-D(21)                  trace(" unit %d", unit);
-#endif
                        if ((upaddr->upcs2 & 07) != unit) {
                        if ((upaddr->upcs2 & 07) != unit) {
-#ifdef UTRACE
-D(22)                          trace(" select");
-#endif
                                upaddr->upcs2 = unit;
                                DELAY(sdelay);
                                nwaitcs2++;
                        } else
                                neasycs2++;
                        if (uptab.b_errcnt >= 16) {
                                upaddr->upcs2 = unit;
                                DELAY(sdelay);
                                nwaitcs2++;
                        } else
                                neasycs2++;
                        if (uptab.b_errcnt >= 16) {
-#ifdef UTRACE
-D(23)                          trace(" rtc");
-#endif
                                upaddr->upcs1 = RTC|GO|IE;
                                DELAY(idelay);
                                while (upaddr->upds & PIP)
                                upaddr->upcs1 = RTC|GO|IE;
                                DELAY(idelay);
                                while (upaddr->upds & PIP)
@@ -704,6 +649,9 @@ D(23)                               trace(" rtc");
                        dp->b_errcnt = 0;
                        dp->b_actf = bp->av_forw;
                        bp->b_resid = (-upaddr->upwc * sizeof(short));
                        dp->b_errcnt = 0;
                        dp->b_actf = bp->av_forw;
                        bp->b_resid = (-upaddr->upwc * sizeof(short));
+                       if (bp->b_resid)
+                               printf("resid %d ds %o er? %o %o %o\n", bp->b_resid, upaddr->upds,
+                                   upaddr->uper1, upaddr->uper2, upaddr->uper3);
                        iodone(bp);
                        if(dp->b_actf)
                                if (upustart(unit))
                        iodone(bp);
                        if(dp->b_actf)
                                if (upustart(unit))
@@ -712,18 +660,12 @@ D(23)                             trace(" rtc");
                as &= ~(1<<unit);
                softas &= ~(1<<unit);
                ubafree(up_ubinfo), up_ubinfo = 0;
                as &= ~(1<<unit);
                softas &= ~(1<<unit);
                ubafree(up_ubinfo), up_ubinfo = 0;
-       }
-#ifndef notdef
-       else {
+       } else {
                if (upaddr->upcs1 & TRE) {
                if (upaddr->upcs1 & TRE) {
-#ifdef UTRACE
-D(24)                  trace(" TRE");
-#endif
                        upaddr->upcs1 = TRE;
                        DELAY(idelay);
                }
        }
                        upaddr->upcs1 = TRE;
                        DELAY(idelay);
                }
        }
-#endif
        /*
         * If we have a unit with an outstanding SEARCH,
         * and the hardware indicates the unit requires attention,
        /*
         * If we have a unit with an outstanding SEARCH,
         * and the hardware indicates the unit requires attention,
@@ -731,47 +673,24 @@ D(24)                     trace(" TRE");
         * Finally, if the controller is not transferring
         * start it if any drives are now ready to transfer.
         */
         * Finally, if the controller is not transferring
         * start it if any drives are now ready to transfer.
         */
-#ifdef UTRACE
-D(25)  trace("\n");
-#endif
        as |= softas;
        osoftas = softas;
        softas = 0;
        for (unit = 0; unit < NUP; unit++)
        as |= softas;
        osoftas = softas;
        softas = 0;
        for (unit = 0; unit < NUP; unit++)
-               if ((as|osoftas) & (1<<unit))
-/*
-                       if (uputab[unit].b_active == 1) {
-*/
-                       {
-                               if (as & (1<<unit)) {
+               if ((as|osoftas) & (1<<unit)) {
+                       if (as & (1<<unit)) {
                                upaddr->upas = 1<<unit;
                                upaddr->upas = 1<<unit;
-#ifdef UTRACE
-D(26)                          trace("as clear %d\n", unit);
-#endif
                                if (asdel) DELAY(asdel);
                                if (asdel) DELAY(asdel);
-                               }
-                               if (upustart(unit))
-                                       needie = 0;
-                       }
-/*
-                       } else {
-                               upaddr->upas = 1<<unit;
-#ifdef UTRACE
-D(27)                          trace("spurious as clear %d\n", unit);
-#endif
-                               DELAY(1000);
                        }
                        }
-*/
+                       if (upustart(unit))
+                               needie = 0;
+               }
        if (uptab.b_actf && uptab.b_active == 0)
                if (upstart())
                        needie = 0;
 out:
        if (uptab.b_actf && uptab.b_active == 0)
                if (upstart())
                        needie = 0;
 out:
-       if (needie) {
-#ifdef UTRACE
-D(28)          trace("upintr set IE\n");
-#endif
+       if (needie)
                upaddr->upcs1 = IE;
                upaddr->upcs1 = IE;
-       }
 }
 
 upread(dev)
 }
 
 upread(dev)