git: 9front

Download patch

ref: dd2e04d3d7f3ad5f17e29f5faef292b579a02a83
parent: 0f3c0d42157b55a6668296894c88aebb9047ff70
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Thu Jan 3 15:46:25 EST 2013

scsi: do only 36 byte inquiry

some devices freeze up with inqiry allocation length
other than 36 bytes. as we do not really care about
the vendor specific part of the inquiry, lets only do
36 byte inquiry for now.

--- a/sys/src/9/port/sdscsi.c
+++ b/sys/src/9/port/sdscsi.c
@@ -45,10 +45,10 @@
 	r->write = 0;
 	r->cmd[0] = 0x12;
 	r->cmd[1] = r->lun<<5;
-	r->cmd[4] = sizeof(unit->inquiry)-1;
+	r->cmd[4] = 36;
 	r->clen = 6;
 	r->data = inquiry;
-	r->dlen = sizeof(unit->inquiry)-1;
+	r->dlen = 36;
 	r->flags = 0;
 
 	r->status = ~0;
--- a/sys/src/cmd/nusb/disk/disk.c
+++ b/sys/src/cmd/nusb/disk/disk.c
@@ -341,7 +341,13 @@
 				i, lun->inquiry[0]);
 			continue;
 		}
-		SRstart(lun, 1);
+
+		if(SRready(lun) < 0 && SRready(lun) < 0 && SRready(lun) < 0)
+			dprint(2, "disk: lun %d not ready\n", i);
+
+		if((lun->inquiry[0] & 0x1F) == 0)
+			SRstart(lun, 1);
+
 		/*
 		 * we ignore the device type reported by inquiry.
 		 * Some devices return a wrong value but would still work.
--- a/sys/src/cmd/nusb/disk/scsireq.c
+++ b/sys/src/cmd/nusb/disk/scsireq.c
@@ -404,12 +404,12 @@
 
 	memset(cmd, 0, sizeof cmd);
 	cmd[0] = ScmdInq;
-	cmd[4] = sizeof rp->inquiry;
+	cmd[4] = 36;
 	rp->cmd.p = cmd;
 	rp->cmd.count = sizeof cmd;
 	memset(rp->inquiry, 0, sizeof rp->inquiry);
 	rp->data.p = rp->inquiry;
-	rp->data.count = sizeof rp->inquiry;
+	rp->data.count = 36;
 	rp->data.write = 0;
 	if(SRrequest(rp) >= 0){
 		rp->flags |= Finqok;
--