usb-storage: Fix devices that cannot handle 32k transfers
authorDoug Maxey <dwm@enoyolf.org>
Thu, 6 Dec 2007 05:36:45 +0000 (23:36 -0600)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 17 Dec 2007 18:47:14 +0000 (10:47 -0800)
When a device cannot handle the smallest previously limited transfer
size (64 blocks) without stalling, limit the device to the amount of
packets that fit in a platform native page.

The lowest possible limit is PAGE_CACHE_SIZE, so if the device is ever
used on a platform that has larger than 8K pages, you lose unless you
can convince the device firmware folks to fix the issue.

Cc: Mathew Dharm <mdharm-scsi@one-eyed-alien.net>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Doug Maxey <dwm@austin.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/storage/scsiglue.c
drivers/usb/storage/unusual_devs.h
include/linux/usb_usual.h

index 836a34ae6ec62a5737c3b46e3f47dfecdeff9c5f..7c9593b7b04e27da6c21577c18e6c3f907206f07 100644 (file)
@@ -114,9 +114,15 @@ static int slave_configure(struct scsi_device *sdev)
         * while others have trouble with more than 64K. At this time we
         * are limiting both to 32K (64 sectores).
         */
-       if ((us->flags & US_FL_MAX_SECTORS_64) &&
-                       sdev->request_queue->max_sectors > 64)
-               blk_queue_max_sectors(sdev->request_queue, 64);
+       if (us->flags & (US_FL_MAX_SECTORS_64 | US_FL_MAX_SECTORS_MIN)) {
+               unsigned int max_sectors = 64;
+
+               if (us->flags & US_FL_MAX_SECTORS_MIN)
+                       max_sectors = PAGE_CACHE_SIZE >> 9;
+               if (sdev->request_queue->max_sectors > max_sectors)
+                       blk_queue_max_sectors(sdev->request_queue,
+                                             max_sectors);
+       }
 
        /* We can't put these settings in slave_alloc() because that gets
         * called before the device type is known.  Consequently these
index 2c27721bd259a5f3c96942d577654fce472aa776..7bbfd31a96450a82744f75bec68766d1723fb572 100644 (file)
@@ -376,6 +376,13 @@ UNUSUAL_DEV(  0x04b0, 0x0417, 0x0100, 0x0100,
                US_SC_DEVICE, US_PR_DEVICE, NULL,
                US_FL_FIX_CAPACITY),
 
+/* Reported by Doug Maxey (dwm@austin.ibm.com) */
+UNUSUAL_DEV(  0x04b3, 0x4001, 0x0110, 0x0110,
+               "IBM",
+               "IBM RSA2",
+               US_SC_DEVICE, US_PR_CB, NULL,
+               US_FL_MAX_SECTORS_MIN),
+
 /* BENQ DC5330
  * Reported by Manuel Fombuena <mfombuena@ya.com> and
  * Frank Copeland <fjc@thingy.apana.org.au> */
index 1b792b9286bae2a499fd5aa46ff1b4ccc1a5aeec..a417b09b8b3db53875a1bd93936448aaf52be018 100644 (file)
        US_FLAG(IGNORE_DEVICE,  0x00000800)                     \
                /* Don't claim device */                        \
        US_FLAG(CAPACITY_HEURISTICS,    0x00001000)             \
-               /* sometimes sizes is too big */
+               /* sometimes sizes is too big */                \
+       US_FLAG(MAX_SECTORS_MIN,0x00002000)                     \
+               /* Sets max_sectors to arch min */
+
 
 #define US_FLAG(name, value)   US_FL_##name = value ,
 enum { US_DO_ALL_FLAGS };