Adjust for new DELAY() ... s/DELAY(1)/DELAY(5)/ and lengthen some

timeouts.
This commit is contained in:
thorpej 1996-05-17 15:15:29 +00:00
parent c3fc839395
commit 3ad552e74b
1 changed files with 30 additions and 27 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsi.c,v 1.8 1996/02/14 02:44:59 thorpej Exp $ */ /* $NetBSD: scsi.c,v 1.9 1996/05/17 15:15:29 thorpej Exp $ */
/* /*
* Copyright (c) 1990, 1993 * Copyright (c) 1990, 1993
@ -64,8 +64,8 @@
* SCSI delays * SCSI delays
* In u-seconds, primarily for state changes on the SPC. * In u-seconds, primarily for state changes on the SPC.
*/ */
#define SCSI_CMD_WAIT 1000 /* wait per step of 'immediate' cmds */ #define SCSI_CMD_WAIT 10000 /* wait per step of 'immediate' cmds */
#define SCSI_DATA_WAIT 1000 /* wait per data in/out step */ #define SCSI_DATA_WAIT 10000 /* wait per data in/out step */
#define SCSI_INIT_WAIT 50000 /* wait per step (both) during init */ #define SCSI_INIT_WAIT 50000 /* wait per step (both) during init */
extern void isrlink(); extern void isrlink();
@ -112,7 +112,8 @@ u_int sgo_wait[MAXWAIT+2];
#define b_cylin b_resid #define b_cylin b_resid
static void static void
scsiabort(hs, hd, where) scsiabort(target, hs, hd, where)
int target;
register struct scsi_softc *hs; register struct scsi_softc *hs;
volatile register struct scsidevice *hd; volatile register struct scsidevice *hd;
char *where; char *where;
@ -122,9 +123,11 @@ scsiabort(hs, hd, where)
int startlen; /* XXX - kludge till I understand whats *supposed* to happen */ int startlen; /* XXX - kludge till I understand whats *supposed* to happen */
u_char junk; u_char junk;
printf("%s: abort from %s: phase=0x%x, ssts=0x%x, ints=0x%x\n", printf("%s: ", hs->sc_hc->hp_xname);
hs->sc_hc->hp_xname, where, hd->scsi_psns, hd->scsi_ssts, if (target != -1)
hd->scsi_ints); printf("targ %d ", target);
printf("abort from %s: phase=0x%x, ssts=0x%x, ints=0x%x\n",
where, hd->scsi_psns, hd->scsi_ssts, hd->scsi_ints);
hd->scsi_ints = hd->scsi_ints; hd->scsi_ints = hd->scsi_ints;
hd->scsi_csr = 0; hd->scsi_csr = 0;
@ -142,7 +145,7 @@ scsiabort(hs, hd, where)
while ((hd->scsi_psns & PSNS_REQ) == 0) { while ((hd->scsi_psns & PSNS_REQ) == 0) {
if (! (hd->scsi_ssts & SSTS_INITIATOR)) if (! (hd->scsi_ssts & SSTS_INITIATOR))
goto out; goto out;
DELAY(1); DELAY(5);
if (--maxtries == 0) { if (--maxtries == 0) {
printf("-- scsiabort gave up after 1000 tries (startlen = %d len = %d)\n", printf("-- scsiabort gave up after 1000 tries (startlen = %d len = %d)\n",
startlen, len); startlen, len);
@ -159,7 +162,7 @@ out2:
hd->scsi_scmd = SCMD_SET_ACK; hd->scsi_scmd = SCMD_SET_ACK;
if (hd->scsi_tmod == 0) if (hd->scsi_tmod == 0)
while (hd->scsi_psns & PSNS_REQ) while (hd->scsi_psns & PSNS_REQ)
DELAY(1); DELAY(5);
junk = hd->scsi_temp; junk = hd->scsi_temp;
} else { } else {
/* one of the output phases - send an abort msg */ /* one of the output phases - send an abort msg */
@ -167,7 +170,7 @@ out2:
hd->scsi_scmd = SCMD_SET_ACK; hd->scsi_scmd = SCMD_SET_ACK;
if (hd->scsi_tmod == 0) if (hd->scsi_tmod == 0)
while (hd->scsi_psns & PSNS_REQ) while (hd->scsi_psns & PSNS_REQ)
DELAY(1); DELAY(5);
} }
hd->scsi_scmd = SCMD_RST_ACK; hd->scsi_scmd = SCMD_RST_ACK;
} }
@ -183,7 +186,7 @@ out:
if (! ((junk = hd->scsi_ints) & INTS_RESEL)) { if (! ((junk = hd->scsi_ints) & INTS_RESEL)) {
hd->scsi_sctl |= SCTL_CTRLRST; hd->scsi_sctl |= SCTL_CTRLRST;
DELAY(1); DELAY(5);
hd->scsi_sctl &=~ SCTL_CTRLRST; hd->scsi_sctl &=~ SCTL_CTRLRST;
hd->scsi_hconf = 0; hd->scsi_hconf = 0;
hd->scsi_ints = hd->scsi_ints; hd->scsi_ints = hd->scsi_ints;
@ -301,7 +304,7 @@ scsiattach(hc)
* XXX scale initialization wait according to CPU speed. * XXX scale initialization wait according to CPU speed.
* Should we do this for all wait? Should we do this at all? * Should we do this for all wait? Should we do this at all?
*/ */
scsi_init_wait *= cpuspeed; scsi_init_wait *= (cpuspeed / 8);
} }
void void
@ -314,7 +317,7 @@ scsireset(unit)
u_int i; u_int i;
if (hs->sc_flags & SCSI_ALIVE) if (hs->sc_flags & SCSI_ALIVE)
scsiabort(hs, hd, "reset"); scsiabort(-1, hs, hd, "reset");
hd->scsi_id = 0xFF; hd->scsi_id = 0xFF;
DELAY(100); DELAY(100);
@ -464,7 +467,7 @@ wait_for_select(hd)
u_char ints; u_char ints;
while ((ints = hd->scsi_ints) == 0) while ((ints = hd->scsi_ints) == 0)
DELAY(1); DELAY(5);
hd->scsi_ints = ints; hd->scsi_ints = ints;
return (!(hd->scsi_ssts & SSTS_INITIATOR)); return (!(hd->scsi_ssts & SSTS_INITIATOR));
} }
@ -495,7 +498,7 @@ ixfer_start(hd, len, phase, wait)
HIST(ixstart_wait, wait) HIST(ixstart_wait, wait)
return (0); return (0);
} }
DELAY(1); DELAY(5);
} }
HIST(ixstart_wait, wait) HIST(ixstart_wait, wait)
return (1); return (1);
@ -520,7 +523,7 @@ ixfer_out(hd, len, buf)
HIST(ixout_wait, wait) HIST(ixout_wait, wait)
return (len); return (len);
} }
DELAY(1); DELAY(5);
} }
hd->scsi_dreg = *buf++; hd->scsi_dreg = *buf++;
} }
@ -551,7 +554,7 @@ ixfer_in(hd, len, buf)
HIST(ixin_wait, wait) HIST(ixin_wait, wait)
return; return;
} }
DELAY(1); DELAY(5);
} }
*buf++ = hd->scsi_dreg; *buf++ = hd->scsi_dreg;
} }
@ -589,7 +592,7 @@ mxfer_in(hd, len, buf, phase)
(hd->scsi_ssts & SSTS_INITIATOR) == 0) (hd->scsi_ssts & SSTS_INITIATOR) == 0)
goto out; goto out;
DELAY(1); DELAY(5);
} }
/* /*
* set ack (which says we're ready for the data, wait for * set ack (which says we're ready for the data, wait for
@ -603,7 +606,7 @@ mxfer_in(hd, len, buf, phase)
HIST(mxin_wait, wait) HIST(mxin_wait, wait)
return (-2); return (-2);
} }
DELAY(1); DELAY(5);
} }
*buf++ = hd->scsi_temp; *buf++ = hd->scsi_temp;
hd->scsi_scmd = SCMD_RST_ACK; hd->scsi_scmd = SCMD_RST_ACK;
@ -619,7 +622,7 @@ out:
while ((hd->scsi_ssts & SSTS_ACTIVE) == SSTS_INITIATOR) { while ((hd->scsi_ssts & SSTS_ACTIVE) == SSTS_INITIATOR) {
if (--wait < 0) if (--wait < 0)
break; break;
DELAY(1); DELAY(5);
} }
HIST(mxin2_wait, wait) HIST(mxin2_wait, wait)
return (i); return (i);
@ -726,7 +729,7 @@ scsiicmd(hs, target, cbuf, clen, buf, len, xferphase)
HIST(cxin_wait, wait) HIST(cxin_wait, wait)
goto abort; goto abort;
} }
DELAY(1); DELAY(5);
} }
HIST(cxin_wait, wait) HIST(cxin_wait, wait)
hd->scsi_ints = ints; hd->scsi_ints = ints;
@ -740,7 +743,7 @@ scsiicmd(hs, target, cbuf, clen, buf, len, xferphase)
} }
} }
abort: abort:
scsiabort(hs, hd, "icmd"); scsiabort(target, hs, hd, "icmd");
out: out:
return (hs->sc_stat[0]); return (hs->sc_stat[0]);
} }
@ -786,7 +789,7 @@ finishxfer(hs, hd, target)
} }
hd->scsi_scmd |= SCMD_PROG_XFR; hd->scsi_scmd |= SCMD_PROG_XFR;
hd->scsi_sctl |= SCTL_CTRLRST; hd->scsi_sctl |= SCTL_CTRLRST;
DELAY(1); DELAY(5);
hd->scsi_sctl &=~ SCTL_CTRLRST; hd->scsi_sctl &=~ SCTL_CTRLRST;
hd->scsi_hconf = 0; hd->scsi_hconf = 0;
/* /*
@ -838,7 +841,7 @@ finishxfer(hs, hd, target)
return; return;
} }
abort: abort:
scsiabort(hs, hd, "finishxfer"); scsiabort(target, hs, hd, "finishxfer");
hs->sc_stat[0] = 0xfe; hs->sc_stat[0] = 0xfe;
} }
@ -1053,7 +1056,7 @@ scsigo(ctlr, slave, unit, bp, cdb, pad)
HIST(sgo_wait, wait) HIST(sgo_wait, wait)
goto abort; goto abort;
} }
DELAY(1); DELAY(5);
} }
HIST(sgo_wait, wait) HIST(sgo_wait, wait)
hd->scsi_ints = ints; hd->scsi_ints = ints;
@ -1135,7 +1138,7 @@ out:
hs->sc_flags |= SCSI_IO; hs->sc_flags |= SCSI_IO;
return (0); return (0);
abort: abort:
scsiabort(hs, hd, "go"); scsiabort(slave, hs, hd, "go");
hs->sc_flags &=~ SCSI_HAVEDMA; hs->sc_flags &=~ SCSI_HAVEDMA;
dmafree(&hs->sc_dq); dmafree(&hs->sc_dq);
return (1); return (1);
@ -1194,7 +1197,7 @@ scsiintr(arg)
hd->scsi_ints = ints; hd->scsi_ints = ints;
hd->scsi_csr = 0; hd->scsi_csr = 0;
scsierror(hs, hd, ints); scsierror(hs, hd, ints);
scsiabort(hs, hd, "intr"); scsiabort(dq->dq_slave, hs, hd, "intr");
if (hs->sc_flags & SCSI_IO) { if (hs->sc_flags & SCSI_IO) {
hs->sc_flags &=~ (SCSI_IO|SCSI_HAVEDMA); hs->sc_flags &=~ (SCSI_IO|SCSI_HAVEDMA);
dmafree(&hs->sc_dq); dmafree(&hs->sc_dq);