[PATCH v3] Re: another unusual flag for a really limited device

Doug Maxey <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
>From cebb5133e9f63af086a8600f52dbe13060eb0007 Mon Sep 17 00:00:00 2001
From: Doug Maxey <[email protected]>
Date: Tue, 27 Nov 2007 18:42:42 -0600
Subject: [PATCH 1/1] usb-storage: limit devices that cannot handle 32k transfers

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.

This version does not duplicate the CAPACITY_HEURISTICS flag.

Cc: Mathew Dharm <[email protected]>
Cc: Alan Stern <[email protected]>
Cc: Pete Zaitcev <[email protected]>
Signed-off-by: Doug Maxey <[email protected]>
---
 drivers/usb/storage/scsiglue.c     |   11 +++++++++++
 drivers/usb/storage/unusual_devs.h |    7 +++++++
 include/linux/usb_usual.h          |    5 ++++-
 3 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 1ba19ea..c071bca 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -118,6 +118,17 @@ static int slave_configure(struct scsi_device *sdev)
 			sdev->request_queue->max_sectors > 64)
 		blk_queue_max_sectors(sdev->request_queue, 64);
 
+	/* And at least one more device needs an even smaller max.
+	 * When testing the native PAGE_SIZE, clamp at 8k.  No need
+	 * allow a 64K or even 16M page in there.
+	 */
+	if (us->flags & US_FL_MAX_SECTORS_MIN) {
+		int min = min(PAGE_SIZE, 8192) / 512;
+
+		if (sdev->request_queue->max_sectors > min)
+			blk_queue_max_sectors(sdev->request_queue, min);
+	}
+
 	/* We can't put these settings in slave_alloc() because that gets
 	 * called before the device type is known.  Consequently these
 	 * settings can't be overridden via the scsi devinfo mechanism. */
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 22ab238..f464b18 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -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 ([email protected]) */
+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 <[email protected]> and
  * Frank Copeland <[email protected]> */
diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h
index 1b792b9..a417b09 100644
--- a/include/linux/usb_usual.h
+++ b/include/linux/usb_usual.h
@@ -48,7 +48,10 @@
 	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 };
-- 
1.5.3.6




-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.