ubafree() becomes ubarelse() to fix race conditions
[unix-history] / usr / src / sys / vax / uba / up.c
index e4c9df5..fe6fed6 100644 (file)
@@ -1,9 +1,9 @@
-/*     up.c    4.    %G%     */
+/*     up.c    4.10    %G%     */
 
 
-#include "../conf/up.h"
+#include "up.h"
 #if NUP > 0
 #if NUP > 0
-#ifdef SC11
-#include "up.c.SC11"
+#if SC11 > 0
+#include "../dev/up.c.SC11"
 #else
 /*
  * UNIBUS disk driver with overlapped seeks and ECC recovery.
 #else
 /*
  * UNIBUS disk driver with overlapped seeks and ECC recovery.
@@ -228,8 +228,8 @@ register struct buf *bp;
                iodone(bp);
                return;
        }
                iodone(bp);
                return;
        }
-       if (DK_N+unit <= DK_NMAX)
-               dk_mspw[DK_N+unit] = .0000020345;
+       if (UPDK_N+unit <= UPDK_NMAX)
+               dk_mspw[UPDK_N+unit] = .0000020345;
        bp->b_cylin = bn/(NSECT*NTRAC) + up_sizes[xunit&07].cyloff;
        dp = &uputab[unit];
        (void) spl5();
        bp->b_cylin = bn/(NSECT*NTRAC) + up_sizes[xunit&07].cyloff;
        dp = &uputab[unit];
        (void) spl5();
@@ -272,8 +272,8 @@ register unit;
         */
        if (unit >= NUP)
                goto out;
         */
        if (unit >= NUP)
                goto out;
-       if (unit+DK_N <= DK_NMAX)
-               dk_busy &= ~(1<<(unit+DK_N));
+       if (unit+UPDK_N <= UPDK_NMAX)
+               dk_busy &= ~(1<<(unit+UPDK_N));
        dp = &uputab[unit];
        if ((bp = dp->b_actf) == NULL)
                goto out;
        dp = &uputab[unit];
        if ((bp = dp->b_actf) == NULL)
                goto out;
@@ -341,8 +341,8 @@ search:
        /*
         * Mark this unit busy.
         */
        /*
         * Mark this unit busy.
         */
-       unit += DK_N;
-       if (unit <= DK_NMAX) {
+       unit += UPDK_N;
+       if (unit <= UPDK_NMAX) {
                dk_busy |= 1<<unit;
                dk_seek[unit]++;
        }
                dk_busy |= 1<<unit;
                dk_seek[unit]++;
        }
@@ -424,7 +424,7 @@ loop:
                        bp->b_flags |= B_ERROR;
                        iodone(bp);
                        /* A funny place to do this ... */
                        bp->b_flags |= B_ERROR;
                        iodone(bp);
                        /* A funny place to do this ... */
-                       ubafree(up_ubinfo), up_ubinfo = 0;
+                       ubarelse(&up_ubinfo);
                        goto loop;
                }
                printf("-- came back\n");
                        goto loop;
                }
                printf("-- came back\n");
@@ -456,13 +456,13 @@ loop:
        upaddr->upcs1 = cmd;
        /*
         * This is a controller busy situation.
        upaddr->upcs1 = cmd;
        /*
         * This is a controller busy situation.
-        * Record in dk slot NUP+DK_N (after last drive)
+        * Record in dk slot NUP+UPDK_N (after last drive)
         * unless there aren't that many slots reserved for
         * us in which case we record this as a drive busy
         * (if there is room for that).
         */
         * unless there aren't that many slots reserved for
         * us in which case we record this as a drive busy
         * (if there is room for that).
         */
-       unit = dn+DK_N;
-       if (unit <= DK_NMAX) {
+       unit = dn+UPDK_N;
+       if (unit <= UPDK_NMAX) {
                dk_busy |= 1<<unit;
                dk_xfer[unit]++;
                dk_wds[unit] += bp->b_bcount>>6;
                dk_busy |= 1<<unit;
                dk_xfer[unit]++;
                dk_wds[unit] += bp->b_bcount>>6;
@@ -509,8 +509,8 @@ upintr()
                dp = uptab.b_actf;
                bp = dp->b_actf;
                unit = dkunit(bp);
                dp = uptab.b_actf;
                bp = dp->b_actf;
                unit = dkunit(bp);
-               if (DK_N+unit <= DK_NMAX)
-                       dk_busy &= ~(1<<(DK_N+unit));
+               if (UPDK_N+unit <= UPDK_NMAX)
+                       dk_busy &= ~(1<<(UPDK_N+unit));
                if ((upaddr->upcs2 & 07) != unit)
                        upaddr->upcs2 = unit;
                if ((upaddr->upds&ERR) || (upaddr->upcs1&TRE)) {
                if ((upaddr->upcs2 & 07) != unit)
                        upaddr->upcs2 = unit;
                if ((upaddr->upds&ERR) || (upaddr->upcs1&TRE)) {
@@ -600,7 +600,7 @@ upintr()
                }
                as &= ~(1<<unit);
                upsoftas &= ~(1<<unit);
                }
                as &= ~(1<<unit);
                upsoftas &= ~(1<<unit);
-               ubafree(up_ubinfo), up_ubinfo = 0;
+               ubarelse(&up_ubinfo);
        } else {
                if (upaddr->upcs1 & TRE)
                        upaddr->upcs1 = TRE;
        } else {
                if (upaddr->upcs1 & TRE)
                        upaddr->upcs1 = TRE;
@@ -740,7 +740,7 @@ upreset()
        uptab.b_actf = uptab.b_actl = 0;
        if (up_ubinfo) {
                printf("<%d>", (up_ubinfo>>28)&0xf);
        uptab.b_actf = uptab.b_actl = 0;
        if (up_ubinfo) {
                printf("<%d>", (up_ubinfo>>28)&0xf);
-               ubafree(up_ubinfo), up_ubinfo = 0;
+               ubarelse(&up_ubinfo);
        }
        UPADDR->upcs2 = CLR;            /* clear controller */
        for (unit = 0; unit < NUP; unit++) {
        }
        UPADDR->upcs2 = CLR;            /* clear controller */
        for (unit = 0; unit < NUP; unit++) {