aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-02-23 11:20:44 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-02-23 11:21:03 -0500
commitc69263c66e5b2a5d0c7e5a41c189b1846ae1de92 (patch)
tree81c6cf0f5b3b05739e2e73b0118077d9dd245182 /drivers/usb/storage
parent45196cee28a5bcfb6ddbe2bffa4270cbed66ae4b (diff)
parent5407a3c3d942e75d4d123d213fd692bce5acc961 (diff)
Merge branch 'usb-3.3-rc4' into usb-next
This is to pull in the xhci changes and the other fixes and device id updates that were done in Linus's tree. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/storage')
-rw-r--r--drivers/usb/storage/alauda.c1
-rw-r--r--drivers/usb/storage/cypress_atacb.c1
-rw-r--r--drivers/usb/storage/datafab.c1
-rw-r--r--drivers/usb/storage/ene_ub6250.c1
-rw-r--r--drivers/usb/storage/freecom.c1
-rw-r--r--drivers/usb/storage/isd200.c1
-rw-r--r--drivers/usb/storage/jumpshot.c1
-rw-r--r--drivers/usb/storage/karma.c1
-rw-r--r--drivers/usb/storage/onetouch.c1
-rw-r--r--drivers/usb/storage/realtek_cr.c1
-rw-r--r--drivers/usb/storage/scsiglue.c55
-rw-r--r--drivers/usb/storage/sddr09.c1
-rw-r--r--drivers/usb/storage/sddr55.c1
-rw-r--r--drivers/usb/storage/shuttle_usbat.c1
-rw-r--r--drivers/usb/storage/uas.c328
-rw-r--r--drivers/usb/storage/usb.c21
16 files changed, 274 insertions, 143 deletions
diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c
index 51af2fee2efd..bab8c8fe8290 100644
--- a/drivers/usb/storage/alauda.c
+++ b/drivers/usb/storage/alauda.c
@@ -1276,6 +1276,7 @@ static struct usb_driver alauda_driver = {
1276 .post_reset = usb_stor_post_reset, 1276 .post_reset = usb_stor_post_reset,
1277 .id_table = alauda_usb_ids, 1277 .id_table = alauda_usb_ids,
1278 .soft_unbind = 1, 1278 .soft_unbind = 1,
1279 .no_dynamic_id = 1,
1279}; 1280};
1280 1281
1281module_usb_driver(alauda_driver); 1282module_usb_driver(alauda_driver);
diff --git a/drivers/usb/storage/cypress_atacb.c b/drivers/usb/storage/cypress_atacb.c
index 387cbd47acc9..5fe451d16e68 100644
--- a/drivers/usb/storage/cypress_atacb.c
+++ b/drivers/usb/storage/cypress_atacb.c
@@ -272,6 +272,7 @@ static struct usb_driver cypress_driver = {
272 .post_reset = usb_stor_post_reset, 272 .post_reset = usb_stor_post_reset,
273 .id_table = cypress_usb_ids, 273 .id_table = cypress_usb_ids,
274 .soft_unbind = 1, 274 .soft_unbind = 1,
275 .no_dynamic_id = 1,
275}; 276};
276 277
277module_usb_driver(cypress_driver); 278module_usb_driver(cypress_driver);
diff --git a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c
index 15d41f2b3d6f..35e9c51e6696 100644
--- a/drivers/usb/storage/datafab.c
+++ b/drivers/usb/storage/datafab.c
@@ -751,6 +751,7 @@ static struct usb_driver datafab_driver = {
751 .post_reset = usb_stor_post_reset, 751 .post_reset = usb_stor_post_reset,
752 .id_table = datafab_usb_ids, 752 .id_table = datafab_usb_ids,
753 .soft_unbind = 1, 753 .soft_unbind = 1,
754 .no_dynamic_id = 1,
754}; 755};
755 756
756module_usb_driver(datafab_driver); 757module_usb_driver(datafab_driver);
diff --git a/drivers/usb/storage/ene_ub6250.c b/drivers/usb/storage/ene_ub6250.c
index a6ade4071a9a..30532d93eecc 100644
--- a/drivers/usb/storage/ene_ub6250.c
+++ b/drivers/usb/storage/ene_ub6250.c
@@ -2407,6 +2407,7 @@ static struct usb_driver ene_ub6250_driver = {
2407 .post_reset = usb_stor_post_reset, 2407 .post_reset = usb_stor_post_reset,
2408 .id_table = ene_ub6250_usb_ids, 2408 .id_table = ene_ub6250_usb_ids,
2409 .soft_unbind = 1, 2409 .soft_unbind = 1,
2410 .no_dynamic_id = 1,
2410}; 2411};
2411 2412
2412module_usb_driver(ene_ub6250_driver); 2413module_usb_driver(ene_ub6250_driver);
diff --git a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c
index fa1615748475..042cf9ef3153 100644
--- a/drivers/usb/storage/freecom.c
+++ b/drivers/usb/storage/freecom.c
@@ -553,6 +553,7 @@ static struct usb_driver freecom_driver = {
553 .post_reset = usb_stor_post_reset, 553 .post_reset = usb_stor_post_reset,
554 .id_table = freecom_usb_ids, 554 .id_table = freecom_usb_ids,
555 .soft_unbind = 1, 555 .soft_unbind = 1,
556 .no_dynamic_id = 1,
556}; 557};
557 558
558module_usb_driver(freecom_driver); 559module_usb_driver(freecom_driver);
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
index bd5502700831..31fa24e7e68a 100644
--- a/drivers/usb/storage/isd200.c
+++ b/drivers/usb/storage/isd200.c
@@ -1566,6 +1566,7 @@ static struct usb_driver isd200_driver = {
1566 .post_reset = usb_stor_post_reset, 1566 .post_reset = usb_stor_post_reset,
1567 .id_table = isd200_usb_ids, 1567 .id_table = isd200_usb_ids,
1568 .soft_unbind = 1, 1568 .soft_unbind = 1,
1569 .no_dynamic_id = 1,
1569}; 1570};
1570 1571
1571module_usb_driver(isd200_driver); 1572module_usb_driver(isd200_driver);
diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c
index a19211b5c265..e3b97383186a 100644
--- a/drivers/usb/storage/jumpshot.c
+++ b/drivers/usb/storage/jumpshot.c
@@ -677,6 +677,7 @@ static struct usb_driver jumpshot_driver = {
677 .post_reset = usb_stor_post_reset, 677 .post_reset = usb_stor_post_reset,
678 .id_table = jumpshot_usb_ids, 678 .id_table = jumpshot_usb_ids,
679 .soft_unbind = 1, 679 .soft_unbind = 1,
680 .no_dynamic_id = 1,
680}; 681};
681 682
682module_usb_driver(jumpshot_driver); 683module_usb_driver(jumpshot_driver);
diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c
index e720f8ebdf9f..a8708eae9788 100644
--- a/drivers/usb/storage/karma.c
+++ b/drivers/usb/storage/karma.c
@@ -230,6 +230,7 @@ static struct usb_driver karma_driver = {
230 .post_reset = usb_stor_post_reset, 230 .post_reset = usb_stor_post_reset,
231 .id_table = karma_usb_ids, 231 .id_table = karma_usb_ids,
232 .soft_unbind = 1, 232 .soft_unbind = 1,
233 .no_dynamic_id = 1,
233}; 234};
234 235
235module_usb_driver(karma_driver); 236module_usb_driver(karma_driver);
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c
index d75155c38200..886567a3806d 100644
--- a/drivers/usb/storage/onetouch.c
+++ b/drivers/usb/storage/onetouch.c
@@ -312,6 +312,7 @@ static struct usb_driver onetouch_driver = {
312 .post_reset = usb_stor_post_reset, 312 .post_reset = usb_stor_post_reset,
313 .id_table = onetouch_usb_ids, 313 .id_table = onetouch_usb_ids,
314 .soft_unbind = 1, 314 .soft_unbind = 1,
315 .no_dynamic_id = 1,
315}; 316};
316 317
317module_usb_driver(onetouch_driver); 318module_usb_driver(onetouch_driver);
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
index d32f72061c09..b1c2fe8b6dcd 100644
--- a/drivers/usb/storage/realtek_cr.c
+++ b/drivers/usb/storage/realtek_cr.c
@@ -1100,6 +1100,7 @@ static struct usb_driver realtek_cr_driver = {
1100 .id_table = realtek_cr_ids, 1100 .id_table = realtek_cr_ids,
1101 .soft_unbind = 1, 1101 .soft_unbind = 1,
1102 .supports_autosuspend = 1, 1102 .supports_autosuspend = 1,
1103 .no_dynamic_id = 1,
1103}; 1104};
1104 1105
1105module_usb_driver(realtek_cr_driver); 1106module_usb_driver(realtek_cr_driver);
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 13b8bcdf3dba..a324a5d21e99 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -78,8 +78,6 @@ static const char* host_info(struct Scsi_Host *host)
78 78
79static int slave_alloc (struct scsi_device *sdev) 79static int slave_alloc (struct scsi_device *sdev)
80{ 80{
81 struct us_data *us = host_to_us(sdev->host);
82
83 /* 81 /*
84 * Set the INQUIRY transfer length to 36. We don't use any of 82 * Set the INQUIRY transfer length to 36. We don't use any of
85 * the extra data and many devices choke if asked for more or 83 * the extra data and many devices choke if asked for more or
@@ -104,18 +102,6 @@ static int slave_alloc (struct scsi_device *sdev)
104 */ 102 */
105 blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1)); 103 blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1));
106 104
107 /*
108 * The UFI spec treates the Peripheral Qualifier bits in an
109 * INQUIRY result as reserved and requires devices to set them
110 * to 0. However the SCSI spec requires these bits to be set
111 * to 3 to indicate when a LUN is not present.
112 *
113 * Let the scanning code know if this target merely sets
114 * Peripheral Device Type to 0x1f to indicate no LUN.
115 */
116 if (us->subclass == USB_SC_UFI)
117 sdev->sdev_target->pdt_1f_for_no_lun = 1;
118
119 return 0; 105 return 0;
120} 106}
121 107
@@ -197,6 +183,9 @@ static int slave_configure(struct scsi_device *sdev)
197 * page x08, so we will skip it. */ 183 * page x08, so we will skip it. */
198 sdev->skip_ms_page_8 = 1; 184 sdev->skip_ms_page_8 = 1;
199 185
186 /* Some devices don't handle VPD pages correctly */
187 sdev->skip_vpd_pages = 1;
188
200 /* Some disks return the total number of blocks in response 189 /* Some disks return the total number of blocks in response
201 * to READ CAPACITY rather than the highest block number. 190 * to READ CAPACITY rather than the highest block number.
202 * If this device makes that mistake, tell the sd driver. */ 191 * If this device makes that mistake, tell the sd driver. */
@@ -217,16 +206,6 @@ static int slave_configure(struct scsi_device *sdev)
217 if (sdev->scsi_level > SCSI_SPC_2) 206 if (sdev->scsi_level > SCSI_SPC_2)
218 us->fflags |= US_FL_SANE_SENSE; 207 us->fflags |= US_FL_SANE_SENSE;
219 208
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 209 /* USB-IDE bridges tend to report SK = 0x04 (Non-recoverable
231 * Hardware Error) when any low-level error occurs, 210 * Hardware Error) when any low-level error occurs,
232 * recoverable or not. Setting this flag tells the SCSI 211 * recoverable or not. Setting this flag tells the SCSI
@@ -283,6 +262,33 @@ static int slave_configure(struct scsi_device *sdev)
283 return 0; 262 return 0;
284} 263}
285 264
265static int target_alloc(struct scsi_target *starget)
266{
267 struct us_data *us = host_to_us(dev_to_shost(starget->dev.parent));
268
269 /*
270 * Some USB drives don't support REPORT LUNS, even though they
271 * report a SCSI revision level above 2. Tell the SCSI layer
272 * not to issue that command; it will perform a normal sequential
273 * scan instead.
274 */
275 starget->no_report_luns = 1;
276
277 /*
278 * The UFI spec treats the Peripheral Qualifier bits in an
279 * INQUIRY result as reserved and requires devices to set them
280 * to 0. However the SCSI spec requires these bits to be set
281 * to 3 to indicate when a LUN is not present.
282 *
283 * Let the scanning code know if this target merely sets
284 * Peripheral Device Type to 0x1f to indicate no LUN.
285 */
286 if (us->subclass == USB_SC_UFI)
287 starget->pdt_1f_for_no_lun = 1;
288
289 return 0;
290}
291
286/* queue a command */ 292/* queue a command */
287/* This is always called with scsi_lock(host) held */ 293/* This is always called with scsi_lock(host) held */
288static int queuecommand_lck(struct scsi_cmnd *srb, 294static int queuecommand_lck(struct scsi_cmnd *srb,
@@ -546,6 +552,7 @@ struct scsi_host_template usb_stor_host_template = {
546 552
547 .slave_alloc = slave_alloc, 553 .slave_alloc = slave_alloc,
548 .slave_configure = slave_configure, 554 .slave_configure = slave_configure,
555 .target_alloc = target_alloc,
549 556
550 /* lots of sg segments can be handled */ 557 /* lots of sg segments can be handled */
551 .sg_tablesize = SCSI_MAX_SG_CHAIN_SEGMENTS, 558 .sg_tablesize = SCSI_MAX_SG_CHAIN_SEGMENTS,
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c
index 425df7df2e56..3252a62b31bc 100644
--- a/drivers/usb/storage/sddr09.c
+++ b/drivers/usb/storage/sddr09.c
@@ -1787,6 +1787,7 @@ static struct usb_driver sddr09_driver = {
1787 .post_reset = usb_stor_post_reset, 1787 .post_reset = usb_stor_post_reset,
1788 .id_table = sddr09_usb_ids, 1788 .id_table = sddr09_usb_ids,
1789 .soft_unbind = 1, 1789 .soft_unbind = 1,
1790 .no_dynamic_id = 1,
1790}; 1791};
1791 1792
1792module_usb_driver(sddr09_driver); 1793module_usb_driver(sddr09_driver);
diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c
index e4ca5fcb7cc3..c144078065a7 100644
--- a/drivers/usb/storage/sddr55.c
+++ b/drivers/usb/storage/sddr55.c
@@ -1006,6 +1006,7 @@ static struct usb_driver sddr55_driver = {
1006 .post_reset = usb_stor_post_reset, 1006 .post_reset = usb_stor_post_reset,
1007 .id_table = sddr55_usb_ids, 1007 .id_table = sddr55_usb_ids,
1008 .soft_unbind = 1, 1008 .soft_unbind = 1,
1009 .no_dynamic_id = 1,
1009}; 1010};
1010 1011
1011module_usb_driver(sddr55_driver); 1012module_usb_driver(sddr55_driver);
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c
index 1369d2590616..fa1ceebc465c 100644
--- a/drivers/usb/storage/shuttle_usbat.c
+++ b/drivers/usb/storage/shuttle_usbat.c
@@ -1863,6 +1863,7 @@ static struct usb_driver usbat_driver = {
1863 .post_reset = usb_stor_post_reset, 1863 .post_reset = usb_stor_post_reset,
1864 .id_table = usbat_usb_ids, 1864 .id_table = usbat_usb_ids,
1865 .soft_unbind = 1, 1865 .soft_unbind = 1,
1866 .no_dynamic_id = 1,
1866}; 1867};
1867 1868
1868module_usb_driver(usbat_driver); 1869module_usb_driver(usbat_driver);
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index a33ead5dce20..8ec8a6e66f50 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -13,7 +13,9 @@
13#include <linux/types.h> 13#include <linux/types.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/usb.h> 15#include <linux/usb.h>
16#include <linux/usb/hcd.h>
16#include <linux/usb/storage.h> 17#include <linux/usb/storage.h>
18#include <linux/usb/uas.h>
17 19
18#include <scsi/scsi.h> 20#include <scsi/scsi.h>
19#include <scsi/scsi_dbg.h> 21#include <scsi/scsi_dbg.h>
@@ -22,49 +24,6 @@
22#include <scsi/scsi_host.h> 24#include <scsi/scsi_host.h>
23#include <scsi/scsi_tcq.h> 25#include <scsi/scsi_tcq.h>
24 26
25/* Common header for all IUs */
26struct iu {
27 __u8 iu_id;
28 __u8 rsvd1;
29 __be16 tag;
30};
31
32enum {
33 IU_ID_COMMAND = 0x01,
34 IU_ID_STATUS = 0x03,
35 IU_ID_RESPONSE = 0x04,
36 IU_ID_TASK_MGMT = 0x05,
37 IU_ID_READ_READY = 0x06,
38 IU_ID_WRITE_READY = 0x07,
39};
40
41struct command_iu {
42 __u8 iu_id;
43 __u8 rsvd1;
44 __be16 tag;
45 __u8 prio_attr;
46 __u8 rsvd5;
47 __u8 len;
48 __u8 rsvd7;
49 struct scsi_lun lun;
50 __u8 cdb[16]; /* XXX: Overflow-checking tools may misunderstand */
51};
52
53/*
54 * Also used for the Read Ready and Write Ready IUs since they have the
55 * same first four bytes
56 */
57struct sense_iu {
58 __u8 iu_id;
59 __u8 rsvd1;
60 __be16 tag;
61 __be16 status_qual;
62 __u8 status;
63 __u8 rsvd7[7];
64 __be16 len;
65 __u8 sense[SCSI_SENSE_BUFFERSIZE];
66};
67
68/* 27/*
69 * The r00-r01c specs define this version of the SENSE IU data structure. 28 * The r00-r01c specs define this version of the SENSE IU data structure.
70 * It's still in use by several different firmware releases. 29 * It's still in use by several different firmware releases.
@@ -79,18 +38,6 @@ struct sense_iu_old {
79 __u8 sense[SCSI_SENSE_BUFFERSIZE]; 38 __u8 sense[SCSI_SENSE_BUFFERSIZE];
80}; 39};
81 40
82enum {
83 CMD_PIPE_ID = 1,
84 STATUS_PIPE_ID = 2,
85 DATA_IN_PIPE_ID = 3,
86 DATA_OUT_PIPE_ID = 4,
87
88 UAS_SIMPLE_TAG = 0,
89 UAS_HEAD_TAG = 1,
90 UAS_ORDERED_TAG = 2,
91 UAS_ACA = 4,
92};
93
94struct uas_dev_info { 41struct uas_dev_info {
95 struct usb_interface *intf; 42 struct usb_interface *intf;
96 struct usb_device *udev; 43 struct usb_device *udev;
@@ -98,6 +45,8 @@ struct uas_dev_info {
98 unsigned cmd_pipe, status_pipe, data_in_pipe, data_out_pipe; 45 unsigned cmd_pipe, status_pipe, data_in_pipe, data_out_pipe;
99 unsigned use_streams:1; 46 unsigned use_streams:1;
100 unsigned uas_sense_old:1; 47 unsigned uas_sense_old:1;
48 struct scsi_cmnd *cmnd;
49 struct urb *status_urb; /* used only if stream support is available */
101}; 50};
102 51
103enum { 52enum {
@@ -109,6 +58,9 @@ enum {
109 SUBMIT_DATA_OUT_URB = (1 << 5), 58 SUBMIT_DATA_OUT_URB = (1 << 5),
110 ALLOC_CMD_URB = (1 << 6), 59 ALLOC_CMD_URB = (1 << 6),
111 SUBMIT_CMD_URB = (1 << 7), 60 SUBMIT_CMD_URB = (1 << 7),
61 COMPLETED_DATA_IN = (1 << 8),
62 COMPLETED_DATA_OUT = (1 << 9),
63 DATA_COMPLETES_CMD = (1 << 10),
112}; 64};
113 65
114/* Overrides scsi_pointer */ 66/* Overrides scsi_pointer */
@@ -116,6 +68,7 @@ struct uas_cmd_info {
116 unsigned int state; 68 unsigned int state;
117 unsigned int stream; 69 unsigned int stream;
118 struct urb *cmd_urb; 70 struct urb *cmd_urb;
71 /* status_urb is used only if stream support isn't available */
119 struct urb *status_urb; 72 struct urb *status_urb;
120 struct urb *data_in_urb; 73 struct urb *data_in_urb;
121 struct urb *data_out_urb; 74 struct urb *data_out_urb;
@@ -125,33 +78,43 @@ struct uas_cmd_info {
125/* I hate forward declarations, but I actually have a loop */ 78/* I hate forward declarations, but I actually have a loop */
126static int uas_submit_urbs(struct scsi_cmnd *cmnd, 79static int uas_submit_urbs(struct scsi_cmnd *cmnd,
127 struct uas_dev_info *devinfo, gfp_t gfp); 80 struct uas_dev_info *devinfo, gfp_t gfp);
81static void uas_do_work(struct work_struct *work);
128 82
83static DECLARE_WORK(uas_work, uas_do_work);
129static DEFINE_SPINLOCK(uas_work_lock); 84static DEFINE_SPINLOCK(uas_work_lock);
130static LIST_HEAD(uas_work_list); 85static LIST_HEAD(uas_work_list);
131 86
132static void uas_do_work(struct work_struct *work) 87static void uas_do_work(struct work_struct *work)
133{ 88{
134 struct uas_cmd_info *cmdinfo; 89 struct uas_cmd_info *cmdinfo;
90 struct uas_cmd_info *temp;
135 struct list_head list; 91 struct list_head list;
92 int err;
136 93
137 spin_lock_irq(&uas_work_lock); 94 spin_lock_irq(&uas_work_lock);
138 list_replace_init(&uas_work_list, &list); 95 list_replace_init(&uas_work_list, &list);
139 spin_unlock_irq(&uas_work_lock); 96 spin_unlock_irq(&uas_work_lock);
140 97
141 list_for_each_entry(cmdinfo, &list, list) { 98 list_for_each_entry_safe(cmdinfo, temp, &list, list) {
142 struct scsi_pointer *scp = (void *)cmdinfo; 99 struct scsi_pointer *scp = (void *)cmdinfo;
143 struct scsi_cmnd *cmnd = container_of(scp, 100 struct scsi_cmnd *cmnd = container_of(scp,
144 struct scsi_cmnd, SCp); 101 struct scsi_cmnd, SCp);
145 uas_submit_urbs(cmnd, cmnd->device->hostdata, GFP_NOIO); 102 err = uas_submit_urbs(cmnd, cmnd->device->hostdata, GFP_NOIO);
103 if (err) {
104 list_del(&cmdinfo->list);
105 spin_lock_irq(&uas_work_lock);
106 list_add_tail(&cmdinfo->list, &uas_work_list);
107 spin_unlock_irq(&uas_work_lock);
108 schedule_work(&uas_work);
109 }
146 } 110 }
147} 111}
148 112
149static DECLARE_WORK(uas_work, uas_do_work);
150
151static void uas_sense(struct urb *urb, struct scsi_cmnd *cmnd) 113static void uas_sense(struct urb *urb, struct scsi_cmnd *cmnd)
152{ 114{
153 struct sense_iu *sense_iu = urb->transfer_buffer; 115 struct sense_iu *sense_iu = urb->transfer_buffer;
154 struct scsi_device *sdev = cmnd->device; 116 struct scsi_device *sdev = cmnd->device;
117 struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
155 118
156 if (urb->actual_length > 16) { 119 if (urb->actual_length > 16) {
157 unsigned len = be16_to_cpup(&sense_iu->len); 120 unsigned len = be16_to_cpup(&sense_iu->len);
@@ -169,16 +132,15 @@ static void uas_sense(struct urb *urb, struct scsi_cmnd *cmnd)
169 } 132 }
170 133
171 cmnd->result = sense_iu->status; 134 cmnd->result = sense_iu->status;
172 if (sdev->current_cmnd) 135 if (!(cmdinfo->state & DATA_COMPLETES_CMD))
173 sdev->current_cmnd = NULL; 136 cmnd->scsi_done(cmnd);
174 cmnd->scsi_done(cmnd);
175 usb_free_urb(urb);
176} 137}
177 138
178static void uas_sense_old(struct urb *urb, struct scsi_cmnd *cmnd) 139static void uas_sense_old(struct urb *urb, struct scsi_cmnd *cmnd)
179{ 140{
180 struct sense_iu_old *sense_iu = urb->transfer_buffer; 141 struct sense_iu_old *sense_iu = urb->transfer_buffer;
181 struct scsi_device *sdev = cmnd->device; 142 struct scsi_device *sdev = cmnd->device;
143 struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
182 144
183 if (urb->actual_length > 8) { 145 if (urb->actual_length > 8) {
184 unsigned len = be16_to_cpup(&sense_iu->len) - 2; 146 unsigned len = be16_to_cpup(&sense_iu->len) - 2;
@@ -196,10 +158,8 @@ static void uas_sense_old(struct urb *urb, struct scsi_cmnd *cmnd)
196 } 158 }
197 159
198 cmnd->result = sense_iu->status; 160 cmnd->result = sense_iu->status;
199 if (sdev->current_cmnd) 161 if (!(cmdinfo->state & DATA_COMPLETES_CMD))
200 sdev->current_cmnd = NULL; 162 cmnd->scsi_done(cmnd);
201 cmnd->scsi_done(cmnd);
202 usb_free_urb(urb);
203} 163}
204 164
205static void uas_xfer_data(struct urb *urb, struct scsi_cmnd *cmnd, 165static void uas_xfer_data(struct urb *urb, struct scsi_cmnd *cmnd,
@@ -208,7 +168,7 @@ static void uas_xfer_data(struct urb *urb, struct scsi_cmnd *cmnd,
208 struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; 168 struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
209 int err; 169 int err;
210 170
211 cmdinfo->state = direction | SUBMIT_STATUS_URB; 171 cmdinfo->state = direction;
212 err = uas_submit_urbs(cmnd, cmnd->device->hostdata, GFP_ATOMIC); 172 err = uas_submit_urbs(cmnd, cmnd->device->hostdata, GFP_ATOMIC);
213 if (err) { 173 if (err) {
214 spin_lock(&uas_work_lock); 174 spin_lock(&uas_work_lock);
@@ -221,27 +181,61 @@ static void uas_xfer_data(struct urb *urb, struct scsi_cmnd *cmnd,
221static void uas_stat_cmplt(struct urb *urb) 181static void uas_stat_cmplt(struct urb *urb)
222{ 182{
223 struct iu *iu = urb->transfer_buffer; 183 struct iu *iu = urb->transfer_buffer;
224 struct scsi_device *sdev = urb->context; 184 struct Scsi_Host *shost = urb->context;
225 struct uas_dev_info *devinfo = sdev->hostdata; 185 struct uas_dev_info *devinfo = (void *)shost->hostdata[0];
226 struct scsi_cmnd *cmnd; 186 struct scsi_cmnd *cmnd;
187 struct uas_cmd_info *cmdinfo;
227 u16 tag; 188 u16 tag;
189 int ret;
228 190
229 if (urb->status) { 191 if (urb->status) {
230 dev_err(&urb->dev->dev, "URB BAD STATUS %d\n", urb->status); 192 dev_err(&urb->dev->dev, "URB BAD STATUS %d\n", urb->status);
231 usb_free_urb(urb); 193 if (devinfo->use_streams)
194 usb_free_urb(urb);
232 return; 195 return;
233 } 196 }
234 197
235 tag = be16_to_cpup(&iu->tag) - 1; 198 tag = be16_to_cpup(&iu->tag) - 1;
236 if (sdev->current_cmnd) 199 if (tag == 0)
237 cmnd = sdev->current_cmnd; 200 cmnd = devinfo->cmnd;
238 else 201 else
239 cmnd = scsi_find_tag(sdev, tag); 202 cmnd = scsi_host_find_tag(shost, tag - 1);
240 if (!cmnd) 203 if (!cmnd) {
204 if (devinfo->use_streams) {
205 usb_free_urb(urb);
206 return;
207 }
208 ret = usb_submit_urb(urb, GFP_ATOMIC);
209 if (ret)
210 dev_err(&urb->dev->dev, "failed submit status urb\n");
241 return; 211 return;
212 }
213 cmdinfo = (void *)&cmnd->SCp;
242 214
243 switch (iu->iu_id) { 215 switch (iu->iu_id) {
244 case IU_ID_STATUS: 216 case IU_ID_STATUS:
217 if (devinfo->cmnd == cmnd)
218 devinfo->cmnd = NULL;
219
220 if (!(cmdinfo->state & COMPLETED_DATA_IN) &&
221 cmdinfo->data_in_urb) {
222 if (devinfo->use_streams) {
223 cmdinfo->state |= DATA_COMPLETES_CMD;
224 usb_unlink_urb(cmdinfo->data_in_urb);
225 } else {
226 usb_free_urb(cmdinfo->data_in_urb);
227 }
228 }
229 if (!(cmdinfo->state & COMPLETED_DATA_OUT) &&
230 cmdinfo->data_out_urb) {
231 if (devinfo->use_streams) {
232 cmdinfo->state |= DATA_COMPLETES_CMD;
233 usb_unlink_urb(cmdinfo->data_in_urb);
234 } else {
235 usb_free_urb(cmdinfo->data_out_urb);
236 }
237 }
238
245 if (urb->actual_length < 16) 239 if (urb->actual_length < 16)
246 devinfo->uas_sense_old = 1; 240 devinfo->uas_sense_old = 1;
247 if (devinfo->uas_sense_old) 241 if (devinfo->uas_sense_old)
@@ -259,29 +253,70 @@ static void uas_stat_cmplt(struct urb *urb)
259 scmd_printk(KERN_ERR, cmnd, 253 scmd_printk(KERN_ERR, cmnd,
260 "Bogus IU (%d) received on status pipe\n", iu->iu_id); 254 "Bogus IU (%d) received on status pipe\n", iu->iu_id);
261 } 255 }
256
257 if (devinfo->use_streams) {
258 usb_free_urb(urb);
259 return;
260 }
261
262 ret = usb_submit_urb(urb, GFP_ATOMIC);
263 if (ret)
264 dev_err(&urb->dev->dev, "failed submit status urb\n");
262} 265}
263 266
264static void uas_data_cmplt(struct urb *urb) 267static void uas_data_out_cmplt(struct urb *urb)
265{ 268{
266 struct scsi_data_buffer *sdb = urb->context; 269 struct scsi_cmnd *cmnd = urb->context;
270 struct scsi_data_buffer *sdb = scsi_out(cmnd);
271 struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
272
273 cmdinfo->state |= COMPLETED_DATA_OUT;
274
267 sdb->resid = sdb->length - urb->actual_length; 275 sdb->resid = sdb->length - urb->actual_length;
268 usb_free_urb(urb); 276 usb_free_urb(urb);
277
278 if (cmdinfo->state & DATA_COMPLETES_CMD)
279 cmnd->scsi_done(cmnd);
280}
281
282static void uas_data_in_cmplt(struct urb *urb)
283{
284 struct scsi_cmnd *cmnd = urb->context;
285 struct scsi_data_buffer *sdb = scsi_in(cmnd);
286 struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
287
288 cmdinfo->state |= COMPLETED_DATA_IN;
289
290 sdb->resid = sdb->length - urb->actual_length;
291 usb_free_urb(urb);
292
293 if (cmdinfo->state & DATA_COMPLETES_CMD)
294 cmnd->scsi_done(cmnd);
269} 295}
270 296
271static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp, 297static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp,
272 unsigned int pipe, u16 stream_id, 298 unsigned int pipe, struct scsi_cmnd *cmnd,
273 struct scsi_data_buffer *sdb, 299 enum dma_data_direction dir)
274 enum dma_data_direction dir)
275{ 300{
301 struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
276 struct usb_device *udev = devinfo->udev; 302 struct usb_device *udev = devinfo->udev;
277 struct urb *urb = usb_alloc_urb(0, gfp); 303 struct urb *urb = usb_alloc_urb(0, gfp);
304 struct scsi_data_buffer *sdb;
305 usb_complete_t complete_fn;
306 u16 stream_id = cmdinfo->stream;
278 307
279 if (!urb) 308 if (!urb)
280 goto out; 309 goto out;
281 usb_fill_bulk_urb(urb, udev, pipe, NULL, sdb->length, uas_data_cmplt, 310 if (dir == DMA_FROM_DEVICE) {
282 sdb); 311 sdb = scsi_in(cmnd);
283 if (devinfo->use_streams) 312 complete_fn = uas_data_in_cmplt;
284 urb->stream_id = stream_id; 313 } else {
314 sdb = scsi_out(cmnd);
315 complete_fn = uas_data_out_cmplt;
316 }
317 usb_fill_bulk_urb(urb, udev, pipe, NULL, sdb->length,
318 complete_fn, cmnd);
319 urb->stream_id = stream_id;
285 urb->num_sgs = udev->bus->sg_tablesize ? sdb->table.nents : 0; 320 urb->num_sgs = udev->bus->sg_tablesize ? sdb->table.nents : 0;
286 urb->sg = sdb->table.sgl; 321 urb->sg = sdb->table.sgl;
287 out: 322 out:
@@ -289,7 +324,7 @@ static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp,
289} 324}
290 325
291static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp, 326static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp,
292 struct scsi_cmnd *cmnd, u16 stream_id) 327 struct Scsi_Host *shost, u16 stream_id)
293{ 328{
294 struct usb_device *udev = devinfo->udev; 329 struct usb_device *udev = devinfo->udev;
295 struct urb *urb = usb_alloc_urb(0, gfp); 330 struct urb *urb = usb_alloc_urb(0, gfp);
@@ -303,7 +338,7 @@ static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp,
303 goto free; 338 goto free;
304 339
305 usb_fill_bulk_urb(urb, udev, devinfo->status_pipe, iu, sizeof(*iu), 340 usb_fill_bulk_urb(urb, udev, devinfo->status_pipe, iu, sizeof(*iu),
306 uas_stat_cmplt, cmnd->device); 341 uas_stat_cmplt, shost);
307 urb->stream_id = stream_id; 342 urb->stream_id = stream_id;
308 urb->transfer_flags |= URB_FREE_BUFFER; 343 urb->transfer_flags |= URB_FREE_BUFFER;
309 out: 344 out:
@@ -334,7 +369,10 @@ static struct urb *uas_alloc_cmd_urb(struct uas_dev_info *devinfo, gfp_t gfp,
334 goto free; 369 goto free;
335 370
336 iu->iu_id = IU_ID_COMMAND; 371 iu->iu_id = IU_ID_COMMAND;
337 iu->tag = cpu_to_be16(stream_id); 372 if (blk_rq_tagged(cmnd->request))
373 iu->tag = cpu_to_be16(cmnd->request->tag + 2);
374 else
375 iu->tag = cpu_to_be16(1);
338 iu->prio_attr = UAS_SIMPLE_TAG; 376 iu->prio_attr = UAS_SIMPLE_TAG;
339 iu->len = len; 377 iu->len = len;
340 int_to_scsilun(sdev->lun, &iu->lun); 378 int_to_scsilun(sdev->lun, &iu->lun);
@@ -362,8 +400,8 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
362 struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; 400 struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
363 401
364 if (cmdinfo->state & ALLOC_STATUS_URB) { 402 if (cmdinfo->state & ALLOC_STATUS_URB) {
365 cmdinfo->status_urb = uas_alloc_sense_urb(devinfo, gfp, cmnd, 403 cmdinfo->status_urb = uas_alloc_sense_urb(devinfo, gfp,
366 cmdinfo->stream); 404 cmnd->device->host, cmdinfo->stream);
367 if (!cmdinfo->status_urb) 405 if (!cmdinfo->status_urb)
368 return SCSI_MLQUEUE_DEVICE_BUSY; 406 return SCSI_MLQUEUE_DEVICE_BUSY;
369 cmdinfo->state &= ~ALLOC_STATUS_URB; 407 cmdinfo->state &= ~ALLOC_STATUS_URB;
@@ -380,8 +418,8 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
380 418
381 if (cmdinfo->state & ALLOC_DATA_IN_URB) { 419 if (cmdinfo->state & ALLOC_DATA_IN_URB) {
382 cmdinfo->data_in_urb = uas_alloc_data_urb(devinfo, gfp, 420 cmdinfo->data_in_urb = uas_alloc_data_urb(devinfo, gfp,
383 devinfo->data_in_pipe, cmdinfo->stream, 421 devinfo->data_in_pipe, cmnd,
384 scsi_in(cmnd), DMA_FROM_DEVICE); 422 DMA_FROM_DEVICE);
385 if (!cmdinfo->data_in_urb) 423 if (!cmdinfo->data_in_urb)
386 return SCSI_MLQUEUE_DEVICE_BUSY; 424 return SCSI_MLQUEUE_DEVICE_BUSY;
387 cmdinfo->state &= ~ALLOC_DATA_IN_URB; 425 cmdinfo->state &= ~ALLOC_DATA_IN_URB;
@@ -398,8 +436,8 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
398 436
399 if (cmdinfo->state & ALLOC_DATA_OUT_URB) { 437 if (cmdinfo->state & ALLOC_DATA_OUT_URB) {
400 cmdinfo->data_out_urb = uas_alloc_data_urb(devinfo, gfp, 438 cmdinfo->data_out_urb = uas_alloc_data_urb(devinfo, gfp,
401 devinfo->data_out_pipe, cmdinfo->stream, 439 devinfo->data_out_pipe, cmnd,
402 scsi_out(cmnd), DMA_TO_DEVICE); 440 DMA_TO_DEVICE);
403 if (!cmdinfo->data_out_urb) 441 if (!cmdinfo->data_out_urb)
404 return SCSI_MLQUEUE_DEVICE_BUSY; 442 return SCSI_MLQUEUE_DEVICE_BUSY;
405 cmdinfo->state &= ~ALLOC_DATA_OUT_URB; 443 cmdinfo->state &= ~ALLOC_DATA_OUT_URB;
@@ -444,13 +482,13 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd,
444 482
445 BUILD_BUG_ON(sizeof(struct uas_cmd_info) > sizeof(struct scsi_pointer)); 483 BUILD_BUG_ON(sizeof(struct uas_cmd_info) > sizeof(struct scsi_pointer));
446 484
447 if (!cmdinfo->status_urb && sdev->current_cmnd) 485 if (devinfo->cmnd)
448 return SCSI_MLQUEUE_DEVICE_BUSY; 486 return SCSI_MLQUEUE_DEVICE_BUSY;
449 487
450 if (blk_rq_tagged(cmnd->request)) { 488 if (blk_rq_tagged(cmnd->request)) {
451 cmdinfo->stream = cmnd->request->tag + 1; 489 cmdinfo->stream = cmnd->request->tag + 2;
452 } else { 490 } else {
453 sdev->current_cmnd = cmnd; 491 devinfo->cmnd = cmnd;
454 cmdinfo->stream = 1; 492 cmdinfo->stream = 1;
455 } 493 }
456 494
@@ -472,7 +510,8 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd,
472 } 510 }
473 511
474 if (!devinfo->use_streams) { 512 if (!devinfo->use_streams) {
475 cmdinfo->state &= ~(SUBMIT_DATA_IN_URB | SUBMIT_DATA_OUT_URB); 513 cmdinfo->state &= ~(SUBMIT_DATA_IN_URB | SUBMIT_DATA_OUT_URB |
514 ALLOC_STATUS_URB | SUBMIT_STATUS_URB);
476 cmdinfo->stream = 0; 515 cmdinfo->stream = 0;
477 } 516 }
478 517
@@ -551,7 +590,7 @@ static int uas_slave_configure(struct scsi_device *sdev)
551{ 590{
552 struct uas_dev_info *devinfo = sdev->hostdata; 591 struct uas_dev_info *devinfo = sdev->hostdata;
553 scsi_set_tag_type(sdev, MSG_ORDERED_TAG); 592 scsi_set_tag_type(sdev, MSG_ORDERED_TAG);
554 scsi_activate_tcq(sdev, devinfo->qdepth - 1); 593 scsi_activate_tcq(sdev, devinfo->qdepth - 2);
555 return 0; 594 return 0;
556} 595}
557 596
@@ -589,22 +628,34 @@ static int uas_is_interface(struct usb_host_interface *intf)
589 intf->desc.bInterfaceProtocol == USB_PR_UAS); 628 intf->desc.bInterfaceProtocol == USB_PR_UAS);
590} 629}
591 630
631static int uas_isnt_supported(struct usb_device *udev)
632{
633 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
634
635 dev_warn(&udev->dev, "The driver for the USB controller %s does not "
636 "support scatter-gather which is\n",
637 hcd->driver->description);
638 dev_warn(&udev->dev, "required by the UAS driver. Please try an"
639 "alternative USB controller if you wish to use UAS.\n");
640 return -ENODEV;
641}
642
592static int uas_switch_interface(struct usb_device *udev, 643static int uas_switch_interface(struct usb_device *udev,
593 struct usb_interface *intf) 644 struct usb_interface *intf)
594{ 645{
595 int i; 646 int i;
596 647 int sg_supported = udev->bus->sg_tablesize != 0;
597 if (uas_is_interface(intf->cur_altsetting))
598 return 0;
599 648
600 for (i = 0; i < intf->num_altsetting; i++) { 649 for (i = 0; i < intf->num_altsetting; i++) {
601 struct usb_host_interface *alt = &intf->altsetting[i]; 650 struct usb_host_interface *alt = &intf->altsetting[i];
602 if (alt == intf->cur_altsetting) 651
603 continue; 652 if (uas_is_interface(alt)) {
604 if (uas_is_interface(alt)) 653 if (!sg_supported)
654 return uas_isnt_supported(udev);
605 return usb_set_interface(udev, 655 return usb_set_interface(udev,
606 alt->desc.bInterfaceNumber, 656 alt->desc.bInterfaceNumber,
607 alt->desc.bAlternateSetting); 657 alt->desc.bAlternateSetting);
658 }
608 } 659 }
609 660
610 return -ENODEV; 661 return -ENODEV;
@@ -619,6 +670,7 @@ static void uas_configure_endpoints(struct uas_dev_info *devinfo)
619 unsigned i, n_endpoints = intf->cur_altsetting->desc.bNumEndpoints; 670 unsigned i, n_endpoints = intf->cur_altsetting->desc.bNumEndpoints;
620 671
621 devinfo->uas_sense_old = 0; 672 devinfo->uas_sense_old = 0;
673 devinfo->cmnd = NULL;
622 674
623 for (i = 0; i < n_endpoints; i++) { 675 for (i = 0; i < n_endpoints; i++) {
624 unsigned char *extra = endpoint[i].extra; 676 unsigned char *extra = endpoint[i].extra;
@@ -670,6 +722,40 @@ static void uas_configure_endpoints(struct uas_dev_info *devinfo)
670 } 722 }
671} 723}
672 724
725static int uas_alloc_status_urb(struct uas_dev_info *devinfo,
726 struct Scsi_Host *shost)
727{
728 if (devinfo->use_streams) {
729 devinfo->status_urb = NULL;
730 return 0;
731 }
732
733 devinfo->status_urb = uas_alloc_sense_urb(devinfo, GFP_KERNEL,
734 shost, 0);
735 if (!devinfo->status_urb)
736 goto err_s_urb;
737
738 if (usb_submit_urb(devinfo->status_urb, GFP_KERNEL))
739 goto err_submit_urb;
740
741 return 0;
742err_submit_urb:
743 usb_free_urb(devinfo->status_urb);
744err_s_urb:
745 return -ENOMEM;
746}
747
748static void uas_free_streams(struct uas_dev_info *devinfo)
749{
750 struct usb_device *udev = devinfo->udev;
751 struct usb_host_endpoint *eps[3];
752
753 eps[0] = usb_pipe_endpoint(udev, devinfo->status_pipe);
754 eps[1] = usb_pipe_endpoint(udev, devinfo->data_in_pipe);
755 eps[2] = usb_pipe_endpoint(udev, devinfo->data_out_pipe);
756 usb_free_streams(devinfo->intf, eps, 3, GFP_KERNEL);
757}
758
673/* 759/*
674 * XXX: What I'd like to do here is register a SCSI host for each USB host in 760 * XXX: What I'd like to do here is register a SCSI host for each USB host in
675 * the system. Follow usb-storage's design of registering a SCSI host for 761 * the system. Follow usb-storage's design of registering a SCSI host for
@@ -699,18 +785,33 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id)
699 shost->max_id = 1; 785 shost->max_id = 1;
700 shost->sg_tablesize = udev->bus->sg_tablesize; 786 shost->sg_tablesize = udev->bus->sg_tablesize;
701 787
702 result = scsi_add_host(shost, &intf->dev); 788 devinfo->intf = intf;
789 devinfo->udev = udev;
790 uas_configure_endpoints(devinfo);
791
792 result = scsi_init_shared_tag_map(shost, devinfo->qdepth - 2);
703 if (result) 793 if (result)
704 goto free; 794 goto free;
795
796 result = scsi_add_host(shost, &intf->dev);
797 if (result)
798 goto deconfig_eps;
799
705 shost->hostdata[0] = (unsigned long)devinfo; 800 shost->hostdata[0] = (unsigned long)devinfo;
706 801
707 devinfo->intf = intf; 802 result = uas_alloc_status_urb(devinfo, shost);
708 devinfo->udev = udev; 803 if (result)
709 uas_configure_endpoints(devinfo); 804 goto err_alloc_status;
710 805
711 scsi_scan_host(shost); 806 scsi_scan_host(shost);
712 usb_set_intfdata(intf, shost); 807 usb_set_intfdata(intf, shost);
713 return result; 808 return result;
809
810err_alloc_status:
811 scsi_remove_host(shost);
812 shost = NULL;
813deconfig_eps:
814 uas_free_streams(devinfo);
714 free: 815 free:
715 kfree(devinfo); 816 kfree(devinfo);
716 if (shost) 817 if (shost)
@@ -732,18 +833,13 @@ static int uas_post_reset(struct usb_interface *intf)
732 833
733static void uas_disconnect(struct usb_interface *intf) 834static void uas_disconnect(struct usb_interface *intf)
734{ 835{
735 struct usb_device *udev = interface_to_usbdev(intf);
736 struct usb_host_endpoint *eps[3];
737 struct Scsi_Host *shost = usb_get_intfdata(intf); 836 struct Scsi_Host *shost = usb_get_intfdata(intf);
738 struct uas_dev_info *devinfo = (void *)shost->hostdata[0]; 837 struct uas_dev_info *devinfo = (void *)shost->hostdata[0];
739 838
740 scsi_remove_host(shost); 839 scsi_remove_host(shost);
741 840 usb_kill_urb(devinfo->status_urb);
742 eps[0] = usb_pipe_endpoint(udev, devinfo->status_pipe); 841 usb_free_urb(devinfo->status_urb);
743 eps[1] = usb_pipe_endpoint(udev, devinfo->data_in_pipe); 842 uas_free_streams(devinfo);
744 eps[2] = usb_pipe_endpoint(udev, devinfo->data_out_pipe);
745 usb_free_streams(intf, eps, 3, GFP_KERNEL);
746
747 kfree(devinfo); 843 kfree(devinfo);
748} 844}
749 845
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index db51ba16dc07..c18538e4a6db 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -125,6 +125,9 @@ static struct us_unusual_dev us_unusual_dev_list[] = {
125 { } /* Terminating entry */ 125 { } /* Terminating entry */
126}; 126};
127 127
128static struct us_unusual_dev for_dynamic_ids =
129 USUAL_DEV(USB_SC_SCSI, USB_PR_BULK, 0);
130
128#undef UNUSUAL_DEV 131#undef UNUSUAL_DEV
129#undef COMPLIANT_DEV 132#undef COMPLIANT_DEV
130#undef USUAL_DEV 133#undef USUAL_DEV
@@ -999,8 +1002,10 @@ EXPORT_SYMBOL_GPL(usb_stor_disconnect);
999static int storage_probe(struct usb_interface *intf, 1002static int storage_probe(struct usb_interface *intf,
1000 const struct usb_device_id *id) 1003 const struct usb_device_id *id)
1001{ 1004{
1005 struct us_unusual_dev *unusual_dev;
1002 struct us_data *us; 1006 struct us_data *us;
1003 int result; 1007 int result;
1008 int size;
1004 1009
1005 /* 1010 /*
1006 * If libusual is configured, let it decide whether a standard 1011 * If libusual is configured, let it decide whether a standard
@@ -1019,8 +1024,19 @@ static int storage_probe(struct usb_interface *intf,
1019 * table, so we use the index of the id entry to find the 1024 * table, so we use the index of the id entry to find the
1020 * corresponding unusual_devs entry. 1025 * corresponding unusual_devs entry.
1021 */ 1026 */
1022 result = usb_stor_probe1(&us, intf, id, 1027
1023 (id - usb_storage_usb_ids) + us_unusual_dev_list); 1028 size = ARRAY_SIZE(us_unusual_dev_list);
1029 if (id >= usb_storage_usb_ids && id < usb_storage_usb_ids + size) {
1030 unusual_dev = (id - usb_storage_usb_ids) + us_unusual_dev_list;
1031 } else {
1032 unusual_dev = &for_dynamic_ids;
1033
1034 US_DEBUGP("%s %s 0x%04x 0x%04x\n", "Use Bulk-Only transport",
1035 "with the Transparent SCSI protocol for dynamic id:",
1036 id->idVendor, id->idProduct);
1037 }
1038
1039 result = usb_stor_probe1(&us, intf, id, unusual_dev);
1024 if (result) 1040 if (result)
1025 return result; 1041 return result;
1026 1042
@@ -1046,7 +1062,6 @@ static struct usb_driver usb_storage_driver = {
1046 .id_table = usb_storage_usb_ids, 1062 .id_table = usb_storage_usb_ids,
1047 .supports_autosuspend = 1, 1063 .supports_autosuspend = 1,
1048 .soft_unbind = 1, 1064 .soft_unbind = 1,
1049 .no_dynamic_id = 1,
1050}; 1065};
1051 1066
1052static int __init usb_stor_init(void) 1067static int __init usb_stor_init(void)