dealing with enclosures that don't handle READ_CAPACITY10

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I got a bug report about an enclosure that mishandles READ_CAPACITY10.
I don't want to introduce yet another quirk. So what about basing this
on USB version?

	Regards
		Oliver

>From 58cb3cd4b8a58d986b74e0a41d52de989dbe64bc Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oneukum@xxxxxxx>
Date: Mon, 12 Aug 2013 14:49:02 +0200
Subject: [PATCH] storage: use READ_CAPACITY16 first on 3.00 devices

Some old devices crash when confronted with READ_CAPACITY16. Therefore
READ_CAPACITY10 is used first and we depend on devices with more
than 2TB correctly reporting an overflow. However some 3.0 devices
do not report an overflow but capacity % 2TB. The value reported thus
is entirely plausible. As these devices also work with another OS
without partition tables, that should copy the expected behavior.

Signed-off-by: Oliver Neukum <oneukum@xxxxxxx>
---
 drivers/usb/storage/scsiglue.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 92b05d9..04bf91d 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -108,6 +108,7 @@ static int slave_alloc (struct scsi_device *sdev)
 static int slave_configure(struct scsi_device *sdev)
 {
 	struct us_data *us = host_to_us(sdev->host);
+	u16 usb_version;
 
 	/* Many devices have trouble transferring more than 32KB at a time,
 	 * while others have trouble with more than 64K. At this time we
@@ -211,8 +212,12 @@ static int slave_configure(struct scsi_device *sdev)
 		/*
 		 * Many devices do not respond properly to READ_CAPACITY_16.
 		 * Tell the SCSI layer to try READ_CAPACITY_10 first.
+		 * However some USB 3.0 drive enclosures return capacity
+		 * modulo 2TB
 		 */
-		sdev->try_rc_10_first = 1;
+		usb_version = le16_to_cpu(us->pusb_dev->descriptor.bcdUSB);
+		if (usb_version < '3' * 0x100)
+			sdev->try_rc_10_first = 1;
 
 		/* assume SPC3 or latter devices support sense size > 18 */
 		if (sdev->scsi_level > SCSI_SPC_2)
-- 
1.8.3.1


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux