aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2012-01-10 13:43:30 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-02-08 20:36:41 -0500
commit09b6b51b0b6c1b9bb61815baf205e4d74c89ff04 (patch)
tree03b7c55b764dc555b1d89528fac457a740f897c3
parentde8c46bfc032fbdf490cfb67f534d2a0188ebeb0 (diff)
SCSI & usb-storage: add flags for VPD pages and REPORT LUNS
This patch (as1507) adds a skip_vpd_pages flag to struct scsi_device and a no_report_luns flag to struct scsi_target. The first is used to control whether sd will look at VPD pages for information on block provisioning, limits, and characteristics. The second prevents scsi_report_lun_scan() from issuing a REPORT LUNS command. The patch also modifies usb-storage to set the new flag bits for all USB devices and targets, and to stop adjusting the scsi_level value. Historically we have seen that USB mass-storage devices often don't support VPD pages or REPORT LUNS properly. Until now we have avoided these things by setting the scsi_level to SCSI_2 for all USB devices. But this has the side effect of storing the LUN bits into the second byte of each CDB, and now we have a report of a device which doesn't like that. The best solution is to stop abusing scsi_level and instead have separate flags for VPD pages and REPORT LUNS. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Reported-by: Perry Wagle <wagle@mac.com> CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net> Cc: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/scsi/scsi_scan.c4
-rw-r--r--drivers/scsi/sd.c2
-rw-r--r--drivers/usb/storage/scsiglue.c26
-rw-r--r--include/scsi/scsi_device.h3
4 files changed, 24 insertions, 11 deletions
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 89da43f73c00..fd37bfbfbcdb 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1295,6 +1295,7 @@ EXPORT_SYMBOL(int_to_scsilun);
1295 * LUNs even if it's older than SCSI-3. 1295 * LUNs even if it's older than SCSI-3.
1296 * If BLIST_NOREPORTLUN is set, return 1 always. 1296 * If BLIST_NOREPORTLUN is set, return 1 always.
1297 * If BLIST_NOLUN is set, return 0 always. 1297 * If BLIST_NOLUN is set, return 0 always.
1298 * If starget->no_report_luns is set, return 1 always.
1298 * 1299 *
1299 * Return: 1300 * Return:
1300 * 0: scan completed (or no memory, so further scanning is futile) 1301 * 0: scan completed (or no memory, so further scanning is futile)
@@ -1321,6 +1322,7 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
1321 * Only support SCSI-3 and up devices if BLIST_NOREPORTLUN is not set. 1322 * Only support SCSI-3 and up devices if BLIST_NOREPORTLUN is not set.
1322 * Also allow SCSI-2 if BLIST_REPORTLUN2 is set and host adapter does 1323 * Also allow SCSI-2 if BLIST_REPORTLUN2 is set and host adapter does
1323 * support more than 8 LUNs. 1324 * support more than 8 LUNs.
1325 * Don't attempt if the target doesn't support REPORT LUNS.
1324 */ 1326 */
1325 if (bflags & BLIST_NOREPORTLUN) 1327 if (bflags & BLIST_NOREPORTLUN)
1326 return 1; 1328 return 1;
@@ -1332,6 +1334,8 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
1332 return 1; 1334 return 1;
1333 if (bflags & BLIST_NOLUN) 1335 if (bflags & BLIST_NOLUN)
1334 return 0; 1336 return 0;
1337 if (starget->no_report_luns)
1338 return 1;
1335 1339
1336 if (!(sdev = scsi_device_lookup_by_target(starget, 0))) { 1340 if (!(sdev = scsi_device_lookup_by_target(starget, 0))) {
1337 sdev = scsi_alloc_sdev(starget, 0, NULL); 1341 sdev = scsi_alloc_sdev(starget, 0, NULL);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index c691fb50e6cb..d173b90b25e9 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2349,7 +2349,7 @@ static int sd_try_extended_inquiry(struct scsi_device *sdp)
2349 * some USB ones crash on receiving them, and the pages 2349 * some USB ones crash on receiving them, and the pages
2350 * we currently ask for are for SPC-3 and beyond 2350 * we currently ask for are for SPC-3 and beyond
2351 */ 2351 */
2352 if (sdp->scsi_level > SCSI_SPC_2) 2352 if (sdp->scsi_level > SCSI_SPC_2 && !sdp->skip_vpd_pages)
2353 return 1; 2353 return 1;
2354 return 0; 2354 return 0;
2355} 2355}
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 13b8bcdf3dba..dc68cc9fef5d 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -197,6 +197,9 @@ static int slave_configure(struct scsi_device *sdev)
197 * page x08, so we will skip it. */ 197 * page x08, so we will skip it. */
198 sdev->skip_ms_page_8 = 1; 198 sdev->skip_ms_page_8 = 1;
199 199
200 /* Some devices don't handle VPD pages correctly */
201 sdev->skip_vpd_pages = 1;
202
200 /* Some disks return the total number of blocks in response 203 /* Some disks return the total number of blocks in response
201 * to READ CAPACITY rather than the highest block number. 204 * to READ CAPACITY rather than the highest block number.
202 * If this device makes that mistake, tell the sd driver. */ 205 * If this device makes that mistake, tell the sd driver. */
@@ -217,16 +220,6 @@ static int slave_configure(struct scsi_device *sdev)
217 if (sdev->scsi_level > SCSI_SPC_2) 220 if (sdev->scsi_level > SCSI_SPC_2)
218 us->fflags |= US_FL_SANE_SENSE; 221 us->fflags |= US_FL_SANE_SENSE;
219 222
220 /* Some devices report a SCSI revision level above 2 but are
221 * unable to handle the REPORT LUNS command (for which
222 * support is mandatory at level 3). Since we already have
223 * a Get-Max-LUN request, we won't lose much by setting the
224 * revision level down to 2. The only devices that would be
225 * affected are those with sparse LUNs. */
226 if (sdev->scsi_level > SCSI_2)
227 sdev->sdev_target->scsi_level =
228 sdev->scsi_level = SCSI_2;
229
230 /* USB-IDE bridges tend to report SK = 0x04 (Non-recoverable 223 /* USB-IDE bridges tend to report SK = 0x04 (Non-recoverable
231 * Hardware Error) when any low-level error occurs, 224 * Hardware Error) when any low-level error occurs,
232 * recoverable or not. Setting this flag tells the SCSI 225 * recoverable or not. Setting this flag tells the SCSI
@@ -283,6 +276,18 @@ static int slave_configure(struct scsi_device *sdev)
283 return 0; 276 return 0;
284} 277}
285 278
279static int target_alloc(struct scsi_target *starget)
280{
281 /*
282 * Some USB drives don't support REPORT LUNS, even though they
283 * report a SCSI revision level above 2. Tell the SCSI layer
284 * not to issue that command; it will perform a normal sequential
285 * scan instead.
286 */
287 starget->no_report_luns = 1;
288 return 0;
289}
290
286/* queue a command */ 291/* queue a command */
287/* This is always called with scsi_lock(host) held */ 292/* This is always called with scsi_lock(host) held */
288static int queuecommand_lck(struct scsi_cmnd *srb, 293static int queuecommand_lck(struct scsi_cmnd *srb,
@@ -546,6 +551,7 @@ struct scsi_host_template usb_stor_host_template = {
546 551
547 .slave_alloc = slave_alloc, 552 .slave_alloc = slave_alloc,
548 .slave_configure = slave_configure, 553 .slave_configure = slave_configure,
554 .target_alloc = target_alloc,
549 555
550 /* lots of sg segments can be handled */ 556 /* lots of sg segments can be handled */
551 .sg_tablesize = SCSI_MAX_SG_CHAIN_SEGMENTS, 557 .sg_tablesize = SCSI_MAX_SG_CHAIN_SEGMENTS,
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 01cb3c4cb74d..b3a1c2daf6cc 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -136,6 +136,7 @@ struct scsi_device {
136 unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */ 136 unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */
137 unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */ 137 unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */
138 unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */ 138 unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */
139 unsigned skip_vpd_pages:1; /* do not read VPD pages */
139 unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */ 140 unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */
140 unsigned no_start_on_add:1; /* do not issue start on add */ 141 unsigned no_start_on_add:1; /* do not issue start on add */
141 unsigned allow_restart:1; /* issue START_UNIT in error handler */ 142 unsigned allow_restart:1; /* issue START_UNIT in error handler */
@@ -248,6 +249,8 @@ struct scsi_target {
248 * for the device at a time. */ 249 * for the device at a time. */
249 unsigned int pdt_1f_for_no_lun:1; /* PDT = 0x1f 250 unsigned int pdt_1f_for_no_lun:1; /* PDT = 0x1f
250 * means no lun present. */ 251 * means no lun present. */
252 unsigned int no_report_luns:1; /* Don't use
253 * REPORT LUNS for scanning. */
251 /* commands actually active on LLD. protected by host lock. */ 254 /* commands actually active on LLD. protected by host lock. */
252 unsigned int target_busy; 255 unsigned int target_busy;
253 /* 256 /*