On Thu, 8 Jul 2004, Matthew Dharm wrote:

> I think, for now, since this seems to be the only device which is so badly
> broken, let's just leave it as a hard-coded thing.  That is, check for the
> Genesys vendorID in both places (max_sectors and delay).

Here it is then.  This patch reduces max_sectors to 32 KB, with a comment
explaining that it will probably work as high as 64 KB.  Since the Genesys
Logic technical support guy didn't say anything about high vs. full speed,
the reduction is made regardless (at full speed the effect will hardly be
noticeable anyway).

Likewise, the time delay is added between the command and data phases, at 
either speed.  In fact, just to play it safe I added the delay even if 
there is no data phase.

It would be a good idea to add something to the appropriate web sites 
explaining what max_sectors is and how to use it.  (Have I said this 
before?)  I'm not sure exactly which web sites are the appropriate ones, 
but your usb-storage site and linux-usb.org spring to mind.  If you want 
to update your page, I'll send something to Stephen Gowdy for the 
linux-usb FAQ.

To everyone on the CC list: Testing would be appreciated.  Although this 
patch sets max_sectors down to 64, it will almost certainly work okay if 
you change it back to 128.  That change doesn't have to be made in the 
source code; it can be done at runtime using the sysfs filesystem, simply 
by doing something like this (as root):

        echo 128 >/sys/block/sda/device/max_sectors

Obviously you will have to adjust that pathname to fit your system.

Alan Stern



Signed-off-by: Alan Stern <[EMAIL PROTECTED]>

===== drivers/usb/storage/scsiglue.c 1.78 vs edited =====
--- 1.78/drivers/usb/storage/scsiglue.c Thu Jun 24 10:09:11 2004
+++ edited/drivers/usb/storage/scsiglue.c       Fri Jul  9 10:00:35 2004
@@ -92,17 +92,15 @@
         * the end, scatter-gather buffers follow page boundaries. */
        blk_queue_dma_alignment(sdev->request_queue, (512 - 1));
 
-       /* Devices using Genesys Logic chips cause a lot of trouble for
-        * high-speed transfers; they die unpredictably when given more
-        * than 64 KB of data at a time.  If we detect such a device,
-        * reduce the maximum transfer size to 64 KB = 128 sectors. */
-
-#define USB_VENDOR_ID_GENESYS  0x05e3          // Needs a standard location
-
+       /* According to the technical support people at Genesys Logic,
+        * devices using their chips have problems transferring more than
+        * 32 KB at a time.  In practice people have found that 64 KB
+        * works okay and that's what Windows does.  But we'll be
+        * conservative; people can always use the sysfs interface to
+        * increase max_sectors. */
        if (us->pusb_dev->descriptor.idVendor == USB_VENDOR_ID_GENESYS &&
-                       us->pusb_dev->speed == USB_SPEED_HIGH &&
-                       sdev->request_queue->max_sectors > 128)
-               blk_queue_max_sectors(sdev->request_queue, 128);
+                       sdev->request_queue->max_sectors > 64)
+               blk_queue_max_sectors(sdev->request_queue, 64);
 
        /* We can't put these settings in slave_alloc() because that gets
         * called before the device type is known.  Consequently these
===== drivers/usb/storage/transport.c 1.141 vs edited =====
--- 1.141/drivers/usb/storage/transport.c       Thu Jun 24 12:44:16 2004
+++ edited/drivers/usb/storage/transport.c      Fri Jul  9 10:01:56 2004
@@ -975,6 +975,12 @@
 
        /* DATA STAGE */
        /* send/receive data payload, if there is any */
+
+       /* Genesys Logic interface chips need a 100us delay between the
+        * command phase and the data phase */
+       if (us->pusb_dev->descriptor.idVendor == USB_VENDOR_ID_GENESYS)
+               udelay(100);
+
        if (transfer_length) {
                unsigned int pipe = srb->sc_data_direction == SCSI_DATA_READ ? 
                                us->recv_bulk_pipe : us->send_bulk_pipe;
===== drivers/usb/storage/usb.h 1.58 vs edited =====
--- 1.58/drivers/usb/storage/usb.h      Mon Jun 21 12:58:51 2004
+++ edited/drivers/usb/storage/usb.h    Fri Jul  9 10:04:57 2004
@@ -180,4 +180,8 @@
 #define scsi_unlock(host)      spin_unlock_irq(host->host_lock)
 #define scsi_lock(host)                spin_lock_irq(host->host_lock)
 
+
+/* Vendor ID list for devices that require special handling */
+#define USB_VENDOR_ID_GENESYS          0x05e3  /* Genesys Logic */
+
 #endif




-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to