On Wed, 30 Aug 2006, Anton Litvinov wrote:
> This device doesn't work if it was hot-plugged.
> But if I plug it before I boot Linux, it works sometimes (see attached log).
Apparently the BIOS gets the device working and after that it's okay.
> If device was hot-plugged then log look like this:
>
> >
> > Linux:
> > INQUIRY
> > TEST UNIT READY (failed: Not ready to ready change)
> > TEST UNIT READY
> > READ CAPACITY
> > MODE SENSE 3f
> > TEST UNIT READY
> > TEST UNIT READY
> > READ CAPACITY
> > MODE SENSE 3f
> > READ(10) 8 sectors at 0 -- crashed
> >
>
> If device was plugged before boot then log look like this:
>
> INQUIRY
> TEST_UNIT_READY
> READ_CAPACITY
> MODE_SENSE
> TEST_UNIT_READY
> ALLOW_MEDIUM_REMOVAL (failure)
> TEST_UNIT_READY
> READ_CAPACITY
> MODE_SENSE
> READ_10
> INQUIRY
> TEST_UNIT_READY
> READ_CAPACITY
> ...
> READ_10
> READ_10
> READ_10
> READ_10
> READ_10
> ...
All right. It looks like you don't need the earlier patch adding the
US_FL_NOT_LOCKABLE flag to unusual_devs.h.
Try this patch instead. It should cause the SCSI disk driver to read a
single sector at location 0, and hopefully the device will work
correctly after that.
Alan Stern
Index: usb-2.6/drivers/scsi/sd.c
===================================================================
--- usb-2.6.orig/drivers/scsi/sd.c
+++ usb-2.6/drivers/scsi/sd.c
@@ -1524,6 +1524,42 @@ defaults:
sdkp->DPOFUA = 0;
}
+/*
+ * Pre-read the partition sector (sector 0) -- one sector only!
+ * Some weird USB flash devices won't work without this.
+ */
+static void
+sd_preread_sector0(struct scsi_disk *sdkp, unsigned char *buffer)
+{
+ unsigned char cmd[16];
+ int the_result, retries;
+ struct scsi_sense_hdr sshdr;
+ struct scsi_device *sdp = sdkp->device;
+
+ if (sdp->sector_size > 512) /* Forget about funny sector sizes */
+ return;
+
+ memset(cmd, 0, sizeof(cmd));
+ if (sdp->use_10_for_rw) {
+ cmd[0] = READ_10;
+ cmd[8] = 1;
+ } else {
+ cmd[0] = READ_6;
+ cmd[4] = 1;
+ }
+
+ for (retries = 0; retries < 3; ++retries) {
+
+ the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
+ buffer, 512, &sshdr,
+ SD_TIMEOUT, SD_MAX_RETRIES);
+ if (the_result == 0)
+ break;
+ if (media_not_present(sdkp, &sshdr))
+ break;
+ } while (the_result && retries);
+}
+
/**
* sd_revalidate_disk - called the first time a new disk is seen,
* performs disk spin up, read_capacity, etc.
@@ -1570,6 +1606,7 @@ static int sd_revalidate_disk(struct gen
sd_read_capacity(sdkp, disk->disk_name, buffer);
sd_read_write_protect_flag(sdkp, disk->disk_name, buffer);
sd_read_cache_type(sdkp, disk->disk_name, buffer);
+ sd_preread_sector0(sdkp, buffer);
}
/*
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-users