All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH]indistinguishable devices with broken and unbroken firmware #2
@ 2007-02-08  8:04 Oliver Neukum
  2007-02-09  1:20 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Oliver Neukum @ 2007-02-08  8:04 UTC (permalink / raw)
  To: usb-storage, linux-scsi, gregkh, Alan Stern

Hi,

there's a USB mass storage device which exists in two version. One
reports the correct size and the other does not. Apart from that they
are identical and cannot be told apart. Here's a heuristic based on the
empirical finding that drives have even sizes.

The requested changes have been made.
Greg, can this go through your tree?

	Regards
		Oliver

Signed-off-by: Oliver Neukum <oneukum@suse.de>
------

--- linux-2.6.20/drivers/usb/storage/unusual_devs.h	2007-02-06 14:14:49.000000000 +0100
+++ linux-2.6.20-autosusp/drivers/usb/storage/unusual_devs.h	2007-02-07 15:14:01.000000000 +0100
@@ -1430,7 +1430,7 @@
 		"DataStor",
 		"USB4500 FW1.04",
 		US_SC_DEVICE, US_PR_DEVICE, NULL,
-		US_FL_FIX_CAPACITY),
+		US_FL_CAPACITY_HEURISTICS),
 
 /* Control/Bulk transport for all SubClass values */
 USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR),
--- linux-2.6.20/drivers/usb/storage/scsiglue.c	2007-02-06 14:13:49.000000000 +0100
+++ linux-2.6.20-autosusp/drivers/usb/storage/scsiglue.c	2007-02-07 15:14:01.000000000 +0100
@@ -170,6 +170,12 @@
 		if (us->flags & US_FL_FIX_CAPACITY)
 			sdev->fix_capacity = 1;
 
+		/* A few disks have two indistinguishable version, one of
+		 * which reports the correct capacity and the other does not.
+		 * The sd driver has to guess which is the case. */
+		if (us->flags & US_FL_CAPACITY_HEURISTICS)
+			sdev->guess_capacity = 1;
+
 		/* Some devices report a SCSI revision level above 2 but are
 		 * unable to handle the REPORT LUNS command (for which
 		 * support is mandatory at level 3).  Since we already have
--- linux-2.6.20/drivers/scsi/sd.c	2007-02-06 14:14:48.000000000 +0100
+++ linux-2.6.20-autosusp/drivers/scsi/sd.c	2007-02-08 08:49:22.000000000 +0100
@@ -1270,9 +1270,18 @@
 
 	/* Some devices return the total number of sectors, not the
 	 * highest sector number.  Make the necessary adjustment. */
-	if (sdp->fix_capacity)
+	if (sdp->fix_capacity) {
 		--sdkp->capacity;
 
+	/* Some devices have version which report the correct sizes
+	 * and others which do not. We guess size according to a heuristic
+	 * and err on the side of lowering the capacity. */
+	} else {
+		if (sdp->guess_capacity)
+			if (sdkp->capacity & 0x01) /* odd sizes are odd */
+				--sdkp->capacity;
+	}
+
 got_data:
 	if (sector_size == 0) {
 		sector_size = 512;
--- linux-2.6.20/include/linux/usb_usual.h	2007-02-06 14:14:07.000000000 +0100
+++ linux-2.6.20-autosusp/include/linux/usb_usual.h	2007-02-07 15:14:01.000000000 +0100
@@ -46,7 +46,9 @@
 	US_FLAG(MAX_SECTORS_64,	0x00000400)			\
 		/* Sets max_sectors to 64    */			\
 	US_FLAG(IGNORE_DEVICE,	0x00000800)			\
-		/* Don't claim device */
+		/* Don't claim device */			\
+	US_FLAG(CAPACITY_HEURISTICS,	0x00001000)		\
+		/* sometimes sizes is too big */
 
 #define US_FLAG(name, value)	US_FL_##name = value ,
 enum { US_DO_ALL_FLAGS };
--- linux-2.6.20/include/scsi/scsi_device.h	2007-02-06 14:14:57.000000000 +0100
+++ linux-2.6.20-autosusp/include/scsi/scsi_device.h	2007-02-07 15:14:01.000000000 +0100
@@ -122,6 +122,7 @@
 	unsigned no_uld_attach:1; /* disable connecting to upper level drivers */
 	unsigned select_no_atn:1;
 	unsigned fix_capacity:1;	/* READ_CAPACITY is too high by 1 */
+	unsigned guess_capacity:1;	/* READ_CAPACITY might be too high by 1 */
 	unsigned retry_hwerror:1;	/* Retry HARDWARE_ERROR */
 
 	unsigned int device_blocked;	/* Device returned QUEUE_FULL. */

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH]indistinguishable devices with broken and unbroken firmware #2
  2007-02-08  8:04 [PATCH]indistinguishable devices with broken and unbroken firmware #2 Oliver Neukum
