diff options
56 files changed, 1050 insertions, 351 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..b27bbb957e16 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 | ||
@@ -54,6 +70,7 @@ MODULE_DEVICE_TABLE (usb, wdm_ids); | |||
54 | #define WDM_POLL_RUNNING 6 | 70 | #define WDM_POLL_RUNNING 6 |
55 | #define WDM_RESPONDING 7 | 71 | #define WDM_RESPONDING 7 |
56 | #define WDM_SUSPENDING 8 | 72 | #define WDM_SUSPENDING 8 |
73 | #define WDM_RESETTING 9 | ||
57 | 74 | ||
58 | #define WDM_MAX 16 | 75 | #define WDM_MAX 16 |
59 | 76 | ||
@@ -82,7 +99,6 @@ struct wdm_device { | |||
82 | u16 bufsize; | 99 | u16 bufsize; |
83 | u16 wMaxCommand; | 100 | u16 wMaxCommand; |
84 | u16 wMaxPacketSize; | 101 | u16 wMaxPacketSize; |
85 | u16 bMaxPacketSize0; | ||
86 | __le16 inum; | 102 | __le16 inum; |
87 | int reslength; | 103 | int reslength; |
88 | int length; | 104 | int length; |
@@ -162,11 +178,9 @@ static void wdm_int_callback(struct urb *urb) | |||
162 | int rv = 0; | 178 | int rv = 0; |
163 | int status = urb->status; | 179 | int status = urb->status; |
164 | struct wdm_device *desc; | 180 | struct wdm_device *desc; |
165 | struct usb_ctrlrequest *req; | ||
166 | struct usb_cdc_notification *dr; | 181 | struct usb_cdc_notification *dr; |
167 | 182 | ||
168 | desc = urb->context; | 183 | desc = urb->context; |
169 | req = desc->irq; | ||
170 | dr = (struct usb_cdc_notification *)desc->sbuf; | 184 | dr = (struct usb_cdc_notification *)desc->sbuf; |
171 | 185 | ||
172 | if (status) { | 186 | if (status) { |
@@ -213,24 +227,6 @@ static void wdm_int_callback(struct urb *urb) | |||
213 | goto exit; | 227 | goto exit; |
214 | } | 228 | } |
215 | 229 | ||
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); | 230 | spin_lock(&desc->iuspin); |
235 | clear_bit(WDM_READ, &desc->flags); | 231 | clear_bit(WDM_READ, &desc->flags); |
236 | set_bit(WDM_RESPONDING, &desc->flags); | 232 | set_bit(WDM_RESPONDING, &desc->flags); |
@@ -279,14 +275,8 @@ static void free_urbs(struct wdm_device *desc) | |||
279 | 275 | ||
280 | static void cleanup(struct wdm_device *desc) | 276 | static void cleanup(struct wdm_device *desc) |
281 | { | 277 | { |
282 | usb_free_coherent(interface_to_usbdev(desc->intf), | 278 | kfree(desc->sbuf); |
283 | desc->wMaxPacketSize, | 279 | 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); | 280 | kfree(desc->orq); |
291 | kfree(desc->irq); | 281 | kfree(desc->irq); |
292 | kfree(desc->ubuf); | 282 | kfree(desc->ubuf); |
@@ -351,6 +341,10 @@ static ssize_t wdm_write | |||
351 | else | 341 | else |
352 | if (test_bit(WDM_IN_USE, &desc->flags)) | 342 | if (test_bit(WDM_IN_USE, &desc->flags)) |
353 | r = -EAGAIN; | 343 | r = -EAGAIN; |
344 | |||
345 | if (test_bit(WDM_RESETTING, &desc->flags)) | ||
346 | r = -EIO; | ||
347 | |||
354 | if (r < 0) { | 348 | if (r < 0) { |
355 | kfree(buf); | 349 | kfree(buf); |
356 | goto out; | 350 | goto out; |
@@ -430,6 +424,10 @@ retry: | |||
430 | rv = -ENODEV; | 424 | rv = -ENODEV; |
431 | goto err; | 425 | goto err; |
432 | } | 426 | } |
427 | if (test_bit(WDM_RESETTING, &desc->flags)) { | ||
428 | rv = -EIO; | ||
429 | goto err; | ||
430 | } | ||
433 | usb_mark_last_busy(interface_to_usbdev(desc->intf)); | 431 | usb_mark_last_busy(interface_to_usbdev(desc->intf)); |
434 | if (rv < 0) { | 432 | if (rv < 0) { |
435 | rv = -ERESTARTSYS; | 433 | rv = -ERESTARTSYS; |
@@ -631,7 +629,6 @@ static void wdm_rxwork(struct work_struct *work) | |||
631 | static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id) | 629 | static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id) |
632 | { | 630 | { |
633 | int rv = -EINVAL; | 631 | int rv = -EINVAL; |
634 | struct usb_device *udev = interface_to_usbdev(intf); | ||
635 | struct wdm_device *desc; | 632 | struct wdm_device *desc; |
636 | struct usb_host_interface *iface; | 633 | struct usb_host_interface *iface; |
637 | struct usb_endpoint_descriptor *ep; | 634 | struct usb_endpoint_descriptor *ep; |
@@ -692,7 +689,6 @@ next_desc: | |||
692 | goto err; | 689 | goto err; |
693 | 690 | ||
694 | desc->wMaxPacketSize = usb_endpoint_maxp(ep); | 691 | desc->wMaxPacketSize = usb_endpoint_maxp(ep); |
695 | desc->bMaxPacketSize0 = udev->descriptor.bMaxPacketSize0; | ||
696 | 692 | ||
697 | desc->orq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); | 693 | desc->orq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); |
698 | if (!desc->orq) | 694 | if (!desc->orq) |
@@ -717,19 +713,13 @@ next_desc: | |||
717 | if (!desc->ubuf) | 713 | if (!desc->ubuf) |
718 | goto err; | 714 | goto err; |
719 | 715 | ||
720 | desc->sbuf = usb_alloc_coherent(interface_to_usbdev(intf), | 716 | desc->sbuf = kmalloc(desc->wMaxPacketSize, GFP_KERNEL); |
721 | desc->wMaxPacketSize, | ||
722 | GFP_KERNEL, | ||
723 | &desc->validity->transfer_dma); | ||
724 | if (!desc->sbuf) | 717 | if (!desc->sbuf) |
725 | goto err; | 718 | goto err; |
726 | 719 | ||
727 | desc->inbuf = usb_alloc_coherent(interface_to_usbdev(intf), | 720 | desc->inbuf = kmalloc(desc->wMaxCommand, GFP_KERNEL); |
728 | desc->wMaxCommand, | ||
729 | GFP_KERNEL, | ||
730 | &desc->response->transfer_dma); | ||
731 | if (!desc->inbuf) | 721 | if (!desc->inbuf) |
732 | goto err2; | 722 | goto err; |
733 | 723 | ||
734 | usb_fill_int_urb( | 724 | usb_fill_int_urb( |
735 | desc->validity, | 725 | desc->validity, |
@@ -741,30 +731,39 @@ next_desc: | |||
741 | desc, | 731 | desc, |
742 | ep->bInterval | 732 | ep->bInterval |
743 | ); | 733 | ); |
744 | desc->validity->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 734 | |
735 | desc->irq->bRequestType = (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE); | ||
736 | desc->irq->bRequest = USB_CDC_GET_ENCAPSULATED_RESPONSE; | ||
737 | desc->irq->wValue = 0; | ||
738 | desc->irq->wIndex = desc->inum; | ||
739 | desc->irq->wLength = cpu_to_le16(desc->wMaxCommand); | ||
740 | |||
741 | usb_fill_control_urb( | ||
742 | desc->response, | ||
743 | interface_to_usbdev(intf), | ||
744 | /* using common endpoint 0 */ | ||
745 | usb_rcvctrlpipe(interface_to_usbdev(desc->intf), 0), | ||
746 | (unsigned char *)desc->irq, | ||
747 | desc->inbuf, | ||
748 | desc->wMaxCommand, | ||
749 | wdm_in_callback, | ||
750 | desc | ||
751 | ); | ||
745 | 752 | ||
746 | usb_set_intfdata(intf, desc); | 753 | usb_set_intfdata(intf, desc); |
747 | rv = usb_register_dev(intf, &wdm_class); | 754 | rv = usb_register_dev(intf, &wdm_class); |
748 | if (rv < 0) | 755 | if (rv < 0) |
749 | goto err3; | 756 | goto err2; |
750 | else | 757 | else |
751 | dev_info(&intf->dev, "cdc-wdm%d: USB WDM device\n", | 758 | dev_info(&intf->dev, "%s: USB WDM device\n", dev_name(intf->usb_dev)); |
752 | intf->minor - WDM_MINOR_BASE); | ||
753 | out: | 759 | out: |
754 | return rv; | 760 | 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: | 761 | err2: |
762 | usb_free_coherent(interface_to_usbdev(desc->intf), | 762 | usb_set_intfdata(intf, NULL); |
763 | desc->wMaxPacketSize, | ||
764 | desc->sbuf, | ||
765 | desc->validity->transfer_dma); | ||
766 | err: | 763 | err: |
767 | free_urbs(desc); | 764 | free_urbs(desc); |
765 | kfree(desc->inbuf); | ||
766 | kfree(desc->sbuf); | ||
768 | kfree(desc->ubuf); | 767 | kfree(desc->ubuf); |
769 | kfree(desc->orq); | 768 | kfree(desc->orq); |
770 | kfree(desc->irq); | 769 | kfree(desc->irq); |
@@ -869,10 +868,6 @@ static int wdm_pre_reset(struct usb_interface *intf) | |||
869 | { | 868 | { |
870 | struct wdm_device *desc = usb_get_intfdata(intf); | 869 | struct wdm_device *desc = usb_get_intfdata(intf); |
871 | 870 | ||
872 | mutex_lock(&desc->rlock); | ||
873 | mutex_lock(&desc->wlock); | ||
874 | kill_urbs(desc); | ||
875 | |||
876 | /* | 871 | /* |
877 | * we notify everybody using poll of | 872 | * we notify everybody using poll of |
878 | * an exceptional situation | 873 | * an exceptional situation |
@@ -880,9 +875,16 @@ static int wdm_pre_reset(struct usb_interface *intf) | |||
880 | * message from the device is lost | 875 | * message from the device is lost |
881 | */ | 876 | */ |
882 | spin_lock_irq(&desc->iuspin); | 877 | spin_lock_irq(&desc->iuspin); |
878 | set_bit(WDM_RESETTING, &desc->flags); /* inform read/write */ | ||
879 | set_bit(WDM_READ, &desc->flags); /* unblock read */ | ||
880 | clear_bit(WDM_IN_USE, &desc->flags); /* unblock write */ | ||
883 | desc->rerr = -EINTR; | 881 | desc->rerr = -EINTR; |
884 | spin_unlock_irq(&desc->iuspin); | 882 | spin_unlock_irq(&desc->iuspin); |
885 | wake_up_all(&desc->wait); | 883 | wake_up_all(&desc->wait); |
884 | mutex_lock(&desc->rlock); | ||
885 | mutex_lock(&desc->wlock); | ||
886 | kill_urbs(desc); | ||
887 | cancel_work_sync(&desc->rxwork); | ||
886 | return 0; | 888 | return 0; |
887 | } | 889 | } |
888 | 890 | ||
@@ -891,6 +893,7 @@ static int wdm_post_reset(struct usb_interface *intf) | |||
891 | struct wdm_device *desc = usb_get_intfdata(intf); | 893 | struct wdm_device *desc = usb_get_intfdata(intf); |
892 | int rv; | 894 | int rv; |
893 | 895 | ||
896 | clear_bit(WDM_RESETTING, &desc->flags); | ||
894 | rv = recover_from_urb_loss(desc); | 897 | rv = recover_from_urb_loss(desc); |
895 | mutex_unlock(&desc->wlock); | 898 | mutex_unlock(&desc->wlock); |
896 | mutex_unlock(&desc->rlock); | 899 | mutex_unlock(&desc->rlock); |
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 265c2f675d04..72c51cdce906 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -62,6 +62,8 @@ struct usb_hub { | |||
62 | resumed */ | 62 | resumed */ |
63 | unsigned long removed_bits[1]; /* ports with a "removed" | 63 | unsigned long removed_bits[1]; /* ports with a "removed" |
64 | device present */ | 64 | device present */ |
65 | unsigned long wakeup_bits[1]; /* ports that have signaled | ||
66 | remote wakeup */ | ||
65 | #if USB_MAXCHILDREN > 31 /* 8*sizeof(unsigned long) - 1 */ | 67 | #if USB_MAXCHILDREN > 31 /* 8*sizeof(unsigned long) - 1 */ |
66 | #error event_bits[] is too short! | 68 | #error event_bits[] is too short! |
67 | #endif | 69 | #endif |
@@ -411,6 +413,29 @@ void usb_kick_khubd(struct usb_device *hdev) | |||
411 | kick_khubd(hub); | 413 | kick_khubd(hub); |
412 | } | 414 | } |
413 | 415 | ||
416 | /* | ||
417 | * Let the USB core know that a USB 3.0 device has sent a Function Wake Device | ||
418 | * Notification, which indicates it had initiated remote wakeup. | ||
419 | * | ||
420 | * USB 3.0 hubs do not report the port link state change from U3 to U0 when the | ||
421 | * device initiates resume, so the USB core will not receive notice of the | ||
422 | * resume through the normal hub interrupt URB. | ||
423 | */ | ||
424 | void usb_wakeup_notification(struct usb_device *hdev, | ||
425 | unsigned int portnum) | ||
426 | { | ||
427 | struct usb_hub *hub; | ||
428 | |||
429 | if (!hdev) | ||
430 | return; | ||
431 | |||
432 | hub = hdev_to_hub(hdev); | ||
433 | if (hub) { | ||
434 | set_bit(portnum, hub->wakeup_bits); | ||
435 | kick_khubd(hub); | ||
436 | } | ||
437 | } | ||
438 | EXPORT_SYMBOL_GPL(usb_wakeup_notification); | ||
414 | 439 | ||
415 | /* completion function, fires on port status changes and various faults */ | 440 | /* completion function, fires on port status changes and various faults */ |
416 | static void hub_irq(struct urb *urb) | 441 | static void hub_irq(struct urb *urb) |
@@ -823,12 +848,6 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) | |||
823 | clear_port_feature(hub->hdev, port1, | 848 | clear_port_feature(hub->hdev, port1, |
824 | USB_PORT_FEAT_C_ENABLE); | 849 | USB_PORT_FEAT_C_ENABLE); |
825 | } | 850 | } |
826 | if (portchange & USB_PORT_STAT_C_LINK_STATE) { | ||
827 | need_debounce_delay = true; | ||
828 | clear_port_feature(hub->hdev, port1, | ||
829 | USB_PORT_FEAT_C_PORT_LINK_STATE); | ||
830 | } | ||
831 | |||
832 | if ((portchange & USB_PORT_STAT_C_BH_RESET) && | 851 | if ((portchange & USB_PORT_STAT_C_BH_RESET) && |
833 | hub_is_superspeed(hub->hdev)) { | 852 | hub_is_superspeed(hub->hdev)) { |
834 | need_debounce_delay = true; | 853 | need_debounce_delay = true; |
@@ -850,12 +869,19 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) | |||
850 | set_bit(port1, hub->change_bits); | 869 | set_bit(port1, hub->change_bits); |
851 | 870 | ||
852 | } else if (portstatus & USB_PORT_STAT_ENABLE) { | 871 | } else if (portstatus & USB_PORT_STAT_ENABLE) { |
872 | bool port_resumed = (portstatus & | ||
873 | USB_PORT_STAT_LINK_STATE) == | ||
874 | USB_SS_PORT_LS_U0; | ||
853 | /* The power session apparently survived the resume. | 875 | /* The power session apparently survived the resume. |
854 | * If there was an overcurrent or suspend change | 876 | * If there was an overcurrent or suspend change |
855 | * (i.e., remote wakeup request), have khubd | 877 | * (i.e., remote wakeup request), have khubd |
856 | * take care of it. | 878 | * take care of it. Look at the port link state |
879 | * for USB 3.0 hubs, since they don't have a suspend | ||
880 | * change bit, and they don't set the port link change | ||
881 | * bit on device-initiated resume. | ||
857 | */ | 882 | */ |
858 | if (portchange) | 883 | if (portchange || (hub_is_superspeed(hub->hdev) && |
884 | port_resumed)) | ||
859 | set_bit(port1, hub->change_bits); | 885 | set_bit(port1, hub->change_bits); |
860 | 886 | ||
861 | } else if (udev->persist_enabled) { | 887 | } else if (udev->persist_enabled) { |
@@ -1293,14 +1319,8 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1293 | desc = intf->cur_altsetting; | 1319 | desc = intf->cur_altsetting; |
1294 | hdev = interface_to_usbdev(intf); | 1320 | hdev = interface_to_usbdev(intf); |
1295 | 1321 | ||
1296 | /* Hubs have proper suspend/resume support. USB 3.0 device suspend is | 1322 | /* Hubs have proper suspend/resume support. */ |
1297 | * different from USB 2.0/1.1 device suspend, and unfortunately we | 1323 | usb_enable_autosuspend(hdev); |
1298 | * don't support it yet. So leave autosuspend disabled for USB 3.0 | ||
1299 | * external hubs for now. Enable autosuspend for USB 3.0 roothubs, | ||
1300 | * since that isn't a "real" hub. | ||
1301 | */ | ||
1302 | if (!hub_is_superspeed(hdev) || !hdev->parent) | ||
1303 | usb_enable_autosuspend(hdev); | ||
1304 | 1324 | ||
1305 | if (hdev->level == MAX_TOPO_LEVEL) { | 1325 | if (hdev->level == MAX_TOPO_LEVEL) { |
1306 | dev_err(&intf->dev, | 1326 | dev_err(&intf->dev, |
@@ -1842,6 +1862,37 @@ fail: | |||
1842 | return err; | 1862 | return err; |
1843 | } | 1863 | } |
1844 | 1864 | ||
1865 | static void set_usb_port_removable(struct usb_device *udev) | ||
1866 | { | ||
1867 | struct usb_device *hdev = udev->parent; | ||
1868 | struct usb_hub *hub; | ||
1869 | u8 port = udev->portnum; | ||
1870 | u16 wHubCharacteristics; | ||
1871 | bool removable = true; | ||
1872 | |||
1873 | if (!hdev) | ||
1874 | return; | ||
1875 | |||
1876 | hub = hdev_to_hub(udev->parent); | ||
1877 | |||
1878 | wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); | ||
1879 | |||
1880 | if (!(wHubCharacteristics & HUB_CHAR_COMPOUND)) | ||
1881 | return; | ||
1882 | |||
1883 | if (hub_is_superspeed(hdev)) { | ||
1884 | if (hub->descriptor->u.ss.DeviceRemovable & (1 << port)) | ||
1885 | removable = false; | ||
1886 | } else { | ||
1887 | if (hub->descriptor->u.hs.DeviceRemovable[port / 8] & (1 << (port % 8))) | ||
1888 | removable = false; | ||
1889 | } | ||
1890 | |||
1891 | if (removable) | ||
1892 | udev->removable = USB_DEVICE_REMOVABLE; | ||
1893 | else | ||
1894 | udev->removable = USB_DEVICE_FIXED; | ||
1895 | } | ||
1845 | 1896 | ||
1846 | /** | 1897 | /** |
1847 | * usb_new_device - perform initial device setup (usbcore-internal) | 1898 | * usb_new_device - perform initial device setup (usbcore-internal) |
@@ -1900,6 +1951,15 @@ int usb_new_device(struct usb_device *udev) | |||
1900 | announce_device(udev); | 1951 | announce_device(udev); |
1901 | 1952 | ||
1902 | device_enable_async_suspend(&udev->dev); | 1953 | device_enable_async_suspend(&udev->dev); |
1954 | |||
1955 | /* | ||
1956 | * check whether the hub marks this port as non-removable. Do it | ||
1957 | * now so that platform-specific data can override it in | ||
1958 | * device_add() | ||
1959 | */ | ||
1960 | if (udev->parent) | ||
1961 | set_usb_port_removable(udev); | ||
1962 | |||
1903 | /* Register the device. The device driver is responsible | 1963 | /* Register the device. The device driver is responsible |
1904 | * for configuring the device and invoking the add-device | 1964 | * for configuring the device and invoking the add-device |
1905 | * notifier chain (used by usbfs and possibly others). | 1965 | * notifier chain (used by usbfs and possibly others). |
@@ -2385,11 +2445,27 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) | |||
2385 | * we don't explicitly enable it here. | 2445 | * we don't explicitly enable it here. |
2386 | */ | 2446 | */ |
2387 | if (udev->do_remote_wakeup) { | 2447 | if (udev->do_remote_wakeup) { |
2388 | status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | 2448 | if (!hub_is_superspeed(hub->hdev)) { |
2389 | USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, | 2449 | status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
2390 | USB_DEVICE_REMOTE_WAKEUP, 0, | 2450 | USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, |
2391 | NULL, 0, | 2451 | USB_DEVICE_REMOTE_WAKEUP, 0, |
2392 | USB_CTRL_SET_TIMEOUT); | 2452 | NULL, 0, |
2453 | USB_CTRL_SET_TIMEOUT); | ||
2454 | } else { | ||
2455 | /* Assume there's only one function on the USB 3.0 | ||
2456 | * device and enable remote wake for the first | ||
2457 | * interface. FIXME if the interface association | ||
2458 | * descriptor shows there's more than one function. | ||
2459 | */ | ||
2460 | status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | ||
2461 | USB_REQ_SET_FEATURE, | ||
2462 | USB_RECIP_INTERFACE, | ||
2463 | USB_INTRF_FUNC_SUSPEND, | ||
2464 | USB_INTRF_FUNC_SUSPEND_RW | | ||
2465 | USB_INTRF_FUNC_SUSPEND_LP, | ||
2466 | NULL, 0, | ||
2467 | USB_CTRL_SET_TIMEOUT); | ||
2468 | } | ||
2393 | if (status) { | 2469 | if (status) { |
2394 | dev_dbg(&udev->dev, "won't remote wakeup, status %d\n", | 2470 | dev_dbg(&udev->dev, "won't remote wakeup, status %d\n", |
2395 | status); | 2471 | status); |
@@ -2679,6 +2755,7 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) | |||
2679 | struct usb_hub *hub = usb_get_intfdata (intf); | 2755 | struct usb_hub *hub = usb_get_intfdata (intf); |
2680 | struct usb_device *hdev = hub->hdev; | 2756 | struct usb_device *hdev = hub->hdev; |
2681 | unsigned port1; | 2757 | unsigned port1; |
2758 | int status; | ||
2682 | 2759 | ||
2683 | /* Warn if children aren't already suspended */ | 2760 | /* Warn if children aren't already suspended */ |
2684 | for (port1 = 1; port1 <= hdev->maxchild; port1++) { | 2761 | for (port1 = 1; port1 <= hdev->maxchild; port1++) { |
@@ -2691,6 +2768,17 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) | |||
2691 | return -EBUSY; | 2768 | return -EBUSY; |
2692 | } | 2769 | } |
2693 | } | 2770 | } |
2771 | if (hub_is_superspeed(hdev) && hdev->do_remote_wakeup) { | ||
2772 | /* Enable hub to send remote wakeup for all ports. */ | ||
2773 | for (port1 = 1; port1 <= hdev->maxchild; port1++) { | ||
2774 | status = set_port_feature(hdev, | ||
2775 | port1 | | ||
2776 | USB_PORT_FEAT_REMOTE_WAKE_CONNECT | | ||
2777 | USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT | | ||
2778 | USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT, | ||
2779 | USB_PORT_FEAT_REMOTE_WAKE_MASK); | ||
2780 | } | ||
2781 | } | ||
2694 | 2782 | ||
2695 | dev_dbg(&intf->dev, "%s\n", __func__); | 2783 | dev_dbg(&intf->dev, "%s\n", __func__); |
2696 | 2784 | ||
@@ -3424,6 +3512,46 @@ done: | |||
3424 | hcd->driver->relinquish_port(hcd, port1); | 3512 | hcd->driver->relinquish_port(hcd, port1); |
3425 | } | 3513 | } |
3426 | 3514 | ||
3515 | /* Returns 1 if there was a remote wakeup and a connect status change. */ | ||
3516 | static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port, | ||
3517 | u16 portstatus, u16 portchange) | ||
3518 | { | ||
3519 | struct usb_device *hdev; | ||
3520 | struct usb_device *udev; | ||
3521 | int connect_change = 0; | ||
3522 | int ret; | ||
3523 | |||
3524 | hdev = hub->hdev; | ||
3525 | udev = hdev->children[port-1]; | ||
3526 | if (!hub_is_superspeed(hdev)) { | ||
3527 | if (!(portchange & USB_PORT_STAT_C_SUSPEND)) | ||
3528 | return 0; | ||
3529 | clear_port_feature(hdev, port, USB_PORT_FEAT_C_SUSPEND); | ||
3530 | } else { | ||
3531 | if (!udev || udev->state != USB_STATE_SUSPENDED || | ||
3532 | (portstatus & USB_PORT_STAT_LINK_STATE) != | ||
3533 | USB_SS_PORT_LS_U0) | ||
3534 | return 0; | ||
3535 | } | ||
3536 | |||
3537 | if (udev) { | ||
3538 | /* TRSMRCY = 10 msec */ | ||
3539 | msleep(10); | ||
3540 | |||
3541 | usb_lock_device(udev); | ||
3542 | ret = usb_remote_wakeup(udev); | ||
3543 | usb_unlock_device(udev); | ||
3544 | if (ret < 0) | ||
3545 | connect_change = 1; | ||
3546 | } else { | ||
3547 | ret = -ENODEV; | ||
3548 | hub_port_disable(hub, port, 1); | ||
3549 | } | ||
3550 | dev_dbg(hub->intfdev, "resume on port %d, status %d\n", | ||
3551 | port, ret); | ||
3552 | return connect_change; | ||
3553 | } | ||
3554 | |||
3427 | static void hub_events(void) | 3555 | static void hub_events(void) |
3428 | { | 3556 | { |
3429 | struct list_head *tmp; | 3557 | struct list_head *tmp; |
@@ -3436,7 +3564,7 @@ static void hub_events(void) | |||
3436 | u16 portstatus; | 3564 | u16 portstatus; |
3437 | u16 portchange; | 3565 | u16 portchange; |
3438 | int i, ret; | 3566 | int i, ret; |
3439 | int connect_change; | 3567 | int connect_change, wakeup_change; |
3440 | 3568 | ||
3441 | /* | 3569 | /* |
3442 | * We restart the list every time to avoid a deadlock with | 3570 | * We restart the list every time to avoid a deadlock with |
@@ -3515,8 +3643,9 @@ static void hub_events(void) | |||
3515 | if (test_bit(i, hub->busy_bits)) | 3643 | if (test_bit(i, hub->busy_bits)) |
3516 | continue; | 3644 | continue; |
3517 | connect_change = test_bit(i, hub->change_bits); | 3645 | connect_change = test_bit(i, hub->change_bits); |
3646 | wakeup_change = test_and_clear_bit(i, hub->wakeup_bits); | ||
3518 | if (!test_and_clear_bit(i, hub->event_bits) && | 3647 | if (!test_and_clear_bit(i, hub->event_bits) && |
3519 | !connect_change) | 3648 | !connect_change && !wakeup_change) |
3520 | continue; | 3649 | continue; |
3521 | 3650 | ||
3522 | ret = hub_port_status(hub, i, | 3651 | ret = hub_port_status(hub, i, |
@@ -3557,31 +3686,10 @@ static void hub_events(void) | |||
3557 | } | 3686 | } |
3558 | } | 3687 | } |
3559 | 3688 | ||
3560 | if (portchange & USB_PORT_STAT_C_SUSPEND) { | 3689 | if (hub_handle_remote_wakeup(hub, i, |
3561 | struct usb_device *udev; | 3690 | portstatus, portchange)) |
3691 | connect_change = 1; | ||
3562 | 3692 | ||
3563 | clear_port_feature(hdev, i, | ||
3564 | USB_PORT_FEAT_C_SUSPEND); | ||
3565 | udev = hdev->children[i-1]; | ||
3566 | if (udev) { | ||
3567 | /* TRSMRCY = 10 msec */ | ||
3568 | msleep(10); | ||
3569 | |||
3570 | usb_lock_device(udev); | ||
3571 | ret = usb_remote_wakeup(hdev-> | ||
3572 | children[i-1]); | ||
3573 | usb_unlock_device(udev); | ||
3574 | if (ret < 0) | ||
3575 | connect_change = 1; | ||
3576 | } else { | ||
3577 | ret = -ENODEV; | ||
3578 | hub_port_disable(hub, i, 1); | ||
3579 | } | ||
3580 | dev_dbg (hub_dev, | ||
3581 | "resume on port %d, status %d\n", | ||
3582 | i, ret); | ||
3583 | } | ||
3584 | |||
3585 | if (portchange & USB_PORT_STAT_C_OVERCURRENT) { | 3693 | if (portchange & USB_PORT_STAT_C_OVERCURRENT) { |
3586 | u16 status = 0; | 3694 | u16 status = 0; |
3587 | u16 unused; | 3695 | u16 unused; |
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-hub.c b/drivers/usb/host/ehci-hub.c index 77bbb2357e47..01011dd0cb5d 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c | |||
@@ -107,7 +107,7 @@ static void ehci_handover_companion_ports(struct ehci_hcd *ehci) | |||
107 | ehci->owned_ports = 0; | 107 | ehci->owned_ports = 0; |
108 | } | 108 | } |
109 | 109 | ||
110 | static int ehci_port_change(struct ehci_hcd *ehci) | 110 | static int __maybe_unused ehci_port_change(struct ehci_hcd *ehci) |
111 | { | 111 | { |
112 | int i = HCS_N_PORTS(ehci->hcs_params); | 112 | int i = HCS_N_PORTS(ehci->hcs_params); |
113 | 113 | ||
@@ -1076,7 +1076,8 @@ error_exit: | |||
1076 | return retval; | 1076 | return retval; |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | static void ehci_relinquish_port(struct usb_hcd *hcd, int portnum) | 1079 | static void __maybe_unused ehci_relinquish_port(struct usb_hcd *hcd, |
1080 | int portnum) | ||
1080 | { | 1081 | { |
1081 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 1082 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
1082 | 1083 | ||
@@ -1085,7 +1086,8 @@ static void ehci_relinquish_port(struct usb_hcd *hcd, int portnum) | |||
1085 | set_owner(ehci, --portnum, PORT_OWNER); | 1086 | set_owner(ehci, --portnum, PORT_OWNER); |
1086 | } | 1087 | } |
1087 | 1088 | ||
1088 | static int ehci_port_handed_over(struct usb_hcd *hcd, int portnum) | 1089 | static int __maybe_unused ehci_port_handed_over(struct usb_hcd *hcd, |
1090 | int portnum) | ||
1089 | { | 1091 | { |
1090 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 1092 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
1091 | u32 __iomem *reg; | 1093 | u32 __iomem *reg; |
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/imx21-dbg.c b/drivers/usb/host/imx21-dbg.c index 6d7533427163..ec98ecee3517 100644 --- a/drivers/usb/host/imx21-dbg.c +++ b/drivers/usb/host/imx21-dbg.c | |||
@@ -239,7 +239,7 @@ static int debug_status_show(struct seq_file *s, void *v) | |||
239 | "ETDs allocated: %d/%d (max=%d)\n" | 239 | "ETDs allocated: %d/%d (max=%d)\n" |
240 | "ETDs in use sw: %d\n" | 240 | "ETDs in use sw: %d\n" |
241 | "ETDs in use hw: %d\n" | 241 | "ETDs in use hw: %d\n" |
242 | "DMEM alocated: %d/%d (max=%d)\n" | 242 | "DMEM allocated: %d/%d (max=%d)\n" |
243 | "DMEM blocks: %d\n" | 243 | "DMEM blocks: %d\n" |
244 | "Queued waiting for ETD: %d\n" | 244 | "Queued waiting for ETD: %d\n" |
245 | "Queued waiting for DMEM: %d\n", | 245 | "Queued waiting for DMEM: %d\n", |
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/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 557b6f32db86..673ad120c43e 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c | |||
@@ -422,6 +422,32 @@ void xhci_set_link_state(struct xhci_hcd *xhci, __le32 __iomem **port_array, | |||
422 | xhci_writel(xhci, temp, port_array[port_id]); | 422 | xhci_writel(xhci, temp, port_array[port_id]); |
423 | } | 423 | } |
424 | 424 | ||
425 | void xhci_set_remote_wake_mask(struct xhci_hcd *xhci, | ||
426 | __le32 __iomem **port_array, int port_id, u16 wake_mask) | ||
427 | { | ||
428 | u32 temp; | ||
429 | |||
430 | temp = xhci_readl(xhci, port_array[port_id]); | ||
431 | temp = xhci_port_state_to_neutral(temp); | ||
432 | |||
433 | if (wake_mask & USB_PORT_FEAT_REMOTE_WAKE_CONNECT) | ||
434 | temp |= PORT_WKCONN_E; | ||
435 | else | ||
436 | temp &= ~PORT_WKCONN_E; | ||
437 | |||
438 | if (wake_mask & USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT) | ||
439 | temp |= PORT_WKDISC_E; | ||
440 | else | ||
441 | temp &= ~PORT_WKDISC_E; | ||
442 | |||
443 | if (wake_mask & USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT) | ||
444 | temp |= PORT_WKOC_E; | ||
445 | else | ||
446 | temp &= ~PORT_WKOC_E; | ||
447 | |||
448 | xhci_writel(xhci, temp, port_array[port_id]); | ||
449 | } | ||
450 | |||
425 | /* Test and clear port RWC bit */ | 451 | /* Test and clear port RWC bit */ |
426 | void xhci_test_and_clear_bit(struct xhci_hcd *xhci, __le32 __iomem **port_array, | 452 | void xhci_test_and_clear_bit(struct xhci_hcd *xhci, __le32 __iomem **port_array, |
427 | int port_id, u32 port_bit) | 453 | int port_id, u32 port_bit) |
@@ -448,6 +474,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
448 | int slot_id; | 474 | int slot_id; |
449 | struct xhci_bus_state *bus_state; | 475 | struct xhci_bus_state *bus_state; |
450 | u16 link_state = 0; | 476 | u16 link_state = 0; |
477 | u16 wake_mask = 0; | ||
451 | 478 | ||
452 | max_ports = xhci_get_ports(hcd, &port_array); | 479 | max_ports = xhci_get_ports(hcd, &port_array); |
453 | bus_state = &xhci->bus_state[hcd_index(hcd)]; | 480 | bus_state = &xhci->bus_state[hcd_index(hcd)]; |
@@ -593,6 +620,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
593 | case SetPortFeature: | 620 | case SetPortFeature: |
594 | if (wValue == USB_PORT_FEAT_LINK_STATE) | 621 | if (wValue == USB_PORT_FEAT_LINK_STATE) |
595 | link_state = (wIndex & 0xff00) >> 3; | 622 | link_state = (wIndex & 0xff00) >> 3; |
623 | if (wValue == USB_PORT_FEAT_REMOTE_WAKE_MASK) | ||
624 | wake_mask = wIndex & 0xff00; | ||
596 | wIndex &= 0xff; | 625 | wIndex &= 0xff; |
597 | if (!wIndex || wIndex > max_ports) | 626 | if (!wIndex || wIndex > max_ports) |
598 | goto error; | 627 | goto error; |
@@ -703,6 +732,14 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
703 | temp = xhci_readl(xhci, port_array[wIndex]); | 732 | temp = xhci_readl(xhci, port_array[wIndex]); |
704 | xhci_dbg(xhci, "set port reset, actual port %d status = 0x%x\n", wIndex, temp); | 733 | xhci_dbg(xhci, "set port reset, actual port %d status = 0x%x\n", wIndex, temp); |
705 | break; | 734 | break; |
735 | case USB_PORT_FEAT_REMOTE_WAKE_MASK: | ||
736 | xhci_set_remote_wake_mask(xhci, port_array, | ||
737 | wIndex, wake_mask); | ||
738 | temp = xhci_readl(xhci, port_array[wIndex]); | ||
739 | xhci_dbg(xhci, "set port remote wake mask, " | ||
740 | "actual port %d status = 0x%x\n", | ||
741 | wIndex, temp); | ||
742 | break; | ||
706 | case USB_PORT_FEAT_BH_PORT_RESET: | 743 | case USB_PORT_FEAT_BH_PORT_RESET: |
707 | temp |= PORT_WR; | 744 | temp |= PORT_WR; |
708 | xhci_writel(xhci, temp, port_array[wIndex]); | 745 | xhci_writel(xhci, temp, port_array[wIndex]); |
@@ -883,6 +920,10 @@ int xhci_bus_suspend(struct usb_hcd *hcd) | |||
883 | t2 |= PORT_LINK_STROBE | XDEV_U3; | 920 | t2 |= PORT_LINK_STROBE | XDEV_U3; |
884 | set_bit(port_index, &bus_state->bus_suspended); | 921 | set_bit(port_index, &bus_state->bus_suspended); |
885 | } | 922 | } |
923 | /* USB core sets remote wake mask for USB 3.0 hubs, | ||
924 | * including the USB 3.0 roothub, but only if CONFIG_USB_SUSPEND | ||
925 | * is enabled, so also enable remote wake here. | ||
926 | */ | ||
886 | if (hcd->self.root_hub->do_remote_wakeup) { | 927 | if (hcd->self.root_hub->do_remote_wakeup) { |
887 | if (t1 & PORT_CONNECT) { | 928 | if (t1 & PORT_CONNECT) { |
888 | t2 |= PORT_WKOC_E | PORT_WKDISC_E; | 929 | t2 |= PORT_WKOC_E | PORT_WKDISC_E; |
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 383fc857491c..8339d826ce58 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c | |||
@@ -2157,7 +2157,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) | |||
2157 | unsigned int val, val2; | 2157 | unsigned int val, val2; |
2158 | u64 val_64; | 2158 | u64 val_64; |
2159 | struct xhci_segment *seg; | 2159 | struct xhci_segment *seg; |
2160 | u32 page_size; | 2160 | u32 page_size, temp; |
2161 | int i; | 2161 | int i; |
2162 | 2162 | ||
2163 | page_size = xhci_readl(xhci, &xhci->op_regs->page_size); | 2163 | page_size = xhci_readl(xhci, &xhci->op_regs->page_size); |
@@ -2340,6 +2340,15 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) | |||
2340 | 2340 | ||
2341 | INIT_LIST_HEAD(&xhci->lpm_failed_devs); | 2341 | INIT_LIST_HEAD(&xhci->lpm_failed_devs); |
2342 | 2342 | ||
2343 | /* Enable USB 3.0 device notifications for function remote wake, which | ||
2344 | * is necessary for allowing USB 3.0 devices to do remote wakeup from | ||
2345 | * U3 (device suspend). | ||
2346 | */ | ||
2347 | temp = xhci_readl(xhci, &xhci->op_regs->dev_notification); | ||
2348 | temp &= ~DEV_NOTE_MASK; | ||
2349 | temp |= DEV_NOTE_FWAKE; | ||
2350 | xhci_writel(xhci, temp, &xhci->op_regs->dev_notification); | ||
2351 | |||
2343 | return 0; | 2352 | return 0; |
2344 | 2353 | ||
2345 | fail: | 2354 | fail: |
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index b62037bff688..3a033240ec64 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -1237,6 +1237,26 @@ static unsigned int find_faked_portnum_from_hw_portnum(struct usb_hcd *hcd, | |||
1237 | return num_similar_speed_ports; | 1237 | return num_similar_speed_ports; |
1238 | } | 1238 | } |
1239 | 1239 | ||
1240 | static void handle_device_notification(struct xhci_hcd *xhci, | ||
1241 | union xhci_trb *event) | ||
1242 | { | ||
1243 | u32 slot_id; | ||
1244 | struct usb_device *udev; | ||
1245 | |||
1246 | slot_id = TRB_TO_SLOT_ID(event->generic.field[3]); | ||
1247 | if (!xhci->devs[slot_id]) { | ||
1248 | xhci_warn(xhci, "Device Notification event for " | ||
1249 | "unused slot %u\n", slot_id); | ||
1250 | return; | ||
1251 | } | ||
1252 | |||
1253 | xhci_dbg(xhci, "Device Wake Notification event for slot ID %u\n", | ||
1254 | slot_id); | ||
1255 | udev = xhci->devs[slot_id]->udev; | ||
1256 | if (udev && udev->parent) | ||
1257 | usb_wakeup_notification(udev->parent, udev->portnum); | ||
1258 | } | ||
1259 | |||
1240 | static void handle_port_status(struct xhci_hcd *xhci, | 1260 | static void handle_port_status(struct xhci_hcd *xhci, |
1241 | union xhci_trb *event) | 1261 | union xhci_trb *event) |
1242 | { | 1262 | { |
@@ -1321,20 +1341,21 @@ static void handle_port_status(struct xhci_hcd *xhci, | |||
1321 | } | 1341 | } |
1322 | 1342 | ||
1323 | if (DEV_SUPERSPEED(temp)) { | 1343 | if (DEV_SUPERSPEED(temp)) { |
1324 | xhci_dbg(xhci, "resume SS port %d\n", port_id); | 1344 | xhci_dbg(xhci, "remote wake SS port %d\n", port_id); |
1345 | /* Set a flag to say the port signaled remote wakeup, | ||
1346 | * so we can tell the difference between the end of | ||
1347 | * device and host initiated resume. | ||
1348 | */ | ||
1349 | bus_state->port_remote_wakeup |= 1 << faked_port_index; | ||
1350 | xhci_test_and_clear_bit(xhci, port_array, | ||
1351 | faked_port_index, PORT_PLC); | ||
1325 | xhci_set_link_state(xhci, port_array, faked_port_index, | 1352 | xhci_set_link_state(xhci, port_array, faked_port_index, |
1326 | XDEV_U0); | 1353 | XDEV_U0); |
1327 | slot_id = xhci_find_slot_id_by_port(hcd, xhci, | 1354 | /* Need to wait until the next link state change |
1328 | faked_port_index + 1); | 1355 | * indicates the device is actually in U0. |
1329 | if (!slot_id) { | 1356 | */ |
1330 | xhci_dbg(xhci, "slot_id is zero\n"); | 1357 | bogus_port_status = true; |
1331 | goto cleanup; | 1358 | goto cleanup; |
1332 | } | ||
1333 | xhci_ring_device(xhci, slot_id); | ||
1334 | xhci_dbg(xhci, "resume SS port %d finished\n", port_id); | ||
1335 | /* Clear PORT_PLC */ | ||
1336 | xhci_test_and_clear_bit(xhci, port_array, | ||
1337 | faked_port_index, PORT_PLC); | ||
1338 | } else { | 1359 | } else { |
1339 | xhci_dbg(xhci, "resume HS port %d\n", port_id); | 1360 | xhci_dbg(xhci, "resume HS port %d\n", port_id); |
1340 | bus_state->resume_done[faked_port_index] = jiffies + | 1361 | bus_state->resume_done[faked_port_index] = jiffies + |
@@ -1345,6 +1366,32 @@ static void handle_port_status(struct xhci_hcd *xhci, | |||
1345 | } | 1366 | } |
1346 | } | 1367 | } |
1347 | 1368 | ||
1369 | if ((temp & PORT_PLC) && (temp & PORT_PLS_MASK) == XDEV_U0 && | ||
1370 | DEV_SUPERSPEED(temp)) { | ||
1371 | xhci_dbg(xhci, "resume SS port %d finished\n", port_id); | ||
1372 | /* We've just brought the device into U0 through either the | ||
1373 | * Resume state after a device remote wakeup, or through the | ||
1374 | * U3Exit state after a host-initiated resume. If it's a device | ||
1375 | * initiated remote wake, don't pass up the link state change, | ||
1376 | * so the roothub behavior is consistent with external | ||
1377 | * USB 3.0 hub behavior. | ||
1378 | */ | ||
1379 | slot_id = xhci_find_slot_id_by_port(hcd, xhci, | ||
1380 | faked_port_index + 1); | ||
1381 | if (slot_id && xhci->devs[slot_id]) | ||
1382 | xhci_ring_device(xhci, slot_id); | ||
1383 | if (bus_state->port_remote_wakeup && (1 << faked_port_index)) { | ||
1384 | bus_state->port_remote_wakeup &= | ||
1385 | ~(1 << faked_port_index); | ||
1386 | xhci_test_and_clear_bit(xhci, port_array, | ||
1387 | faked_port_index, PORT_PLC); | ||
1388 | usb_wakeup_notification(hcd->self.root_hub, | ||
1389 | faked_port_index + 1); | ||
1390 | bogus_port_status = true; | ||
1391 | goto cleanup; | ||
1392 | } | ||
1393 | } | ||
1394 | |||
1348 | if (hcd->speed != HCD_USB3) | 1395 | if (hcd->speed != HCD_USB3) |
1349 | xhci_test_and_clear_bit(xhci, port_array, faked_port_index, | 1396 | xhci_test_and_clear_bit(xhci, port_array, faked_port_index, |
1350 | PORT_PLC); | 1397 | PORT_PLC); |
@@ -2277,6 +2324,9 @@ static int xhci_handle_event(struct xhci_hcd *xhci) | |||
2277 | else | 2324 | else |
2278 | update_ptrs = 0; | 2325 | update_ptrs = 0; |
2279 | break; | 2326 | break; |
2327 | case TRB_TYPE(TRB_DEV_NOTE): | ||
2328 | handle_device_notification(xhci, event); | ||
2329 | break; | ||
2280 | default: | 2330 | default: |
2281 | if ((le32_to_cpu(event->event_cmd.flags) & TRB_TYPE_BITMASK) >= | 2331 | if ((le32_to_cpu(event->event_cmd.flags) & TRB_TYPE_BITMASK) >= |
2282 | TRB_TYPE(48)) | 2332 | TRB_TYPE(48)) |
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index fb99c8379142..0f4936956103 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -1344,6 +1344,7 @@ struct xhci_bus_state { | |||
1344 | /* ports suspend status arrays - max 31 ports for USB2, 15 for USB3 */ | 1344 | /* ports suspend status arrays - max 31 ports for USB2, 15 for USB3 */ |
1345 | u32 port_c_suspend; | 1345 | u32 port_c_suspend; |
1346 | u32 suspended_ports; | 1346 | u32 suspended_ports; |
1347 | u32 port_remote_wakeup; | ||
1347 | unsigned long resume_done[USB_MAXCHILDREN]; | 1348 | unsigned long resume_done[USB_MAXCHILDREN]; |
1348 | }; | 1349 | }; |
1349 | 1350 | ||
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index 08a5575724cd..ec9dc4e9a3ff 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c | |||
@@ -286,7 +286,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request, | |||
286 | 286 | ||
287 | if (result != size) { | 287 | if (result != size) { |
288 | dbg("%s - Unable to send config request, " | 288 | dbg("%s - Unable to send config request, " |
289 | "request=0x%x size=%d result=%d\n", | 289 | "request=0x%x size=%d result=%d", |
290 | __func__, request, size, result); | 290 | __func__, request, size, result); |
291 | if (result > 0) | 291 | if (result > 0) |
292 | result = -EPROTO; | 292 | result = -EPROTO; |
@@ -340,7 +340,7 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request, | |||
340 | 340 | ||
341 | if ((size > 2 && result != size) || result < 0) { | 341 | if ((size > 2 && result != size) || result < 0) { |
342 | dbg("%s - Unable to send request, " | 342 | dbg("%s - Unable to send request, " |
343 | "request=0x%x size=%d result=%d\n", | 343 | "request=0x%x size=%d result=%d", |
344 | __func__, request, size, result); | 344 | __func__, request, size, result); |
345 | if (result > 0) | 345 | if (result > 0) |
346 | result = -EPROTO; | 346 | result = -EPROTO; |
@@ -683,13 +683,13 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
683 | default: | 683 | default: |
684 | dbg("cp210x driver does not " | 684 | dbg("cp210x driver does not " |
685 | "support the number of bits requested," | 685 | "support the number of bits requested," |
686 | " using 8 bit mode\n"); | 686 | " using 8 bit mode"); |
687 | bits |= BITS_DATA_8; | 687 | bits |= BITS_DATA_8; |
688 | break; | 688 | break; |
689 | } | 689 | } |
690 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) | 690 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) |
691 | dbg("Number of data bits requested " | 691 | dbg("Number of data bits requested " |
692 | "not supported by device\n"); | 692 | "not supported by device"); |
693 | } | 693 | } |
694 | 694 | ||
695 | if ((cflag & (PARENB|PARODD|CMSPAR)) != | 695 | if ((cflag & (PARENB|PARODD|CMSPAR)) != |
@@ -716,8 +716,7 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
716 | } | 716 | } |
717 | } | 717 | } |
718 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) | 718 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) |
719 | dbg("Parity mode not supported " | 719 | dbg("Parity mode not supported by device"); |
720 | "by device\n"); | ||
721 | } | 720 | } |
722 | 721 | ||
723 | if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) { | 722 | if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) { |
@@ -732,7 +731,7 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
732 | } | 731 | } |
733 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) | 732 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) |
734 | dbg("Number of stop bits requested " | 733 | dbg("Number of stop bits requested " |
735 | "not supported by device\n"); | 734 | "not supported by device"); |
736 | } | 735 | } |
737 | 736 | ||
738 | if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { | 737 | 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 75b838eff178..74f2c7746cc4 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -1250,7 +1250,6 @@ static void ti_bulk_out_callback(struct urb *urb) | |||
1250 | { | 1250 | { |
1251 | struct ti_port *tport = urb->context; | 1251 | struct ti_port *tport = urb->context; |
1252 | struct usb_serial_port *port = tport->tp_port; | 1252 | struct usb_serial_port *port = tport->tp_port; |
1253 | struct device *dev = &urb->dev->dev; | ||
1254 | int status = urb->status; | 1253 | int status = urb->status; |
1255 | 1254 | ||
1256 | dbg("%s - port %d", __func__, port->number); | 1255 | dbg("%s - port %d", __func__, port->number); |
@@ -1268,7 +1267,7 @@ static void ti_bulk_out_callback(struct urb *urb) | |||
1268 | wake_up_interruptible(&tport->tp_write_wait); | 1267 | wake_up_interruptible(&tport->tp_write_wait); |
1269 | return; | 1268 | return; |
1270 | default: | 1269 | default: |
1271 | dev_err(dev, "%s - nonzero urb status, %d\n", | 1270 | dev_err_console(port, "%s - nonzero urb status, %d\n", |
1272 | __func__, status); | 1271 | __func__, status); |
1273 | tport->tp_tdev->td_urb_error = 1; | 1272 | tport->tp_tdev->td_urb_error = 1; |
1274 | wake_up_interruptible(&tport->tp_write_wait); | 1273 | wake_up_interruptible(&tport->tp_write_wait); |
@@ -1337,7 +1336,7 @@ static void ti_send(struct ti_port *tport) | |||
1337 | 1336 | ||
1338 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 1337 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
1339 | if (result) { | 1338 | if (result) { |
1340 | dev_err(&port->dev, "%s - submit write urb failed, %d\n", | 1339 | dev_err_console(port, "%s - submit write urb failed, %d\n", |
1341 | __func__, result); | 1340 | __func__, result); |
1342 | tport->tp_write_urb_in_use = 0; | 1341 | tport->tp_write_urb_in_use = 0; |
1343 | /* TODO: reschedule ti_send */ | 1342 | /* 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 db51ba16dc07..c18538e4a6db 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c | |||
@@ -125,6 +125,9 @@ static struct us_unusual_dev us_unusual_dev_list[] = { | |||
125 | { } /* Terminating entry */ | 125 | { } /* Terminating entry */ |
126 | }; | 126 | }; |
127 | 127 | ||
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 |
@@ -999,8 +1002,10 @@ EXPORT_SYMBOL_GPL(usb_stor_disconnect); | |||
999 | static int storage_probe(struct usb_interface *intf, | 1002 | static int storage_probe(struct usb_interface *intf, |
1000 | const struct usb_device_id *id) | 1003 | const struct usb_device_id *id) |
1001 | { | 1004 | { |
1005 | struct us_unusual_dev *unusual_dev; | ||
1002 | struct us_data *us; | 1006 | struct us_data *us; |
1003 | int result; | 1007 | int result; |
1008 | int size; | ||
1004 | 1009 | ||
1005 | /* | 1010 | /* |
1006 | * If libusual is configured, let it decide whether a standard | 1011 | * If libusual is configured, let it decide whether a standard |
@@ -1019,8 +1024,19 @@ static int storage_probe(struct usb_interface *intf, | |||
1019 | * table, so we use the index of the id entry to find the | 1024 | * table, so we use the index of the id entry to find the |
1020 | * corresponding unusual_devs entry. | 1025 | * corresponding unusual_devs entry. |
1021 | */ | 1026 | */ |
1022 | result = usb_stor_probe1(&us, intf, id, | 1027 | |
1023 | (id - usb_storage_usb_ids) + us_unusual_dev_list); | 1028 | size = ARRAY_SIZE(us_unusual_dev_list); |
1029 | if (id >= usb_storage_usb_ids && id < usb_storage_usb_ids + size) { | ||
1030 | unusual_dev = (id - usb_storage_usb_ids) + us_unusual_dev_list; | ||
1031 | } else { | ||
1032 | unusual_dev = &for_dynamic_ids; | ||
1033 | |||
1034 | US_DEBUGP("%s %s 0x%04x 0x%04x\n", "Use Bulk-Only transport", | ||
1035 | "with the Transparent SCSI protocol for dynamic id:", | ||
1036 | id->idVendor, id->idProduct); | ||
1037 | } | ||
1038 | |||
1039 | result = usb_stor_probe1(&us, intf, id, unusual_dev); | ||
1024 | if (result) | 1040 | if (result) |
1025 | return result; | 1041 | return result; |
1026 | 1042 | ||
@@ -1046,7 +1062,6 @@ static struct usb_driver usb_storage_driver = { | |||
1046 | .id_table = usb_storage_usb_ids, | 1062 | .id_table = usb_storage_usb_ids, |
1047 | .supports_autosuspend = 1, | 1063 | .supports_autosuspend = 1, |
1048 | .soft_unbind = 1, | 1064 | .soft_unbind = 1, |
1049 | .no_dynamic_id = 1, | ||
1050 | }; | 1065 | }; |
1051 | 1066 | ||
1052 | static int __init usb_stor_init(void) | 1067 | 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/ch11.h b/include/linux/usb/ch11.h index 0b83acd3360a..f1d26b6067f1 100644 --- a/include/linux/usb/ch11.h +++ b/include/linux/usb/ch11.h | |||
@@ -76,6 +76,11 @@ | |||
76 | #define USB_PORT_FEAT_C_BH_PORT_RESET 29 | 76 | #define USB_PORT_FEAT_C_BH_PORT_RESET 29 |
77 | #define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30 | 77 | #define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30 |
78 | 78 | ||
79 | /* USB 3.0 hub remote wake mask bits, see table 10-14 */ | ||
80 | #define USB_PORT_FEAT_REMOTE_WAKE_CONNECT (1 << 8) | ||
81 | #define USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT (1 << 9) | ||
82 | #define USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT (1 << 10) | ||
83 | |||
79 | /* | 84 | /* |
80 | * Hub Status and Hub Change results | 85 | * Hub Status and Hub Change results |
81 | * See USB 2.0 spec Table 11-19 and Table 11-20 | 86 | * See USB 2.0 spec Table 11-19 and Table 11-20 |
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index b2f62f3a32af..2e6071efbfb7 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h | |||
@@ -412,6 +412,8 @@ extern irqreturn_t usb_hcd_irq(int irq, void *__hcd); | |||
412 | 412 | ||
413 | extern void usb_hc_died(struct usb_hcd *hcd); | 413 | extern void usb_hc_died(struct usb_hcd *hcd); |
414 | extern void usb_hcd_poll_rh_status(struct usb_hcd *hcd); | 414 | extern void usb_hcd_poll_rh_status(struct usb_hcd *hcd); |
415 | extern void usb_wakeup_notification(struct usb_device *hdev, | ||
416 | unsigned int portnum); | ||
415 | 417 | ||
416 | /* The D0/D1 toggle bits ... USE WITH CAUTION (they're almost hcd-internal) */ | 418 | /* The D0/D1 toggle bits ... USE WITH CAUTION (they're almost hcd-internal) */ |
417 | #define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> (ep)) & 1) | 419 | #define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> (ep)) & 1) |
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 | /* |