diff options
48 files changed, 791 insertions, 283 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-usb b/Documentation/ABI/testing/sysfs-bus-usb index b4f548792e32..7c22a532fdfb 100644 --- a/Documentation/ABI/testing/sysfs-bus-usb +++ b/Documentation/ABI/testing/sysfs-bus-usb | |||
@@ -182,3 +182,14 @@ Description: | |||
182 | USB2 hardware LPM is enabled for the device. Developer can | 182 | USB2 hardware LPM is enabled for the device. Developer can |
183 | write y/Y/1 or n/N/0 to the file to enable/disable the | 183 | write y/Y/1 or n/N/0 to the file to enable/disable the |
184 | feature. | 184 | feature. |
185 | |||
186 | What: /sys/bus/usb/devices/.../removable | ||
187 | Date: February 2012 | ||
188 | Contact: Matthew Garrett <mjg@redhat.com> | ||
189 | Description: | ||
190 | Some information about whether a given USB device is | ||
191 | physically fixed to the platform can be inferred from a | ||
192 | combination of hub decriptor bits and platform-specific data | ||
193 | such as ACPI. This file will read either "removable" or | ||
194 | "fixed" if the information is available, and "unknown" | ||
195 | otherwise. \ No newline at end of file | ||
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 89da43f73c00..fd37bfbfbcdb 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c | |||
@@ -1295,6 +1295,7 @@ EXPORT_SYMBOL(int_to_scsilun); | |||
1295 | * LUNs even if it's older than SCSI-3. | 1295 | * LUNs even if it's older than SCSI-3. |
1296 | * If BLIST_NOREPORTLUN is set, return 1 always. | 1296 | * If BLIST_NOREPORTLUN is set, return 1 always. |
1297 | * If BLIST_NOLUN is set, return 0 always. | 1297 | * If BLIST_NOLUN is set, return 0 always. |
1298 | * If starget->no_report_luns is set, return 1 always. | ||
1298 | * | 1299 | * |
1299 | * Return: | 1300 | * Return: |
1300 | * 0: scan completed (or no memory, so further scanning is futile) | 1301 | * 0: scan completed (or no memory, so further scanning is futile) |
@@ -1321,6 +1322,7 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags, | |||
1321 | * Only support SCSI-3 and up devices if BLIST_NOREPORTLUN is not set. | 1322 | * Only support SCSI-3 and up devices if BLIST_NOREPORTLUN is not set. |
1322 | * Also allow SCSI-2 if BLIST_REPORTLUN2 is set and host adapter does | 1323 | * Also allow SCSI-2 if BLIST_REPORTLUN2 is set and host adapter does |
1323 | * support more than 8 LUNs. | 1324 | * support more than 8 LUNs. |
1325 | * Don't attempt if the target doesn't support REPORT LUNS. | ||
1324 | */ | 1326 | */ |
1325 | if (bflags & BLIST_NOREPORTLUN) | 1327 | if (bflags & BLIST_NOREPORTLUN) |
1326 | return 1; | 1328 | return 1; |
@@ -1332,6 +1334,8 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags, | |||
1332 | return 1; | 1334 | return 1; |
1333 | if (bflags & BLIST_NOLUN) | 1335 | if (bflags & BLIST_NOLUN) |
1334 | return 0; | 1336 | return 0; |
1337 | if (starget->no_report_luns) | ||
1338 | return 1; | ||
1335 | 1339 | ||
1336 | if (!(sdev = scsi_device_lookup_by_target(starget, 0))) { | 1340 | if (!(sdev = scsi_device_lookup_by_target(starget, 0))) { |
1337 | sdev = scsi_alloc_sdev(starget, 0, NULL); | 1341 | sdev = scsi_alloc_sdev(starget, 0, NULL); |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index c691fb50e6cb..d173b90b25e9 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -2349,7 +2349,7 @@ static int sd_try_extended_inquiry(struct scsi_device *sdp) | |||
2349 | * some USB ones crash on receiving them, and the pages | 2349 | * some USB ones crash on receiving them, and the pages |
2350 | * we currently ask for are for SPC-3 and beyond | 2350 | * we currently ask for are for SPC-3 and beyond |
2351 | */ | 2351 | */ |
2352 | if (sdp->scsi_level > SCSI_SPC_2) | 2352 | if (sdp->scsi_level > SCSI_SPC_2 && !sdp->skip_vpd_pages) |
2353 | return 1; | 2353 | return 1; |
2354 | return 0; | 2354 | return 0; |
2355 | } | 2355 | } |
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 75823a1abeb6..0b0afc81a542 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig | |||
@@ -76,6 +76,7 @@ config USB_ARCH_HAS_EHCI | |||
76 | default y if MICROBLAZE | 76 | default y if MICROBLAZE |
77 | default y if SPARC_LEON | 77 | default y if SPARC_LEON |
78 | default y if ARCH_MMP | 78 | default y if ARCH_MMP |
79 | default y if MACH_LOONGSON1 | ||
79 | default PCI | 80 | default PCI |
80 | 81 | ||
81 | # some non-PCI HCDs implement xHCI | 82 | # some non-PCI HCDs implement xHCI |
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index d2b3cffca3f7..f63601a2054c 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c | |||
@@ -31,6 +31,8 @@ | |||
31 | #define DRIVER_AUTHOR "Oliver Neukum" | 31 | #define DRIVER_AUTHOR "Oliver Neukum" |
32 | #define DRIVER_DESC "USB Abstract Control Model driver for USB WCM Device Management" | 32 | #define DRIVER_DESC "USB Abstract Control Model driver for USB WCM Device Management" |
33 | 33 | ||
34 | #define HUAWEI_VENDOR_ID 0x12D1 | ||
35 | |||
34 | static const struct usb_device_id wdm_ids[] = { | 36 | static const struct usb_device_id wdm_ids[] = { |
35 | { | 37 | { |
36 | .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS | | 38 | .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS | |
@@ -38,6 +40,20 @@ static const struct usb_device_id wdm_ids[] = { | |||
38 | .bInterfaceClass = USB_CLASS_COMM, | 40 | .bInterfaceClass = USB_CLASS_COMM, |
39 | .bInterfaceSubClass = USB_CDC_SUBCLASS_DMM | 41 | .bInterfaceSubClass = USB_CDC_SUBCLASS_DMM |
40 | }, | 42 | }, |
43 | { | ||
44 | /* | ||
45 | * Huawei E392, E398 and possibly other Qualcomm based modems | ||
46 | * embed the Qualcomm QMI protocol inside CDC on CDC ECM like | ||
47 | * control interfaces. Userspace access to this is required | ||
48 | * to configure the accompanying data interface | ||
49 | */ | ||
50 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR | | ||
51 | USB_DEVICE_ID_MATCH_INT_INFO, | ||
52 | .idVendor = HUAWEI_VENDOR_ID, | ||
53 | .bInterfaceClass = USB_CLASS_VENDOR_SPEC, | ||
54 | .bInterfaceSubClass = 1, | ||
55 | .bInterfaceProtocol = 9, /* NOTE: CDC ECM control interface! */ | ||
56 | }, | ||
41 | { } | 57 | { } |
42 | }; | 58 | }; |
43 | 59 | ||
@@ -82,7 +98,6 @@ struct wdm_device { | |||
82 | u16 bufsize; | 98 | u16 bufsize; |
83 | u16 wMaxCommand; | 99 | u16 wMaxCommand; |
84 | u16 wMaxPacketSize; | 100 | u16 wMaxPacketSize; |
85 | u16 bMaxPacketSize0; | ||
86 | __le16 inum; | 101 | __le16 inum; |
87 | int reslength; | 102 | int reslength; |
88 | int length; | 103 | int length; |
@@ -162,11 +177,9 @@ static void wdm_int_callback(struct urb *urb) | |||
162 | int rv = 0; | 177 | int rv = 0; |
163 | int status = urb->status; | 178 | int status = urb->status; |
164 | struct wdm_device *desc; | 179 | struct wdm_device *desc; |
165 | struct usb_ctrlrequest *req; | ||
166 | struct usb_cdc_notification *dr; | 180 | struct usb_cdc_notification *dr; |
167 | 181 | ||
168 | desc = urb->context; | 182 | desc = urb->context; |
169 | req = desc->irq; | ||
170 | dr = (struct usb_cdc_notification *)desc->sbuf; | 183 | dr = (struct usb_cdc_notification *)desc->sbuf; |
171 | 184 | ||
172 | if (status) { | 185 | if (status) { |
@@ -213,24 +226,6 @@ static void wdm_int_callback(struct urb *urb) | |||
213 | goto exit; | 226 | goto exit; |
214 | } | 227 | } |
215 | 228 | ||
216 | req->bRequestType = (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE); | ||
217 | req->bRequest = USB_CDC_GET_ENCAPSULATED_RESPONSE; | ||
218 | req->wValue = 0; | ||
219 | req->wIndex = desc->inum; | ||
220 | req->wLength = cpu_to_le16(desc->wMaxCommand); | ||
221 | |||
222 | usb_fill_control_urb( | ||
223 | desc->response, | ||
224 | interface_to_usbdev(desc->intf), | ||
225 | /* using common endpoint 0 */ | ||
226 | usb_rcvctrlpipe(interface_to_usbdev(desc->intf), 0), | ||
227 | (unsigned char *)req, | ||
228 | desc->inbuf, | ||
229 | desc->wMaxCommand, | ||
230 | wdm_in_callback, | ||
231 | desc | ||
232 | ); | ||
233 | desc->response->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
234 | spin_lock(&desc->iuspin); | 229 | spin_lock(&desc->iuspin); |
235 | clear_bit(WDM_READ, &desc->flags); | 230 | clear_bit(WDM_READ, &desc->flags); |
236 | set_bit(WDM_RESPONDING, &desc->flags); | 231 | set_bit(WDM_RESPONDING, &desc->flags); |
@@ -279,14 +274,8 @@ static void free_urbs(struct wdm_device *desc) | |||
279 | 274 | ||
280 | static void cleanup(struct wdm_device *desc) | 275 | static void cleanup(struct wdm_device *desc) |
281 | { | 276 | { |
282 | usb_free_coherent(interface_to_usbdev(desc->intf), | 277 | kfree(desc->sbuf); |
283 | desc->wMaxPacketSize, | 278 | kfree(desc->inbuf); |
284 | desc->sbuf, | ||
285 | desc->validity->transfer_dma); | ||
286 | usb_free_coherent(interface_to_usbdev(desc->intf), | ||
287 | desc->bMaxPacketSize0, | ||
288 | desc->inbuf, | ||
289 | desc->response->transfer_dma); | ||
290 | kfree(desc->orq); | 279 | kfree(desc->orq); |
291 | kfree(desc->irq); | 280 | kfree(desc->irq); |
292 | kfree(desc->ubuf); | 281 | kfree(desc->ubuf); |
@@ -631,7 +620,6 @@ static void wdm_rxwork(struct work_struct *work) | |||
631 | static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id) | 620 | static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id) |
632 | { | 621 | { |
633 | int rv = -EINVAL; | 622 | int rv = -EINVAL; |
634 | struct usb_device *udev = interface_to_usbdev(intf); | ||
635 | struct wdm_device *desc; | 623 | struct wdm_device *desc; |
636 | struct usb_host_interface *iface; | 624 | struct usb_host_interface *iface; |
637 | struct usb_endpoint_descriptor *ep; | 625 | struct usb_endpoint_descriptor *ep; |
@@ -692,7 +680,6 @@ next_desc: | |||
692 | goto err; | 680 | goto err; |
693 | 681 | ||
694 | desc->wMaxPacketSize = usb_endpoint_maxp(ep); | 682 | desc->wMaxPacketSize = usb_endpoint_maxp(ep); |
695 | desc->bMaxPacketSize0 = udev->descriptor.bMaxPacketSize0; | ||
696 | 683 | ||
697 | desc->orq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); | 684 | desc->orq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); |
698 | if (!desc->orq) | 685 | if (!desc->orq) |
@@ -717,19 +704,13 @@ next_desc: | |||
717 | if (!desc->ubuf) | 704 | if (!desc->ubuf) |
718 | goto err; | 705 | goto err; |
719 | 706 | ||
720 | desc->sbuf = usb_alloc_coherent(interface_to_usbdev(intf), | 707 | desc->sbuf = kmalloc(desc->wMaxPacketSize, GFP_KERNEL); |
721 | desc->wMaxPacketSize, | ||
722 | GFP_KERNEL, | ||
723 | &desc->validity->transfer_dma); | ||
724 | if (!desc->sbuf) | 708 | if (!desc->sbuf) |
725 | goto err; | 709 | goto err; |
726 | 710 | ||
727 | desc->inbuf = usb_alloc_coherent(interface_to_usbdev(intf), | 711 | desc->inbuf = kmalloc(desc->wMaxCommand, GFP_KERNEL); |
728 | desc->wMaxCommand, | ||
729 | GFP_KERNEL, | ||
730 | &desc->response->transfer_dma); | ||
731 | if (!desc->inbuf) | 712 | if (!desc->inbuf) |
732 | goto err2; | 713 | goto err; |
733 | 714 | ||
734 | usb_fill_int_urb( | 715 | usb_fill_int_urb( |
735 | desc->validity, | 716 | desc->validity, |
@@ -741,30 +722,39 @@ next_desc: | |||
741 | desc, | 722 | desc, |
742 | ep->bInterval | 723 | ep->bInterval |
743 | ); | 724 | ); |
744 | desc->validity->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 725 | |
726 | desc->irq->bRequestType = (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE); | ||
727 | desc->irq->bRequest = USB_CDC_GET_ENCAPSULATED_RESPONSE; | ||
728 | desc->irq->wValue = 0; | ||
729 | desc->irq->wIndex = desc->inum; | ||
730 | desc->irq->wLength = cpu_to_le16(desc->wMaxCommand); | ||
731 | |||
732 | usb_fill_control_urb( | ||
733 | desc->response, | ||
734 | interface_to_usbdev(intf), | ||
735 | /* using common endpoint 0 */ | ||
736 | usb_rcvctrlpipe(interface_to_usbdev(desc->intf), 0), | ||
737 | (unsigned char *)desc->irq, | ||
738 | desc->inbuf, | ||
739 | desc->wMaxCommand, | ||
740 | wdm_in_callback, | ||
741 | desc | ||
742 | ); | ||
745 | 743 | ||
746 | usb_set_intfdata(intf, desc); | 744 | usb_set_intfdata(intf, desc); |
747 | rv = usb_register_dev(intf, &wdm_class); | 745 | rv = usb_register_dev(intf, &wdm_class); |
748 | if (rv < 0) | 746 | if (rv < 0) |
749 | goto err3; | 747 | goto err2; |
750 | else | 748 | else |
751 | dev_info(&intf->dev, "cdc-wdm%d: USB WDM device\n", | 749 | dev_info(&intf->dev, "%s: USB WDM device\n", dev_name(intf->usb_dev)); |
752 | intf->minor - WDM_MINOR_BASE); | ||
753 | out: | 750 | out: |
754 | return rv; | 751 | return rv; |
755 | err3: | ||
756 | usb_set_intfdata(intf, NULL); | ||
757 | usb_free_coherent(interface_to_usbdev(desc->intf), | ||
758 | desc->bMaxPacketSize0, | ||
759 | desc->inbuf, | ||
760 | desc->response->transfer_dma); | ||
761 | err2: | 752 | err2: |
762 | usb_free_coherent(interface_to_usbdev(desc->intf), | 753 | usb_set_intfdata(intf, NULL); |
763 | desc->wMaxPacketSize, | ||
764 | desc->sbuf, | ||
765 | desc->validity->transfer_dma); | ||
766 | err: | 754 | err: |
767 | free_urbs(desc); | 755 | free_urbs(desc); |
756 | kfree(desc->inbuf); | ||
757 | kfree(desc->sbuf); | ||
768 | kfree(desc->ubuf); | 758 | kfree(desc->ubuf); |
769 | kfree(desc->orq); | 759 | kfree(desc->orq); |
770 | kfree(desc->irq); | 760 | kfree(desc->irq); |
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index d40ff9568813..d77daf3683da 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -958,13 +958,8 @@ void usb_rebind_intf(struct usb_interface *intf) | |||
958 | int rc; | 958 | int rc; |
959 | 959 | ||
960 | /* Delayed unbind of an existing driver */ | 960 | /* Delayed unbind of an existing driver */ |
961 | if (intf->dev.driver) { | 961 | if (intf->dev.driver) |
962 | struct usb_driver *driver = | 962 | usb_forced_unbind_intf(intf); |
963 | to_usb_driver(intf->dev.driver); | ||
964 | |||
965 | dev_dbg(&intf->dev, "forced unbind\n"); | ||
966 | usb_driver_release_interface(driver, intf); | ||
967 | } | ||
968 | 963 | ||
969 | /* Try to rebind the interface */ | 964 | /* Try to rebind the interface */ |
970 | if (!intf->dev.power.is_prepared) { | 965 | if (!intf->dev.power.is_prepared) { |
@@ -977,15 +972,13 @@ void usb_rebind_intf(struct usb_interface *intf) | |||
977 | 972 | ||
978 | #ifdef CONFIG_PM | 973 | #ifdef CONFIG_PM |
979 | 974 | ||
980 | #define DO_UNBIND 0 | 975 | /* Unbind drivers for @udev's interfaces that don't support suspend/resume |
981 | #define DO_REBIND 1 | 976 | * There is no check for reset_resume here because it can be determined |
982 | 977 | * only during resume whether reset_resume is needed. | |
983 | /* Unbind drivers for @udev's interfaces that don't support suspend/resume, | ||
984 | * or rebind interfaces that have been unbound, according to @action. | ||
985 | * | 978 | * |
986 | * The caller must hold @udev's device lock. | 979 | * The caller must hold @udev's device lock. |
987 | */ | 980 | */ |
988 | static void do_unbind_rebind(struct usb_device *udev, int action) | 981 | static void unbind_no_pm_drivers_interfaces(struct usb_device *udev) |
989 | { | 982 | { |
990 | struct usb_host_config *config; | 983 | struct usb_host_config *config; |
991 | int i; | 984 | int i; |
@@ -996,23 +989,53 @@ static void do_unbind_rebind(struct usb_device *udev, int action) | |||
996 | if (config) { | 989 | if (config) { |
997 | for (i = 0; i < config->desc.bNumInterfaces; ++i) { | 990 | for (i = 0; i < config->desc.bNumInterfaces; ++i) { |
998 | intf = config->interface[i]; | 991 | intf = config->interface[i]; |
999 | switch (action) { | 992 | |
1000 | case DO_UNBIND: | 993 | if (intf->dev.driver) { |
1001 | if (intf->dev.driver) { | 994 | drv = to_usb_driver(intf->dev.driver); |
1002 | drv = to_usb_driver(intf->dev.driver); | 995 | if (!drv->suspend || !drv->resume) |
1003 | if (!drv->suspend || !drv->resume) | 996 | usb_forced_unbind_intf(intf); |
1004 | usb_forced_unbind_intf(intf); | ||
1005 | } | ||
1006 | break; | ||
1007 | case DO_REBIND: | ||
1008 | if (intf->needs_binding) | ||
1009 | usb_rebind_intf(intf); | ||
1010 | break; | ||
1011 | } | 997 | } |
1012 | } | 998 | } |
1013 | } | 999 | } |
1014 | } | 1000 | } |
1015 | 1001 | ||
1002 | /* Unbind drivers for @udev's interfaces that failed to support reset-resume. | ||
1003 | * These interfaces have the needs_binding flag set by usb_resume_interface(). | ||
1004 | * | ||
1005 | * The caller must hold @udev's device lock. | ||
1006 | */ | ||
1007 | static void unbind_no_reset_resume_drivers_interfaces(struct usb_device *udev) | ||
1008 | { | ||
1009 | struct usb_host_config *config; | ||
1010 | int i; | ||
1011 | struct usb_interface *intf; | ||
1012 | |||
1013 | config = udev->actconfig; | ||
1014 | if (config) { | ||
1015 | for (i = 0; i < config->desc.bNumInterfaces; ++i) { | ||
1016 | intf = config->interface[i]; | ||
1017 | if (intf->dev.driver && intf->needs_binding) | ||
1018 | usb_forced_unbind_intf(intf); | ||
1019 | } | ||
1020 | } | ||
1021 | } | ||
1022 | |||
1023 | static void do_rebind_interfaces(struct usb_device *udev) | ||
1024 | { | ||
1025 | struct usb_host_config *config; | ||
1026 | int i; | ||
1027 | struct usb_interface *intf; | ||
1028 | |||
1029 | config = udev->actconfig; | ||
1030 | if (config) { | ||
1031 | for (i = 0; i < config->desc.bNumInterfaces; ++i) { | ||
1032 | intf = config->interface[i]; | ||
1033 | if (intf->needs_binding) | ||
1034 | usb_rebind_intf(intf); | ||
1035 | } | ||
1036 | } | ||
1037 | } | ||
1038 | |||
1016 | static int usb_suspend_device(struct usb_device *udev, pm_message_t msg) | 1039 | static int usb_suspend_device(struct usb_device *udev, pm_message_t msg) |
1017 | { | 1040 | { |
1018 | struct usb_device_driver *udriver; | 1041 | struct usb_device_driver *udriver; |
@@ -1302,35 +1325,48 @@ int usb_suspend(struct device *dev, pm_message_t msg) | |||
1302 | { | 1325 | { |
1303 | struct usb_device *udev = to_usb_device(dev); | 1326 | struct usb_device *udev = to_usb_device(dev); |
1304 | 1327 | ||
1305 | do_unbind_rebind(udev, DO_UNBIND); | 1328 | unbind_no_pm_drivers_interfaces(udev); |
1329 | |||
1330 | /* From now on we are sure all drivers support suspend/resume | ||
1331 | * but not necessarily reset_resume() | ||
1332 | * so we may still need to unbind and rebind upon resume | ||
1333 | */ | ||
1306 | choose_wakeup(udev, msg); | 1334 | choose_wakeup(udev, msg); |
1307 | return usb_suspend_both(udev, msg); | 1335 | return usb_suspend_both(udev, msg); |
1308 | } | 1336 | } |
1309 | 1337 | ||
1310 | /* The device lock is held by the PM core */ | 1338 | /* The device lock is held by the PM core */ |
1339 | int usb_resume_complete(struct device *dev) | ||
1340 | { | ||
1341 | struct usb_device *udev = to_usb_device(dev); | ||
1342 | |||
1343 | /* For PM complete calls, all we do is rebind interfaces | ||
1344 | * whose needs_binding flag is set | ||
1345 | */ | ||
1346 | if (udev->state != USB_STATE_NOTATTACHED) | ||
1347 | do_rebind_interfaces(udev); | ||
1348 | return 0; | ||
1349 | } | ||
1350 | |||
1351 | /* The device lock is held by the PM core */ | ||
1311 | int usb_resume(struct device *dev, pm_message_t msg) | 1352 | int usb_resume(struct device *dev, pm_message_t msg) |
1312 | { | 1353 | { |
1313 | struct usb_device *udev = to_usb_device(dev); | 1354 | struct usb_device *udev = to_usb_device(dev); |
1314 | int status; | 1355 | int status; |
1315 | 1356 | ||
1316 | /* For PM complete calls, all we do is rebind interfaces */ | 1357 | /* For all calls, take the device back to full power and |
1317 | if (msg.event == PM_EVENT_ON) { | ||
1318 | if (udev->state != USB_STATE_NOTATTACHED) | ||
1319 | do_unbind_rebind(udev, DO_REBIND); | ||
1320 | status = 0; | ||
1321 | |||
1322 | /* For all other calls, take the device back to full power and | ||
1323 | * tell the PM core in case it was autosuspended previously. | 1358 | * tell the PM core in case it was autosuspended previously. |
1324 | * Unbind the interfaces that will need rebinding later. | 1359 | * Unbind the interfaces that will need rebinding later, |
1360 | * because they fail to support reset_resume. | ||
1361 | * (This can't be done in usb_resume_interface() | ||
1362 | * above because it doesn't own the right set of locks.) | ||
1325 | */ | 1363 | */ |
1326 | } else { | 1364 | status = usb_resume_both(udev, msg); |
1327 | status = usb_resume_both(udev, msg); | 1365 | if (status == 0) { |
1328 | if (status == 0) { | 1366 | pm_runtime_disable(dev); |
1329 | pm_runtime_disable(dev); | 1367 | pm_runtime_set_active(dev); |
1330 | pm_runtime_set_active(dev); | 1368 | pm_runtime_enable(dev); |
1331 | pm_runtime_enable(dev); | 1369 | unbind_no_reset_resume_drivers_interfaces(udev); |
1332 | do_unbind_rebind(udev, DO_REBIND); | ||
1333 | } | ||
1334 | } | 1370 | } |
1335 | 1371 | ||
1336 | /* Avoid PM error messages for devices disconnected while suspended | 1372 | /* Avoid PM error messages for devices disconnected while suspended |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index a0613d8f9be7..2d773cbe191c 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -1838,6 +1838,37 @@ fail: | |||
1838 | return err; | 1838 | return err; |
1839 | } | 1839 | } |
1840 | 1840 | ||
1841 | static void set_usb_port_removable(struct usb_device *udev) | ||
1842 | { | ||
1843 | struct usb_device *hdev = udev->parent; | ||
1844 | struct usb_hub *hub; | ||
1845 | u8 port = udev->portnum; | ||
1846 | u16 wHubCharacteristics; | ||
1847 | bool removable = true; | ||
1848 | |||
1849 | if (!hdev) | ||
1850 | return; | ||
1851 | |||
1852 | hub = hdev_to_hub(udev->parent); | ||
1853 | |||
1854 | wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); | ||
1855 | |||
1856 | if (!(wHubCharacteristics & HUB_CHAR_COMPOUND)) | ||
1857 | return; | ||
1858 | |||
1859 | if (hub_is_superspeed(hdev)) { | ||
1860 | if (hub->descriptor->u.ss.DeviceRemovable & (1 << port)) | ||
1861 | removable = false; | ||
1862 | } else { | ||
1863 | if (hub->descriptor->u.hs.DeviceRemovable[port / 8] & (1 << (port % 8))) | ||
1864 | removable = false; | ||
1865 | } | ||
1866 | |||
1867 | if (removable) | ||
1868 | udev->removable = USB_DEVICE_REMOVABLE; | ||
1869 | else | ||
1870 | udev->removable = USB_DEVICE_FIXED; | ||
1871 | } | ||
1841 | 1872 | ||
1842 | /** | 1873 | /** |
1843 | * usb_new_device - perform initial device setup (usbcore-internal) | 1874 | * usb_new_device - perform initial device setup (usbcore-internal) |
@@ -1896,6 +1927,15 @@ int usb_new_device(struct usb_device *udev) | |||
1896 | announce_device(udev); | 1927 | announce_device(udev); |
1897 | 1928 | ||
1898 | device_enable_async_suspend(&udev->dev); | 1929 | device_enable_async_suspend(&udev->dev); |
1930 | |||
1931 | /* | ||
1932 | * check whether the hub marks this port as non-removable. Do it | ||
1933 | * now so that platform-specific data can override it in | ||
1934 | * device_add() | ||
1935 | */ | ||
1936 | if (udev->parent) | ||
1937 | set_usb_port_removable(udev); | ||
1938 | |||
1899 | /* Register the device. The device driver is responsible | 1939 | /* Register the device. The device driver is responsible |
1900 | * for configuring the device and invoking the add-device | 1940 | * for configuring the device and invoking the add-device |
1901 | * notifier chain (used by usbfs and possibly others). | 1941 | * notifier chain (used by usbfs and possibly others). |
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 9e491ca2e5c4..566d9f94f735 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -230,6 +230,28 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf) | |||
230 | } | 230 | } |
231 | static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL); | 231 | static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL); |
232 | 232 | ||
233 | static ssize_t | ||
234 | show_removable(struct device *dev, struct device_attribute *attr, char *buf) | ||
235 | { | ||
236 | struct usb_device *udev; | ||
237 | char *state; | ||
238 | |||
239 | udev = to_usb_device(dev); | ||
240 | |||
241 | switch (udev->removable) { | ||
242 | case USB_DEVICE_REMOVABLE: | ||
243 | state = "removable"; | ||
244 | break; | ||
245 | case USB_DEVICE_FIXED: | ||
246 | state = "fixed"; | ||
247 | break; | ||
248 | default: | ||
249 | state = "unknown"; | ||
250 | } | ||
251 | |||
252 | return sprintf(buf, "%s\n", state); | ||
253 | } | ||
254 | static DEVICE_ATTR(removable, S_IRUGO, show_removable, NULL); | ||
233 | 255 | ||
234 | #ifdef CONFIG_PM | 256 | #ifdef CONFIG_PM |
235 | 257 | ||
@@ -626,6 +648,7 @@ static struct attribute *dev_attrs[] = { | |||
626 | &dev_attr_avoid_reset_quirk.attr, | 648 | &dev_attr_avoid_reset_quirk.attr, |
627 | &dev_attr_authorized.attr, | 649 | &dev_attr_authorized.attr, |
628 | &dev_attr_remove.attr, | 650 | &dev_attr_remove.attr, |
651 | &dev_attr_removable.attr, | ||
629 | NULL, | 652 | NULL, |
630 | }; | 653 | }; |
631 | static struct attribute_group dev_attr_grp = { | 654 | static struct attribute_group dev_attr_grp = { |
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index 909625b91eb3..f4f20c7b7765 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c | |||
@@ -403,20 +403,17 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
403 | * cause problems in HCDs if they get it wrong. | 403 | * cause problems in HCDs if they get it wrong. |
404 | */ | 404 | */ |
405 | { | 405 | { |
406 | unsigned int orig_flags = urb->transfer_flags; | ||
407 | unsigned int allowed; | 406 | unsigned int allowed; |
408 | static int pipetypes[4] = { | 407 | static int pipetypes[4] = { |
409 | PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT | 408 | PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT |
410 | }; | 409 | }; |
411 | 410 | ||
412 | /* Check that the pipe's type matches the endpoint's type */ | 411 | /* Check that the pipe's type matches the endpoint's type */ |
413 | if (usb_pipetype(urb->pipe) != pipetypes[xfertype]) { | 412 | if (usb_pipetype(urb->pipe) != pipetypes[xfertype]) |
414 | dev_err(&dev->dev, "BOGUS urb xfer, pipe %x != type %x\n", | 413 | dev_WARN(&dev->dev, "BOGUS urb xfer, pipe %x != type %x\n", |
415 | usb_pipetype(urb->pipe), pipetypes[xfertype]); | 414 | usb_pipetype(urb->pipe), pipetypes[xfertype]); |
416 | return -EPIPE; /* The most suitable error code :-) */ | ||
417 | } | ||
418 | 415 | ||
419 | /* enforce simple/standard policy */ | 416 | /* Check against a simple/standard policy */ |
420 | allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT | URB_DIR_MASK | | 417 | allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT | URB_DIR_MASK | |
421 | URB_FREE_BUFFER); | 418 | URB_FREE_BUFFER); |
422 | switch (xfertype) { | 419 | switch (xfertype) { |
@@ -435,14 +432,12 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
435 | allowed |= URB_ISO_ASAP; | 432 | allowed |= URB_ISO_ASAP; |
436 | break; | 433 | break; |
437 | } | 434 | } |
438 | urb->transfer_flags &= allowed; | 435 | allowed &= urb->transfer_flags; |
439 | 436 | ||
440 | /* fail if submitter gave bogus flags */ | 437 | /* warn if submitter gave bogus flags */ |
441 | if (urb->transfer_flags != orig_flags) { | 438 | if (allowed != urb->transfer_flags) |
442 | dev_err(&dev->dev, "BOGUS urb flags, %x --> %x\n", | 439 | dev_WARN(&dev->dev, "BOGUS urb flags, %x --> %x\n", |
443 | orig_flags, urb->transfer_flags); | 440 | urb->transfer_flags, allowed); |
444 | return -EINVAL; | ||
445 | } | ||
446 | } | 441 | } |
447 | #endif | 442 | #endif |
448 | /* | 443 | /* |
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 8ca9f994a280..c74ba7bbc748 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -274,7 +274,7 @@ static int usb_dev_prepare(struct device *dev) | |||
274 | static void usb_dev_complete(struct device *dev) | 274 | static void usb_dev_complete(struct device *dev) |
275 | { | 275 | { |
276 | /* Currently used only for rebinding interfaces */ | 276 | /* Currently used only for rebinding interfaces */ |
277 | usb_resume(dev, PMSG_ON); /* FIXME: change to PMSG_COMPLETE */ | 277 | usb_resume_complete(dev); |
278 | } | 278 | } |
279 | 279 | ||
280 | static int usb_dev_suspend(struct device *dev) | 280 | static int usb_dev_suspend(struct device *dev) |
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 45e8479c377d..71648dcbe438 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h | |||
@@ -56,6 +56,7 @@ extern void usb_major_cleanup(void); | |||
56 | 56 | ||
57 | extern int usb_suspend(struct device *dev, pm_message_t msg); | 57 | extern int usb_suspend(struct device *dev, pm_message_t msg); |
58 | extern int usb_resume(struct device *dev, pm_message_t msg); | 58 | extern int usb_resume(struct device *dev, pm_message_t msg); |
59 | extern int usb_resume_complete(struct device *dev); | ||
59 | 60 | ||
60 | extern int usb_port_suspend(struct usb_device *dev, pm_message_t msg); | 61 | extern int usb_port_suspend(struct usb_device *dev, pm_message_t msg); |
61 | extern int usb_port_resume(struct usb_device *dev, pm_message_t msg); | 62 | extern int usb_port_resume(struct usb_device *dev, pm_message_t msg); |
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index c26a82e83f6e..10e008a730a5 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c | |||
@@ -323,7 +323,9 @@ static int ehci_fsl_setup(struct usb_hcd *hcd) | |||
323 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 323 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
324 | int retval; | 324 | int retval; |
325 | struct fsl_usb2_platform_data *pdata; | 325 | struct fsl_usb2_platform_data *pdata; |
326 | struct device *dev; | ||
326 | 327 | ||
328 | dev = hcd->self.controller; | ||
327 | pdata = hcd->self.controller->platform_data; | 329 | pdata = hcd->self.controller->platform_data; |
328 | ehci->big_endian_desc = pdata->big_endian_desc; | 330 | ehci->big_endian_desc = pdata->big_endian_desc; |
329 | ehci->big_endian_mmio = pdata->big_endian_mmio; | 331 | ehci->big_endian_mmio = pdata->big_endian_mmio; |
@@ -353,6 +355,16 @@ static int ehci_fsl_setup(struct usb_hcd *hcd) | |||
353 | 355 | ||
354 | ehci_reset(ehci); | 356 | ehci_reset(ehci); |
355 | 357 | ||
358 | if (of_device_is_compatible(dev->parent->of_node, | ||
359 | "fsl,mpc5121-usb2-dr")) { | ||
360 | /* | ||
361 | * set SBUSCFG:AHBBRST so that control msgs don't | ||
362 | * fail when doing heavy PATA writes. | ||
363 | */ | ||
364 | ehci_writel(ehci, SBUSCFG_INCR8, | ||
365 | hcd->regs + FSL_SOC_USB_SBUSCFG); | ||
366 | } | ||
367 | |||
356 | retval = ehci_fsl_reinit(ehci); | 368 | retval = ehci_fsl_reinit(ehci); |
357 | return retval; | 369 | return retval; |
358 | } | 370 | } |
@@ -476,6 +488,8 @@ static int ehci_fsl_mpc512x_drv_resume(struct device *dev) | |||
476 | ehci_writel(ehci, ISIPHYCTRL_PXE | ISIPHYCTRL_PHYE, | 488 | ehci_writel(ehci, ISIPHYCTRL_PXE | ISIPHYCTRL_PHYE, |
477 | hcd->regs + FSL_SOC_USB_ISIPHYCTRL); | 489 | hcd->regs + FSL_SOC_USB_ISIPHYCTRL); |
478 | 490 | ||
491 | ehci_writel(ehci, SBUSCFG_INCR8, hcd->regs + FSL_SOC_USB_SBUSCFG); | ||
492 | |||
479 | /* restore EHCI registers */ | 493 | /* restore EHCI registers */ |
480 | ehci_writel(ehci, pdata->pm_command, &ehci->regs->command); | 494 | ehci_writel(ehci, pdata->pm_command, &ehci->regs->command); |
481 | ehci_writel(ehci, pdata->pm_intr_enable, &ehci->regs->intr_enable); | 495 | ehci_writel(ehci, pdata->pm_intr_enable, &ehci->regs->intr_enable); |
diff --git a/drivers/usb/host/ehci-fsl.h b/drivers/usb/host/ehci-fsl.h index bdf43e2adc51..6d5a94e9bb3c 100644 --- a/drivers/usb/host/ehci-fsl.h +++ b/drivers/usb/host/ehci-fsl.h | |||
@@ -19,6 +19,8 @@ | |||
19 | #define _EHCI_FSL_H | 19 | #define _EHCI_FSL_H |
20 | 20 | ||
21 | /* offsets for the non-ehci registers in the FSL SOC USB controller */ | 21 | /* offsets for the non-ehci registers in the FSL SOC USB controller */ |
22 | #define FSL_SOC_USB_SBUSCFG 0x90 | ||
23 | #define SBUSCFG_INCR8 0x02 /* INCR8, specified */ | ||
22 | #define FSL_SOC_USB_ULPIVP 0x170 | 24 | #define FSL_SOC_USB_ULPIVP 0x170 |
23 | #define FSL_SOC_USB_PORTSC1 0x184 | 25 | #define FSL_SOC_USB_PORTSC1 0x184 |
24 | #define PORT_PTS_MSK (3<<30) | 26 | #define PORT_PTS_MSK (3<<30) |
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index a007a9fe0f87..4918b0c59af9 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -1376,6 +1376,11 @@ MODULE_LICENSE ("GPL"); | |||
1376 | #define PLATFORM_DRIVER ehci_mv_driver | 1376 | #define PLATFORM_DRIVER ehci_mv_driver |
1377 | #endif | 1377 | #endif |
1378 | 1378 | ||
1379 | #ifdef CONFIG_MACH_LOONGSON1 | ||
1380 | #include "ehci-ls1x.c" | ||
1381 | #define PLATFORM_DRIVER ehci_ls1x_driver | ||
1382 | #endif | ||
1383 | |||
1379 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ | 1384 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ |
1380 | !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \ | 1385 | !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \ |
1381 | !defined(XILINX_OF_PLATFORM_DRIVER) | 1386 | !defined(XILINX_OF_PLATFORM_DRIVER) |
diff --git a/drivers/usb/host/ehci-ls1x.c b/drivers/usb/host/ehci-ls1x.c new file mode 100644 index 000000000000..a283e59709d6 --- /dev/null +++ b/drivers/usb/host/ehci-ls1x.c | |||
@@ -0,0 +1,159 @@ | |||
1 | /* | ||
2 | * Bus Glue for Loongson LS1X built-in EHCI controller. | ||
3 | * | ||
4 | * Copyright (c) 2012 Zhang, Keguang <keguang.zhang@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License version 2 as published | ||
8 | * by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | |||
12 | #include <linux/platform_device.h> | ||
13 | |||
14 | static int ehci_ls1x_reset(struct usb_hcd *hcd) | ||
15 | { | ||
16 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
17 | int ret; | ||
18 | |||
19 | ehci->caps = hcd->regs; | ||
20 | |||
21 | ret = ehci_setup(hcd); | ||
22 | if (ret) | ||
23 | return ret; | ||
24 | |||
25 | ehci_port_power(ehci, 0); | ||
26 | |||
27 | return 0; | ||
28 | } | ||
29 | |||
30 | static const struct hc_driver ehci_ls1x_hc_driver = { | ||
31 | .description = hcd_name, | ||
32 | .product_desc = "LOONGSON1 EHCI", | ||
33 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
34 | |||
35 | /* | ||
36 | * generic hardware linkage | ||
37 | */ | ||
38 | .irq = ehci_irq, | ||
39 | .flags = HCD_MEMORY | HCD_USB2, | ||
40 | |||
41 | /* | ||
42 | * basic lifecycle operations | ||
43 | */ | ||
44 | .reset = ehci_ls1x_reset, | ||
45 | .start = ehci_run, | ||
46 | .stop = ehci_stop, | ||
47 | .shutdown = ehci_shutdown, | ||
48 | |||
49 | /* | ||
50 | * managing i/o requests and associated device resources | ||
51 | */ | ||
52 | .urb_enqueue = ehci_urb_enqueue, | ||
53 | .urb_dequeue = ehci_urb_dequeue, | ||
54 | .endpoint_disable = ehci_endpoint_disable, | ||
55 | .endpoint_reset = ehci_endpoint_reset, | ||
56 | |||
57 | /* | ||
58 | * scheduling support | ||
59 | */ | ||
60 | .get_frame_number = ehci_get_frame, | ||
61 | |||
62 | /* | ||
63 | * root hub support | ||
64 | */ | ||
65 | .hub_status_data = ehci_hub_status_data, | ||
66 | .hub_control = ehci_hub_control, | ||
67 | .relinquish_port = ehci_relinquish_port, | ||
68 | .port_handed_over = ehci_port_handed_over, | ||
69 | |||
70 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
71 | }; | ||
72 | |||
73 | static int ehci_hcd_ls1x_probe(struct platform_device *pdev) | ||
74 | { | ||
75 | struct usb_hcd *hcd; | ||
76 | struct resource *res; | ||
77 | int irq; | ||
78 | int ret; | ||
79 | |||
80 | pr_debug("initializing loongson1 ehci USB Controller\n"); | ||
81 | |||
82 | if (usb_disabled()) | ||
83 | return -ENODEV; | ||
84 | |||
85 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
86 | if (!res) { | ||
87 | dev_err(&pdev->dev, | ||
88 | "Found HC with no IRQ. Check %s setup!\n", | ||
89 | dev_name(&pdev->dev)); | ||
90 | return -ENODEV; | ||
91 | } | ||
92 | irq = res->start; | ||
93 | |||
94 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
95 | if (!res) { | ||
96 | dev_err(&pdev->dev, | ||
97 | "Found HC with no register addr. Check %s setup!\n", | ||
98 | dev_name(&pdev->dev)); | ||
99 | return -ENODEV; | ||
100 | } | ||
101 | |||
102 | hcd = usb_create_hcd(&ehci_ls1x_hc_driver, &pdev->dev, | ||
103 | dev_name(&pdev->dev)); | ||
104 | if (!hcd) | ||
105 | return -ENOMEM; | ||
106 | hcd->rsrc_start = res->start; | ||
107 | hcd->rsrc_len = resource_size(res); | ||
108 | |||
109 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
110 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
111 | ret = -EBUSY; | ||
112 | goto err_put_hcd; | ||
113 | } | ||
114 | |||
115 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
116 | if (hcd->regs == NULL) { | ||
117 | dev_dbg(&pdev->dev, "error mapping memory\n"); | ||
118 | ret = -EFAULT; | ||
119 | goto err_release_region; | ||
120 | } | ||
121 | |||
122 | ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); | ||
123 | if (ret) | ||
124 | goto err_iounmap; | ||
125 | |||
126 | return ret; | ||
127 | |||
128 | err_iounmap: | ||
129 | iounmap(hcd->regs); | ||
130 | err_release_region: | ||
131 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
132 | err_put_hcd: | ||
133 | usb_put_hcd(hcd); | ||
134 | return ret; | ||
135 | } | ||
136 | |||
137 | static int ehci_hcd_ls1x_remove(struct platform_device *pdev) | ||
138 | { | ||
139 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
140 | |||
141 | usb_remove_hcd(hcd); | ||
142 | iounmap(hcd->regs); | ||
143 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
144 | usb_put_hcd(hcd); | ||
145 | |||
146 | return 0; | ||
147 | } | ||
148 | |||
149 | static struct platform_driver ehci_ls1x_driver = { | ||
150 | .probe = ehci_hcd_ls1x_probe, | ||
151 | .remove = ehci_hcd_ls1x_remove, | ||
152 | .shutdown = usb_hcd_platform_shutdown, | ||
153 | .driver = { | ||
154 | .name = "ls1x-ehci", | ||
155 | .owner = THIS_MODULE, | ||
156 | }, | ||
157 | }; | ||
158 | |||
159 | MODULE_ALIAS(PLATFORM_MODULE_PREFIX "ls1x-ehci"); | ||
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index 6b5eb1017e2c..e37dea87bb56 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c | |||
@@ -565,6 +565,9 @@ static int uhci_start(struct usb_hcd *hcd) | |||
565 | struct dentry __maybe_unused *dentry; | 565 | struct dentry __maybe_unused *dentry; |
566 | 566 | ||
567 | hcd->uses_new_polling = 1; | 567 | hcd->uses_new_polling = 1; |
568 | /* Accept arbitrarily long scatter-gather lists */ | ||
569 | if (!(hcd->driver->flags & HCD_LOCAL_MEM)) | ||
570 | hcd->self.sg_tablesize = ~0; | ||
568 | 571 | ||
569 | spin_lock_init(&uhci->lock); | 572 | spin_lock_init(&uhci->lock); |
570 | setup_timer(&uhci->fsbr_timer, uhci_fsbr_timeout, | 573 | setup_timer(&uhci->fsbr_timer, uhci_fsbr_timeout, |
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index 8dbf51a43c45..90721b49eed7 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c | |||
@@ -284,7 +284,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request, | |||
284 | 284 | ||
285 | if (result != size) { | 285 | if (result != size) { |
286 | dbg("%s - Unable to send config request, " | 286 | dbg("%s - Unable to send config request, " |
287 | "request=0x%x size=%d result=%d\n", | 287 | "request=0x%x size=%d result=%d", |
288 | __func__, request, size, result); | 288 | __func__, request, size, result); |
289 | if (result > 0) | 289 | if (result > 0) |
290 | result = -EPROTO; | 290 | result = -EPROTO; |
@@ -338,7 +338,7 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request, | |||
338 | 338 | ||
339 | if ((size > 2 && result != size) || result < 0) { | 339 | if ((size > 2 && result != size) || result < 0) { |
340 | dbg("%s - Unable to send request, " | 340 | dbg("%s - Unable to send request, " |
341 | "request=0x%x size=%d result=%d\n", | 341 | "request=0x%x size=%d result=%d", |
342 | __func__, request, size, result); | 342 | __func__, request, size, result); |
343 | if (result > 0) | 343 | if (result > 0) |
344 | result = -EPROTO; | 344 | result = -EPROTO; |
@@ -681,13 +681,13 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
681 | default: | 681 | default: |
682 | dbg("cp210x driver does not " | 682 | dbg("cp210x driver does not " |
683 | "support the number of bits requested," | 683 | "support the number of bits requested," |
684 | " using 8 bit mode\n"); | 684 | " using 8 bit mode"); |
685 | bits |= BITS_DATA_8; | 685 | bits |= BITS_DATA_8; |
686 | break; | 686 | break; |
687 | } | 687 | } |
688 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) | 688 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) |
689 | dbg("Number of data bits requested " | 689 | dbg("Number of data bits requested " |
690 | "not supported by device\n"); | 690 | "not supported by device"); |
691 | } | 691 | } |
692 | 692 | ||
693 | if ((cflag & (PARENB|PARODD|CMSPAR)) != | 693 | if ((cflag & (PARENB|PARODD|CMSPAR)) != |
@@ -714,8 +714,7 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
714 | } | 714 | } |
715 | } | 715 | } |
716 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) | 716 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) |
717 | dbg("Parity mode not supported " | 717 | dbg("Parity mode not supported by device"); |
718 | "by device\n"); | ||
719 | } | 718 | } |
720 | 719 | ||
721 | if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) { | 720 | if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) { |
@@ -730,7 +729,7 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
730 | } | 729 | } |
731 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) | 730 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) |
732 | dbg("Number of stop bits requested " | 731 | dbg("Number of stop bits requested " |
733 | "not supported by device\n"); | 732 | "not supported by device"); |
734 | } | 733 | } |
735 | 734 | ||
736 | if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { | 735 | if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { |
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index 3bdeafa29c24..5ae86b349cad 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c | |||
@@ -800,7 +800,7 @@ send: | |||
800 | cypress_write_int_callback, port, priv->write_urb_interval); | 800 | cypress_write_int_callback, port, priv->write_urb_interval); |
801 | result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC); | 801 | result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC); |
802 | if (result) { | 802 | if (result) { |
803 | dev_err(&port->dev, | 803 | dev_err_console(port, |
804 | "%s - failed submitting write urb, error %d\n", | 804 | "%s - failed submitting write urb, error %d\n", |
805 | __func__, result); | 805 | __func__, result); |
806 | priv->write_urb_in_use = 0; | 806 | priv->write_urb_in_use = 0; |
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index b23bebd721a1..2b1da0cc071a 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c | |||
@@ -995,7 +995,7 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
995 | /* return length of new data written, or error */ | 995 | /* return length of new data written, or error */ |
996 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); | 996 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
997 | if (ret < 0) | 997 | if (ret < 0) |
998 | dev_err(&port->dev, | 998 | dev_err_console(port, |
999 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", | 999 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", |
1000 | __func__, ret, priv->dp_port_num); | 1000 | __func__, ret, priv->dp_port_num); |
1001 | dbg("digi_write: returning %d", ret); | 1001 | dbg("digi_write: returning %d", ret); |
@@ -1065,7 +1065,7 @@ static void digi_write_bulk_callback(struct urb *urb) | |||
1065 | 1065 | ||
1066 | spin_unlock(&priv->dp_port_lock); | 1066 | spin_unlock(&priv->dp_port_lock); |
1067 | if (ret && ret != -EPERM) | 1067 | if (ret && ret != -EPERM) |
1068 | dev_err(&port->dev, | 1068 | dev_err_console(port, |
1069 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", | 1069 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", |
1070 | __func__, ret, priv->dp_port_num); | 1070 | __func__, ret, priv->dp_port_num); |
1071 | } | 1071 | } |
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index f7403576f99f..2a2fa2d0489d 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c | |||
@@ -217,7 +217,7 @@ retry: | |||
217 | clear_bit(i, &port->write_urbs_free); | 217 | clear_bit(i, &port->write_urbs_free); |
218 | result = usb_submit_urb(urb, GFP_ATOMIC); | 218 | result = usb_submit_urb(urb, GFP_ATOMIC); |
219 | if (result) { | 219 | if (result) { |
220 | dev_err(&port->dev, "%s - error submitting urb: %d\n", | 220 | dev_err_console(port, "%s - error submitting urb: %d\n", |
221 | __func__, result); | 221 | __func__, result); |
222 | set_bit(i, &port->write_urbs_free); | 222 | set_bit(i, &port->write_urbs_free); |
223 | spin_lock_irqsave(&port->lock, flags); | 223 | spin_lock_irqsave(&port->lock, flags); |
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 0497575e4799..616b07862771 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -1286,7 +1286,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, | |||
1286 | count = fifo->count; | 1286 | count = fifo->count; |
1287 | buffer = kmalloc(count+2, GFP_ATOMIC); | 1287 | buffer = kmalloc(count+2, GFP_ATOMIC); |
1288 | if (buffer == NULL) { | 1288 | if (buffer == NULL) { |
1289 | dev_err(&edge_port->port->dev, | 1289 | dev_err_console(edge_port->port, |
1290 | "%s - no more kernel memory...\n", __func__); | 1290 | "%s - no more kernel memory...\n", __func__); |
1291 | edge_port->write_in_progress = false; | 1291 | edge_port->write_in_progress = false; |
1292 | goto exit_send; | 1292 | goto exit_send; |
@@ -1331,7 +1331,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, | |||
1331 | status = usb_submit_urb(urb, GFP_ATOMIC); | 1331 | status = usb_submit_urb(urb, GFP_ATOMIC); |
1332 | if (status) { | 1332 | if (status) { |
1333 | /* something went wrong */ | 1333 | /* something went wrong */ |
1334 | dev_err(&edge_port->port->dev, | 1334 | dev_err_console(edge_port->port, |
1335 | "%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n", | 1335 | "%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n", |
1336 | __func__, status); | 1336 | __func__, status); |
1337 | edge_port->write_in_progress = false; | 1337 | edge_port->write_in_progress = false; |
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 5818bfc3261e..58a3697246a8 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c | |||
@@ -1817,7 +1817,7 @@ static void edge_bulk_out_callback(struct urb *urb) | |||
1817 | __func__, status); | 1817 | __func__, status); |
1818 | return; | 1818 | return; |
1819 | default: | 1819 | default: |
1820 | dev_err(&urb->dev->dev, "%s - nonzero write bulk status " | 1820 | dev_err_console(port, "%s - nonzero write bulk status " |
1821 | "received: %d\n", __func__, status); | 1821 | "received: %d\n", __func__, status); |
1822 | } | 1822 | } |
1823 | 1823 | ||
@@ -2111,7 +2111,7 @@ static void edge_send(struct tty_struct *tty) | |||
2111 | /* send the data out the bulk port */ | 2111 | /* send the data out the bulk port */ |
2112 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 2112 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
2113 | if (result) { | 2113 | if (result) { |
2114 | dev_err(&port->dev, | 2114 | dev_err_console(port, |
2115 | "%s - failed submitting write urb, error %d\n", | 2115 | "%s - failed submitting write urb, error %d\n", |
2116 | __func__, result); | 2116 | __func__, result); |
2117 | edge_port->ep_write_urb_in_use = 0; | 2117 | edge_port->ep_write_urb_in_use = 0; |
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index 4554ee49e635..4fb29b4aaad6 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c | |||
@@ -1294,7 +1294,7 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1294 | urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, | 1294 | urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, |
1295 | GFP_KERNEL); | 1295 | GFP_KERNEL); |
1296 | if (urb->transfer_buffer == NULL) { | 1296 | if (urb->transfer_buffer == NULL) { |
1297 | dev_err(&port->dev, "%s no more kernel memory...\n", | 1297 | dev_err_console(port, "%s no more kernel memory...\n", |
1298 | __func__); | 1298 | __func__); |
1299 | goto exit; | 1299 | goto exit; |
1300 | } | 1300 | } |
@@ -1315,7 +1315,7 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1315 | /* send it down the pipe */ | 1315 | /* send it down the pipe */ |
1316 | status = usb_submit_urb(urb, GFP_ATOMIC); | 1316 | status = usb_submit_urb(urb, GFP_ATOMIC); |
1317 | if (status) { | 1317 | if (status) { |
1318 | dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed " | 1318 | dev_err_console(port, "%s - usb_submit_urb(write bulk) failed " |
1319 | "with status = %d\n", __func__, status); | 1319 | "with status = %d\n", __func__, status); |
1320 | bytes_sent = status; | 1320 | bytes_sent = status; |
1321 | goto exit; | 1321 | goto exit; |
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 03b5e249e95e..19b11cece6ba 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
@@ -1509,7 +1509,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1509 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); | 1509 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); |
1510 | 1510 | ||
1511 | if (urb->transfer_buffer == NULL) { | 1511 | if (urb->transfer_buffer == NULL) { |
1512 | dev_err(&port->dev, "%s no more kernel memory...\n", | 1512 | dev_err_console(port, "%s no more kernel memory...\n", |
1513 | __func__); | 1513 | __func__); |
1514 | goto exit; | 1514 | goto exit; |
1515 | } | 1515 | } |
@@ -1535,7 +1535,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1535 | 1535 | ||
1536 | if (status) { | 1536 | if (status) { |
1537 | mos7840_port->busy[i] = 0; | 1537 | mos7840_port->busy[i] = 0; |
1538 | dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed " | 1538 | dev_err_console(port, "%s - usb_submit_urb(write bulk) failed " |
1539 | "with status = %d\n", __func__, status); | 1539 | "with status = %d\n", __func__, status); |
1540 | bytes_sent = status; | 1540 | bytes_sent = status; |
1541 | goto exit; | 1541 | goto exit; |
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index 8b8d58a2ac12..033e8afa6c77 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c | |||
@@ -254,7 +254,7 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
254 | result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); | 254 | result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); |
255 | if (result) { | 255 | if (result) { |
256 | set_bit(0, &wport->write_urbs_free); | 256 | set_bit(0, &wport->write_urbs_free); |
257 | dev_err(&port->dev, | 257 | dev_err_console(port, |
258 | "%s - failed submitting write urb, error %d\n", | 258 | "%s - failed submitting write urb, error %d\n", |
259 | __func__, result); | 259 | __func__, result); |
260 | } else | 260 | } else |
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c index e287fd32682c..343e626a06f8 100644 --- a/drivers/usb/serial/oti6858.c +++ b/drivers/usb/serial/oti6858.c | |||
@@ -302,7 +302,7 @@ static void send_data(struct work_struct *work) | |||
302 | if (count != 0) { | 302 | if (count != 0) { |
303 | allow = kmalloc(1, GFP_KERNEL); | 303 | allow = kmalloc(1, GFP_KERNEL); |
304 | if (!allow) { | 304 | if (!allow) { |
305 | dev_err(&port->dev, "%s(): kmalloc failed\n", | 305 | dev_err_console(port, "%s(): kmalloc failed\n", |
306 | __func__); | 306 | __func__); |
307 | return; | 307 | return; |
308 | } | 308 | } |
@@ -334,7 +334,7 @@ static void send_data(struct work_struct *work) | |||
334 | port->write_urb->transfer_buffer_length = count; | 334 | port->write_urb->transfer_buffer_length = count; |
335 | result = usb_submit_urb(port->write_urb, GFP_NOIO); | 335 | result = usb_submit_urb(port->write_urb, GFP_NOIO); |
336 | if (result != 0) { | 336 | if (result != 0) { |
337 | dev_err(&port->dev, "%s(): usb_submit_urb() failed" | 337 | dev_err_console(port, "%s(): usb_submit_urb() failed" |
338 | " with error %d\n", __func__, result); | 338 | " with error %d\n", __func__, result); |
339 | priv->flags.write_urb_in_use = 0; | 339 | priv->flags.write_urb_in_use = 0; |
340 | } | 340 | } |
@@ -938,7 +938,7 @@ static void oti6858_write_bulk_callback(struct urb *urb) | |||
938 | port->write_urb->transfer_buffer_length = 1; | 938 | port->write_urb->transfer_buffer_length = 1; |
939 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 939 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
940 | if (result) { | 940 | if (result) { |
941 | dev_err(&port->dev, "%s(): usb_submit_urb() failed," | 941 | dev_err_console(port, "%s(): usb_submit_urb() failed," |
942 | " error %d\n", __func__, result); | 942 | " error %d\n", __func__, result); |
943 | } else { | 943 | } else { |
944 | return; | 944 | return; |
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 8468eb769a29..91d0dc640360 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -1248,7 +1248,6 @@ static void ti_bulk_out_callback(struct urb *urb) | |||
1248 | { | 1248 | { |
1249 | struct ti_port *tport = urb->context; | 1249 | struct ti_port *tport = urb->context; |
1250 | struct usb_serial_port *port = tport->tp_port; | 1250 | struct usb_serial_port *port = tport->tp_port; |
1251 | struct device *dev = &urb->dev->dev; | ||
1252 | int status = urb->status; | 1251 | int status = urb->status; |
1253 | 1252 | ||
1254 | dbg("%s - port %d", __func__, port->number); | 1253 | dbg("%s - port %d", __func__, port->number); |
@@ -1266,7 +1265,7 @@ static void ti_bulk_out_callback(struct urb *urb) | |||
1266 | wake_up_interruptible(&tport->tp_write_wait); | 1265 | wake_up_interruptible(&tport->tp_write_wait); |
1267 | return; | 1266 | return; |
1268 | default: | 1267 | default: |
1269 | dev_err(dev, "%s - nonzero urb status, %d\n", | 1268 | dev_err_console(port, "%s - nonzero urb status, %d\n", |
1270 | __func__, status); | 1269 | __func__, status); |
1271 | tport->tp_tdev->td_urb_error = 1; | 1270 | tport->tp_tdev->td_urb_error = 1; |
1272 | wake_up_interruptible(&tport->tp_write_wait); | 1271 | wake_up_interruptible(&tport->tp_write_wait); |
@@ -1335,7 +1334,7 @@ static void ti_send(struct ti_port *tport) | |||
1335 | 1334 | ||
1336 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 1335 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
1337 | if (result) { | 1336 | if (result) { |
1338 | dev_err(&port->dev, "%s - submit write urb failed, %d\n", | 1337 | dev_err_console(port, "%s - submit write urb failed, %d\n", |
1339 | __func__, result); | 1338 | __func__, result); |
1340 | tport->tp_write_urb_in_use = 0; | 1339 | tport->tp_write_urb_in_use = 0; |
1341 | /* TODO: reschedule ti_send */ | 1340 | /* TODO: reschedule ti_send */ |
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index 7e0acf5c8e38..007cf3a2481a 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c | |||
@@ -740,7 +740,7 @@ static int whiteheat_write(struct tty_struct *tty, | |||
740 | urb->transfer_buffer_length = bytes; | 740 | urb->transfer_buffer_length = bytes; |
741 | result = usb_submit_urb(urb, GFP_ATOMIC); | 741 | result = usb_submit_urb(urb, GFP_ATOMIC); |
742 | if (result) { | 742 | if (result) { |
743 | dev_err(&port->dev, | 743 | dev_err_console(port, |
744 | "%s - failed submitting write urb, error %d\n", | 744 | "%s - failed submitting write urb, error %d\n", |
745 | __func__, result); | 745 | __func__, result); |
746 | sent = result; | 746 | sent = result; |
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 | ||
1281 | module_usb_driver(alauda_driver); | 1282 | module_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 | ||
277 | module_usb_driver(cypress_driver); | 278 | module_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 | ||
756 | module_usb_driver(datafab_driver); | 757 | module_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 | ||
2412 | module_usb_driver(ene_ub6250_driver); | 2413 | module_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 | ||
558 | module_usb_driver(freecom_driver); | 559 | module_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 | ||
1571 | module_usb_driver(isd200_driver); | 1572 | module_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 | ||
682 | module_usb_driver(jumpshot_driver); | 683 | module_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 | ||
235 | module_usb_driver(karma_driver); | 236 | module_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 | ||
317 | module_usb_driver(onetouch_driver); | 318 | module_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 | ||
1105 | module_usb_driver(realtek_cr_driver); | 1106 | module_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 | ||
79 | static int slave_alloc (struct scsi_device *sdev) | 79 | static 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 | ||
265 | static 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 */ |
288 | static int queuecommand_lck(struct scsi_cmnd *srb, | 294 | static 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 | ||
1792 | module_usb_driver(sddr09_driver); | 1793 | module_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 | ||
1011 | module_usb_driver(sddr55_driver); | 1012 | module_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 | ||
1868 | module_usb_driver(usbat_driver); | 1869 | module_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 */ | ||
26 | struct iu { | ||
27 | __u8 iu_id; | ||
28 | __u8 rsvd1; | ||
29 | __be16 tag; | ||
30 | }; | ||
31 | |||
32 | enum { | ||
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 | |||
41 | struct 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 | */ | ||
57 | struct 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 | ||
82 | enum { | ||
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 | |||
94 | struct uas_dev_info { | 41 | struct 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 | ||
103 | enum { | 52 | enum { |
@@ -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 */ |
126 | static int uas_submit_urbs(struct scsi_cmnd *cmnd, | 79 | static 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); |
81 | static void uas_do_work(struct work_struct *work); | ||
128 | 82 | ||
83 | static DECLARE_WORK(uas_work, uas_do_work); | ||
129 | static DEFINE_SPINLOCK(uas_work_lock); | 84 | static DEFINE_SPINLOCK(uas_work_lock); |
130 | static LIST_HEAD(uas_work_list); | 85 | static LIST_HEAD(uas_work_list); |
131 | 86 | ||
132 | static void uas_do_work(struct work_struct *work) | 87 | static 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 | ||
149 | static DECLARE_WORK(uas_work, uas_do_work); | ||
150 | |||
151 | static void uas_sense(struct urb *urb, struct scsi_cmnd *cmnd) | 113 | static 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 | ||
178 | static void uas_sense_old(struct urb *urb, struct scsi_cmnd *cmnd) | 139 | static 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 | ||
205 | static void uas_xfer_data(struct urb *urb, struct scsi_cmnd *cmnd, | 165 | static 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, | |||
221 | static void uas_stat_cmplt(struct urb *urb) | 181 | static 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 | ||
264 | static void uas_data_cmplt(struct urb *urb) | 267 | static 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 | |||
282 | static 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 | ||
271 | static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp, | 297 | static 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 | ||
291 | static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp, | 326 | static 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 | ||
631 | static 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 | |||
592 | static int uas_switch_interface(struct usb_device *udev, | 643 | static 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 | ||
725 | static 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; | ||
742 | err_submit_urb: | ||
743 | usb_free_urb(devinfo->status_urb); | ||
744 | err_s_urb: | ||
745 | return -ENOMEM; | ||
746 | } | ||
747 | |||
748 | static 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 | |||
810 | err_alloc_status: | ||
811 | scsi_remove_host(shost); | ||
812 | shost = NULL; | ||
813 | deconfig_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 | ||
733 | static void uas_disconnect(struct usb_interface *intf) | 834 | static 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 3dd7da9fd504..58f56775ecde 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 | ||
128 | static 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 |
@@ -1027,8 +1030,10 @@ EXPORT_SYMBOL_GPL(usb_stor_disconnect); | |||
1027 | static int storage_probe(struct usb_interface *intf, | 1030 | static int storage_probe(struct usb_interface *intf, |
1028 | const struct usb_device_id *id) | 1031 | const struct usb_device_id *id) |
1029 | { | 1032 | { |
1033 | struct us_unusual_dev *unusual_dev; | ||
1030 | struct us_data *us; | 1034 | struct us_data *us; |
1031 | int result; | 1035 | int result; |
1036 | int size; | ||
1032 | 1037 | ||
1033 | /* | 1038 | /* |
1034 | * If libusual is configured, let it decide whether a standard | 1039 | * If libusual is configured, let it decide whether a standard |
@@ -1047,8 +1052,19 @@ static int storage_probe(struct usb_interface *intf, | |||
1047 | * table, so we use the index of the id entry to find the | 1052 | * table, so we use the index of the id entry to find the |
1048 | * corresponding unusual_devs entry. | 1053 | * corresponding unusual_devs entry. |
1049 | */ | 1054 | */ |
1050 | result = usb_stor_probe1(&us, intf, id, | 1055 | |
1051 | (id - usb_storage_usb_ids) + us_unusual_dev_list); | 1056 | size = ARRAY_SIZE(us_unusual_dev_list); |
1057 | if (id >= usb_storage_usb_ids && id < usb_storage_usb_ids + size) { | ||
1058 | unusual_dev = (id - usb_storage_usb_ids) + us_unusual_dev_list; | ||
1059 | } else { | ||
1060 | unusual_dev = &for_dynamic_ids; | ||
1061 | |||
1062 | US_DEBUGP("%s %s 0x%04x 0x%04x\n", "Use Bulk-Only transport", | ||
1063 | "with the Transparent SCSI protocol for dynamic id:", | ||
1064 | id->idVendor, id->idProduct); | ||
1065 | } | ||
1066 | |||
1067 | result = usb_stor_probe1(&us, intf, id, unusual_dev); | ||
1052 | if (result) | 1068 | if (result) |
1053 | return result; | 1069 | return result; |
1054 | 1070 | ||
@@ -1074,7 +1090,6 @@ static struct usb_driver usb_storage_driver = { | |||
1074 | .id_table = usb_storage_usb_ids, | 1090 | .id_table = usb_storage_usb_ids, |
1075 | .supports_autosuspend = 1, | 1091 | .supports_autosuspend = 1, |
1076 | .soft_unbind = 1, | 1092 | .soft_unbind = 1, |
1077 | .no_dynamic_id = 1, | ||
1078 | }; | 1093 | }; |
1079 | 1094 | ||
1080 | static int __init usb_stor_init(void) | 1095 | static int __init usb_stor_init(void) |
diff --git a/include/linux/usb.h b/include/linux/usb.h index 69d845739bc2..0c51663f2733 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
@@ -376,6 +376,12 @@ struct usb_bus { | |||
376 | 376 | ||
377 | struct usb_tt; | 377 | struct usb_tt; |
378 | 378 | ||
379 | enum usb_device_removable { | ||
380 | USB_DEVICE_REMOVABLE_UNKNOWN = 0, | ||
381 | USB_DEVICE_REMOVABLE, | ||
382 | USB_DEVICE_FIXED, | ||
383 | }; | ||
384 | |||
379 | /** | 385 | /** |
380 | * struct usb_device - kernel's representation of a USB device | 386 | * struct usb_device - kernel's representation of a USB device |
381 | * @devnum: device number; address on a USB bus | 387 | * @devnum: device number; address on a USB bus |
@@ -432,6 +438,7 @@ struct usb_tt; | |||
432 | * @wusb_dev: if this is a Wireless USB device, link to the WUSB | 438 | * @wusb_dev: if this is a Wireless USB device, link to the WUSB |
433 | * specific data for the device. | 439 | * specific data for the device. |
434 | * @slot_id: Slot ID assigned by xHCI | 440 | * @slot_id: Slot ID assigned by xHCI |
441 | * @removable: Device can be physically removed from this port | ||
435 | * | 442 | * |
436 | * Notes: | 443 | * Notes: |
437 | * Usbcore drivers should not set usbdev->state directly. Instead use | 444 | * Usbcore drivers should not set usbdev->state directly. Instead use |
@@ -509,6 +516,7 @@ struct usb_device { | |||
509 | #endif | 516 | #endif |
510 | struct wusb_dev *wusb_dev; | 517 | struct wusb_dev *wusb_dev; |
511 | int slot_id; | 518 | int slot_id; |
519 | enum usb_device_removable removable; | ||
512 | }; | 520 | }; |
513 | #define to_usb_device(d) container_of(d, struct usb_device, dev) | 521 | #define to_usb_device(d) container_of(d, struct usb_device, dev) |
514 | 522 | ||
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index 4267a9c717ba..10cb74d2ad1d 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h | |||
@@ -389,5 +389,20 @@ do { \ | |||
389 | printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \ | 389 | printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \ |
390 | } while (0) | 390 | } while (0) |
391 | 391 | ||
392 | /* | ||
393 | * Macro for reporting errors in write path to avoid inifinite loop | ||
394 | * when port is used as a console. | ||
395 | */ | ||
396 | #define dev_err_console(usport, fmt, ...) \ | ||
397 | do { \ | ||
398 | static bool __print_once; \ | ||
399 | struct usb_serial_port *__port = (usport); \ | ||
400 | \ | ||
401 | if (!__port->port.console || !__print_once) { \ | ||
402 | __print_once = true; \ | ||
403 | dev_err(&__port->dev, fmt, ##__VA_ARGS__); \ | ||
404 | } \ | ||
405 | } while (0) | ||
406 | |||
392 | #endif /* __LINUX_USB_SERIAL_H */ | 407 | #endif /* __LINUX_USB_SERIAL_H */ |
393 | 408 | ||
diff --git a/include/linux/usb/uas.h b/include/linux/usb/uas.h new file mode 100644 index 000000000000..9a988e413694 --- /dev/null +++ b/include/linux/usb/uas.h | |||
@@ -0,0 +1,69 @@ | |||
1 | #ifndef __USB_UAS_H__ | ||
2 | #define __USB_UAS_H__ | ||
3 | |||
4 | #include <scsi/scsi.h> | ||
5 | #include <scsi/scsi_cmnd.h> | ||
6 | |||
7 | /* Common header for all IUs */ | ||
8 | struct iu { | ||
9 | __u8 iu_id; | ||
10 | __u8 rsvd1; | ||
11 | __be16 tag; | ||
12 | }; | ||
13 | |||
14 | enum { | ||
15 | IU_ID_COMMAND = 0x01, | ||
16 | IU_ID_STATUS = 0x03, | ||
17 | IU_ID_RESPONSE = 0x04, | ||
18 | IU_ID_TASK_MGMT = 0x05, | ||
19 | IU_ID_READ_READY = 0x06, | ||
20 | IU_ID_WRITE_READY = 0x07, | ||
21 | }; | ||
22 | |||
23 | struct command_iu { | ||
24 | __u8 iu_id; | ||
25 | __u8 rsvd1; | ||
26 | __be16 tag; | ||
27 | __u8 prio_attr; | ||
28 | __u8 rsvd5; | ||
29 | __u8 len; | ||
30 | __u8 rsvd7; | ||
31 | struct scsi_lun lun; | ||
32 | __u8 cdb[16]; /* XXX: Overflow-checking tools may misunderstand */ | ||
33 | }; | ||
34 | |||
35 | /* | ||
36 | * Also used for the Read Ready and Write Ready IUs since they have the | ||
37 | * same first four bytes | ||
38 | */ | ||
39 | struct sense_iu { | ||
40 | __u8 iu_id; | ||
41 | __u8 rsvd1; | ||
42 | __be16 tag; | ||
43 | __be16 status_qual; | ||
44 | __u8 status; | ||
45 | __u8 rsvd7[7]; | ||
46 | __be16 len; | ||
47 | __u8 sense[SCSI_SENSE_BUFFERSIZE]; | ||
48 | }; | ||
49 | |||
50 | struct usb_pipe_usage_descriptor { | ||
51 | __u8 bLength; | ||
52 | __u8 bDescriptorType; | ||
53 | |||
54 | __u8 bPipeID; | ||
55 | __u8 Reserved; | ||
56 | } __attribute__((__packed__)); | ||
57 | |||
58 | enum { | ||
59 | CMD_PIPE_ID = 1, | ||
60 | STATUS_PIPE_ID = 2, | ||
61 | DATA_IN_PIPE_ID = 3, | ||
62 | DATA_OUT_PIPE_ID = 4, | ||
63 | |||
64 | UAS_SIMPLE_TAG = 0, | ||
65 | UAS_HEAD_TAG = 1, | ||
66 | UAS_ORDERED_TAG = 2, | ||
67 | UAS_ACA = 4, | ||
68 | }; | ||
69 | #endif | ||
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 77273f2fdd80..b3a1c2daf6cc 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h | |||
@@ -136,6 +136,7 @@ struct scsi_device { | |||
136 | unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */ | 136 | unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */ |
137 | unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */ | 137 | unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */ |
138 | unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */ | 138 | unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */ |
139 | unsigned skip_vpd_pages:1; /* do not read VPD pages */ | ||
139 | unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */ | 140 | unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */ |
140 | unsigned no_start_on_add:1; /* do not issue start on add */ | 141 | unsigned no_start_on_add:1; /* do not issue start on add */ |
141 | unsigned allow_restart:1; /* issue START_UNIT in error handler */ | 142 | unsigned allow_restart:1; /* issue START_UNIT in error handler */ |
@@ -246,8 +247,10 @@ struct scsi_target { | |||
246 | unsigned int single_lun:1; /* Indicates we should only | 247 | unsigned int single_lun:1; /* Indicates we should only |
247 | * allow I/O to one of the luns | 248 | * allow I/O to one of the luns |
248 | * for the device at a time. */ | 249 | * for the device at a time. */ |
249 | unsigned int pdt_1f_for_no_lun; /* PDT = 0x1f */ | 250 | unsigned int pdt_1f_for_no_lun:1; /* PDT = 0x1f |
250 | /* means no lun present */ | 251 | * means no lun present. */ |
252 | unsigned int no_report_luns:1; /* Don't use | ||
253 | * REPORT LUNS for scanning. */ | ||
251 | /* commands actually active on LLD. protected by host lock. */ | 254 | /* commands actually active on LLD. protected by host lock. */ |
252 | unsigned int target_busy; | 255 | unsigned int target_busy; |
253 | /* | 256 | /* |