From owner-freebsd-scsi Thu Feb 21 6:58:48 2002 Delivered-To: freebsd-scsi@freebsd.org Received: from mail.sat.t.u-tokyo.ac.jp (nat.keisu.t.u-tokyo.ac.jp [133.11.68.2]) by hub.freebsd.org (Postfix) with ESMTP id 4F7A137B400 for ; Thu, 21 Feb 2002 06:58:43 -0800 (PST) Received: from ett.sat.t.u-tokyo.ac.jp (ett.sat.t.u-tokyo.ac.jp [10.6.1.30]) by mail.sat.t.u-tokyo.ac.jp (Postfix) with ESMTP id D90F42DABD; Thu, 21 Feb 2002 23:58:41 +0900 (JST) Date: Thu, 21 Feb 2002 23:58:41 +0900 Message-ID: From: Hidetoshi Shimokawa To: "Justin T. Gibbs" Cc: freebsd-scsi@FreeBSD.ORG, joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) Subject: READ_6 patch (Re: RBC support patch) Newsgroups: freebsd.scsi In-Reply-To: References: <200202201936.g1KJaAO07448@uriah.heep.sax.de> <200202202359.g1KNxeI41069@aslan.scsiguy.com> User-Agent: Wanderlust/2.4.1 (Stand By Me) REMI/1.14.3 (Matsudai) FLIM/1.13.2 (Kasanui) APEL/10.3 MULE XEmacs/21.2 (beta19) (Shinjuku) (i386-unknown-freebsd3.2) X-Face: OE([KxWyJI0r[R~S/>7ia}SJ)i%a,$-9%7{*yihQk|]gl}2p#"oXmX/fT}Bn7:#j7i14gu$ jgR\S*&C3R/pJX List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org At Thu, 21 Feb 2002 20:56:29 +0900, Hidetoshi Shimokawa wrote: > At Wed, 20 Feb 2002 16:59:40 -0700, > Justin T. Gibbs wrote: > > > > > What do you mean by "adjust dynamically"? > > > > If a 6 byte command fails with "command not supported", switch to > > 10 byte commands, and retry the current transaction. As far as I > > know, the devices do return a proper response. Those that don't, > > we will still have to black list. > > > > -- > > Justin > > This seems right way to go. How about this? Could you review this patch? /\ Hidetoshi Shimokawa \/ simokawa@sat.t.u-tokyo.ac.jp PGP public key: http://www.sat.t.u-tokyo.ac.jp/~simokawa/pgp.html Index: scsi/scsi_da.c =================================================================== RCS file: /home/ncvs/src/sys/cam/scsi/scsi_da.c,v retrieving revision 1.97 diff -u -r1.97 scsi_da.c --- scsi/scsi_da.c 18 Feb 2002 13:35:30 -0000 1.97 +++ scsi/scsi_da.c 21 Feb 2002 14:47:03 -0000 @@ -1308,6 +1324,22 @@ } } +static void +cmd6to10(struct ccb_scsiio *csio) +{ + struct scsi_rw_6 cmd6; + struct scsi_rw_10 *cmd10; + + bcopy(&csio->cdb_io.cdb_bytes, &cmd6, sizeof(struct scsi_rw_6)); + cmd10 = (struct scsi_rw_10 *) &csio->cdb_io.cdb_bytes; + cmd10->opcode = (cmd6.opcode == READ_6) ? READ_10 : WRITE_10; + cmd10->byte2 = 0; + scsi_ulto4b(scsi_3btoul(cmd6.addr), cmd10->addr); + cmd10->reserved = 0; + scsi_ulto2b(cmd6.length, cmd10->length); + cmd10->control = cmd6.control; + csio->cdb_len = sizeof(*cmd10); +} static void dadone(struct cam_periph *periph, union ccb *done_ccb) @@ -1328,12 +1360,37 @@ int error; int s; int sf; + u_int8_t opcode; if ((csio->ccb_h.ccb_state & DA_CCB_RETRY_UA) != 0) sf = SF_RETRY_UA; else sf = 0; + /* XXX + * Work around for broken direct access device + * which doesn't support READ(6)/WRITE(6). + */ + opcode = ((struct scsi_rw_6 *) + &csio->cdb_io.cdb_bytes)->opcode; + if (opcode == READ_6 || opcode == WRITE_6) { + int sense_key, error_code; + int asc, ascq; + scsi_extract_sense(&csio->sense_data, + &error_code, + &sense_key, + &asc, &ascq); + if (sense_key == SSD_KEY_ILLEGAL_REQUEST) { + printf( + "READ(6)/WRITE(6) failed, " + "minimum_cmd_size is " + "increased to 10.\n"); + softc->minimum_cmd_size = 10; + cmd6to10(csio); + done_ccb->ccb_h.status = + CAM_REQUEUE_REQ; + } + } error = daerror(done_ccb, CAM_RETRY_SELTO, sf); if (error == ERESTART) { /* To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-scsi" in the body of the message