@ 2007-02-09  1:20 ` Greg KH
  2007-02-09 15:30   ` Alan Stern
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2007-02-09  1:20 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: usb-storage, linux-scsi, Alan Stern

On Thu, Feb 08, 2007 at 09:04:48AM +0100, Oliver Neukum wrote:
> Hi,
> 
> there's a USB mass storage device which exists in two version. One
> reports the correct size and the other does not. Apart from that they
> are identical and cannot be told apart. Here's a heuristic based on the
> empirical finding that drives have even sizes.
> 
> The requested changes have been made.
> Greg, can this go through your tree?

If the usb-storage people ACK it, I'll be glad to add it to my trees.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH]indistinguishable devices with broken and unbroken firmware #2
  2007-02-09  1:20 ` Greg KH
@ 2007-02-09 15:30   ` Alan Stern
  2007-02-09 17:44     ` [usb-storage] " Matthew Dharm
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Stern @ 2007-02-09 15:30 UTC (permalink / raw)
  To: Greg KH; +Cc: Oliver Neukum, usb-storage, linux-scsi

On Thu, 8 Feb 2007, Greg KH wrote:

> On Thu, Feb 08, 2007 at 09:04:48AM +0100, Oliver Neukum wrote:
> > Hi,
> > 
> > there's a USB mass storage device which exists in two version. One
> > reports the correct size and the other does not. Apart from that they
> > are identical and cannot be told apart. Here's a heuristic based on the
> > empirical finding that drives have even sizes.
> > 
> > The requested changes have been made.
> > Greg, can this go through your tree?
> 
> If the usb-storage people ACK it, I'll be glad to add it to my trees.

It's okay with me.

Acked-by: Alan Stern <stern@rowland.harvard.edu>

Alan Stern


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [usb-storage] [PATCH]indistinguishable devices with broken and unbroken firmware #2
  2007-02-09 15:30   ` Alan Stern
@ 2007-02-09 17:44     ` Matthew Dharm
  0 siblings, 0 replies; 4+ messages in thread
From: Matthew Dharm @ 2007-02-09 17:44 UTC (permalink / raw)
  To: Alan Stern; +Cc: Greg KH, usb-storage, Oliver Neukum, linux-scsi

[-- Attachment #1: Type: text/plain, Size: 1121 bytes --]

On Fri, Feb 09, 2007 at 10:30:37AM -0500, Alan Stern wrote:
> On Thu, 8 Feb 2007, Greg KH wrote:
> 
> > On Thu, Feb 08, 2007 at 09:04:48AM +0100, Oliver Neukum wrote:
> > > Hi,
> > > 
> > > there's a USB mass storage device which exists in two version. One
> > > reports the correct size and the other does not. Apart from that they
> > > are identical and cannot be told apart. Here's a heuristic based on the
> > > empirical finding that drives have even sizes.
> > > 
> > > The requested changes have been made.
> > > Greg, can this go through your tree?
> > 
> > If the usb-storage people ACK it, I'll be glad to add it to my trees.
> 
> It's okay with me.
> 
> Acked-by: Alan Stern <stern@rowland.harvard.edu>

Looks okay to me too.

Acked-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net>

Matt

-- 
Matthew Dharm                              Home: mdharm-usb@one-eyed-alien.net 
Maintainer, Linux USB Mass Storage Driver

E:  You run this ship with Windows?!  YOU IDIOT!
L:  Give me a break, it came bundled with the computer!
					-- ESR and Lan Solaris
User Friendly, 12/8/1998

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-02-09 18:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-08  8:04 [PATCH]indistinguishable devices with broken and unbroken firmware #2 Oliver Neukum
2007-02-09  1:20 ` Greg KH
2007-02-09 15:30   ` Alan Stern
2007-02-09 17:44     ` [usb-storage] " Matthew Dharm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.