summaryrefslogtreecommitdiff
path: root/sys/scsi
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2008-06-21 21:11:35 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2008-06-21 21:11:35 +0000
commit7e3d01f6eb5ea37acdc9ae9c4000be332e19f7ca (patch)
treef9e59bfeb7bfc92017e0d19518053ef05d97d474 /sys/scsi
parentad9cbfe6ecb56a2e6038fc1d8747fd71ec1123fd (diff)
fgsch@ points out my last commit changed the retry limit for CD capacity
commands. Bump limit back to the standard 4, and at the same time eliminate SDRETRIES and CDRETRIES (both defined to 4) in favour of a new define, SCSI_RETRIES, also defined to 4.
Diffstat (limited to 'sys/scsi')
-rw-r--r--sys/scsi/cd.c48
-rw-r--r--sys/scsi/cd.h4
-rw-r--r--sys/scsi/scsiconf.h9
-rw-r--r--sys/scsi/sd.c10
-rw-r--r--sys/scsi/sdvar.h4
5 files changed, 38 insertions, 37 deletions
diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c
index 4ce9a53f37d..7598251c26f 100644
--- a/sys/scsi/cd.c
+++ b/sys/scsi/cd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd.c,v 1.140 2008/06/21 18:50:24 krw Exp $ */
+/* $OpenBSD: cd.c,v 1.141 2008/06/21 21:11:34 krw Exp $ */
/* $NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $ */
/*
@@ -637,7 +637,7 @@ cdstart(void *v)
* Note: we cannot sleep as we may be an interrupt
*/
error = scsi_scsi_cmd(sc_link, cmdp, cmdlen,
- (u_char *) bp->b_data, bp->b_bcount, CDRETRIES, 30000, bp,
+ (u_char *) bp->b_data, bp->b_bcount, SCSI_RETRIES, 30000, bp,
SCSI_NOSLEEP | ((bp->b_flags & B_READ) ? SCSI_DATA_IN :
SCSI_DATA_OUT));
switch (error) {
@@ -1297,7 +1297,7 @@ cd_load_unload(struct cd_softc *cd, int options, int slot)
cmd.slot = slot;
return (scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&cmd,
- sizeof(cmd), 0, 0, CDRETRIES, 200000, NULL, 0));
+ sizeof(cmd), 0, 0, SCSI_RETRIES, 200000, NULL, 0));
}
int
@@ -1353,7 +1353,7 @@ cd_play(struct cd_softc *cd, int blkno, int nblks)
_lto2b(nblks, scsi_cmd.xfer_len);
return (scsi_scsi_cmd(cd->sc_link,
(struct scsi_generic *)&scsi_cmd, sizeof(scsi_cmd),
- 0, 0, CDRETRIES, 200000, NULL, 0));
+ 0, 0, SCSI_RETRIES, 200000, NULL, 0));
}
/*
@@ -1434,7 +1434,7 @@ cd_play_msf(struct cd_softc *cd, int startm, int starts, int startf, int endm,
scsi_cmd.end_f = endf;
return (scsi_scsi_cmd(cd->sc_link,
(struct scsi_generic *)&scsi_cmd, sizeof(scsi_cmd),
- 0, 0, CDRETRIES, 20000, NULL, 0));
+ 0, 0, SCSI_RETRIES, 20000, NULL, 0));
}
/*
@@ -1449,7 +1449,7 @@ cd_pause(struct cd_softc *cd, int go)
scsi_cmd.opcode = PAUSE;
scsi_cmd.resume = go;
return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd,
- sizeof(scsi_cmd), 0, 0, CDRETRIES, 2000, NULL, 0);
+ sizeof(scsi_cmd), 0, 0, SCSI_RETRIES, 2000, NULL, 0);
}
/*
@@ -1458,7 +1458,7 @@ cd_pause(struct cd_softc *cd, int go)
int
cd_reset(struct cd_softc *cd)
{
- return scsi_scsi_cmd(cd->sc_link, 0, 0, 0, 0, CDRETRIES, 2000, NULL,
+ return scsi_scsi_cmd(cd->sc_link, 0, 0, 0, 0, SCSI_RETRIES, 2000, NULL,
SCSI_RESET);
}
@@ -1481,7 +1481,7 @@ cd_read_subchannel(struct cd_softc *cd, int mode, int format, int track,
_lto2b(len, scsi_cmd.data_len);
return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd,
sizeof(struct scsi_read_subchannel), (u_char *)data, len,
- CDRETRIES, 5000, NULL, SCSI_DATA_IN|SCSI_SILENT);
+ SCSI_RETRIES, 5000, NULL, SCSI_DATA_IN|SCSI_SILENT);
}
/*
@@ -1504,7 +1504,7 @@ cd_read_toc(struct cd_softc *cd, int mode, int start, void *data, int len,
scsi_cmd.control = control;
return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd,
- sizeof(struct scsi_read_toc), (u_char *)data, len, CDRETRIES,
+ sizeof(struct scsi_read_toc), (u_char *)data, len, SCSI_RETRIES,
5000, NULL, SCSI_DATA_IN | SCSI_IGNORE_ILLEGAL_REQUEST);
}
@@ -1588,7 +1588,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
cmd.bytes[8] = 8;
cmd.bytes[9] = 0 | (0 << 6);
error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 8,
- CDRETRIES, 30000, NULL, SCSI_DATA_IN);
+ SCSI_RETRIES, 30000, NULL, SCSI_DATA_IN);
if (error)
return (error);
a->lsa.agid = buf[7] >> 6;
@@ -1599,7 +1599,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
cmd.bytes[8] = 16;
cmd.bytes[9] = 1 | (a->lsc.agid << 6);
error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 16,
- CDRETRIES, 30000, NULL, SCSI_DATA_IN);
+ SCSI_RETRIES, 30000, NULL, SCSI_DATA_IN);
if (error)
return (error);
dvd_copy_challenge(a->lsc.chal, &buf[4]);
@@ -1610,7 +1610,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
cmd.bytes[8] = 12;
cmd.bytes[9] = 2 | (a->lsk.agid << 6);
error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 12,
- CDRETRIES, 30000, NULL, SCSI_DATA_IN);
+ SCSI_RETRIES, 30000, NULL, SCSI_DATA_IN);
if (error)
return (error);
dvd_copy_key(a->lsk.key, &buf[4]);
@@ -1622,7 +1622,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
cmd.bytes[8] = 12;
cmd.bytes[9] = 4 | (a->lstk.agid << 6);
error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 12,
- CDRETRIES, 30000, NULL, SCSI_DATA_IN);
+ SCSI_RETRIES, 30000, NULL, SCSI_DATA_IN);
if (error)
return (error);
a->lstk.cpm = (buf[4] >> 7) & 1;
@@ -1636,7 +1636,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
cmd.bytes[8] = 8;
cmd.bytes[9] = 5 | (a->lsasf.agid << 6);
error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 8,
- CDRETRIES, 30000, NULL, SCSI_DATA_IN);
+ SCSI_RETRIES, 30000, NULL, SCSI_DATA_IN);
if (error)
return (error);
a->lsasf.asf = buf[7] & 1;
@@ -1649,7 +1649,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
buf[1] = 14;
dvd_copy_challenge(&buf[4], a->hsc.chal);
error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 16,
- CDRETRIES, 30000, NULL, SCSI_DATA_OUT);
+ SCSI_RETRIES, 30000, NULL, SCSI_DATA_OUT);
if (error)
return (error);
a->type = DVD_LU_SEND_KEY1;
@@ -1662,7 +1662,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
buf[1] = 10;
dvd_copy_key(&buf[4], a->hsk.key);
error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 12,
- CDRETRIES, 30000, NULL, SCSI_DATA_OUT);
+ SCSI_RETRIES, 30000, NULL, SCSI_DATA_OUT);
if (error) {
a->type = DVD_AUTH_FAILURE;
return (error);
@@ -1674,7 +1674,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
cmd.opcode = GPCMD_REPORT_KEY;
cmd.bytes[9] = 0x3f | (a->lsa.agid << 6);
error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 16,
- CDRETRIES, 30000, NULL, 0);
+ SCSI_RETRIES, 30000, NULL, 0);
if (error)
return (error);
return (0);
@@ -1684,7 +1684,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
cmd.bytes[8] = 8;
cmd.bytes[9] = 8 | (0 << 6);
error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 8,
- CDRETRIES, 30000, NULL, SCSI_DATA_IN);
+ SCSI_RETRIES, 30000, NULL, SCSI_DATA_IN);
if (error)
return (error);
a->lrpcs.type = (buf[4] >> 6) & 3;
@@ -1701,7 +1701,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
buf[1] = 6;
buf[4] = a->hrpcs.pdrc;
error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 8,
- CDRETRIES, 30000, NULL, SCSI_DATA_OUT);
+ SCSI_RETRIES, 30000, NULL, SCSI_DATA_OUT);
if (error)
return (error);
return (0);
@@ -1730,7 +1730,7 @@ dvd_read_physical(cd, s)
cmd.bytes[5] = s->physical.layer_num;
error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, sizeof(buf),
- CDRETRIES, 30000, NULL, SCSI_DATA_IN);
+ SCSI_RETRIES, 30000, NULL, SCSI_DATA_IN);
if (error)
return (error);
for (i = 0, bufp = &buf[4], layer = &s->physical.layer[0]; i < 4;
@@ -1770,7 +1770,7 @@ dvd_read_copyright(cd, s)
cmd.bytes[5] = s->copyright.layer_num;
error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, sizeof(buf),
- CDRETRIES, 30000, NULL, SCSI_DATA_IN);
+ SCSI_RETRIES, 30000, NULL, SCSI_DATA_IN);
if (error)
return (error);
s->copyright.cpst = buf[4];
@@ -1798,7 +1798,7 @@ dvd_read_disckey(cd, s)
_lto2b(sizeof(*buf), cmd.length);
error = scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&cmd,
- sizeof(cmd), (u_char *)buf, sizeof(*buf), CDRETRIES, 30000, NULL,
+ sizeof(cmd), (u_char *)buf, sizeof(*buf), SCSI_RETRIES, 30000, NULL,
SCSI_DATA_IN);
if (error == 0)
bcopy(buf->data, s->disckey.value, sizeof(s->disckey.value));
@@ -1823,7 +1823,7 @@ dvd_read_bca(cd, s)
_lto2b(sizeof(buf), &cmd.bytes[7]);
error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, sizeof(buf),
- CDRETRIES, 30000, NULL, SCSI_DATA_IN);
+ SCSI_RETRIES, 30000, NULL, SCSI_DATA_IN);
if (error)
return (error);
s->bca.len = _2btol(&buf[0]);
@@ -1852,7 +1852,7 @@ dvd_read_manufact(cd, s)
_lto2b(sizeof(*buf), cmd.length);
error = scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&cmd,
- sizeof(cmd), (u_char *)buf, sizeof(*buf), CDRETRIES, 30000, NULL,
+ sizeof(cmd), (u_char *)buf, sizeof(*buf), SCSI_RETRIES, 30000, NULL,
SCSI_DATA_IN);
if (error == 0) {
s->manufact.len = _2btol(buf->len);
diff --git a/sys/scsi/cd.h b/sys/scsi/cd.h
index 4ec7db3ec81..4136deddba5 100644
--- a/sys/scsi/cd.h
+++ b/sys/scsi/cd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd.h,v 1.17 2008/06/21 18:50:24 krw Exp $ */
+/* $OpenBSD: cd.h,v 1.18 2008/06/21 21:11:34 krw Exp $ */
/* $NetBSD: scsi_cd.h,v 1.6 1996/03/19 03:06:39 mycroft Exp $ */
/*
@@ -253,8 +253,6 @@ struct cd_audio_page {
#define CD_NORMAL_DENSITY_CODE 0x00 /* from Toshiba CD-ROM specs */
#define CD_DA_DENSITY_CODE 0x82 /* from Toshiba CD-ROM specs */
-#define CDRETRIES 4
-
struct scsi_read_dvd_structure {
u_int8_t opcode; /* GPCMD_READ_DVD_STRUCTURE */
u_int8_t reserved;
diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h
index 1f6c4dfd10d..d7e252fd042 100644
--- a/sys/scsi/scsiconf.h
+++ b/sys/scsi/scsiconf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsiconf.h,v 1.92 2008/06/14 01:57:51 krw Exp $ */
+/* $OpenBSD: scsiconf.h,v 1.93 2008/06/21 21:11:34 krw Exp $ */
/* $NetBSD: scsiconf.h,v 1.35 1997/04/02 02:29:38 mycroft Exp $ */
/*
@@ -297,10 +297,15 @@ struct scsi_xfer {
#define XS_RESET 8 /* bus was reset; possible retry command */
/*
- * Possible retries numbers for scsi_test_unit_ready()
+ * Possible retries for scsi_test_unit_ready()
*/
#define TEST_READY_RETRIES 5
+/*
+ * Possible retries for most SCSI commands.
+ */
+#define SCSI_RETRIES 4
+
const void *scsi_inqmatch(struct scsi_inquiry_data *, const void *, int,
int, int *);
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index 6dc072ef776..fe14b8ab623 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd.c,v 1.148 2008/06/15 00:52:25 krw Exp $ */
+/* $OpenBSD: sd.c,v 1.149 2008/06/21 21:11:34 krw Exp $ */
/* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */
/*-
@@ -742,7 +742,7 @@ sdstart(void *v)
*/
error = scsi_scsi_cmd(sc_link, cmdp, cmdlen,
(u_char *)bp->b_data, bp->b_bcount,
- SDRETRIES, 60000, bp, SCSI_NOSLEEP |
+ SCSI_RETRIES, 60000, bp, SCSI_NOSLEEP |
((bp->b_flags & B_READ) ? SCSI_DATA_IN : SCSI_DATA_OUT));
switch (error) {
case 0:
@@ -1108,7 +1108,7 @@ sd_reassign_blocks(struct sd_softc *sd, u_long blkno)
_lto4b(blkno, rbdata.defect_descriptor[0].dlbaddr);
return scsi_scsi_cmd(sd->sc_link, (struct scsi_generic *)&scsi_cmd,
- sizeof(scsi_cmd), (u_char *)&rbdata, sizeof(rbdata), SDRETRIES,
+ sizeof(scsi_cmd), (u_char *)&rbdata, sizeof(rbdata), SCSI_RETRIES,
5000, NULL, SCSI_DATA_OUT);
}
@@ -1283,7 +1283,7 @@ sddump(dev_t dev, daddr64_t blkno, caddr_t va, size_t size)
bzero(xs, sizeof(sx));
xs->flags |= SCSI_AUTOCONF | SCSI_DATA_OUT;
xs->sc_link = sd->sc_link;
- xs->retries = SDRETRIES;
+ xs->retries = SCSI_RETRIES;
xs->timeout = 10000; /* 10000 millisecs for a disk ! */
xs->cmd = (struct scsi_generic *)&cmd;
xs->cmdlen = sizeof(cmd);
@@ -1500,7 +1500,7 @@ sd_flush(struct sd_softc *sd, int flags)
cmd.opcode = SYNCHRONIZE_CACHE;
if (scsi_scsi_cmd(sc_link, (struct scsi_generic *)&cmd, sizeof(cmd),
- NULL, 0, SDRETRIES, 100000, NULL,
+ NULL, 0, SCSI_RETRIES, 100000, NULL,
flags | SCSI_IGNORE_ILLEGAL_REQUEST)) {
SC_DEBUG(sc_link, SDEV_DB1, ("cache sync failed\n"));
} else
diff --git a/sys/scsi/sdvar.h b/sys/scsi/sdvar.h
index d81c3058bea..52319417a5b 100644
--- a/sys/scsi/sdvar.h
+++ b/sys/scsi/sdvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdvar.h,v 1.13 2007/11/06 02:49:19 krw Exp $ */
+/* $OpenBSD: sdvar.h,v 1.14 2008/06/21 21:11:34 krw Exp $ */
/* $NetBSD: sdvar.h,v 1.7 1998/08/17 00:49:03 mycroft Exp $ */
/*-
@@ -54,8 +54,6 @@
* Ported to run under 386BSD by Julian Elischer (julian@dialix.oz.au) Sept 1992
*/
-#define SDRETRIES 4
-
struct sd_softc {
struct device sc_dev;
struct disk sc_dk;