Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 1 | /* |
| 2 | * USB Attached SCSI |
| 3 | * Note that this is not the same as the USB Mass Storage driver |
| 4 | * |
| 5 | * Copyright Matthew Wilcox for Intel Corp, 2010 |
| 6 | * Copyright Sarah Sharp for Intel Corp, 2010 |
| 7 | * |
| 8 | * Distributed under the terms of the GNU GPL, version two. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/blkdev.h> |
| 12 | #include <linux/slab.h> |
| 13 | #include <linux/types.h> |
Paul Gortmaker | 6eb0de8 | 2011-07-03 16:09:31 -0400 | [diff] [blame] | 14 | #include <linux/module.h> |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 15 | #include <linux/usb.h> |
Sebastian Andrzej Siewior | c898add | 2012-01-11 12:42:32 +0100 | [diff] [blame] | 16 | #include <linux/usb/hcd.h> |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 17 | #include <linux/usb/storage.h> |
Sebastian Andrzej Siewior | 348748b | 2012-01-11 12:45:56 +0100 | [diff] [blame] | 18 | #include <linux/usb/uas.h> |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 19 | |
| 20 | #include <scsi/scsi.h> |
Hans de Goede | 4de7a373 | 2013-10-22 16:10:44 +0100 | [diff] [blame] | 21 | #include <scsi/scsi_eh.h> |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 22 | #include <scsi/scsi_dbg.h> |
| 23 | #include <scsi/scsi_cmnd.h> |
| 24 | #include <scsi/scsi_device.h> |
| 25 | #include <scsi/scsi_host.h> |
| 26 | #include <scsi/scsi_tcq.h> |
| 27 | |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 28 | /* |
| 29 | * The r00-r01c specs define this version of the SENSE IU data structure. |
| 30 | * It's still in use by several different firmware releases. |
| 31 | */ |
| 32 | struct sense_iu_old { |
| 33 | __u8 iu_id; |
| 34 | __u8 rsvd1; |
| 35 | __be16 tag; |
| 36 | __be16 len; |
| 37 | __u8 status; |
| 38 | __u8 service_response; |
| 39 | __u8 sense[SCSI_SENSE_BUFFERSIZE]; |
| 40 | }; |
| 41 | |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 42 | struct uas_dev_info { |
| 43 | struct usb_interface *intf; |
| 44 | struct usb_device *udev; |
Gerd Hoffmann | a0e39e3 | 2012-09-25 10:47:04 +0200 | [diff] [blame] | 45 | struct usb_anchor cmd_urbs; |
Gerd Hoffmann | bdd000f | 2012-06-19 09:54:53 +0200 | [diff] [blame] | 46 | struct usb_anchor sense_urbs; |
| 47 | struct usb_anchor data_urbs; |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 48 | int qdepth, resetting; |
Hans de Goede | e52e031 | 2013-10-23 14:27:09 +0100 | [diff] [blame] | 49 | struct response_iu response; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 50 | unsigned cmd_pipe, status_pipe, data_in_pipe, data_out_pipe; |
| 51 | unsigned use_streams:1; |
| 52 | unsigned uas_sense_old:1; |
Sebastian Andrzej Siewior | 22188f4 | 2011-12-19 20:22:39 +0100 | [diff] [blame] | 53 | struct scsi_cmnd *cmnd; |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 54 | spinlock_t lock; |
Gerd Hoffmann | 1bf8198 | 2013-09-13 13:27:12 +0200 | [diff] [blame] | 55 | struct work_struct work; |
| 56 | struct list_head work_list; |
Gerd Hoffmann | 326349f | 2013-09-13 13:27:13 +0200 | [diff] [blame] | 57 | struct list_head dead_list; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | enum { |
Matthew Wilcox | 92a3f76 | 2010-12-15 15:44:04 -0500 | [diff] [blame] | 61 | SUBMIT_STATUS_URB = (1 << 1), |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 62 | ALLOC_DATA_IN_URB = (1 << 2), |
| 63 | SUBMIT_DATA_IN_URB = (1 << 3), |
| 64 | ALLOC_DATA_OUT_URB = (1 << 4), |
| 65 | SUBMIT_DATA_OUT_URB = (1 << 5), |
| 66 | ALLOC_CMD_URB = (1 << 6), |
| 67 | SUBMIT_CMD_URB = (1 << 7), |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 68 | COMMAND_INFLIGHT = (1 << 8), |
| 69 | DATA_IN_URB_INFLIGHT = (1 << 9), |
| 70 | DATA_OUT_URB_INFLIGHT = (1 << 10), |
| 71 | COMMAND_COMPLETED = (1 << 11), |
Gerd Hoffmann | ef018cc9 | 2012-09-25 10:47:06 +0200 | [diff] [blame] | 72 | COMMAND_ABORTED = (1 << 12), |
Gerd Hoffmann | b06e48a | 2012-11-30 11:54:41 +0100 | [diff] [blame] | 73 | UNLINK_DATA_URBS = (1 << 13), |
Gerd Hoffmann | efefecf | 2012-11-30 11:54:42 +0100 | [diff] [blame] | 74 | IS_IN_WORK_LIST = (1 << 14), |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | /* Overrides scsi_pointer */ |
| 78 | struct uas_cmd_info { |
| 79 | unsigned int state; |
| 80 | unsigned int stream; |
| 81 | struct urb *cmd_urb; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 82 | struct urb *data_in_urb; |
| 83 | struct urb *data_out_urb; |
Gerd Hoffmann | 1bf8198 | 2013-09-13 13:27:12 +0200 | [diff] [blame] | 84 | struct list_head work; |
Gerd Hoffmann | 326349f | 2013-09-13 13:27:13 +0200 | [diff] [blame] | 85 | struct list_head dead; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | /* I hate forward declarations, but I actually have a loop */ |
| 89 | static int uas_submit_urbs(struct scsi_cmnd *cmnd, |
| 90 | struct uas_dev_info *devinfo, gfp_t gfp); |
Sarah Sharp | ea9da1c | 2011-12-02 11:55:44 -0800 | [diff] [blame] | 91 | static void uas_do_work(struct work_struct *work); |
Gerd Hoffmann | 4c45697 | 2012-11-30 11:54:44 +0100 | [diff] [blame] | 92 | static int uas_try_complete(struct scsi_cmnd *cmnd, const char *caller); |
Gerd Hoffmann | d89bd83 | 2013-09-13 13:27:11 +0200 | [diff] [blame] | 93 | static void uas_configure_endpoints(struct uas_dev_info *devinfo); |
| 94 | static void uas_free_streams(struct uas_dev_info *devinfo); |
Gerd Hoffmann | 326349f | 2013-09-13 13:27:13 +0200 | [diff] [blame] | 95 | static void uas_log_cmd_state(struct scsi_cmnd *cmnd, const char *caller); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 96 | |
Hans de Goede | 7e50e0b | 2013-10-17 19:19:04 +0200 | [diff] [blame] | 97 | /* Must be called with devinfo->lock held, will temporary unlock the lock */ |
Gerd Hoffmann | aa8f612 | 2012-11-30 11:54:40 +0100 | [diff] [blame] | 98 | static void uas_unlink_data_urbs(struct uas_dev_info *devinfo, |
Hans de Goede | 7e50e0b | 2013-10-17 19:19:04 +0200 | [diff] [blame] | 99 | struct uas_cmd_info *cmdinfo, |
| 100 | unsigned long *lock_flags) |
Gerd Hoffmann | aa8f612 | 2012-11-30 11:54:40 +0100 | [diff] [blame] | 101 | { |
Gerd Hoffmann | b06e48a | 2012-11-30 11:54:41 +0100 | [diff] [blame] | 102 | /* |
| 103 | * The UNLINK_DATA_URBS flag makes sure uas_try_complete |
| 104 | * (called by urb completion) doesn't release cmdinfo |
| 105 | * underneath us. |
| 106 | */ |
Gerd Hoffmann | b06e48a | 2012-11-30 11:54:41 +0100 | [diff] [blame] | 107 | cmdinfo->state |= UNLINK_DATA_URBS; |
Hans de Goede | 7e50e0b | 2013-10-17 19:19:04 +0200 | [diff] [blame] | 108 | spin_unlock_irqrestore(&devinfo->lock, *lock_flags); |
Gerd Hoffmann | b06e48a | 2012-11-30 11:54:41 +0100 | [diff] [blame] | 109 | |
Gerd Hoffmann | aa8f612 | 2012-11-30 11:54:40 +0100 | [diff] [blame] | 110 | if (cmdinfo->data_in_urb) |
| 111 | usb_unlink_urb(cmdinfo->data_in_urb); |
| 112 | if (cmdinfo->data_out_urb) |
| 113 | usb_unlink_urb(cmdinfo->data_out_urb); |
Gerd Hoffmann | b06e48a | 2012-11-30 11:54:41 +0100 | [diff] [blame] | 114 | |
Hans de Goede | 7e50e0b | 2013-10-17 19:19:04 +0200 | [diff] [blame] | 115 | spin_lock_irqsave(&devinfo->lock, *lock_flags); |
Gerd Hoffmann | b06e48a | 2012-11-30 11:54:41 +0100 | [diff] [blame] | 116 | cmdinfo->state &= ~UNLINK_DATA_URBS; |
Gerd Hoffmann | aa8f612 | 2012-11-30 11:54:40 +0100 | [diff] [blame] | 117 | } |
| 118 | |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 119 | static void uas_do_work(struct work_struct *work) |
| 120 | { |
Gerd Hoffmann | 1bf8198 | 2013-09-13 13:27:12 +0200 | [diff] [blame] | 121 | struct uas_dev_info *devinfo = |
| 122 | container_of(work, struct uas_dev_info, work); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 123 | struct uas_cmd_info *cmdinfo; |
Sarah Sharp | ea9da1c | 2011-12-02 11:55:44 -0800 | [diff] [blame] | 124 | struct uas_cmd_info *temp; |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 125 | unsigned long flags; |
Sarah Sharp | ea9da1c | 2011-12-02 11:55:44 -0800 | [diff] [blame] | 126 | int err; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 127 | |
Gerd Hoffmann | 1bf8198 | 2013-09-13 13:27:12 +0200 | [diff] [blame] | 128 | spin_lock_irqsave(&devinfo->lock, flags); |
| 129 | list_for_each_entry_safe(cmdinfo, temp, &devinfo->work_list, work) { |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 130 | struct scsi_pointer *scp = (void *)cmdinfo; |
Gerd Hoffmann | 1bf8198 | 2013-09-13 13:27:12 +0200 | [diff] [blame] | 131 | struct scsi_cmnd *cmnd = container_of(scp, struct scsi_cmnd, |
| 132 | SCp); |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 133 | err = uas_submit_urbs(cmnd, cmnd->device->hostdata, GFP_ATOMIC); |
Gerd Hoffmann | 1bf8198 | 2013-09-13 13:27:12 +0200 | [diff] [blame] | 134 | if (!err) { |
Gerd Hoffmann | efefecf | 2012-11-30 11:54:42 +0100 | [diff] [blame] | 135 | cmdinfo->state &= ~IS_IN_WORK_LIST; |
Gerd Hoffmann | 1bf8198 | 2013-09-13 13:27:12 +0200 | [diff] [blame] | 136 | list_del(&cmdinfo->work); |
| 137 | } else { |
| 138 | schedule_work(&devinfo->work); |
Sarah Sharp | ea9da1c | 2011-12-02 11:55:44 -0800 | [diff] [blame] | 139 | } |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 140 | } |
Gerd Hoffmann | 1bf8198 | 2013-09-13 13:27:12 +0200 | [diff] [blame] | 141 | spin_unlock_irqrestore(&devinfo->lock, flags); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 142 | } |
| 143 | |
Gerd Hoffmann | 4c45697 | 2012-11-30 11:54:44 +0100 | [diff] [blame] | 144 | static void uas_abort_work(struct uas_dev_info *devinfo) |
| 145 | { |
| 146 | struct uas_cmd_info *cmdinfo; |
| 147 | struct uas_cmd_info *temp; |
Gerd Hoffmann | 4c45697 | 2012-11-30 11:54:44 +0100 | [diff] [blame] | 148 | unsigned long flags; |
| 149 | |
Gerd Hoffmann | 4c45697 | 2012-11-30 11:54:44 +0100 | [diff] [blame] | 150 | spin_lock_irqsave(&devinfo->lock, flags); |
Gerd Hoffmann | 1bf8198 | 2013-09-13 13:27:12 +0200 | [diff] [blame] | 151 | list_for_each_entry_safe(cmdinfo, temp, &devinfo->work_list, work) { |
Gerd Hoffmann | 4c45697 | 2012-11-30 11:54:44 +0100 | [diff] [blame] | 152 | struct scsi_pointer *scp = (void *)cmdinfo; |
Gerd Hoffmann | 1bf8198 | 2013-09-13 13:27:12 +0200 | [diff] [blame] | 153 | struct scsi_cmnd *cmnd = container_of(scp, struct scsi_cmnd, |
| 154 | SCp); |
Gerd Hoffmann | 326349f | 2013-09-13 13:27:13 +0200 | [diff] [blame] | 155 | uas_log_cmd_state(cmnd, __func__); |
Gerd Hoffmann | f491ecb | 2013-09-13 13:27:14 +0200 | [diff] [blame] | 156 | WARN_ON_ONCE(cmdinfo->state & COMMAND_ABORTED); |
Gerd Hoffmann | 1bf8198 | 2013-09-13 13:27:12 +0200 | [diff] [blame] | 157 | cmdinfo->state |= COMMAND_ABORTED; |
| 158 | cmdinfo->state &= ~IS_IN_WORK_LIST; |
Gerd Hoffmann | 1bf8198 | 2013-09-13 13:27:12 +0200 | [diff] [blame] | 159 | list_del(&cmdinfo->work); |
Gerd Hoffmann | 326349f | 2013-09-13 13:27:13 +0200 | [diff] [blame] | 160 | list_add_tail(&cmdinfo->dead, &devinfo->dead_list); |
Gerd Hoffmann | 4c45697 | 2012-11-30 11:54:44 +0100 | [diff] [blame] | 161 | } |
| 162 | spin_unlock_irqrestore(&devinfo->lock, flags); |
| 163 | } |
| 164 | |
Gerd Hoffmann | 1bf8198 | 2013-09-13 13:27:12 +0200 | [diff] [blame] | 165 | static void uas_add_work(struct uas_cmd_info *cmdinfo) |
| 166 | { |
| 167 | struct scsi_pointer *scp = (void *)cmdinfo; |
| 168 | struct scsi_cmnd *cmnd = container_of(scp, struct scsi_cmnd, SCp); |
| 169 | struct uas_dev_info *devinfo = cmnd->device->hostdata; |
| 170 | |
Gerd Hoffmann | f491ecb | 2013-09-13 13:27:14 +0200 | [diff] [blame] | 171 | WARN_ON_ONCE(!spin_is_locked(&devinfo->lock)); |
Gerd Hoffmann | 1bf8198 | 2013-09-13 13:27:12 +0200 | [diff] [blame] | 172 | list_add_tail(&cmdinfo->work, &devinfo->work_list); |
| 173 | cmdinfo->state |= IS_IN_WORK_LIST; |
| 174 | schedule_work(&devinfo->work); |
| 175 | } |
| 176 | |
Gerd Hoffmann | 326349f | 2013-09-13 13:27:13 +0200 | [diff] [blame] | 177 | static void uas_zap_dead(struct uas_dev_info *devinfo) |
| 178 | { |
| 179 | struct uas_cmd_info *cmdinfo; |
| 180 | struct uas_cmd_info *temp; |
| 181 | unsigned long flags; |
| 182 | |
| 183 | spin_lock_irqsave(&devinfo->lock, flags); |
| 184 | list_for_each_entry_safe(cmdinfo, temp, &devinfo->dead_list, dead) { |
| 185 | struct scsi_pointer *scp = (void *)cmdinfo; |
| 186 | struct scsi_cmnd *cmnd = container_of(scp, struct scsi_cmnd, |
| 187 | SCp); |
| 188 | uas_log_cmd_state(cmnd, __func__); |
Gerd Hoffmann | f491ecb | 2013-09-13 13:27:14 +0200 | [diff] [blame] | 189 | WARN_ON_ONCE(!(cmdinfo->state & COMMAND_ABORTED)); |
Gerd Hoffmann | 326349f | 2013-09-13 13:27:13 +0200 | [diff] [blame] | 190 | /* all urbs are killed, clear inflight bits */ |
| 191 | cmdinfo->state &= ~(COMMAND_INFLIGHT | |
| 192 | DATA_IN_URB_INFLIGHT | |
| 193 | DATA_OUT_URB_INFLIGHT); |
| 194 | uas_try_complete(cmnd, __func__); |
| 195 | } |
| 196 | spin_unlock_irqrestore(&devinfo->lock, flags); |
| 197 | } |
| 198 | |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 199 | static void uas_sense(struct urb *urb, struct scsi_cmnd *cmnd) |
| 200 | { |
| 201 | struct sense_iu *sense_iu = urb->transfer_buffer; |
| 202 | struct scsi_device *sdev = cmnd->device; |
| 203 | |
| 204 | if (urb->actual_length > 16) { |
| 205 | unsigned len = be16_to_cpup(&sense_iu->len); |
| 206 | if (len + 16 != urb->actual_length) { |
| 207 | int newlen = min(len + 16, urb->actual_length) - 16; |
| 208 | if (newlen < 0) |
| 209 | newlen = 0; |
| 210 | sdev_printk(KERN_INFO, sdev, "%s: urb length %d " |
| 211 | "disagrees with IU sense data length %d, " |
| 212 | "using %d bytes of sense data\n", __func__, |
| 213 | urb->actual_length, len, newlen); |
| 214 | len = newlen; |
| 215 | } |
| 216 | memcpy(cmnd->sense_buffer, sense_iu->sense, len); |
| 217 | } |
| 218 | |
| 219 | cmnd->result = sense_iu->status; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | static void uas_sense_old(struct urb *urb, struct scsi_cmnd *cmnd) |
| 223 | { |
| 224 | struct sense_iu_old *sense_iu = urb->transfer_buffer; |
| 225 | struct scsi_device *sdev = cmnd->device; |
| 226 | |
| 227 | if (urb->actual_length > 8) { |
| 228 | unsigned len = be16_to_cpup(&sense_iu->len) - 2; |
| 229 | if (len + 8 != urb->actual_length) { |
| 230 | int newlen = min(len + 8, urb->actual_length) - 8; |
| 231 | if (newlen < 0) |
| 232 | newlen = 0; |
| 233 | sdev_printk(KERN_INFO, sdev, "%s: urb length %d " |
| 234 | "disagrees with IU sense data length %d, " |
| 235 | "using %d bytes of sense data\n", __func__, |
| 236 | urb->actual_length, len, newlen); |
| 237 | len = newlen; |
| 238 | } |
| 239 | memcpy(cmnd->sense_buffer, sense_iu->sense, len); |
| 240 | } |
| 241 | |
| 242 | cmnd->result = sense_iu->status; |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | static void uas_log_cmd_state(struct scsi_cmnd *cmnd, const char *caller) |
| 246 | { |
| 247 | struct uas_cmd_info *ci = (void *)&cmnd->SCp; |
| 248 | |
| 249 | scmd_printk(KERN_INFO, cmnd, "%s %p tag %d, inflight:" |
Gerd Hoffmann | efefecf | 2012-11-30 11:54:42 +0100 | [diff] [blame] | 250 | "%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 251 | caller, cmnd, cmnd->request->tag, |
| 252 | (ci->state & SUBMIT_STATUS_URB) ? " s-st" : "", |
| 253 | (ci->state & ALLOC_DATA_IN_URB) ? " a-in" : "", |
| 254 | (ci->state & SUBMIT_DATA_IN_URB) ? " s-in" : "", |
| 255 | (ci->state & ALLOC_DATA_OUT_URB) ? " a-out" : "", |
| 256 | (ci->state & SUBMIT_DATA_OUT_URB) ? " s-out" : "", |
| 257 | (ci->state & ALLOC_CMD_URB) ? " a-cmd" : "", |
| 258 | (ci->state & SUBMIT_CMD_URB) ? " s-cmd" : "", |
| 259 | (ci->state & COMMAND_INFLIGHT) ? " CMD" : "", |
| 260 | (ci->state & DATA_IN_URB_INFLIGHT) ? " IN" : "", |
| 261 | (ci->state & DATA_OUT_URB_INFLIGHT) ? " OUT" : "", |
Gerd Hoffmann | ef018cc9 | 2012-09-25 10:47:06 +0200 | [diff] [blame] | 262 | (ci->state & COMMAND_COMPLETED) ? " done" : "", |
Gerd Hoffmann | b06e48a | 2012-11-30 11:54:41 +0100 | [diff] [blame] | 263 | (ci->state & COMMAND_ABORTED) ? " abort" : "", |
Gerd Hoffmann | efefecf | 2012-11-30 11:54:42 +0100 | [diff] [blame] | 264 | (ci->state & UNLINK_DATA_URBS) ? " unlink": "", |
| 265 | (ci->state & IS_IN_WORK_LIST) ? " work" : ""); |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | static int uas_try_complete(struct scsi_cmnd *cmnd, const char *caller) |
| 269 | { |
| 270 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 271 | struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata; |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 272 | |
Gerd Hoffmann | f491ecb | 2013-09-13 13:27:14 +0200 | [diff] [blame] | 273 | WARN_ON_ONCE(!spin_is_locked(&devinfo->lock)); |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 274 | if (cmdinfo->state & (COMMAND_INFLIGHT | |
| 275 | DATA_IN_URB_INFLIGHT | |
Gerd Hoffmann | b06e48a | 2012-11-30 11:54:41 +0100 | [diff] [blame] | 276 | DATA_OUT_URB_INFLIGHT | |
| 277 | UNLINK_DATA_URBS)) |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 278 | return -EBUSY; |
Gerd Hoffmann | f491ecb | 2013-09-13 13:27:14 +0200 | [diff] [blame] | 279 | WARN_ON_ONCE(cmdinfo->state & COMMAND_COMPLETED); |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 280 | cmdinfo->state |= COMMAND_COMPLETED; |
| 281 | usb_free_urb(cmdinfo->data_in_urb); |
| 282 | usb_free_urb(cmdinfo->data_out_urb); |
Gerd Hoffmann | 0871d7d | 2012-09-25 10:47:07 +0200 | [diff] [blame] | 283 | if (cmdinfo->state & COMMAND_ABORTED) { |
| 284 | scmd_printk(KERN_INFO, cmnd, "abort completed\n"); |
| 285 | cmnd->result = DID_ABORT << 16; |
Gerd Hoffmann | 326349f | 2013-09-13 13:27:13 +0200 | [diff] [blame] | 286 | list_del(&cmdinfo->dead); |
Gerd Hoffmann | 0871d7d | 2012-09-25 10:47:07 +0200 | [diff] [blame] | 287 | } |
Gerd Hoffmann | c621a81 | 2012-06-19 09:54:48 +0200 | [diff] [blame] | 288 | cmnd->scsi_done(cmnd); |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 289 | return 0; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | static void uas_xfer_data(struct urb *urb, struct scsi_cmnd *cmnd, |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 293 | unsigned direction) |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 294 | { |
| 295 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; |
| 296 | int err; |
| 297 | |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 298 | cmdinfo->state |= direction | SUBMIT_STATUS_URB; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 299 | err = uas_submit_urbs(cmnd, cmnd->device->hostdata, GFP_ATOMIC); |
| 300 | if (err) { |
Gerd Hoffmann | 1bf8198 | 2013-09-13 13:27:12 +0200 | [diff] [blame] | 301 | uas_add_work(cmdinfo); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 302 | } |
| 303 | } |
| 304 | |
| 305 | static void uas_stat_cmplt(struct urb *urb) |
| 306 | { |
| 307 | struct iu *iu = urb->transfer_buffer; |
Sebastian Andrzej Siewior | 22188f4 | 2011-12-19 20:22:39 +0100 | [diff] [blame] | 308 | struct Scsi_Host *shost = urb->context; |
| 309 | struct uas_dev_info *devinfo = (void *)shost->hostdata[0]; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 310 | struct scsi_cmnd *cmnd; |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 311 | struct uas_cmd_info *cmdinfo; |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 312 | unsigned long flags; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 313 | u16 tag; |
| 314 | |
| 315 | if (urb->status) { |
Gerd Hoffmann | 326349f | 2013-09-13 13:27:13 +0200 | [diff] [blame] | 316 | if (urb->status == -ENOENT) { |
| 317 | dev_err(&urb->dev->dev, "stat urb: killed, stream %d\n", |
| 318 | urb->stream_id); |
| 319 | } else { |
| 320 | dev_err(&urb->dev->dev, "stat urb: status %d\n", |
| 321 | urb->status); |
| 322 | } |
Gerd Hoffmann | db32de1 | 2012-06-19 09:54:49 +0200 | [diff] [blame] | 323 | usb_free_urb(urb); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 324 | return; |
| 325 | } |
| 326 | |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 327 | if (devinfo->resetting) { |
| 328 | usb_free_urb(urb); |
| 329 | return; |
| 330 | } |
| 331 | |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 332 | spin_lock_irqsave(&devinfo->lock, flags); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 333 | tag = be16_to_cpup(&iu->tag) - 1; |
Sebastian Andrzej Siewior | 22188f4 | 2011-12-19 20:22:39 +0100 | [diff] [blame] | 334 | if (tag == 0) |
| 335 | cmnd = devinfo->cmnd; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 336 | else |
Sebastian Andrzej Siewior | 22188f4 | 2011-12-19 20:22:39 +0100 | [diff] [blame] | 337 | cmnd = scsi_host_find_tag(shost, tag - 1); |
Gerd Hoffmann | e0423de | 2012-09-26 10:29:03 +0200 | [diff] [blame] | 338 | |
Sarah Sharp | 96c1eb9 | 2011-12-02 11:55:48 -0800 | [diff] [blame] | 339 | if (!cmnd) { |
Gerd Hoffmann | e0423de | 2012-09-26 10:29:03 +0200 | [diff] [blame] | 340 | if (iu->iu_id == IU_ID_RESPONSE) { |
| 341 | /* store results for uas_eh_task_mgmt() */ |
| 342 | memcpy(&devinfo->response, iu, sizeof(devinfo->response)); |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 343 | } |
Gerd Hoffmann | e0423de | 2012-09-26 10:29:03 +0200 | [diff] [blame] | 344 | usb_free_urb(urb); |
| 345 | spin_unlock_irqrestore(&devinfo->lock, flags); |
| 346 | return; |
Sarah Sharp | 96c1eb9 | 2011-12-02 11:55:48 -0800 | [diff] [blame] | 347 | } |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 348 | |
Gerd Hoffmann | e0423de | 2012-09-26 10:29:03 +0200 | [diff] [blame] | 349 | cmdinfo = (void *)&cmnd->SCp; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 350 | switch (iu->iu_id) { |
| 351 | case IU_ID_STATUS: |
Sebastian Andrzej Siewior | 22188f4 | 2011-12-19 20:22:39 +0100 | [diff] [blame] | 352 | if (devinfo->cmnd == cmnd) |
| 353 | devinfo->cmnd = NULL; |
| 354 | |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 355 | if (urb->actual_length < 16) |
| 356 | devinfo->uas_sense_old = 1; |
| 357 | if (devinfo->uas_sense_old) |
| 358 | uas_sense_old(urb, cmnd); |
| 359 | else |
| 360 | uas_sense(urb, cmnd); |
Gerd Hoffmann | 8aac863 | 2012-06-19 09:54:52 +0200 | [diff] [blame] | 361 | if (cmnd->result != 0) { |
| 362 | /* cancel data transfers on error */ |
Hans de Goede | 7e50e0b | 2013-10-17 19:19:04 +0200 | [diff] [blame] | 363 | uas_unlink_data_urbs(devinfo, cmdinfo, &flags); |
Gerd Hoffmann | 8aac863 | 2012-06-19 09:54:52 +0200 | [diff] [blame] | 364 | } |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 365 | cmdinfo->state &= ~COMMAND_INFLIGHT; |
| 366 | uas_try_complete(cmnd, __func__); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 367 | break; |
| 368 | case IU_ID_READ_READY: |
| 369 | uas_xfer_data(urb, cmnd, SUBMIT_DATA_IN_URB); |
| 370 | break; |
| 371 | case IU_ID_WRITE_READY: |
| 372 | uas_xfer_data(urb, cmnd, SUBMIT_DATA_OUT_URB); |
| 373 | break; |
| 374 | default: |
| 375 | scmd_printk(KERN_ERR, cmnd, |
| 376 | "Bogus IU (%d) received on status pipe\n", iu->iu_id); |
| 377 | } |
Gerd Hoffmann | e9bd7e1 | 2012-06-19 09:54:50 +0200 | [diff] [blame] | 378 | usb_free_urb(urb); |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 379 | spin_unlock_irqrestore(&devinfo->lock, flags); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 380 | } |
| 381 | |
Gerd Hoffmann | c621a81 | 2012-06-19 09:54:48 +0200 | [diff] [blame] | 382 | static void uas_data_cmplt(struct urb *urb) |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 383 | { |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 384 | struct scsi_cmnd *cmnd = urb->context; |
| 385 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 386 | struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata; |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 387 | struct scsi_data_buffer *sdb = NULL; |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 388 | unsigned long flags; |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 389 | |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 390 | spin_lock_irqsave(&devinfo->lock, flags); |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 391 | if (cmdinfo->data_in_urb == urb) { |
| 392 | sdb = scsi_in(cmnd); |
| 393 | cmdinfo->state &= ~DATA_IN_URB_INFLIGHT; |
| 394 | } else if (cmdinfo->data_out_urb == urb) { |
| 395 | sdb = scsi_out(cmnd); |
| 396 | cmdinfo->state &= ~DATA_OUT_URB_INFLIGHT; |
| 397 | } |
Gerd Hoffmann | f491ecb | 2013-09-13 13:27:14 +0200 | [diff] [blame] | 398 | if (sdb == NULL) { |
| 399 | WARN_ON_ONCE(1); |
| 400 | } else if (urb->status) { |
Gerd Hoffmann | 8aac863 | 2012-06-19 09:54:52 +0200 | [diff] [blame] | 401 | /* error: no data transfered */ |
| 402 | sdb->resid = sdb->length; |
| 403 | } else { |
| 404 | sdb->resid = sdb->length - urb->actual_length; |
| 405 | } |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 406 | uas_try_complete(cmnd, __func__); |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 407 | spin_unlock_irqrestore(&devinfo->lock, flags); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp, |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 411 | unsigned int pipe, u16 stream_id, |
| 412 | struct scsi_cmnd *cmnd, |
| 413 | enum dma_data_direction dir) |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 414 | { |
| 415 | struct usb_device *udev = devinfo->udev; |
| 416 | struct urb *urb = usb_alloc_urb(0, gfp); |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 417 | struct scsi_data_buffer *sdb = (dir == DMA_FROM_DEVICE) |
| 418 | ? scsi_in(cmnd) : scsi_out(cmnd); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 419 | |
| 420 | if (!urb) |
| 421 | goto out; |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 422 | usb_fill_bulk_urb(urb, udev, pipe, NULL, sdb->length, |
| 423 | uas_data_cmplt, cmnd); |
Gerd Hoffmann | c621a81 | 2012-06-19 09:54:48 +0200 | [diff] [blame] | 424 | if (devinfo->use_streams) |
| 425 | urb->stream_id = stream_id; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 426 | urb->num_sgs = udev->bus->sg_tablesize ? sdb->table.nents : 0; |
| 427 | urb->sg = sdb->table.sgl; |
| 428 | out: |
| 429 | return urb; |
| 430 | } |
| 431 | |
| 432 | static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp, |
Gerd Hoffmann | e9bd7e1 | 2012-06-19 09:54:50 +0200 | [diff] [blame] | 433 | struct Scsi_Host *shost, u16 stream_id) |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 434 | { |
| 435 | struct usb_device *udev = devinfo->udev; |
| 436 | struct urb *urb = usb_alloc_urb(0, gfp); |
| 437 | struct sense_iu *iu; |
| 438 | |
| 439 | if (!urb) |
| 440 | goto out; |
| 441 | |
Matthew Wilcox | ac563cf | 2010-12-15 15:44:03 -0500 | [diff] [blame] | 442 | iu = kzalloc(sizeof(*iu), gfp); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 443 | if (!iu) |
| 444 | goto free; |
| 445 | |
| 446 | usb_fill_bulk_urb(urb, udev, devinfo->status_pipe, iu, sizeof(*iu), |
Gerd Hoffmann | e9bd7e1 | 2012-06-19 09:54:50 +0200 | [diff] [blame] | 447 | uas_stat_cmplt, shost); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 448 | urb->stream_id = stream_id; |
| 449 | urb->transfer_flags |= URB_FREE_BUFFER; |
| 450 | out: |
| 451 | return urb; |
| 452 | free: |
| 453 | usb_free_urb(urb); |
| 454 | return NULL; |
| 455 | } |
| 456 | |
| 457 | static struct urb *uas_alloc_cmd_urb(struct uas_dev_info *devinfo, gfp_t gfp, |
Hans de Goede | a887cd3 | 2013-10-17 19:47:28 +0200 | [diff] [blame] | 458 | struct scsi_cmnd *cmnd) |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 459 | { |
| 460 | struct usb_device *udev = devinfo->udev; |
| 461 | struct scsi_device *sdev = cmnd->device; |
| 462 | struct urb *urb = usb_alloc_urb(0, gfp); |
| 463 | struct command_iu *iu; |
| 464 | int len; |
| 465 | |
| 466 | if (!urb) |
| 467 | goto out; |
| 468 | |
| 469 | len = cmnd->cmd_len - 16; |
| 470 | if (len < 0) |
| 471 | len = 0; |
| 472 | len = ALIGN(len, 4); |
Matthew Wilcox | ac563cf | 2010-12-15 15:44:03 -0500 | [diff] [blame] | 473 | iu = kzalloc(sizeof(*iu) + len, gfp); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 474 | if (!iu) |
| 475 | goto free; |
| 476 | |
| 477 | iu->iu_id = IU_ID_COMMAND; |
Sarah Sharp | 9eb4454 | 2011-12-02 11:55:46 -0800 | [diff] [blame] | 478 | if (blk_rq_tagged(cmnd->request)) |
Sebastian Andrzej Siewior | 22188f4 | 2011-12-19 20:22:39 +0100 | [diff] [blame] | 479 | iu->tag = cpu_to_be16(cmnd->request->tag + 2); |
Sarah Sharp | 9eb4454 | 2011-12-02 11:55:46 -0800 | [diff] [blame] | 480 | else |
| 481 | iu->tag = cpu_to_be16(1); |
Christoph Hellwig | 02e031c | 2010-11-10 14:54:09 +0100 | [diff] [blame] | 482 | iu->prio_attr = UAS_SIMPLE_TAG; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 483 | iu->len = len; |
| 484 | int_to_scsilun(sdev->lun, &iu->lun); |
| 485 | memcpy(iu->cdb, cmnd->cmnd, cmnd->cmd_len); |
| 486 | |
| 487 | usb_fill_bulk_urb(urb, udev, devinfo->cmd_pipe, iu, sizeof(*iu) + len, |
| 488 | usb_free_urb, NULL); |
| 489 | urb->transfer_flags |= URB_FREE_BUFFER; |
| 490 | out: |
| 491 | return urb; |
| 492 | free: |
| 493 | usb_free_urb(urb); |
| 494 | return NULL; |
| 495 | } |
| 496 | |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 497 | static int uas_submit_task_urb(struct scsi_cmnd *cmnd, gfp_t gfp, |
| 498 | u8 function, u16 stream_id) |
| 499 | { |
| 500 | struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata; |
| 501 | struct usb_device *udev = devinfo->udev; |
| 502 | struct urb *urb = usb_alloc_urb(0, gfp); |
| 503 | struct task_mgmt_iu *iu; |
| 504 | int err = -ENOMEM; |
| 505 | |
| 506 | if (!urb) |
| 507 | goto err; |
| 508 | |
| 509 | iu = kzalloc(sizeof(*iu), gfp); |
| 510 | if (!iu) |
| 511 | goto err; |
| 512 | |
| 513 | iu->iu_id = IU_ID_TASK_MGMT; |
| 514 | iu->tag = cpu_to_be16(stream_id); |
| 515 | int_to_scsilun(cmnd->device->lun, &iu->lun); |
| 516 | |
| 517 | iu->function = function; |
| 518 | switch (function) { |
| 519 | case TMF_ABORT_TASK: |
| 520 | if (blk_rq_tagged(cmnd->request)) |
| 521 | iu->task_tag = cpu_to_be16(cmnd->request->tag + 2); |
| 522 | else |
| 523 | iu->task_tag = cpu_to_be16(1); |
| 524 | break; |
| 525 | } |
| 526 | |
| 527 | usb_fill_bulk_urb(urb, udev, devinfo->cmd_pipe, iu, sizeof(*iu), |
| 528 | usb_free_urb, NULL); |
| 529 | urb->transfer_flags |= URB_FREE_BUFFER; |
| 530 | |
Gerd Hoffmann | a0e39e3 | 2012-09-25 10:47:04 +0200 | [diff] [blame] | 531 | usb_anchor_urb(urb, &devinfo->cmd_urbs); |
Hans de Goede | d5f808d | 2013-10-17 19:30:26 +0200 | [diff] [blame] | 532 | err = usb_submit_urb(urb, gfp); |
| 533 | if (err) { |
| 534 | usb_unanchor_urb(urb); |
| 535 | goto err; |
| 536 | } |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 537 | |
| 538 | return 0; |
| 539 | |
| 540 | err: |
| 541 | usb_free_urb(urb); |
| 542 | return err; |
| 543 | } |
| 544 | |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 545 | /* |
| 546 | * Why should I request the Status IU before sending the Command IU? Spec |
| 547 | * says to, but also says the device may receive them in any order. Seems |
| 548 | * daft to me. |
| 549 | */ |
| 550 | |
Gerd Hoffmann | e9bd7e1 | 2012-06-19 09:54:50 +0200 | [diff] [blame] | 551 | static int uas_submit_sense_urb(struct Scsi_Host *shost, |
| 552 | gfp_t gfp, unsigned int stream) |
| 553 | { |
| 554 | struct uas_dev_info *devinfo = (void *)shost->hostdata[0]; |
| 555 | struct urb *urb; |
| 556 | |
| 557 | urb = uas_alloc_sense_urb(devinfo, gfp, shost, stream); |
| 558 | if (!urb) |
| 559 | return SCSI_MLQUEUE_DEVICE_BUSY; |
Hans de Goede | d5f808d | 2013-10-17 19:30:26 +0200 | [diff] [blame] | 560 | usb_anchor_urb(urb, &devinfo->sense_urbs); |
Gerd Hoffmann | e9bd7e1 | 2012-06-19 09:54:50 +0200 | [diff] [blame] | 561 | if (usb_submit_urb(urb, gfp)) { |
Hans de Goede | d5f808d | 2013-10-17 19:30:26 +0200 | [diff] [blame] | 562 | usb_unanchor_urb(urb); |
Gerd Hoffmann | e9bd7e1 | 2012-06-19 09:54:50 +0200 | [diff] [blame] | 563 | shost_printk(KERN_INFO, shost, |
| 564 | "sense urb submission failure\n"); |
| 565 | usb_free_urb(urb); |
| 566 | return SCSI_MLQUEUE_DEVICE_BUSY; |
| 567 | } |
| 568 | return 0; |
| 569 | } |
| 570 | |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 571 | static int uas_submit_urbs(struct scsi_cmnd *cmnd, |
Gerd Hoffmann | e9bd7e1 | 2012-06-19 09:54:50 +0200 | [diff] [blame] | 572 | struct uas_dev_info *devinfo, gfp_t gfp) |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 573 | { |
| 574 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; |
Gerd Hoffmann | e9bd7e1 | 2012-06-19 09:54:50 +0200 | [diff] [blame] | 575 | int err; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 576 | |
Gerd Hoffmann | f491ecb | 2013-09-13 13:27:14 +0200 | [diff] [blame] | 577 | WARN_ON_ONCE(!spin_is_locked(&devinfo->lock)); |
Matthew Wilcox | 92a3f76 | 2010-12-15 15:44:04 -0500 | [diff] [blame] | 578 | if (cmdinfo->state & SUBMIT_STATUS_URB) { |
Gerd Hoffmann | e9bd7e1 | 2012-06-19 09:54:50 +0200 | [diff] [blame] | 579 | err = uas_submit_sense_urb(cmnd->device->host, gfp, |
| 580 | cmdinfo->stream); |
| 581 | if (err) { |
| 582 | return err; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 583 | } |
Matthew Wilcox | 92a3f76 | 2010-12-15 15:44:04 -0500 | [diff] [blame] | 584 | cmdinfo->state &= ~SUBMIT_STATUS_URB; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 585 | } |
| 586 | |
| 587 | if (cmdinfo->state & ALLOC_DATA_IN_URB) { |
| 588 | cmdinfo->data_in_urb = uas_alloc_data_urb(devinfo, gfp, |
Gerd Hoffmann | c621a81 | 2012-06-19 09:54:48 +0200 | [diff] [blame] | 589 | devinfo->data_in_pipe, cmdinfo->stream, |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 590 | cmnd, DMA_FROM_DEVICE); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 591 | if (!cmdinfo->data_in_urb) |
| 592 | return SCSI_MLQUEUE_DEVICE_BUSY; |
| 593 | cmdinfo->state &= ~ALLOC_DATA_IN_URB; |
| 594 | } |
| 595 | |
| 596 | if (cmdinfo->state & SUBMIT_DATA_IN_URB) { |
Hans de Goede | d5f808d | 2013-10-17 19:30:26 +0200 | [diff] [blame] | 597 | usb_anchor_urb(cmdinfo->data_in_urb, &devinfo->data_urbs); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 598 | if (usb_submit_urb(cmdinfo->data_in_urb, gfp)) { |
Hans de Goede | d5f808d | 2013-10-17 19:30:26 +0200 | [diff] [blame] | 599 | usb_unanchor_urb(cmdinfo->data_in_urb); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 600 | scmd_printk(KERN_INFO, cmnd, |
| 601 | "data in urb submission failure\n"); |
| 602 | return SCSI_MLQUEUE_DEVICE_BUSY; |
| 603 | } |
| 604 | cmdinfo->state &= ~SUBMIT_DATA_IN_URB; |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 605 | cmdinfo->state |= DATA_IN_URB_INFLIGHT; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 606 | } |
| 607 | |
| 608 | if (cmdinfo->state & ALLOC_DATA_OUT_URB) { |
| 609 | cmdinfo->data_out_urb = uas_alloc_data_urb(devinfo, gfp, |
Gerd Hoffmann | c621a81 | 2012-06-19 09:54:48 +0200 | [diff] [blame] | 610 | devinfo->data_out_pipe, cmdinfo->stream, |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 611 | cmnd, DMA_TO_DEVICE); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 612 | if (!cmdinfo->data_out_urb) |
| 613 | return SCSI_MLQUEUE_DEVICE_BUSY; |
| 614 | cmdinfo->state &= ~ALLOC_DATA_OUT_URB; |
| 615 | } |
| 616 | |
| 617 | if (cmdinfo->state & SUBMIT_DATA_OUT_URB) { |
Hans de Goede | d5f808d | 2013-10-17 19:30:26 +0200 | [diff] [blame] | 618 | usb_anchor_urb(cmdinfo->data_out_urb, &devinfo->data_urbs); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 619 | if (usb_submit_urb(cmdinfo->data_out_urb, gfp)) { |
Hans de Goede | d5f808d | 2013-10-17 19:30:26 +0200 | [diff] [blame] | 620 | usb_unanchor_urb(cmdinfo->data_out_urb); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 621 | scmd_printk(KERN_INFO, cmnd, |
| 622 | "data out urb submission failure\n"); |
| 623 | return SCSI_MLQUEUE_DEVICE_BUSY; |
| 624 | } |
| 625 | cmdinfo->state &= ~SUBMIT_DATA_OUT_URB; |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 626 | cmdinfo->state |= DATA_OUT_URB_INFLIGHT; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 627 | } |
| 628 | |
| 629 | if (cmdinfo->state & ALLOC_CMD_URB) { |
Hans de Goede | a887cd3 | 2013-10-17 19:47:28 +0200 | [diff] [blame] | 630 | cmdinfo->cmd_urb = uas_alloc_cmd_urb(devinfo, gfp, cmnd); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 631 | if (!cmdinfo->cmd_urb) |
| 632 | return SCSI_MLQUEUE_DEVICE_BUSY; |
| 633 | cmdinfo->state &= ~ALLOC_CMD_URB; |
| 634 | } |
| 635 | |
| 636 | if (cmdinfo->state & SUBMIT_CMD_URB) { |
Hans de Goede | d5f808d | 2013-10-17 19:30:26 +0200 | [diff] [blame] | 637 | usb_anchor_urb(cmdinfo->cmd_urb, &devinfo->cmd_urbs); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 638 | if (usb_submit_urb(cmdinfo->cmd_urb, gfp)) { |
Hans de Goede | d5f808d | 2013-10-17 19:30:26 +0200 | [diff] [blame] | 639 | usb_unanchor_urb(cmdinfo->cmd_urb); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 640 | scmd_printk(KERN_INFO, cmnd, |
| 641 | "cmd urb submission failure\n"); |
| 642 | return SCSI_MLQUEUE_DEVICE_BUSY; |
| 643 | } |
Gerd Hoffmann | a0e39e3 | 2012-09-25 10:47:04 +0200 | [diff] [blame] | 644 | cmdinfo->cmd_urb = NULL; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 645 | cmdinfo->state &= ~SUBMIT_CMD_URB; |
Gerd Hoffmann | b1d6769 | 2012-06-19 09:54:51 +0200 | [diff] [blame] | 646 | cmdinfo->state |= COMMAND_INFLIGHT; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | return 0; |
| 650 | } |
| 651 | |
Jeff Garzik | f281233 | 2010-11-16 02:10:29 -0500 | [diff] [blame] | 652 | static int uas_queuecommand_lck(struct scsi_cmnd *cmnd, |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 653 | void (*done)(struct scsi_cmnd *)) |
| 654 | { |
| 655 | struct scsi_device *sdev = cmnd->device; |
| 656 | struct uas_dev_info *devinfo = sdev->hostdata; |
| 657 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 658 | unsigned long flags; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 659 | int err; |
| 660 | |
| 661 | BUILD_BUG_ON(sizeof(struct uas_cmd_info) > sizeof(struct scsi_pointer)); |
| 662 | |
Gerd Hoffmann | f8be6bf | 2012-11-30 11:54:45 +0100 | [diff] [blame] | 663 | if (devinfo->resetting) { |
| 664 | cmnd->result = DID_ERROR << 16; |
| 665 | cmnd->scsi_done(cmnd); |
| 666 | return 0; |
| 667 | } |
| 668 | |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 669 | spin_lock_irqsave(&devinfo->lock, flags); |
| 670 | if (devinfo->cmnd) { |
| 671 | spin_unlock_irqrestore(&devinfo->lock, flags); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 672 | return SCSI_MLQUEUE_DEVICE_BUSY; |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 673 | } |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 674 | |
| 675 | if (blk_rq_tagged(cmnd->request)) { |
Sebastian Andrzej Siewior | 22188f4 | 2011-12-19 20:22:39 +0100 | [diff] [blame] | 676 | cmdinfo->stream = cmnd->request->tag + 2; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 677 | } else { |
Sebastian Andrzej Siewior | 22188f4 | 2011-12-19 20:22:39 +0100 | [diff] [blame] | 678 | devinfo->cmnd = cmnd; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 679 | cmdinfo->stream = 1; |
| 680 | } |
| 681 | |
| 682 | cmnd->scsi_done = done; |
| 683 | |
Gerd Hoffmann | e9bd7e1 | 2012-06-19 09:54:50 +0200 | [diff] [blame] | 684 | cmdinfo->state = SUBMIT_STATUS_URB | |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 685 | ALLOC_CMD_URB | SUBMIT_CMD_URB; |
| 686 | |
| 687 | switch (cmnd->sc_data_direction) { |
| 688 | case DMA_FROM_DEVICE: |
| 689 | cmdinfo->state |= ALLOC_DATA_IN_URB | SUBMIT_DATA_IN_URB; |
| 690 | break; |
| 691 | case DMA_BIDIRECTIONAL: |
| 692 | cmdinfo->state |= ALLOC_DATA_IN_URB | SUBMIT_DATA_IN_URB; |
| 693 | case DMA_TO_DEVICE: |
| 694 | cmdinfo->state |= ALLOC_DATA_OUT_URB | SUBMIT_DATA_OUT_URB; |
| 695 | case DMA_NONE: |
| 696 | break; |
| 697 | } |
| 698 | |
| 699 | if (!devinfo->use_streams) { |
Gerd Hoffmann | db32de1 | 2012-06-19 09:54:49 +0200 | [diff] [blame] | 700 | cmdinfo->state &= ~(SUBMIT_DATA_IN_URB | SUBMIT_DATA_OUT_URB); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 701 | cmdinfo->stream = 0; |
| 702 | } |
| 703 | |
| 704 | err = uas_submit_urbs(cmnd, devinfo, GFP_ATOMIC); |
| 705 | if (err) { |
| 706 | /* If we did nothing, give up now */ |
Matthew Wilcox | 92a3f76 | 2010-12-15 15:44:04 -0500 | [diff] [blame] | 707 | if (cmdinfo->state & SUBMIT_STATUS_URB) { |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 708 | spin_unlock_irqrestore(&devinfo->lock, flags); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 709 | return SCSI_MLQUEUE_DEVICE_BUSY; |
| 710 | } |
Gerd Hoffmann | 1bf8198 | 2013-09-13 13:27:12 +0200 | [diff] [blame] | 711 | uas_add_work(cmdinfo); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 712 | } |
| 713 | |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 714 | spin_unlock_irqrestore(&devinfo->lock, flags); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 715 | return 0; |
| 716 | } |
| 717 | |
Jeff Garzik | f281233 | 2010-11-16 02:10:29 -0500 | [diff] [blame] | 718 | static DEF_SCSI_QCMD(uas_queuecommand) |
| 719 | |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 720 | static int uas_eh_task_mgmt(struct scsi_cmnd *cmnd, |
| 721 | const char *fname, u8 function) |
| 722 | { |
| 723 | struct Scsi_Host *shost = cmnd->device->host; |
| 724 | struct uas_dev_info *devinfo = (void *)shost->hostdata[0]; |
Hans de Goede | d3f7c15 | 2013-10-23 17:46:17 +0100 | [diff] [blame^] | 725 | u16 tag = devinfo->qdepth; |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 726 | unsigned long flags; |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 727 | |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 728 | spin_lock_irqsave(&devinfo->lock, flags); |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 729 | memset(&devinfo->response, 0, sizeof(devinfo->response)); |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 730 | if (uas_submit_sense_urb(shost, GFP_ATOMIC, tag)) { |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 731 | shost_printk(KERN_INFO, shost, |
| 732 | "%s: %s: submit sense urb failed\n", |
| 733 | __func__, fname); |
Gerd Hoffmann | 1994ff4 | 2012-09-26 10:28:58 +0200 | [diff] [blame] | 734 | spin_unlock_irqrestore(&devinfo->lock, flags); |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 735 | return FAILED; |
| 736 | } |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 737 | if (uas_submit_task_urb(cmnd, GFP_ATOMIC, function, tag)) { |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 738 | shost_printk(KERN_INFO, shost, |
| 739 | "%s: %s: submit task mgmt urb failed\n", |
| 740 | __func__, fname); |
Gerd Hoffmann | 1994ff4 | 2012-09-26 10:28:58 +0200 | [diff] [blame] | 741 | spin_unlock_irqrestore(&devinfo->lock, flags); |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 742 | return FAILED; |
| 743 | } |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 744 | spin_unlock_irqrestore(&devinfo->lock, flags); |
| 745 | |
| 746 | if (usb_wait_anchor_empty_timeout(&devinfo->sense_urbs, 3000) == 0) { |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 747 | shost_printk(KERN_INFO, shost, |
| 748 | "%s: %s timed out\n", __func__, fname); |
| 749 | return FAILED; |
| 750 | } |
| 751 | if (be16_to_cpu(devinfo->response.tag) != tag) { |
| 752 | shost_printk(KERN_INFO, shost, |
| 753 | "%s: %s failed (wrong tag %d/%d)\n", __func__, |
| 754 | fname, be16_to_cpu(devinfo->response.tag), tag); |
| 755 | return FAILED; |
| 756 | } |
| 757 | if (devinfo->response.response_code != RC_TMF_COMPLETE) { |
| 758 | shost_printk(KERN_INFO, shost, |
| 759 | "%s: %s failed (rc 0x%x)\n", __func__, |
| 760 | fname, devinfo->response.response_code); |
| 761 | return FAILED; |
| 762 | } |
| 763 | return SUCCESS; |
| 764 | } |
| 765 | |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 766 | static int uas_eh_abort_handler(struct scsi_cmnd *cmnd) |
| 767 | { |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 768 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 769 | struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata; |
| 770 | unsigned long flags; |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 771 | int ret; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 772 | |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 773 | uas_log_cmd_state(cmnd, __func__); |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 774 | spin_lock_irqsave(&devinfo->lock, flags); |
Gerd Hoffmann | f491ecb | 2013-09-13 13:27:14 +0200 | [diff] [blame] | 775 | WARN_ON_ONCE(cmdinfo->state & COMMAND_ABORTED); |
Gerd Hoffmann | ef018cc9 | 2012-09-25 10:47:06 +0200 | [diff] [blame] | 776 | cmdinfo->state |= COMMAND_ABORTED; |
Gerd Hoffmann | 326349f | 2013-09-13 13:27:13 +0200 | [diff] [blame] | 777 | list_add_tail(&cmdinfo->dead, &devinfo->dead_list); |
Gerd Hoffmann | 5d39040 | 2012-11-30 11:54:43 +0100 | [diff] [blame] | 778 | if (cmdinfo->state & IS_IN_WORK_LIST) { |
Gerd Hoffmann | 1bf8198 | 2013-09-13 13:27:12 +0200 | [diff] [blame] | 779 | list_del(&cmdinfo->work); |
Gerd Hoffmann | 5d39040 | 2012-11-30 11:54:43 +0100 | [diff] [blame] | 780 | cmdinfo->state &= ~IS_IN_WORK_LIST; |
Gerd Hoffmann | 5d39040 | 2012-11-30 11:54:43 +0100 | [diff] [blame] | 781 | } |
| 782 | if (cmdinfo->state & COMMAND_INFLIGHT) { |
| 783 | spin_unlock_irqrestore(&devinfo->lock, flags); |
| 784 | ret = uas_eh_task_mgmt(cmnd, "ABORT TASK", TMF_ABORT_TASK); |
| 785 | } else { |
Hans de Goede | 7e50e0b | 2013-10-17 19:19:04 +0200 | [diff] [blame] | 786 | uas_unlink_data_urbs(devinfo, cmdinfo, &flags); |
Gerd Hoffmann | 5d39040 | 2012-11-30 11:54:43 +0100 | [diff] [blame] | 787 | uas_try_complete(cmnd, __func__); |
| 788 | spin_unlock_irqrestore(&devinfo->lock, flags); |
| 789 | ret = SUCCESS; |
| 790 | } |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 791 | return ret; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 792 | } |
| 793 | |
| 794 | static int uas_eh_device_reset_handler(struct scsi_cmnd *cmnd) |
| 795 | { |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 796 | sdev_printk(KERN_INFO, cmnd->device, "%s\n", __func__); |
| 797 | return uas_eh_task_mgmt(cmnd, "LOGICAL UNIT RESET", |
| 798 | TMF_LOGICAL_UNIT_RESET); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 799 | } |
| 800 | |
| 801 | static int uas_eh_bus_reset_handler(struct scsi_cmnd *cmnd) |
| 802 | { |
| 803 | struct scsi_device *sdev = cmnd->device; |
| 804 | struct uas_dev_info *devinfo = sdev->hostdata; |
| 805 | struct usb_device *udev = devinfo->udev; |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 806 | int err; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 807 | |
Hans de Goede | be326f4 | 2013-09-22 16:27:02 +0200 | [diff] [blame] | 808 | err = usb_lock_device_for_reset(udev, devinfo->intf); |
| 809 | if (err) { |
| 810 | shost_printk(KERN_ERR, sdev->host, |
| 811 | "%s FAILED to get lock err %d\n", __func__, err); |
| 812 | return FAILED; |
| 813 | } |
| 814 | |
Gerd Hoffmann | 326349f | 2013-09-13 13:27:13 +0200 | [diff] [blame] | 815 | shost_printk(KERN_INFO, sdev->host, "%s start\n", __func__); |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 816 | devinfo->resetting = 1; |
Gerd Hoffmann | 4c45697 | 2012-11-30 11:54:44 +0100 | [diff] [blame] | 817 | uas_abort_work(devinfo); |
Gerd Hoffmann | a0e39e3 | 2012-09-25 10:47:04 +0200 | [diff] [blame] | 818 | usb_kill_anchored_urbs(&devinfo->cmd_urbs); |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 819 | usb_kill_anchored_urbs(&devinfo->sense_urbs); |
| 820 | usb_kill_anchored_urbs(&devinfo->data_urbs); |
Gerd Hoffmann | 326349f | 2013-09-13 13:27:13 +0200 | [diff] [blame] | 821 | uas_zap_dead(devinfo); |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 822 | err = usb_reset_device(udev); |
| 823 | devinfo->resetting = 0; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 824 | |
Hans de Goede | be326f4 | 2013-09-22 16:27:02 +0200 | [diff] [blame] | 825 | usb_unlock_device(udev); |
| 826 | |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 827 | if (err) { |
| 828 | shost_printk(KERN_INFO, sdev->host, "%s FAILED\n", __func__); |
| 829 | return FAILED; |
| 830 | } |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 831 | |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 832 | shost_printk(KERN_INFO, sdev->host, "%s success\n", __func__); |
| 833 | return SUCCESS; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 834 | } |
| 835 | |
| 836 | static int uas_slave_alloc(struct scsi_device *sdev) |
| 837 | { |
| 838 | sdev->hostdata = (void *)sdev->host->hostdata[0]; |
| 839 | return 0; |
| 840 | } |
| 841 | |
| 842 | static int uas_slave_configure(struct scsi_device *sdev) |
| 843 | { |
| 844 | struct uas_dev_info *devinfo = sdev->hostdata; |
| 845 | scsi_set_tag_type(sdev, MSG_ORDERED_TAG); |
Hans de Goede | d3f7c15 | 2013-10-23 17:46:17 +0100 | [diff] [blame^] | 846 | scsi_activate_tcq(sdev, devinfo->qdepth - 2); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 847 | return 0; |
| 848 | } |
| 849 | |
| 850 | static struct scsi_host_template uas_host_template = { |
| 851 | .module = THIS_MODULE, |
| 852 | .name = "uas", |
| 853 | .queuecommand = uas_queuecommand, |
| 854 | .slave_alloc = uas_slave_alloc, |
| 855 | .slave_configure = uas_slave_configure, |
| 856 | .eh_abort_handler = uas_eh_abort_handler, |
| 857 | .eh_device_reset_handler = uas_eh_device_reset_handler, |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 858 | .eh_bus_reset_handler = uas_eh_bus_reset_handler, |
| 859 | .can_queue = 65536, /* Is there a limit on the _host_ ? */ |
| 860 | .this_id = -1, |
| 861 | .sg_tablesize = SG_NONE, |
| 862 | .cmd_per_lun = 1, /* until we override it */ |
| 863 | .skip_settle_delay = 1, |
| 864 | .ordered_tag = 1, |
| 865 | }; |
| 866 | |
| 867 | static struct usb_device_id uas_usb_ids[] = { |
| 868 | { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, USB_SC_SCSI, USB_PR_BULK) }, |
| 869 | { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, USB_SC_SCSI, USB_PR_UAS) }, |
| 870 | /* 0xaa is a prototype device I happen to have access to */ |
| 871 | { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, USB_SC_SCSI, 0xaa) }, |
| 872 | { } |
| 873 | }; |
| 874 | MODULE_DEVICE_TABLE(usb, uas_usb_ids); |
| 875 | |
Matthew Wilcox | 89dc290 | 2010-12-15 15:44:05 -0500 | [diff] [blame] | 876 | static int uas_is_interface(struct usb_host_interface *intf) |
| 877 | { |
| 878 | return (intf->desc.bInterfaceClass == USB_CLASS_MASS_STORAGE && |
| 879 | intf->desc.bInterfaceSubClass == USB_SC_SCSI && |
| 880 | intf->desc.bInterfaceProtocol == USB_PR_UAS); |
| 881 | } |
| 882 | |
Sebastian Andrzej Siewior | c898add | 2012-01-11 12:42:32 +0100 | [diff] [blame] | 883 | static int uas_isnt_supported(struct usb_device *udev) |
| 884 | { |
| 885 | struct usb_hcd *hcd = bus_to_hcd(udev->bus); |
| 886 | |
| 887 | dev_warn(&udev->dev, "The driver for the USB controller %s does not " |
| 888 | "support scatter-gather which is\n", |
| 889 | hcd->driver->description); |
| 890 | dev_warn(&udev->dev, "required by the UAS driver. Please try an" |
| 891 | "alternative USB controller if you wish to use UAS.\n"); |
| 892 | return -ENODEV; |
| 893 | } |
| 894 | |
Matthew Wilcox | 89dc290 | 2010-12-15 15:44:05 -0500 | [diff] [blame] | 895 | static int uas_switch_interface(struct usb_device *udev, |
| 896 | struct usb_interface *intf) |
| 897 | { |
| 898 | int i; |
Sebastian Andrzej Siewior | c898add | 2012-01-11 12:42:32 +0100 | [diff] [blame] | 899 | int sg_supported = udev->bus->sg_tablesize != 0; |
Matthew Wilcox | 89dc290 | 2010-12-15 15:44:05 -0500 | [diff] [blame] | 900 | |
| 901 | for (i = 0; i < intf->num_altsetting; i++) { |
| 902 | struct usb_host_interface *alt = &intf->altsetting[i]; |
Sebastian Andrzej Siewior | c898add | 2012-01-11 12:42:32 +0100 | [diff] [blame] | 903 | |
| 904 | if (uas_is_interface(alt)) { |
| 905 | if (!sg_supported) |
| 906 | return uas_isnt_supported(udev); |
Matthew Wilcox | 89dc290 | 2010-12-15 15:44:05 -0500 | [diff] [blame] | 907 | return usb_set_interface(udev, |
| 908 | alt->desc.bInterfaceNumber, |
| 909 | alt->desc.bAlternateSetting); |
Sebastian Andrzej Siewior | c898add | 2012-01-11 12:42:32 +0100 | [diff] [blame] | 910 | } |
Matthew Wilcox | 89dc290 | 2010-12-15 15:44:05 -0500 | [diff] [blame] | 911 | } |
| 912 | |
| 913 | return -ENODEV; |
| 914 | } |
| 915 | |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 916 | static void uas_configure_endpoints(struct uas_dev_info *devinfo) |
| 917 | { |
| 918 | struct usb_host_endpoint *eps[4] = { }; |
| 919 | struct usb_interface *intf = devinfo->intf; |
| 920 | struct usb_device *udev = devinfo->udev; |
| 921 | struct usb_host_endpoint *endpoint = intf->cur_altsetting->endpoint; |
| 922 | unsigned i, n_endpoints = intf->cur_altsetting->desc.bNumEndpoints; |
| 923 | |
| 924 | devinfo->uas_sense_old = 0; |
Sebastian Andrzej Siewior | 22188f4 | 2011-12-19 20:22:39 +0100 | [diff] [blame] | 925 | devinfo->cmnd = NULL; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 926 | |
| 927 | for (i = 0; i < n_endpoints; i++) { |
| 928 | unsigned char *extra = endpoint[i].extra; |
| 929 | int len = endpoint[i].extralen; |
| 930 | while (len > 1) { |
| 931 | if (extra[1] == USB_DT_PIPE_USAGE) { |
| 932 | unsigned pipe_id = extra[2]; |
| 933 | if (pipe_id > 0 && pipe_id < 5) |
| 934 | eps[pipe_id - 1] = &endpoint[i]; |
| 935 | break; |
| 936 | } |
| 937 | len -= extra[0]; |
| 938 | extra += extra[0]; |
| 939 | } |
| 940 | } |
| 941 | |
| 942 | /* |
| 943 | * Assume that if we didn't find a control pipe descriptor, we're |
| 944 | * using a device with old firmware that happens to be set up like |
| 945 | * this. |
| 946 | */ |
| 947 | if (!eps[0]) { |
| 948 | devinfo->cmd_pipe = usb_sndbulkpipe(udev, 1); |
| 949 | devinfo->status_pipe = usb_rcvbulkpipe(udev, 1); |
| 950 | devinfo->data_in_pipe = usb_rcvbulkpipe(udev, 2); |
| 951 | devinfo->data_out_pipe = usb_sndbulkpipe(udev, 2); |
| 952 | |
| 953 | eps[1] = usb_pipe_endpoint(udev, devinfo->status_pipe); |
| 954 | eps[2] = usb_pipe_endpoint(udev, devinfo->data_in_pipe); |
| 955 | eps[3] = usb_pipe_endpoint(udev, devinfo->data_out_pipe); |
| 956 | } else { |
| 957 | devinfo->cmd_pipe = usb_sndbulkpipe(udev, |
Hans de Goede | 6c2334e | 2013-10-17 22:20:54 +0200 | [diff] [blame] | 958 | usb_endpoint_num(&eps[0]->desc)); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 959 | devinfo->status_pipe = usb_rcvbulkpipe(udev, |
Hans de Goede | 6c2334e | 2013-10-17 22:20:54 +0200 | [diff] [blame] | 960 | usb_endpoint_num(&eps[1]->desc)); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 961 | devinfo->data_in_pipe = usb_rcvbulkpipe(udev, |
Hans de Goede | 6c2334e | 2013-10-17 22:20:54 +0200 | [diff] [blame] | 962 | usb_endpoint_num(&eps[2]->desc)); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 963 | devinfo->data_out_pipe = usb_sndbulkpipe(udev, |
Hans de Goede | 6c2334e | 2013-10-17 22:20:54 +0200 | [diff] [blame] | 964 | usb_endpoint_num(&eps[3]->desc)); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 965 | } |
| 966 | |
| 967 | devinfo->qdepth = usb_alloc_streams(devinfo->intf, eps + 1, 3, 256, |
| 968 | GFP_KERNEL); |
| 969 | if (devinfo->qdepth < 0) { |
| 970 | devinfo->qdepth = 256; |
| 971 | devinfo->use_streams = 0; |
| 972 | } else { |
| 973 | devinfo->use_streams = 1; |
| 974 | } |
| 975 | } |
| 976 | |
Sebastian Andrzej Siewior | dae5154 | 2011-12-19 17:06:08 +0100 | [diff] [blame] | 977 | static void uas_free_streams(struct uas_dev_info *devinfo) |
| 978 | { |
| 979 | struct usb_device *udev = devinfo->udev; |
| 980 | struct usb_host_endpoint *eps[3]; |
| 981 | |
| 982 | eps[0] = usb_pipe_endpoint(udev, devinfo->status_pipe); |
| 983 | eps[1] = usb_pipe_endpoint(udev, devinfo->data_in_pipe); |
| 984 | eps[2] = usb_pipe_endpoint(udev, devinfo->data_out_pipe); |
| 985 | usb_free_streams(devinfo->intf, eps, 3, GFP_KERNEL); |
| 986 | } |
| 987 | |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 988 | /* |
| 989 | * XXX: What I'd like to do here is register a SCSI host for each USB host in |
| 990 | * the system. Follow usb-storage's design of registering a SCSI host for |
| 991 | * each USB device for the moment. Can implement this by walking up the |
| 992 | * USB hierarchy until we find a USB host. |
| 993 | */ |
| 994 | static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id) |
| 995 | { |
Hans de Goede | 6ce8213 | 2013-10-17 19:00:45 +0200 | [diff] [blame] | 996 | int result = -ENOMEM; |
| 997 | struct Scsi_Host *shost = NULL; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 998 | struct uas_dev_info *devinfo; |
| 999 | struct usb_device *udev = interface_to_usbdev(intf); |
| 1000 | |
Matthew Wilcox | 89dc290 | 2010-12-15 15:44:05 -0500 | [diff] [blame] | 1001 | if (uas_switch_interface(udev, intf)) |
| 1002 | return -ENODEV; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 1003 | |
| 1004 | devinfo = kmalloc(sizeof(struct uas_dev_info), GFP_KERNEL); |
| 1005 | if (!devinfo) |
Hans de Goede | 6ce8213 | 2013-10-17 19:00:45 +0200 | [diff] [blame] | 1006 | goto set_alt0; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 1007 | |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 1008 | shost = scsi_host_alloc(&uas_host_template, sizeof(void *)); |
| 1009 | if (!shost) |
Hans de Goede | 6ce8213 | 2013-10-17 19:00:45 +0200 | [diff] [blame] | 1010 | goto set_alt0; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 1011 | |
| 1012 | shost->max_cmd_len = 16 + 252; |
| 1013 | shost->max_id = 1; |
Gerd Hoffmann | bde027b | 2013-01-25 15:03:36 +0100 | [diff] [blame] | 1014 | shost->max_lun = 256; |
| 1015 | shost->max_channel = 0; |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 1016 | shost->sg_tablesize = udev->bus->sg_tablesize; |
| 1017 | |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 1018 | devinfo->intf = intf; |
| 1019 | devinfo->udev = udev; |
Gerd Hoffmann | 023b515 | 2012-06-19 09:54:54 +0200 | [diff] [blame] | 1020 | devinfo->resetting = 0; |
Gerd Hoffmann | a0e39e3 | 2012-09-25 10:47:04 +0200 | [diff] [blame] | 1021 | init_usb_anchor(&devinfo->cmd_urbs); |
Gerd Hoffmann | bdd000f | 2012-06-19 09:54:53 +0200 | [diff] [blame] | 1022 | init_usb_anchor(&devinfo->sense_urbs); |
| 1023 | init_usb_anchor(&devinfo->data_urbs); |
Gerd Hoffmann | e064852 | 2012-09-25 10:47:08 +0200 | [diff] [blame] | 1024 | spin_lock_init(&devinfo->lock); |
Gerd Hoffmann | 1bf8198 | 2013-09-13 13:27:12 +0200 | [diff] [blame] | 1025 | INIT_WORK(&devinfo->work, uas_do_work); |
| 1026 | INIT_LIST_HEAD(&devinfo->work_list); |
Gerd Hoffmann | 326349f | 2013-09-13 13:27:13 +0200 | [diff] [blame] | 1027 | INIT_LIST_HEAD(&devinfo->dead_list); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 1028 | uas_configure_endpoints(devinfo); |
| 1029 | |
Hans de Goede | d3f7c15 | 2013-10-23 17:46:17 +0100 | [diff] [blame^] | 1030 | result = scsi_init_shared_tag_map(shost, devinfo->qdepth - 2); |
Sebastian Andrzej Siewior | dae5154 | 2011-12-19 17:06:08 +0100 | [diff] [blame] | 1031 | if (result) |
Hans de Goede | 6ce8213 | 2013-10-17 19:00:45 +0200 | [diff] [blame] | 1032 | goto free_streams; |
Sebastian Andrzej Siewior | dae5154 | 2011-12-19 17:06:08 +0100 | [diff] [blame] | 1033 | |
| 1034 | result = scsi_add_host(shost, &intf->dev); |
| 1035 | if (result) |
Hans de Goede | 6ce8213 | 2013-10-17 19:00:45 +0200 | [diff] [blame] | 1036 | goto free_streams; |
Sebastian Andrzej Siewior | dae5154 | 2011-12-19 17:06:08 +0100 | [diff] [blame] | 1037 | |
| 1038 | shost->hostdata[0] = (unsigned long)devinfo; |
| 1039 | |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 1040 | scsi_scan_host(shost); |
| 1041 | usb_set_intfdata(intf, shost); |
| 1042 | return result; |
Sebastian Andrzej Siewior | dae5154 | 2011-12-19 17:06:08 +0100 | [diff] [blame] | 1043 | |
Hans de Goede | 6ce8213 | 2013-10-17 19:00:45 +0200 | [diff] [blame] | 1044 | free_streams: |
Sebastian Andrzej Siewior | dae5154 | 2011-12-19 17:06:08 +0100 | [diff] [blame] | 1045 | uas_free_streams(devinfo); |
Hans de Goede | 6ce8213 | 2013-10-17 19:00:45 +0200 | [diff] [blame] | 1046 | set_alt0: |
| 1047 | usb_set_interface(udev, intf->altsetting[0].desc.bInterfaceNumber, 0); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 1048 | kfree(devinfo); |
| 1049 | if (shost) |
| 1050 | scsi_host_put(shost); |
| 1051 | return result; |
| 1052 | } |
| 1053 | |
| 1054 | static int uas_pre_reset(struct usb_interface *intf) |
| 1055 | { |
Hans de Goede | 4de7a373 | 2013-10-22 16:10:44 +0100 | [diff] [blame] | 1056 | struct Scsi_Host *shost = usb_get_intfdata(intf); |
| 1057 | struct uas_dev_info *devinfo = (void *)shost->hostdata[0]; |
| 1058 | unsigned long flags; |
| 1059 | |
| 1060 | /* Block new requests */ |
| 1061 | spin_lock_irqsave(shost->host_lock, flags); |
| 1062 | scsi_block_requests(shost); |
| 1063 | spin_unlock_irqrestore(shost->host_lock, flags); |
| 1064 | |
| 1065 | /* Wait for any pending requests to complete */ |
| 1066 | flush_work(&devinfo->work); |
| 1067 | if (usb_wait_anchor_empty_timeout(&devinfo->sense_urbs, 5000) == 0) { |
| 1068 | shost_printk(KERN_ERR, shost, "%s: timed out\n", __func__); |
| 1069 | return 1; |
| 1070 | } |
| 1071 | |
| 1072 | uas_free_streams(devinfo); |
| 1073 | |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 1074 | return 0; |
| 1075 | } |
| 1076 | |
| 1077 | static int uas_post_reset(struct usb_interface *intf) |
| 1078 | { |
Hans de Goede | 4de7a373 | 2013-10-22 16:10:44 +0100 | [diff] [blame] | 1079 | struct Scsi_Host *shost = usb_get_intfdata(intf); |
| 1080 | struct uas_dev_info *devinfo = (void *)shost->hostdata[0]; |
| 1081 | unsigned long flags; |
| 1082 | |
| 1083 | uas_configure_endpoints(devinfo); |
| 1084 | |
| 1085 | spin_lock_irqsave(shost->host_lock, flags); |
| 1086 | scsi_report_bus_reset(shost, 0); |
| 1087 | spin_unlock_irqrestore(shost->host_lock, flags); |
| 1088 | |
| 1089 | scsi_unblock_requests(shost); |
| 1090 | |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 1091 | return 0; |
| 1092 | } |
| 1093 | |
| 1094 | static void uas_disconnect(struct usb_interface *intf) |
| 1095 | { |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 1096 | struct Scsi_Host *shost = usb_get_intfdata(intf); |
| 1097 | struct uas_dev_info *devinfo = (void *)shost->hostdata[0]; |
| 1098 | |
Gerd Hoffmann | 4c45697 | 2012-11-30 11:54:44 +0100 | [diff] [blame] | 1099 | devinfo->resetting = 1; |
Gerd Hoffmann | 1bf8198 | 2013-09-13 13:27:12 +0200 | [diff] [blame] | 1100 | cancel_work_sync(&devinfo->work); |
Gerd Hoffmann | 4c45697 | 2012-11-30 11:54:44 +0100 | [diff] [blame] | 1101 | uas_abort_work(devinfo); |
Gerd Hoffmann | a0e39e3 | 2012-09-25 10:47:04 +0200 | [diff] [blame] | 1102 | usb_kill_anchored_urbs(&devinfo->cmd_urbs); |
Gerd Hoffmann | bdd000f | 2012-06-19 09:54:53 +0200 | [diff] [blame] | 1103 | usb_kill_anchored_urbs(&devinfo->sense_urbs); |
| 1104 | usb_kill_anchored_urbs(&devinfo->data_urbs); |
Gerd Hoffmann | 326349f | 2013-09-13 13:27:13 +0200 | [diff] [blame] | 1105 | uas_zap_dead(devinfo); |
Gerd Hoffmann | 4c45697 | 2012-11-30 11:54:44 +0100 | [diff] [blame] | 1106 | scsi_remove_host(shost); |
Sebastian Andrzej Siewior | dae5154 | 2011-12-19 17:06:08 +0100 | [diff] [blame] | 1107 | uas_free_streams(devinfo); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 1108 | kfree(devinfo); |
| 1109 | } |
| 1110 | |
| 1111 | /* |
| 1112 | * XXX: Should this plug into libusual so we can auto-upgrade devices from |
| 1113 | * Bulk-Only to UAS? |
| 1114 | */ |
| 1115 | static struct usb_driver uas_driver = { |
| 1116 | .name = "uas", |
| 1117 | .probe = uas_probe, |
| 1118 | .disconnect = uas_disconnect, |
| 1119 | .pre_reset = uas_pre_reset, |
| 1120 | .post_reset = uas_post_reset, |
| 1121 | .id_table = uas_usb_ids, |
| 1122 | }; |
| 1123 | |
Greg Kroah-Hartman | 65db430 | 2011-11-18 09:34:02 -0800 | [diff] [blame] | 1124 | module_usb_driver(uas_driver); |
Matthew Wilcox | 115bb1f | 2010-10-07 13:05:23 +0200 | [diff] [blame] | 1125 | |
| 1126 | MODULE_LICENSE("GPL"); |
| 1127 | MODULE_AUTHOR("Matthew Wilcox and Sarah Sharp"); |