diff options
46 files changed, 550 insertions, 316 deletions
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 0aa9e7d697a5..25dbd8c7aec7 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c | |||
@@ -239,6 +239,16 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, | |||
239 | if (ifp->desc.bNumEndpoints >= num_ep) | 239 | if (ifp->desc.bNumEndpoints >= num_ep) |
240 | goto skip_to_next_endpoint_or_interface_descriptor; | 240 | goto skip_to_next_endpoint_or_interface_descriptor; |
241 | 241 | ||
242 | /* Check for duplicate endpoint addresses */ | ||
243 | for (i = 0; i < ifp->desc.bNumEndpoints; ++i) { | ||
244 | if (ifp->endpoint[i].desc.bEndpointAddress == | ||
245 | d->bEndpointAddress) { | ||
246 | dev_warn(ddev, "config %d interface %d altsetting %d has a duplicate endpoint with address 0x%X, skipping\n", | ||
247 | cfgno, inum, asnum, d->bEndpointAddress); | ||
248 | goto skip_to_next_endpoint_or_interface_descriptor; | ||
249 | } | ||
250 | } | ||
251 | |||
242 | endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints]; | 252 | endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints]; |
243 | ++ifp->desc.bNumEndpoints; | 253 | ++ifp->desc.bNumEndpoints; |
244 | 254 | ||
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 1fa5c0f29c64..a56c75e09786 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -103,8 +103,7 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem); | |||
103 | 103 | ||
104 | static void hub_release(struct kref *kref); | 104 | static void hub_release(struct kref *kref); |
105 | static int usb_reset_and_verify_device(struct usb_device *udev); | 105 | static int usb_reset_and_verify_device(struct usb_device *udev); |
106 | static void hub_usb3_port_prepare_disable(struct usb_hub *hub, | 106 | static int hub_port_disable(struct usb_hub *hub, int port1, int set_state); |
107 | struct usb_port *port_dev); | ||
108 | 107 | ||
109 | static inline char *portspeed(struct usb_hub *hub, int portstatus) | 108 | static inline char *portspeed(struct usb_hub *hub, int portstatus) |
110 | { | 109 | { |
@@ -903,34 +902,6 @@ static int hub_set_port_link_state(struct usb_hub *hub, int port1, | |||
903 | } | 902 | } |
904 | 903 | ||
905 | /* | 904 | /* |
906 | * USB-3 does not have a similar link state as USB-2 that will avoid negotiating | ||
907 | * a connection with a plugged-in cable but will signal the host when the cable | ||
908 | * is unplugged. Disable remote wake and set link state to U3 for USB-3 devices | ||
909 | */ | ||
910 | static int hub_port_disable(struct usb_hub *hub, int port1, int set_state) | ||
911 | { | ||
912 | struct usb_port *port_dev = hub->ports[port1 - 1]; | ||
913 | struct usb_device *hdev = hub->hdev; | ||
914 | int ret = 0; | ||
915 | |||
916 | if (!hub->error) { | ||
917 | if (hub_is_superspeed(hub->hdev)) { | ||
918 | hub_usb3_port_prepare_disable(hub, port_dev); | ||
919 | ret = hub_set_port_link_state(hub, port_dev->portnum, | ||
920 | USB_SS_PORT_LS_U3); | ||
921 | } else { | ||
922 | ret = usb_clear_port_feature(hdev, port1, | ||
923 | USB_PORT_FEAT_ENABLE); | ||
924 | } | ||
925 | } | ||
926 | if (port_dev->child && set_state) | ||
927 | usb_set_device_state(port_dev->child, USB_STATE_NOTATTACHED); | ||
928 | if (ret && ret != -ENODEV) | ||
929 | dev_err(&port_dev->dev, "cannot disable (err = %d)\n", ret); | ||
930 | return ret; | ||
931 | } | ||
932 | |||
933 | /* | ||
934 | * Disable a port and mark a logical connect-change event, so that some | 905 | * Disable a port and mark a logical connect-change event, so that some |
935 | * time later hub_wq will disconnect() any existing usb_device on the port | 906 | * time later hub_wq will disconnect() any existing usb_device on the port |
936 | * and will re-enumerate if there actually is a device attached. | 907 | * and will re-enumerate if there actually is a device attached. |
@@ -4162,6 +4133,34 @@ static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port, | |||
4162 | 4133 | ||
4163 | #endif /* CONFIG_PM */ | 4134 | #endif /* CONFIG_PM */ |
4164 | 4135 | ||
4136 | /* | ||
4137 | * USB-3 does not have a similar link state as USB-2 that will avoid negotiating | ||
4138 | * a connection with a plugged-in cable but will signal the host when the cable | ||
4139 | * is unplugged. Disable remote wake and set link state to U3 for USB-3 devices | ||
4140 | */ | ||
4141 | static int hub_port_disable(struct usb_hub *hub, int port1, int set_state) | ||
4142 | { | ||
4143 | struct usb_port *port_dev = hub->ports[port1 - 1]; | ||
4144 | struct usb_device *hdev = hub->hdev; | ||
4145 | int ret = 0; | ||
4146 | |||
4147 | if (!hub->error) { | ||
4148 | if (hub_is_superspeed(hub->hdev)) { | ||
4149 | hub_usb3_port_prepare_disable(hub, port_dev); | ||
4150 | ret = hub_set_port_link_state(hub, port_dev->portnum, | ||
4151 | USB_SS_PORT_LS_U3); | ||
4152 | } else { | ||
4153 | ret = usb_clear_port_feature(hdev, port1, | ||
4154 | USB_PORT_FEAT_ENABLE); | ||
4155 | } | ||
4156 | } | ||
4157 | if (port_dev->child && set_state) | ||
4158 | usb_set_device_state(port_dev->child, USB_STATE_NOTATTACHED); | ||
4159 | if (ret && ret != -ENODEV) | ||
4160 | dev_err(&port_dev->dev, "cannot disable (err = %d)\n", ret); | ||
4161 | return ret; | ||
4162 | } | ||
4163 | |||
4165 | 4164 | ||
4166 | /* USB 2.0 spec, 7.1.7.3 / fig 7-29: | 4165 | /* USB 2.0 spec, 7.1.7.3 / fig 7-29: |
4167 | * | 4166 | * |
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index b95930f20d90..c55db4aa54d6 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c | |||
@@ -3753,7 +3753,7 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep, | |||
3753 | hs_ep->desc_list = dma_alloc_coherent(hsotg->dev, | 3753 | hs_ep->desc_list = dma_alloc_coherent(hsotg->dev, |
3754 | MAX_DMA_DESC_NUM_GENERIC * | 3754 | MAX_DMA_DESC_NUM_GENERIC * |
3755 | sizeof(struct dwc2_dma_desc), | 3755 | sizeof(struct dwc2_dma_desc), |
3756 | &hs_ep->desc_list_dma, GFP_KERNEL); | 3756 | &hs_ep->desc_list_dma, GFP_ATOMIC); |
3757 | if (!hs_ep->desc_list) { | 3757 | if (!hs_ep->desc_list) { |
3758 | ret = -ENOMEM; | 3758 | ret = -ENOMEM; |
3759 | goto error2; | 3759 | goto error2; |
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index a786256535b6..11fe68a4627b 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c | |||
@@ -247,8 +247,6 @@ MODULE_DEVICE_TABLE(of, dwc2_of_match_table); | |||
247 | static void dwc2_get_device_property(struct dwc2_hsotg *hsotg, | 247 | static void dwc2_get_device_property(struct dwc2_hsotg *hsotg, |
248 | char *property, u8 size, u64 *value) | 248 | char *property, u8 size, u64 *value) |
249 | { | 249 | { |
250 | u8 val8; | ||
251 | u16 val16; | ||
252 | u32 val32; | 250 | u32 val32; |
253 | 251 | ||
254 | switch (size) { | 252 | switch (size) { |
@@ -256,17 +254,7 @@ static void dwc2_get_device_property(struct dwc2_hsotg *hsotg, | |||
256 | *value = device_property_read_bool(hsotg->dev, property); | 254 | *value = device_property_read_bool(hsotg->dev, property); |
257 | break; | 255 | break; |
258 | case 1: | 256 | case 1: |
259 | if (device_property_read_u8(hsotg->dev, property, &val8)) | ||
260 | return; | ||
261 | |||
262 | *value = val8; | ||
263 | break; | ||
264 | case 2: | 257 | case 2: |
265 | if (device_property_read_u16(hsotg->dev, property, &val16)) | ||
266 | return; | ||
267 | |||
268 | *value = val16; | ||
269 | break; | ||
270 | case 4: | 258 | case 4: |
271 | if (device_property_read_u32(hsotg->dev, property, &val32)) | 259 | if (device_property_read_u32(hsotg->dev, property, &val32)) |
272 | return; | 260 | return; |
@@ -1100,13 +1088,13 @@ static void dwc2_set_gadget_dma(struct dwc2_hsotg *hsotg) | |||
1100 | /* Buffer DMA */ | 1088 | /* Buffer DMA */ |
1101 | dwc2_set_param_bool(hsotg, &p->g_dma, | 1089 | dwc2_set_param_bool(hsotg, &p->g_dma, |
1102 | false, "gadget-dma", | 1090 | false, "gadget-dma", |
1103 | true, false, | 1091 | dma_capable, false, |
1104 | dma_capable); | 1092 | dma_capable); |
1105 | 1093 | ||
1106 | /* DMA Descriptor */ | 1094 | /* DMA Descriptor */ |
1107 | dwc2_set_param_bool(hsotg, &p->g_dma_desc, false, | 1095 | dwc2_set_param_bool(hsotg, &p->g_dma_desc, false, |
1108 | "gadget-dma-desc", | 1096 | "gadget-dma-desc", |
1109 | p->g_dma, false, | 1097 | !!hw->dma_desc_enable, false, |
1110 | !!hw->dma_desc_enable); | 1098 | !!hw->dma_desc_enable); |
1111 | } | 1099 | } |
1112 | 1100 | ||
@@ -1130,8 +1118,14 @@ static void dwc2_set_parameters(struct dwc2_hsotg *hsotg, | |||
1130 | 1118 | ||
1131 | dwc2_set_param_bool(hsotg, &p->host_dma, | 1119 | dwc2_set_param_bool(hsotg, &p->host_dma, |
1132 | false, "host-dma", | 1120 | false, "host-dma", |
1133 | true, false, | 1121 | dma_capable, false, |
1134 | dma_capable); | 1122 | dma_capable); |
1123 | dwc2_set_param_host_rx_fifo_size(hsotg, | ||
1124 | params->host_rx_fifo_size); | ||
1125 | dwc2_set_param_host_nperio_tx_fifo_size(hsotg, | ||
1126 | params->host_nperio_tx_fifo_size); | ||
1127 | dwc2_set_param_host_perio_tx_fifo_size(hsotg, | ||
1128 | params->host_perio_tx_fifo_size); | ||
1135 | } | 1129 | } |
1136 | dwc2_set_param_dma_desc_enable(hsotg, params->dma_desc_enable); | 1130 | dwc2_set_param_dma_desc_enable(hsotg, params->dma_desc_enable); |
1137 | dwc2_set_param_dma_desc_fs_enable(hsotg, params->dma_desc_fs_enable); | 1131 | dwc2_set_param_dma_desc_fs_enable(hsotg, params->dma_desc_fs_enable); |
@@ -1140,12 +1134,6 @@ static void dwc2_set_parameters(struct dwc2_hsotg *hsotg, | |||
1140 | params->host_support_fs_ls_low_power); | 1134 | params->host_support_fs_ls_low_power); |
1141 | dwc2_set_param_enable_dynamic_fifo(hsotg, | 1135 | dwc2_set_param_enable_dynamic_fifo(hsotg, |
1142 | params->enable_dynamic_fifo); | 1136 | params->enable_dynamic_fifo); |
1143 | dwc2_set_param_host_rx_fifo_size(hsotg, | ||
1144 | params->host_rx_fifo_size); | ||
1145 | dwc2_set_param_host_nperio_tx_fifo_size(hsotg, | ||
1146 | params->host_nperio_tx_fifo_size); | ||
1147 | dwc2_set_param_host_perio_tx_fifo_size(hsotg, | ||
1148 | params->host_perio_tx_fifo_size); | ||
1149 | dwc2_set_param_max_transfer_size(hsotg, | 1137 | dwc2_set_param_max_transfer_size(hsotg, |
1150 | params->max_transfer_size); | 1138 | params->max_transfer_size); |
1151 | dwc2_set_param_max_packet_count(hsotg, | 1139 | dwc2_set_param_max_packet_count(hsotg, |
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index de5a8570be04..14b760209680 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h | |||
@@ -45,9 +45,7 @@ | |||
45 | #define DWC3_XHCI_RESOURCES_NUM 2 | 45 | #define DWC3_XHCI_RESOURCES_NUM 2 |
46 | 46 | ||
47 | #define DWC3_SCRATCHBUF_SIZE 4096 /* each buffer is assumed to be 4KiB */ | 47 | #define DWC3_SCRATCHBUF_SIZE 4096 /* each buffer is assumed to be 4KiB */ |
48 | #define DWC3_EVENT_SIZE 4 /* bytes */ | 48 | #define DWC3_EVENT_BUFFERS_SIZE 4096 |
49 | #define DWC3_EVENT_MAX_NUM 64 /* 2 events/endpoint */ | ||
50 | #define DWC3_EVENT_BUFFERS_SIZE (DWC3_EVENT_SIZE * DWC3_EVENT_MAX_NUM) | ||
51 | #define DWC3_EVENT_TYPE_MASK 0xfe | 49 | #define DWC3_EVENT_TYPE_MASK 0xfe |
52 | 50 | ||
53 | #define DWC3_EVENT_TYPE_DEV 0 | 51 | #define DWC3_EVENT_TYPE_DEV 0 |
@@ -311,9 +309,8 @@ | |||
311 | #define DWC3_DCFG_SUPERSPEED_PLUS (5 << 0) /* DWC_usb31 only */ | 309 | #define DWC3_DCFG_SUPERSPEED_PLUS (5 << 0) /* DWC_usb31 only */ |
312 | #define DWC3_DCFG_SUPERSPEED (4 << 0) | 310 | #define DWC3_DCFG_SUPERSPEED (4 << 0) |
313 | #define DWC3_DCFG_HIGHSPEED (0 << 0) | 311 | #define DWC3_DCFG_HIGHSPEED (0 << 0) |
314 | #define DWC3_DCFG_FULLSPEED2 (1 << 0) | 312 | #define DWC3_DCFG_FULLSPEED (1 << 0) |
315 | #define DWC3_DCFG_LOWSPEED (2 << 0) | 313 | #define DWC3_DCFG_LOWSPEED (2 << 0) |
316 | #define DWC3_DCFG_FULLSPEED1 (3 << 0) | ||
317 | 314 | ||
318 | #define DWC3_DCFG_NUMP_SHIFT 17 | 315 | #define DWC3_DCFG_NUMP_SHIFT 17 |
319 | #define DWC3_DCFG_NUMP(n) (((n) >> DWC3_DCFG_NUMP_SHIFT) & 0x1f) | 316 | #define DWC3_DCFG_NUMP(n) (((n) >> DWC3_DCFG_NUMP_SHIFT) & 0x1f) |
@@ -405,9 +402,8 @@ | |||
405 | #define DWC3_DSTS_SUPERSPEED_PLUS (5 << 0) /* DWC_usb31 only */ | 402 | #define DWC3_DSTS_SUPERSPEED_PLUS (5 << 0) /* DWC_usb31 only */ |
406 | #define DWC3_DSTS_SUPERSPEED (4 << 0) | 403 | #define DWC3_DSTS_SUPERSPEED (4 << 0) |
407 | #define DWC3_DSTS_HIGHSPEED (0 << 0) | 404 | #define DWC3_DSTS_HIGHSPEED (0 << 0) |
408 | #define DWC3_DSTS_FULLSPEED2 (1 << 0) | 405 | #define DWC3_DSTS_FULLSPEED (1 << 0) |
409 | #define DWC3_DSTS_LOWSPEED (2 << 0) | 406 | #define DWC3_DSTS_LOWSPEED (2 << 0) |
410 | #define DWC3_DSTS_FULLSPEED1 (3 << 0) | ||
411 | 407 | ||
412 | /* Device Generic Command Register */ | 408 | /* Device Generic Command Register */ |
413 | #define DWC3_DGCMD_SET_LMP 0x01 | 409 | #define DWC3_DGCMD_SET_LMP 0x01 |
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index 29e80cc9b634..eb1b9cb3f9d1 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/irq.h> | ||
22 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
23 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
24 | #include <linux/platform_data/dwc3-omap.h> | 25 | #include <linux/platform_data/dwc3-omap.h> |
@@ -510,7 +511,7 @@ static int dwc3_omap_probe(struct platform_device *pdev) | |||
510 | 511 | ||
511 | /* check the DMA Status */ | 512 | /* check the DMA Status */ |
512 | reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG); | 513 | reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG); |
513 | 514 | irq_set_status_flags(omap->irq, IRQ_NOAUTOEN); | |
514 | ret = devm_request_threaded_irq(dev, omap->irq, dwc3_omap_interrupt, | 515 | ret = devm_request_threaded_irq(dev, omap->irq, dwc3_omap_interrupt, |
515 | dwc3_omap_interrupt_thread, IRQF_SHARED, | 516 | dwc3_omap_interrupt_thread, IRQF_SHARED, |
516 | "dwc3-omap", omap); | 517 | "dwc3-omap", omap); |
@@ -531,7 +532,7 @@ static int dwc3_omap_probe(struct platform_device *pdev) | |||
531 | } | 532 | } |
532 | 533 | ||
533 | dwc3_omap_enable_irqs(omap); | 534 | dwc3_omap_enable_irqs(omap); |
534 | 535 | enable_irq(omap->irq); | |
535 | return 0; | 536 | return 0; |
536 | 537 | ||
537 | err2: | 538 | err2: |
@@ -552,6 +553,7 @@ static int dwc3_omap_remove(struct platform_device *pdev) | |||
552 | extcon_unregister_notifier(omap->edev, EXTCON_USB, &omap->vbus_nb); | 553 | extcon_unregister_notifier(omap->edev, EXTCON_USB, &omap->vbus_nb); |
553 | extcon_unregister_notifier(omap->edev, EXTCON_USB_HOST, &omap->id_nb); | 554 | extcon_unregister_notifier(omap->edev, EXTCON_USB_HOST, &omap->id_nb); |
554 | dwc3_omap_disable_irqs(omap); | 555 | dwc3_omap_disable_irqs(omap); |
556 | disable_irq(omap->irq); | ||
555 | of_platform_depopulate(omap->dev); | 557 | of_platform_depopulate(omap->dev); |
556 | pm_runtime_put_sync(&pdev->dev); | 558 | pm_runtime_put_sync(&pdev->dev); |
557 | pm_runtime_disable(&pdev->dev); | 559 | pm_runtime_disable(&pdev->dev); |
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index 2b73339f286b..cce0a220b6b0 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #define PCI_DEVICE_ID_INTEL_BXT_M 0x1aaa | 38 | #define PCI_DEVICE_ID_INTEL_BXT_M 0x1aaa |
39 | #define PCI_DEVICE_ID_INTEL_APL 0x5aaa | 39 | #define PCI_DEVICE_ID_INTEL_APL 0x5aaa |
40 | #define PCI_DEVICE_ID_INTEL_KBP 0xa2b0 | 40 | #define PCI_DEVICE_ID_INTEL_KBP 0xa2b0 |
41 | #define PCI_DEVICE_ID_INTEL_GLK 0x31aa | ||
41 | 42 | ||
42 | #define PCI_INTEL_BXT_DSM_UUID "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511" | 43 | #define PCI_INTEL_BXT_DSM_UUID "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511" |
43 | #define PCI_INTEL_BXT_FUNC_PMU_PWR 4 | 44 | #define PCI_INTEL_BXT_FUNC_PMU_PWR 4 |
@@ -73,16 +74,6 @@ static int dwc3_pci_quirks(struct dwc3_pci *dwc) | |||
73 | { | 74 | { |
74 | struct platform_device *dwc3 = dwc->dwc3; | 75 | struct platform_device *dwc3 = dwc->dwc3; |
75 | struct pci_dev *pdev = dwc->pci; | 76 | struct pci_dev *pdev = dwc->pci; |
76 | int ret; | ||
77 | |||
78 | struct property_entry sysdev_property[] = { | ||
79 | PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"), | ||
80 | { }, | ||
81 | }; | ||
82 | |||
83 | ret = platform_device_add_properties(dwc3, sysdev_property); | ||
84 | if (ret) | ||
85 | return ret; | ||
86 | 77 | ||
87 | if (pdev->vendor == PCI_VENDOR_ID_AMD && | 78 | if (pdev->vendor == PCI_VENDOR_ID_AMD && |
88 | pdev->device == PCI_DEVICE_ID_AMD_NL_USB) { | 79 | pdev->device == PCI_DEVICE_ID_AMD_NL_USB) { |
@@ -105,6 +96,7 @@ static int dwc3_pci_quirks(struct dwc3_pci *dwc) | |||
105 | PROPERTY_ENTRY_BOOL("snps,disable_scramble_quirk"), | 96 | PROPERTY_ENTRY_BOOL("snps,disable_scramble_quirk"), |
106 | PROPERTY_ENTRY_BOOL("snps,dis_u3_susphy_quirk"), | 97 | PROPERTY_ENTRY_BOOL("snps,dis_u3_susphy_quirk"), |
107 | PROPERTY_ENTRY_BOOL("snps,dis_u2_susphy_quirk"), | 98 | PROPERTY_ENTRY_BOOL("snps,dis_u2_susphy_quirk"), |
99 | PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"), | ||
108 | { }, | 100 | { }, |
109 | }; | 101 | }; |
110 | 102 | ||
@@ -115,7 +107,8 @@ static int dwc3_pci_quirks(struct dwc3_pci *dwc) | |||
115 | int ret; | 107 | int ret; |
116 | 108 | ||
117 | struct property_entry properties[] = { | 109 | struct property_entry properties[] = { |
118 | PROPERTY_ENTRY_STRING("dr-mode", "peripheral"), | 110 | PROPERTY_ENTRY_STRING("dr_mode", "peripheral"), |
111 | PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"), | ||
119 | { } | 112 | { } |
120 | }; | 113 | }; |
121 | 114 | ||
@@ -167,6 +160,7 @@ static int dwc3_pci_quirks(struct dwc3_pci *dwc) | |||
167 | PROPERTY_ENTRY_BOOL("snps,usb3_lpm_capable"), | 160 | PROPERTY_ENTRY_BOOL("snps,usb3_lpm_capable"), |
168 | PROPERTY_ENTRY_BOOL("snps,has-lpm-erratum"), | 161 | PROPERTY_ENTRY_BOOL("snps,has-lpm-erratum"), |
169 | PROPERTY_ENTRY_BOOL("snps,dis_enblslpm_quirk"), | 162 | PROPERTY_ENTRY_BOOL("snps,dis_enblslpm_quirk"), |
163 | PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"), | ||
170 | { }, | 164 | { }, |
171 | }; | 165 | }; |
172 | 166 | ||
@@ -274,6 +268,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = { | |||
274 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT_M), }, | 268 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT_M), }, |
275 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), }, | 269 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), }, |
276 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBP), }, | 270 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBP), }, |
271 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_GLK), }, | ||
277 | { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), }, | 272 | { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), }, |
278 | { } /* Terminating Entry */ | 273 | { } /* Terminating Entry */ |
279 | }; | 274 | }; |
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index 4878d187c7d4..9bb1f8526f3e 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c | |||
@@ -39,18 +39,13 @@ static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep); | |||
39 | static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, | 39 | static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, |
40 | struct dwc3_ep *dep, struct dwc3_request *req); | 40 | struct dwc3_ep *dep, struct dwc3_request *req); |
41 | 41 | ||
42 | static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, | 42 | static void dwc3_ep0_prepare_one_trb(struct dwc3 *dwc, u8 epnum, |
43 | u32 len, u32 type, bool chain) | 43 | dma_addr_t buf_dma, u32 len, u32 type, bool chain) |
44 | { | 44 | { |
45 | struct dwc3_gadget_ep_cmd_params params; | ||
46 | struct dwc3_trb *trb; | 45 | struct dwc3_trb *trb; |
47 | struct dwc3_ep *dep; | 46 | struct dwc3_ep *dep; |
48 | 47 | ||
49 | int ret; | ||
50 | |||
51 | dep = dwc->eps[epnum]; | 48 | dep = dwc->eps[epnum]; |
52 | if (dep->flags & DWC3_EP_BUSY) | ||
53 | return 0; | ||
54 | 49 | ||
55 | trb = &dwc->ep0_trb[dep->trb_enqueue]; | 50 | trb = &dwc->ep0_trb[dep->trb_enqueue]; |
56 | 51 | ||
@@ -71,15 +66,23 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, | |||
71 | trb->ctrl |= (DWC3_TRB_CTRL_IOC | 66 | trb->ctrl |= (DWC3_TRB_CTRL_IOC |
72 | | DWC3_TRB_CTRL_LST); | 67 | | DWC3_TRB_CTRL_LST); |
73 | 68 | ||
74 | if (chain) | 69 | trace_dwc3_prepare_trb(dep, trb); |
70 | } | ||
71 | |||
72 | static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum) | ||
73 | { | ||
74 | struct dwc3_gadget_ep_cmd_params params; | ||
75 | struct dwc3_ep *dep; | ||
76 | int ret; | ||
77 | |||
78 | dep = dwc->eps[epnum]; | ||
79 | if (dep->flags & DWC3_EP_BUSY) | ||
75 | return 0; | 80 | return 0; |
76 | 81 | ||
77 | memset(¶ms, 0, sizeof(params)); | 82 | memset(¶ms, 0, sizeof(params)); |
78 | params.param0 = upper_32_bits(dwc->ep0_trb_addr); | 83 | params.param0 = upper_32_bits(dwc->ep0_trb_addr); |
79 | params.param1 = lower_32_bits(dwc->ep0_trb_addr); | 84 | params.param1 = lower_32_bits(dwc->ep0_trb_addr); |
80 | 85 | ||
81 | trace_dwc3_prepare_trb(dep, trb); | ||
82 | |||
83 | ret = dwc3_send_gadget_ep_cmd(dep, DWC3_DEPCMD_STARTTRANSFER, ¶ms); | 86 | ret = dwc3_send_gadget_ep_cmd(dep, DWC3_DEPCMD_STARTTRANSFER, ¶ms); |
84 | if (ret < 0) | 87 | if (ret < 0) |
85 | return ret; | 88 | return ret; |
@@ -280,8 +283,9 @@ void dwc3_ep0_out_start(struct dwc3 *dwc) | |||
280 | 283 | ||
281 | complete(&dwc->ep0_in_setup); | 284 | complete(&dwc->ep0_in_setup); |
282 | 285 | ||
283 | ret = dwc3_ep0_start_trans(dwc, 0, dwc->ctrl_req_addr, 8, | 286 | dwc3_ep0_prepare_one_trb(dwc, 0, dwc->ctrl_req_addr, 8, |
284 | DWC3_TRBCTL_CONTROL_SETUP, false); | 287 | DWC3_TRBCTL_CONTROL_SETUP, false); |
288 | ret = dwc3_ep0_start_trans(dwc, 0); | ||
285 | WARN_ON(ret < 0); | 289 | WARN_ON(ret < 0); |
286 | } | 290 | } |
287 | 291 | ||
@@ -912,9 +916,9 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, | |||
912 | 916 | ||
913 | dwc->ep0_next_event = DWC3_EP0_COMPLETE; | 917 | dwc->ep0_next_event = DWC3_EP0_COMPLETE; |
914 | 918 | ||
915 | ret = dwc3_ep0_start_trans(dwc, epnum, | 919 | dwc3_ep0_prepare_one_trb(dwc, epnum, dwc->ctrl_req_addr, |
916 | dwc->ctrl_req_addr, 0, | 920 | 0, DWC3_TRBCTL_CONTROL_DATA, false); |
917 | DWC3_TRBCTL_CONTROL_DATA, false); | 921 | ret = dwc3_ep0_start_trans(dwc, epnum); |
918 | WARN_ON(ret < 0); | 922 | WARN_ON(ret < 0); |
919 | } | 923 | } |
920 | } | 924 | } |
@@ -993,9 +997,10 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, | |||
993 | req->direction = !!dep->number; | 997 | req->direction = !!dep->number; |
994 | 998 | ||
995 | if (req->request.length == 0) { | 999 | if (req->request.length == 0) { |
996 | ret = dwc3_ep0_start_trans(dwc, dep->number, | 1000 | dwc3_ep0_prepare_one_trb(dwc, dep->number, |
997 | dwc->ctrl_req_addr, 0, | 1001 | dwc->ctrl_req_addr, 0, |
998 | DWC3_TRBCTL_CONTROL_DATA, false); | 1002 | DWC3_TRBCTL_CONTROL_DATA, false); |
1003 | ret = dwc3_ep0_start_trans(dwc, dep->number); | ||
999 | } else if (!IS_ALIGNED(req->request.length, dep->endpoint.maxpacket) | 1004 | } else if (!IS_ALIGNED(req->request.length, dep->endpoint.maxpacket) |
1000 | && (dep->number == 0)) { | 1005 | && (dep->number == 0)) { |
1001 | u32 transfer_size = 0; | 1006 | u32 transfer_size = 0; |
@@ -1011,7 +1016,7 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, | |||
1011 | if (req->request.length > DWC3_EP0_BOUNCE_SIZE) { | 1016 | if (req->request.length > DWC3_EP0_BOUNCE_SIZE) { |
1012 | transfer_size = ALIGN(req->request.length - maxpacket, | 1017 | transfer_size = ALIGN(req->request.length - maxpacket, |
1013 | maxpacket); | 1018 | maxpacket); |
1014 | ret = dwc3_ep0_start_trans(dwc, dep->number, | 1019 | dwc3_ep0_prepare_one_trb(dwc, dep->number, |
1015 | req->request.dma, | 1020 | req->request.dma, |
1016 | transfer_size, | 1021 | transfer_size, |
1017 | DWC3_TRBCTL_CONTROL_DATA, | 1022 | DWC3_TRBCTL_CONTROL_DATA, |
@@ -1023,18 +1028,20 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, | |||
1023 | 1028 | ||
1024 | dwc->ep0_bounced = true; | 1029 | dwc->ep0_bounced = true; |
1025 | 1030 | ||
1026 | ret = dwc3_ep0_start_trans(dwc, dep->number, | 1031 | dwc3_ep0_prepare_one_trb(dwc, dep->number, |
1027 | dwc->ep0_bounce_addr, transfer_size, | 1032 | dwc->ep0_bounce_addr, transfer_size, |
1028 | DWC3_TRBCTL_CONTROL_DATA, false); | 1033 | DWC3_TRBCTL_CONTROL_DATA, false); |
1034 | ret = dwc3_ep0_start_trans(dwc, dep->number); | ||
1029 | } else { | 1035 | } else { |
1030 | ret = usb_gadget_map_request_by_dev(dwc->sysdev, | 1036 | ret = usb_gadget_map_request_by_dev(dwc->sysdev, |
1031 | &req->request, dep->number); | 1037 | &req->request, dep->number); |
1032 | if (ret) | 1038 | if (ret) |
1033 | return; | 1039 | return; |
1034 | 1040 | ||
1035 | ret = dwc3_ep0_start_trans(dwc, dep->number, req->request.dma, | 1041 | dwc3_ep0_prepare_one_trb(dwc, dep->number, req->request.dma, |
1036 | req->request.length, DWC3_TRBCTL_CONTROL_DATA, | 1042 | req->request.length, DWC3_TRBCTL_CONTROL_DATA, |
1037 | false); | 1043 | false); |
1044 | ret = dwc3_ep0_start_trans(dwc, dep->number); | ||
1038 | } | 1045 | } |
1039 | 1046 | ||
1040 | WARN_ON(ret < 0); | 1047 | WARN_ON(ret < 0); |
@@ -1048,8 +1055,9 @@ static int dwc3_ep0_start_control_status(struct dwc3_ep *dep) | |||
1048 | type = dwc->three_stage_setup ? DWC3_TRBCTL_CONTROL_STATUS3 | 1055 | type = dwc->three_stage_setup ? DWC3_TRBCTL_CONTROL_STATUS3 |
1049 | : DWC3_TRBCTL_CONTROL_STATUS2; | 1056 | : DWC3_TRBCTL_CONTROL_STATUS2; |
1050 | 1057 | ||
1051 | return dwc3_ep0_start_trans(dwc, dep->number, | 1058 | dwc3_ep0_prepare_one_trb(dwc, dep->number, |
1052 | dwc->ctrl_req_addr, 0, type, false); | 1059 | dwc->ctrl_req_addr, 0, type, false); |
1060 | return dwc3_ep0_start_trans(dwc, dep->number); | ||
1053 | } | 1061 | } |
1054 | 1062 | ||
1055 | static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep) | 1063 | static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep) |
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index efddaf5d11d1..204c754cc647 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
@@ -180,11 +180,11 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, | |||
180 | if (req->request.status == -EINPROGRESS) | 180 | if (req->request.status == -EINPROGRESS) |
181 | req->request.status = status; | 181 | req->request.status = status; |
182 | 182 | ||
183 | if (dwc->ep0_bounced && dep->number == 0) | 183 | if (dwc->ep0_bounced && dep->number <= 1) |
184 | dwc->ep0_bounced = false; | 184 | dwc->ep0_bounced = false; |
185 | else | 185 | |
186 | usb_gadget_unmap_request_by_dev(dwc->sysdev, | 186 | usb_gadget_unmap_request_by_dev(dwc->sysdev, |
187 | &req->request, req->direction); | 187 | &req->request, req->direction); |
188 | 188 | ||
189 | trace_dwc3_gadget_giveback(req); | 189 | trace_dwc3_gadget_giveback(req); |
190 | 190 | ||
@@ -1720,7 +1720,7 @@ static int __dwc3_gadget_start(struct dwc3 *dwc) | |||
1720 | reg |= DWC3_DCFG_LOWSPEED; | 1720 | reg |= DWC3_DCFG_LOWSPEED; |
1721 | break; | 1721 | break; |
1722 | case USB_SPEED_FULL: | 1722 | case USB_SPEED_FULL: |
1723 | reg |= DWC3_DCFG_FULLSPEED1; | 1723 | reg |= DWC3_DCFG_FULLSPEED; |
1724 | break; | 1724 | break; |
1725 | case USB_SPEED_HIGH: | 1725 | case USB_SPEED_HIGH: |
1726 | reg |= DWC3_DCFG_HIGHSPEED; | 1726 | reg |= DWC3_DCFG_HIGHSPEED; |
@@ -2232,9 +2232,14 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc, | |||
2232 | 2232 | ||
2233 | dep = dwc->eps[epnum]; | 2233 | dep = dwc->eps[epnum]; |
2234 | 2234 | ||
2235 | if (!(dep->flags & DWC3_EP_ENABLED) && | 2235 | if (!(dep->flags & DWC3_EP_ENABLED)) { |
2236 | !(dep->flags & DWC3_EP_END_TRANSFER_PENDING)) | 2236 | if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING)) |
2237 | return; | 2237 | return; |
2238 | |||
2239 | /* Handle only EPCMDCMPLT when EP disabled */ | ||
2240 | if (event->endpoint_event != DWC3_DEPEVT_EPCMDCMPLT) | ||
2241 | return; | ||
2242 | } | ||
2238 | 2243 | ||
2239 | if (epnum == 0 || epnum == 1) { | 2244 | if (epnum == 0 || epnum == 1) { |
2240 | dwc3_ep0_interrupt(dwc, event); | 2245 | dwc3_ep0_interrupt(dwc, event); |
@@ -2531,8 +2536,7 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) | |||
2531 | dwc->gadget.ep0->maxpacket = 64; | 2536 | dwc->gadget.ep0->maxpacket = 64; |
2532 | dwc->gadget.speed = USB_SPEED_HIGH; | 2537 | dwc->gadget.speed = USB_SPEED_HIGH; |
2533 | break; | 2538 | break; |
2534 | case DWC3_DSTS_FULLSPEED2: | 2539 | case DWC3_DSTS_FULLSPEED: |
2535 | case DWC3_DSTS_FULLSPEED1: | ||
2536 | dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(64); | 2540 | dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(64); |
2537 | dwc->gadget.ep0->maxpacket = 64; | 2541 | dwc->gadget.ep0->maxpacket = 64; |
2538 | dwc->gadget.speed = USB_SPEED_FULL; | 2542 | dwc->gadget.speed = USB_SPEED_FULL; |
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 41ab61f9b6e0..002822d98fda 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c | |||
@@ -1694,9 +1694,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
1694 | value = min(w_length, (u16) 1); | 1694 | value = min(w_length, (u16) 1); |
1695 | break; | 1695 | break; |
1696 | 1696 | ||
1697 | /* function drivers must handle get/set altsetting; if there's | 1697 | /* function drivers must handle get/set altsetting */ |
1698 | * no get() method, we know only altsetting zero works. | ||
1699 | */ | ||
1700 | case USB_REQ_SET_INTERFACE: | 1698 | case USB_REQ_SET_INTERFACE: |
1701 | if (ctrl->bRequestType != USB_RECIP_INTERFACE) | 1699 | if (ctrl->bRequestType != USB_RECIP_INTERFACE) |
1702 | goto unknown; | 1700 | goto unknown; |
@@ -1705,7 +1703,13 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
1705 | f = cdev->config->interface[intf]; | 1703 | f = cdev->config->interface[intf]; |
1706 | if (!f) | 1704 | if (!f) |
1707 | break; | 1705 | break; |
1708 | if (w_value && !f->set_alt) | 1706 | |
1707 | /* | ||
1708 | * If there's no get_alt() method, we know only altsetting zero | ||
1709 | * works. There is no need to check if set_alt() is not NULL | ||
1710 | * as we check this in usb_add_function(). | ||
1711 | */ | ||
1712 | if (w_value && !f->get_alt) | ||
1709 | break; | 1713 | break; |
1710 | value = f->set_alt(f, w_index, w_value); | 1714 | value = f->set_alt(f, w_index, w_value); |
1711 | if (value == USB_GADGET_DELAYED_STATUS) { | 1715 | if (value == USB_GADGET_DELAYED_STATUS) { |
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index aab3fc1dbb94..5e746adc8a2d 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c | |||
@@ -2091,8 +2091,8 @@ static int __ffs_data_do_entity(enum ffs_entity_type type, | |||
2091 | 2091 | ||
2092 | case FFS_STRING: | 2092 | case FFS_STRING: |
2093 | /* | 2093 | /* |
2094 | * Strings are indexed from 1 (0 is magic ;) reserved | 2094 | * Strings are indexed from 1 (0 is reserved |
2095 | * for languages list or some such) | 2095 | * for languages list) |
2096 | */ | 2096 | */ |
2097 | if (*valuep > helper->ffs->strings_count) | 2097 | if (*valuep > helper->ffs->strings_count) |
2098 | helper->ffs->strings_count = *valuep; | 2098 | helper->ffs->strings_count = *valuep; |
@@ -2252,7 +2252,7 @@ static int __ffs_data_do_os_desc(enum ffs_os_desc_type type, | |||
2252 | 2252 | ||
2253 | if (len < sizeof(*d) || | 2253 | if (len < sizeof(*d) || |
2254 | d->bFirstInterfaceNumber >= ffs->interfaces_count || | 2254 | d->bFirstInterfaceNumber >= ffs->interfaces_count || |
2255 | !d->Reserved1) | 2255 | d->Reserved1) |
2256 | return -EINVAL; | 2256 | return -EINVAL; |
2257 | for (i = 0; i < ARRAY_SIZE(d->Reserved2); ++i) | 2257 | for (i = 0; i < ARRAY_SIZE(d->Reserved2); ++i) |
2258 | if (d->Reserved2[i]) | 2258 | if (d->Reserved2[i]) |
@@ -3666,6 +3666,7 @@ static void ffs_closed(struct ffs_data *ffs) | |||
3666 | { | 3666 | { |
3667 | struct ffs_dev *ffs_obj; | 3667 | struct ffs_dev *ffs_obj; |
3668 | struct f_fs_opts *opts; | 3668 | struct f_fs_opts *opts; |
3669 | struct config_item *ci; | ||
3669 | 3670 | ||
3670 | ENTER(); | 3671 | ENTER(); |
3671 | ffs_dev_lock(); | 3672 | ffs_dev_lock(); |
@@ -3689,8 +3690,11 @@ static void ffs_closed(struct ffs_data *ffs) | |||
3689 | || !atomic_read(&opts->func_inst.group.cg_item.ci_kref.refcount)) | 3690 | || !atomic_read(&opts->func_inst.group.cg_item.ci_kref.refcount)) |
3690 | goto done; | 3691 | goto done; |
3691 | 3692 | ||
3692 | unregister_gadget_item(ffs_obj->opts-> | 3693 | ci = opts->func_inst.group.cg_item.ci_parent->ci_parent; |
3693 | func_inst.group.cg_item.ci_parent->ci_parent); | 3694 | ffs_dev_unlock(); |
3695 | |||
3696 | unregister_gadget_item(ci); | ||
3697 | return; | ||
3694 | done: | 3698 | done: |
3695 | ffs_dev_unlock(); | 3699 | ffs_dev_unlock(); |
3696 | } | 3700 | } |
diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c index 3151d2a0fe59..5f8139b8e601 100644 --- a/drivers/usb/gadget/function/f_hid.c +++ b/drivers/usb/gadget/function/f_hid.c | |||
@@ -593,7 +593,7 @@ static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
593 | } | 593 | } |
594 | status = usb_ep_enable(hidg->out_ep); | 594 | status = usb_ep_enable(hidg->out_ep); |
595 | if (status < 0) { | 595 | if (status < 0) { |
596 | ERROR(cdev, "Enable IN endpoint FAILED!\n"); | 596 | ERROR(cdev, "Enable OUT endpoint FAILED!\n"); |
597 | goto fail; | 597 | goto fail; |
598 | } | 598 | } |
599 | hidg->out_ep->driver_data = hidg; | 599 | hidg->out_ep->driver_data = hidg; |
diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c index e8f4102d19df..6bde4396927c 100644 --- a/drivers/usb/gadget/legacy/inode.c +++ b/drivers/usb/gadget/legacy/inode.c | |||
@@ -1126,7 +1126,7 @@ ep0_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
1126 | /* data and/or status stage for control request */ | 1126 | /* data and/or status stage for control request */ |
1127 | } else if (dev->state == STATE_DEV_SETUP) { | 1127 | } else if (dev->state == STATE_DEV_SETUP) { |
1128 | 1128 | ||
1129 | /* IN DATA+STATUS caller makes len <= wLength */ | 1129 | len = min_t(size_t, len, dev->setup_wLength); |
1130 | if (dev->setup_in) { | 1130 | if (dev->setup_in) { |
1131 | retval = setup_req (dev->gadget->ep0, dev->req, len); | 1131 | retval = setup_req (dev->gadget->ep0, dev->req, len); |
1132 | if (retval == 0) { | 1132 | if (retval == 0) { |
@@ -1734,10 +1734,12 @@ static struct usb_gadget_driver gadgetfs_driver = { | |||
1734 | * such as configuration notifications. | 1734 | * such as configuration notifications. |
1735 | */ | 1735 | */ |
1736 | 1736 | ||
1737 | static int is_valid_config (struct usb_config_descriptor *config) | 1737 | static int is_valid_config(struct usb_config_descriptor *config, |
1738 | unsigned int total) | ||
1738 | { | 1739 | { |
1739 | return config->bDescriptorType == USB_DT_CONFIG | 1740 | return config->bDescriptorType == USB_DT_CONFIG |
1740 | && config->bLength == USB_DT_CONFIG_SIZE | 1741 | && config->bLength == USB_DT_CONFIG_SIZE |
1742 | && total >= USB_DT_CONFIG_SIZE | ||
1741 | && config->bConfigurationValue != 0 | 1743 | && config->bConfigurationValue != 0 |
1742 | && (config->bmAttributes & USB_CONFIG_ATT_ONE) != 0 | 1744 | && (config->bmAttributes & USB_CONFIG_ATT_ONE) != 0 |
1743 | && (config->bmAttributes & USB_CONFIG_ATT_WAKEUP) == 0; | 1745 | && (config->bmAttributes & USB_CONFIG_ATT_WAKEUP) == 0; |
@@ -1762,7 +1764,8 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
1762 | } | 1764 | } |
1763 | spin_unlock_irq(&dev->lock); | 1765 | spin_unlock_irq(&dev->lock); |
1764 | 1766 | ||
1765 | if (len < (USB_DT_CONFIG_SIZE + USB_DT_DEVICE_SIZE + 4)) | 1767 | if ((len < (USB_DT_CONFIG_SIZE + USB_DT_DEVICE_SIZE + 4)) || |
1768 | (len > PAGE_SIZE * 4)) | ||
1766 | return -EINVAL; | 1769 | return -EINVAL; |
1767 | 1770 | ||
1768 | /* we might need to change message format someday */ | 1771 | /* we might need to change message format someday */ |
@@ -1786,7 +1789,8 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
1786 | /* full or low speed config */ | 1789 | /* full or low speed config */ |
1787 | dev->config = (void *) kbuf; | 1790 | dev->config = (void *) kbuf; |
1788 | total = le16_to_cpu(dev->config->wTotalLength); | 1791 | total = le16_to_cpu(dev->config->wTotalLength); |
1789 | if (!is_valid_config (dev->config) || total >= length) | 1792 | if (!is_valid_config(dev->config, total) || |
1793 | total > length - USB_DT_DEVICE_SIZE) | ||
1790 | goto fail; | 1794 | goto fail; |
1791 | kbuf += total; | 1795 | kbuf += total; |
1792 | length -= total; | 1796 | length -= total; |
@@ -1795,10 +1799,13 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
1795 | if (kbuf [1] == USB_DT_CONFIG) { | 1799 | if (kbuf [1] == USB_DT_CONFIG) { |
1796 | dev->hs_config = (void *) kbuf; | 1800 | dev->hs_config = (void *) kbuf; |
1797 | total = le16_to_cpu(dev->hs_config->wTotalLength); | 1801 | total = le16_to_cpu(dev->hs_config->wTotalLength); |
1798 | if (!is_valid_config (dev->hs_config) || total >= length) | 1802 | if (!is_valid_config(dev->hs_config, total) || |
1803 | total > length - USB_DT_DEVICE_SIZE) | ||
1799 | goto fail; | 1804 | goto fail; |
1800 | kbuf += total; | 1805 | kbuf += total; |
1801 | length -= total; | 1806 | length -= total; |
1807 | } else { | ||
1808 | dev->hs_config = NULL; | ||
1802 | } | 1809 | } |
1803 | 1810 | ||
1804 | /* could support multiple configs, using another encoding! */ | 1811 | /* could support multiple configs, using another encoding! */ |
@@ -1811,7 +1818,6 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
1811 | || dev->dev->bDescriptorType != USB_DT_DEVICE | 1818 | || dev->dev->bDescriptorType != USB_DT_DEVICE |
1812 | || dev->dev->bNumConfigurations != 1) | 1819 | || dev->dev->bNumConfigurations != 1) |
1813 | goto fail; | 1820 | goto fail; |
1814 | dev->dev->bNumConfigurations = 1; | ||
1815 | dev->dev->bcdUSB = cpu_to_le16 (0x0200); | 1821 | dev->dev->bcdUSB = cpu_to_le16 (0x0200); |
1816 | 1822 | ||
1817 | /* triggers gadgetfs_bind(); then we can enumerate. */ | 1823 | /* triggers gadgetfs_bind(); then we can enumerate. */ |
diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c index 9483489080f6..0402177f93cd 100644 --- a/drivers/usb/gadget/udc/core.c +++ b/drivers/usb/gadget/udc/core.c | |||
@@ -1317,7 +1317,11 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver) | |||
1317 | if (!ret) | 1317 | if (!ret) |
1318 | break; | 1318 | break; |
1319 | } | 1319 | } |
1320 | if (!ret && !udc->driver) | 1320 | if (ret) |
1321 | ret = -ENODEV; | ||
1322 | else if (udc->driver) | ||
1323 | ret = -EBUSY; | ||
1324 | else | ||
1321 | goto found; | 1325 | goto found; |
1322 | } else { | 1326 | } else { |
1323 | list_for_each_entry(udc, &udc_list, list) { | 1327 | list_for_each_entry(udc, &udc_list, list) { |
diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c index 02b14e91ae6c..c60abe3a68f9 100644 --- a/drivers/usb/gadget/udc/dummy_hcd.c +++ b/drivers/usb/gadget/udc/dummy_hcd.c | |||
@@ -330,7 +330,7 @@ static void nuke(struct dummy *dum, struct dummy_ep *ep) | |||
330 | /* caller must hold lock */ | 330 | /* caller must hold lock */ |
331 | static void stop_activity(struct dummy *dum) | 331 | static void stop_activity(struct dummy *dum) |
332 | { | 332 | { |
333 | struct dummy_ep *ep; | 333 | int i; |
334 | 334 | ||
335 | /* prevent any more requests */ | 335 | /* prevent any more requests */ |
336 | dum->address = 0; | 336 | dum->address = 0; |
@@ -338,8 +338,8 @@ static void stop_activity(struct dummy *dum) | |||
338 | /* The timer is left running so that outstanding URBs can fail */ | 338 | /* The timer is left running so that outstanding URBs can fail */ |
339 | 339 | ||
340 | /* nuke any pending requests first, so driver i/o is quiesced */ | 340 | /* nuke any pending requests first, so driver i/o is quiesced */ |
341 | list_for_each_entry(ep, &dum->gadget.ep_list, ep.ep_list) | 341 | for (i = 0; i < DUMMY_ENDPOINTS; ++i) |
342 | nuke(dum, ep); | 342 | nuke(dum, &dum->ep[i]); |
343 | 343 | ||
344 | /* driver now does any non-usb quiescing necessary */ | 344 | /* driver now does any non-usb quiescing necessary */ |
345 | } | 345 | } |
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index be9e63836881..414e3c376dbb 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c | |||
@@ -43,7 +43,6 @@ struct at91_usbh_data { | |||
43 | struct gpio_desc *overcurrent_pin[AT91_MAX_USBH_PORTS]; | 43 | struct gpio_desc *overcurrent_pin[AT91_MAX_USBH_PORTS]; |
44 | u8 ports; /* number of ports on root hub */ | 44 | u8 ports; /* number of ports on root hub */ |
45 | u8 overcurrent_supported; | 45 | u8 overcurrent_supported; |
46 | u8 vbus_pin_active_low[AT91_MAX_USBH_PORTS]; | ||
47 | u8 overcurrent_status[AT91_MAX_USBH_PORTS]; | 46 | u8 overcurrent_status[AT91_MAX_USBH_PORTS]; |
48 | u8 overcurrent_changed[AT91_MAX_USBH_PORTS]; | 47 | u8 overcurrent_changed[AT91_MAX_USBH_PORTS]; |
49 | }; | 48 | }; |
@@ -266,8 +265,7 @@ static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int | |||
266 | if (!valid_port(port)) | 265 | if (!valid_port(port)) |
267 | return; | 266 | return; |
268 | 267 | ||
269 | gpiod_set_value(pdata->vbus_pin[port], | 268 | gpiod_set_value(pdata->vbus_pin[port], enable); |
270 | pdata->vbus_pin_active_low[port] ^ enable); | ||
271 | } | 269 | } |
272 | 270 | ||
273 | static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port) | 271 | static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port) |
@@ -275,8 +273,7 @@ static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port) | |||
275 | if (!valid_port(port)) | 273 | if (!valid_port(port)) |
276 | return -EINVAL; | 274 | return -EINVAL; |
277 | 275 | ||
278 | return gpiod_get_value(pdata->vbus_pin[port]) ^ | 276 | return gpiod_get_value(pdata->vbus_pin[port]); |
279 | pdata->vbus_pin_active_low[port]; | ||
280 | } | 277 | } |
281 | 278 | ||
282 | /* | 279 | /* |
@@ -533,18 +530,17 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) | |||
533 | pdata->ports = ports; | 530 | pdata->ports = ports; |
534 | 531 | ||
535 | at91_for_each_port(i) { | 532 | at91_for_each_port(i) { |
536 | pdata->vbus_pin[i] = devm_gpiod_get_optional(&pdev->dev, | 533 | if (i >= pdata->ports) |
537 | "atmel,vbus-gpio", | 534 | break; |
538 | GPIOD_IN); | 535 | |
536 | pdata->vbus_pin[i] = | ||
537 | devm_gpiod_get_index_optional(&pdev->dev, "atmel,vbus", | ||
538 | i, GPIOD_OUT_HIGH); | ||
539 | if (IS_ERR(pdata->vbus_pin[i])) { | 539 | if (IS_ERR(pdata->vbus_pin[i])) { |
540 | err = PTR_ERR(pdata->vbus_pin[i]); | 540 | err = PTR_ERR(pdata->vbus_pin[i]); |
541 | dev_err(&pdev->dev, "unable to claim gpio \"vbus\": %d\n", err); | 541 | dev_err(&pdev->dev, "unable to claim gpio \"vbus\": %d\n", err); |
542 | continue; | 542 | continue; |
543 | } | 543 | } |
544 | |||
545 | pdata->vbus_pin_active_low[i] = gpiod_get_value(pdata->vbus_pin[i]); | ||
546 | |||
547 | ohci_at91_usb_set_power(pdata, i, 1); | ||
548 | } | 544 | } |
549 | 545 | ||
550 | at91_for_each_port(i) { | 546 | at91_for_each_port(i) { |
@@ -552,8 +548,8 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) | |||
552 | break; | 548 | break; |
553 | 549 | ||
554 | pdata->overcurrent_pin[i] = | 550 | pdata->overcurrent_pin[i] = |
555 | devm_gpiod_get_optional(&pdev->dev, | 551 | devm_gpiod_get_index_optional(&pdev->dev, "atmel,oc", |
556 | "atmel,oc-gpio", GPIOD_IN); | 552 | i, GPIOD_IN); |
557 | if (IS_ERR(pdata->overcurrent_pin[i])) { | 553 | if (IS_ERR(pdata->overcurrent_pin[i])) { |
558 | err = PTR_ERR(pdata->overcurrent_pin[i]); | 554 | err = PTR_ERR(pdata->overcurrent_pin[i]); |
559 | dev_err(&pdev->dev, "unable to claim gpio \"overcurrent\": %d\n", err); | 555 | dev_err(&pdev->dev, "unable to claim gpio \"overcurrent\": %d\n", err); |
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 321de2e0161b..8414ed2a02de 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c | |||
@@ -979,6 +979,40 @@ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id) | |||
979 | xhci->devs[slot_id] = NULL; | 979 | xhci->devs[slot_id] = NULL; |
980 | } | 980 | } |
981 | 981 | ||
982 | /* | ||
983 | * Free a virt_device structure. | ||
984 | * If the virt_device added a tt_info (a hub) and has children pointing to | ||
985 | * that tt_info, then free the child first. Recursive. | ||
986 | * We can't rely on udev at this point to find child-parent relationships. | ||
987 | */ | ||
988 | void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_id) | ||
989 | { | ||
990 | struct xhci_virt_device *vdev; | ||
991 | struct list_head *tt_list_head; | ||
992 | struct xhci_tt_bw_info *tt_info, *next; | ||
993 | int i; | ||
994 | |||
995 | vdev = xhci->devs[slot_id]; | ||
996 | if (!vdev) | ||
997 | return; | ||
998 | |||
999 | tt_list_head = &(xhci->rh_bw[vdev->real_port - 1].tts); | ||
1000 | list_for_each_entry_safe(tt_info, next, tt_list_head, tt_list) { | ||
1001 | /* is this a hub device that added a tt_info to the tts list */ | ||
1002 | if (tt_info->slot_id == slot_id) { | ||
1003 | /* are any devices using this tt_info? */ | ||
1004 | for (i = 1; i < HCS_MAX_SLOTS(xhci->hcs_params1); i++) { | ||
1005 | vdev = xhci->devs[i]; | ||
1006 | if (vdev && (vdev->tt_info == tt_info)) | ||
1007 | xhci_free_virt_devices_depth_first( | ||
1008 | xhci, i); | ||
1009 | } | ||
1010 | } | ||
1011 | } | ||
1012 | /* we are now at a leaf device */ | ||
1013 | xhci_free_virt_device(xhci, slot_id); | ||
1014 | } | ||
1015 | |||
982 | int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, | 1016 | int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, |
983 | struct usb_device *udev, gfp_t flags) | 1017 | struct usb_device *udev, gfp_t flags) |
984 | { | 1018 | { |
@@ -1795,7 +1829,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci) | |||
1795 | int size; | 1829 | int size; |
1796 | int i, j, num_ports; | 1830 | int i, j, num_ports; |
1797 | 1831 | ||
1798 | del_timer_sync(&xhci->cmd_timer); | 1832 | cancel_delayed_work_sync(&xhci->cmd_timer); |
1799 | 1833 | ||
1800 | /* Free the Event Ring Segment Table and the actual Event Ring */ | 1834 | /* Free the Event Ring Segment Table and the actual Event Ring */ |
1801 | size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries); | 1835 | size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries); |
@@ -1828,8 +1862,8 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci) | |||
1828 | } | 1862 | } |
1829 | } | 1863 | } |
1830 | 1864 | ||
1831 | for (i = 1; i < MAX_HC_SLOTS; ++i) | 1865 | for (i = HCS_MAX_SLOTS(xhci->hcs_params1); i > 0; i--) |
1832 | xhci_free_virt_device(xhci, i); | 1866 | xhci_free_virt_devices_depth_first(xhci, i); |
1833 | 1867 | ||
1834 | dma_pool_destroy(xhci->segment_pool); | 1868 | dma_pool_destroy(xhci->segment_pool); |
1835 | xhci->segment_pool = NULL; | 1869 | xhci->segment_pool = NULL; |
@@ -2342,9 +2376,9 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) | |||
2342 | 2376 | ||
2343 | INIT_LIST_HEAD(&xhci->cmd_list); | 2377 | INIT_LIST_HEAD(&xhci->cmd_list); |
2344 | 2378 | ||
2345 | /* init command timeout timer */ | 2379 | /* init command timeout work */ |
2346 | setup_timer(&xhci->cmd_timer, xhci_handle_command_timeout, | 2380 | INIT_DELAYED_WORK(&xhci->cmd_timer, xhci_handle_command_timeout); |
2347 | (unsigned long)xhci); | 2381 | init_completion(&xhci->cmd_ring_stop_completion); |
2348 | 2382 | ||
2349 | page_size = readl(&xhci->op_regs->page_size); | 2383 | page_size = readl(&xhci->op_regs->page_size); |
2350 | xhci_dbg_trace(xhci, trace_xhci_dbg_init, | 2384 | xhci_dbg_trace(xhci, trace_xhci_dbg_init, |
diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index 1094ebd2838f..bac961cd24ad 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c | |||
@@ -579,8 +579,10 @@ static int xhci_mtk_probe(struct platform_device *pdev) | |||
579 | goto disable_ldos; | 579 | goto disable_ldos; |
580 | 580 | ||
581 | irq = platform_get_irq(pdev, 0); | 581 | irq = platform_get_irq(pdev, 0); |
582 | if (irq < 0) | 582 | if (irq < 0) { |
583 | ret = irq; | ||
583 | goto disable_clk; | 584 | goto disable_clk; |
585 | } | ||
584 | 586 | ||
585 | /* Initialize dma_mask and coherent_dma_mask to 32-bits */ | 587 | /* Initialize dma_mask and coherent_dma_mask to 32-bits */ |
586 | ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32)); | 588 | ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32)); |
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index e96ae80d107e..954abfd5014d 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c | |||
@@ -165,7 +165,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) | |||
165 | pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI || | 165 | pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI || |
166 | pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || | 166 | pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || |
167 | pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI || | 167 | pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI || |
168 | pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI)) { | 168 | pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI || |
169 | pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI)) { | ||
169 | xhci->quirks |= XHCI_PME_STUCK_QUIRK; | 170 | xhci->quirks |= XHCI_PME_STUCK_QUIRK; |
170 | } | 171 | } |
171 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && | 172 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && |
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index bdf6b13d9b67..25f522b09dd9 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -279,23 +279,76 @@ void xhci_ring_cmd_db(struct xhci_hcd *xhci) | |||
279 | readl(&xhci->dba->doorbell[0]); | 279 | readl(&xhci->dba->doorbell[0]); |
280 | } | 280 | } |
281 | 281 | ||
282 | static int xhci_abort_cmd_ring(struct xhci_hcd *xhci) | 282 | static bool xhci_mod_cmd_timer(struct xhci_hcd *xhci, unsigned long delay) |
283 | { | ||
284 | return mod_delayed_work(system_wq, &xhci->cmd_timer, delay); | ||
285 | } | ||
286 | |||
287 | static struct xhci_command *xhci_next_queued_cmd(struct xhci_hcd *xhci) | ||
288 | { | ||
289 | return list_first_entry_or_null(&xhci->cmd_list, struct xhci_command, | ||
290 | cmd_list); | ||
291 | } | ||
292 | |||
293 | /* | ||
294 | * Turn all commands on command ring with status set to "aborted" to no-op trbs. | ||
295 | * If there are other commands waiting then restart the ring and kick the timer. | ||
296 | * This must be called with command ring stopped and xhci->lock held. | ||
297 | */ | ||
298 | static void xhci_handle_stopped_cmd_ring(struct xhci_hcd *xhci, | ||
299 | struct xhci_command *cur_cmd) | ||
300 | { | ||
301 | struct xhci_command *i_cmd; | ||
302 | u32 cycle_state; | ||
303 | |||
304 | /* Turn all aborted commands in list to no-ops, then restart */ | ||
305 | list_for_each_entry(i_cmd, &xhci->cmd_list, cmd_list) { | ||
306 | |||
307 | if (i_cmd->status != COMP_CMD_ABORT) | ||
308 | continue; | ||
309 | |||
310 | i_cmd->status = COMP_CMD_STOP; | ||
311 | |||
312 | xhci_dbg(xhci, "Turn aborted command %p to no-op\n", | ||
313 | i_cmd->command_trb); | ||
314 | /* get cycle state from the original cmd trb */ | ||
315 | cycle_state = le32_to_cpu( | ||
316 | i_cmd->command_trb->generic.field[3]) & TRB_CYCLE; | ||
317 | /* modify the command trb to no-op command */ | ||
318 | i_cmd->command_trb->generic.field[0] = 0; | ||
319 | i_cmd->command_trb->generic.field[1] = 0; | ||
320 | i_cmd->command_trb->generic.field[2] = 0; | ||
321 | i_cmd->command_trb->generic.field[3] = cpu_to_le32( | ||
322 | TRB_TYPE(TRB_CMD_NOOP) | cycle_state); | ||
323 | |||
324 | /* | ||
325 | * caller waiting for completion is called when command | ||
326 | * completion event is received for these no-op commands | ||
327 | */ | ||
328 | } | ||
329 | |||
330 | xhci->cmd_ring_state = CMD_RING_STATE_RUNNING; | ||
331 | |||
332 | /* ring command ring doorbell to restart the command ring */ | ||
333 | if ((xhci->cmd_ring->dequeue != xhci->cmd_ring->enqueue) && | ||
334 | !(xhci->xhc_state & XHCI_STATE_DYING)) { | ||
335 | xhci->current_cmd = cur_cmd; | ||
336 | xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT); | ||
337 | xhci_ring_cmd_db(xhci); | ||
338 | } | ||
339 | } | ||
340 | |||
341 | /* Must be called with xhci->lock held, releases and aquires lock back */ | ||
342 | static int xhci_abort_cmd_ring(struct xhci_hcd *xhci, unsigned long flags) | ||
283 | { | 343 | { |
284 | u64 temp_64; | 344 | u64 temp_64; |
285 | int ret; | 345 | int ret; |
286 | 346 | ||
287 | xhci_dbg(xhci, "Abort command ring\n"); | 347 | xhci_dbg(xhci, "Abort command ring\n"); |
288 | 348 | ||
289 | temp_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); | 349 | reinit_completion(&xhci->cmd_ring_stop_completion); |
290 | xhci->cmd_ring_state = CMD_RING_STATE_ABORTED; | ||
291 | 350 | ||
292 | /* | 351 | temp_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); |
293 | * Writing the CMD_RING_ABORT bit should cause a cmd completion event, | ||
294 | * however on some host hw the CMD_RING_RUNNING bit is correctly cleared | ||
295 | * but the completion event in never sent. Use the cmd timeout timer to | ||
296 | * handle those cases. Use twice the time to cover the bit polling retry | ||
297 | */ | ||
298 | mod_timer(&xhci->cmd_timer, jiffies + (2 * XHCI_CMD_DEFAULT_TIMEOUT)); | ||
299 | xhci_write_64(xhci, temp_64 | CMD_RING_ABORT, | 352 | xhci_write_64(xhci, temp_64 | CMD_RING_ABORT, |
300 | &xhci->op_regs->cmd_ring); | 353 | &xhci->op_regs->cmd_ring); |
301 | 354 | ||
@@ -315,17 +368,30 @@ static int xhci_abort_cmd_ring(struct xhci_hcd *xhci) | |||
315 | udelay(1000); | 368 | udelay(1000); |
316 | ret = xhci_handshake(&xhci->op_regs->cmd_ring, | 369 | ret = xhci_handshake(&xhci->op_regs->cmd_ring, |
317 | CMD_RING_RUNNING, 0, 3 * 1000 * 1000); | 370 | CMD_RING_RUNNING, 0, 3 * 1000 * 1000); |
318 | if (ret == 0) | 371 | if (ret < 0) { |
319 | return 0; | 372 | xhci_err(xhci, "Stopped the command ring failed, " |
320 | 373 | "maybe the host is dead\n"); | |
321 | xhci_err(xhci, "Stopped the command ring failed, " | 374 | xhci->xhc_state |= XHCI_STATE_DYING; |
322 | "maybe the host is dead\n"); | 375 | xhci_halt(xhci); |
323 | del_timer(&xhci->cmd_timer); | 376 | return -ESHUTDOWN; |
324 | xhci->xhc_state |= XHCI_STATE_DYING; | 377 | } |
325 | xhci_halt(xhci); | 378 | } |
326 | return -ESHUTDOWN; | 379 | /* |
380 | * Writing the CMD_RING_ABORT bit should cause a cmd completion event, | ||
381 | * however on some host hw the CMD_RING_RUNNING bit is correctly cleared | ||
382 | * but the completion event in never sent. Wait 2 secs (arbitrary | ||
383 | * number) to handle those cases after negation of CMD_RING_RUNNING. | ||
384 | */ | ||
385 | spin_unlock_irqrestore(&xhci->lock, flags); | ||
386 | ret = wait_for_completion_timeout(&xhci->cmd_ring_stop_completion, | ||
387 | msecs_to_jiffies(2000)); | ||
388 | spin_lock_irqsave(&xhci->lock, flags); | ||
389 | if (!ret) { | ||
390 | xhci_dbg(xhci, "No stop event for abort, ring start fail?\n"); | ||
391 | xhci_cleanup_command_queue(xhci); | ||
392 | } else { | ||
393 | xhci_handle_stopped_cmd_ring(xhci, xhci_next_queued_cmd(xhci)); | ||
327 | } | 394 | } |
328 | |||
329 | return 0; | 395 | return 0; |
330 | } | 396 | } |
331 | 397 | ||
@@ -1207,101 +1273,62 @@ void xhci_cleanup_command_queue(struct xhci_hcd *xhci) | |||
1207 | xhci_complete_del_and_free_cmd(cur_cmd, COMP_CMD_ABORT); | 1273 | xhci_complete_del_and_free_cmd(cur_cmd, COMP_CMD_ABORT); |
1208 | } | 1274 | } |
1209 | 1275 | ||
1210 | /* | 1276 | void xhci_handle_command_timeout(struct work_struct *work) |
1211 | * Turn all commands on command ring with status set to "aborted" to no-op trbs. | ||
1212 | * If there are other commands waiting then restart the ring and kick the timer. | ||
1213 | * This must be called with command ring stopped and xhci->lock held. | ||
1214 | */ | ||
1215 | static void xhci_handle_stopped_cmd_ring(struct xhci_hcd *xhci, | ||
1216 | struct xhci_command *cur_cmd) | ||
1217 | { | ||
1218 | struct xhci_command *i_cmd, *tmp_cmd; | ||
1219 | u32 cycle_state; | ||
1220 | |||
1221 | /* Turn all aborted commands in list to no-ops, then restart */ | ||
1222 | list_for_each_entry_safe(i_cmd, tmp_cmd, &xhci->cmd_list, | ||
1223 | cmd_list) { | ||
1224 | |||
1225 | if (i_cmd->status != COMP_CMD_ABORT) | ||
1226 | continue; | ||
1227 | |||
1228 | i_cmd->status = COMP_CMD_STOP; | ||
1229 | |||
1230 | xhci_dbg(xhci, "Turn aborted command %p to no-op\n", | ||
1231 | i_cmd->command_trb); | ||
1232 | /* get cycle state from the original cmd trb */ | ||
1233 | cycle_state = le32_to_cpu( | ||
1234 | i_cmd->command_trb->generic.field[3]) & TRB_CYCLE; | ||
1235 | /* modify the command trb to no-op command */ | ||
1236 | i_cmd->command_trb->generic.field[0] = 0; | ||
1237 | i_cmd->command_trb->generic.field[1] = 0; | ||
1238 | i_cmd->command_trb->generic.field[2] = 0; | ||
1239 | i_cmd->command_trb->generic.field[3] = cpu_to_le32( | ||
1240 | TRB_TYPE(TRB_CMD_NOOP) | cycle_state); | ||
1241 | |||
1242 | /* | ||
1243 | * caller waiting for completion is called when command | ||
1244 | * completion event is received for these no-op commands | ||
1245 | */ | ||
1246 | } | ||
1247 | |||
1248 | xhci->cmd_ring_state = CMD_RING_STATE_RUNNING; | ||
1249 | |||
1250 | /* ring command ring doorbell to restart the command ring */ | ||
1251 | if ((xhci->cmd_ring->dequeue != xhci->cmd_ring->enqueue) && | ||
1252 | !(xhci->xhc_state & XHCI_STATE_DYING)) { | ||
1253 | xhci->current_cmd = cur_cmd; | ||
1254 | mod_timer(&xhci->cmd_timer, jiffies + XHCI_CMD_DEFAULT_TIMEOUT); | ||
1255 | xhci_ring_cmd_db(xhci); | ||
1256 | } | ||
1257 | return; | ||
1258 | } | ||
1259 | |||
1260 | |||
1261 | void xhci_handle_command_timeout(unsigned long data) | ||
1262 | { | 1277 | { |
1263 | struct xhci_hcd *xhci; | 1278 | struct xhci_hcd *xhci; |
1264 | int ret; | 1279 | int ret; |
1265 | unsigned long flags; | 1280 | unsigned long flags; |
1266 | u64 hw_ring_state; | 1281 | u64 hw_ring_state; |
1267 | bool second_timeout = false; | ||
1268 | xhci = (struct xhci_hcd *) data; | ||
1269 | 1282 | ||
1270 | /* mark this command to be cancelled */ | 1283 | xhci = container_of(to_delayed_work(work), struct xhci_hcd, cmd_timer); |
1284 | |||
1271 | spin_lock_irqsave(&xhci->lock, flags); | 1285 | spin_lock_irqsave(&xhci->lock, flags); |
1272 | if (xhci->current_cmd) { | 1286 | |
1273 | if (xhci->current_cmd->status == COMP_CMD_ABORT) | 1287 | /* |
1274 | second_timeout = true; | 1288 | * If timeout work is pending, or current_cmd is NULL, it means we |
1275 | xhci->current_cmd->status = COMP_CMD_ABORT; | 1289 | * raced with command completion. Command is handled so just return. |
1290 | */ | ||
1291 | if (!xhci->current_cmd || delayed_work_pending(&xhci->cmd_timer)) { | ||
1292 | spin_unlock_irqrestore(&xhci->lock, flags); | ||
1293 | return; | ||
1276 | } | 1294 | } |
1295 | /* mark this command to be cancelled */ | ||
1296 | xhci->current_cmd->status = COMP_CMD_ABORT; | ||
1277 | 1297 | ||
1278 | /* Make sure command ring is running before aborting it */ | 1298 | /* Make sure command ring is running before aborting it */ |
1279 | hw_ring_state = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); | 1299 | hw_ring_state = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); |
1280 | if ((xhci->cmd_ring_state & CMD_RING_STATE_RUNNING) && | 1300 | if ((xhci->cmd_ring_state & CMD_RING_STATE_RUNNING) && |
1281 | (hw_ring_state & CMD_RING_RUNNING)) { | 1301 | (hw_ring_state & CMD_RING_RUNNING)) { |
1282 | spin_unlock_irqrestore(&xhci->lock, flags); | 1302 | /* Prevent new doorbell, and start command abort */ |
1303 | xhci->cmd_ring_state = CMD_RING_STATE_ABORTED; | ||
1283 | xhci_dbg(xhci, "Command timeout\n"); | 1304 | xhci_dbg(xhci, "Command timeout\n"); |
1284 | ret = xhci_abort_cmd_ring(xhci); | 1305 | ret = xhci_abort_cmd_ring(xhci, flags); |
1285 | if (unlikely(ret == -ESHUTDOWN)) { | 1306 | if (unlikely(ret == -ESHUTDOWN)) { |
1286 | xhci_err(xhci, "Abort command ring failed\n"); | 1307 | xhci_err(xhci, "Abort command ring failed\n"); |
1287 | xhci_cleanup_command_queue(xhci); | 1308 | xhci_cleanup_command_queue(xhci); |
1309 | spin_unlock_irqrestore(&xhci->lock, flags); | ||
1288 | usb_hc_died(xhci_to_hcd(xhci)->primary_hcd); | 1310 | usb_hc_died(xhci_to_hcd(xhci)->primary_hcd); |
1289 | xhci_dbg(xhci, "xHCI host controller is dead.\n"); | 1311 | xhci_dbg(xhci, "xHCI host controller is dead.\n"); |
1312 | |||
1313 | return; | ||
1290 | } | 1314 | } |
1291 | return; | 1315 | |
1316 | goto time_out_completed; | ||
1292 | } | 1317 | } |
1293 | 1318 | ||
1294 | /* command ring failed to restart, or host removed. Bail out */ | 1319 | /* host removed. Bail out */ |
1295 | if (second_timeout || xhci->xhc_state & XHCI_STATE_REMOVING) { | 1320 | if (xhci->xhc_state & XHCI_STATE_REMOVING) { |
1296 | spin_unlock_irqrestore(&xhci->lock, flags); | 1321 | xhci_dbg(xhci, "host removed, ring start fail?\n"); |
1297 | xhci_dbg(xhci, "command timed out twice, ring start fail?\n"); | ||
1298 | xhci_cleanup_command_queue(xhci); | 1322 | xhci_cleanup_command_queue(xhci); |
1299 | return; | 1323 | |
1324 | goto time_out_completed; | ||
1300 | } | 1325 | } |
1301 | 1326 | ||
1302 | /* command timeout on stopped ring, ring can't be aborted */ | 1327 | /* command timeout on stopped ring, ring can't be aborted */ |
1303 | xhci_dbg(xhci, "Command timeout on stopped ring\n"); | 1328 | xhci_dbg(xhci, "Command timeout on stopped ring\n"); |
1304 | xhci_handle_stopped_cmd_ring(xhci, xhci->current_cmd); | 1329 | xhci_handle_stopped_cmd_ring(xhci, xhci->current_cmd); |
1330 | |||
1331 | time_out_completed: | ||
1305 | spin_unlock_irqrestore(&xhci->lock, flags); | 1332 | spin_unlock_irqrestore(&xhci->lock, flags); |
1306 | return; | 1333 | return; |
1307 | } | 1334 | } |
@@ -1333,7 +1360,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, | |||
1333 | 1360 | ||
1334 | cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list); | 1361 | cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list); |
1335 | 1362 | ||
1336 | del_timer(&xhci->cmd_timer); | 1363 | cancel_delayed_work(&xhci->cmd_timer); |
1337 | 1364 | ||
1338 | trace_xhci_cmd_completion(cmd_trb, (struct xhci_generic_trb *) event); | 1365 | trace_xhci_cmd_completion(cmd_trb, (struct xhci_generic_trb *) event); |
1339 | 1366 | ||
@@ -1341,7 +1368,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, | |||
1341 | 1368 | ||
1342 | /* If CMD ring stopped we own the trbs between enqueue and dequeue */ | 1369 | /* If CMD ring stopped we own the trbs between enqueue and dequeue */ |
1343 | if (cmd_comp_code == COMP_CMD_STOP) { | 1370 | if (cmd_comp_code == COMP_CMD_STOP) { |
1344 | xhci_handle_stopped_cmd_ring(xhci, cmd); | 1371 | complete_all(&xhci->cmd_ring_stop_completion); |
1345 | return; | 1372 | return; |
1346 | } | 1373 | } |
1347 | 1374 | ||
@@ -1359,8 +1386,11 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, | |||
1359 | */ | 1386 | */ |
1360 | if (cmd_comp_code == COMP_CMD_ABORT) { | 1387 | if (cmd_comp_code == COMP_CMD_ABORT) { |
1361 | xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; | 1388 | xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; |
1362 | if (cmd->status == COMP_CMD_ABORT) | 1389 | if (cmd->status == COMP_CMD_ABORT) { |
1390 | if (xhci->current_cmd == cmd) | ||
1391 | xhci->current_cmd = NULL; | ||
1363 | goto event_handled; | 1392 | goto event_handled; |
1393 | } | ||
1364 | } | 1394 | } |
1365 | 1395 | ||
1366 | cmd_type = TRB_FIELD_TO_TYPE(le32_to_cpu(cmd_trb->generic.field[3])); | 1396 | cmd_type = TRB_FIELD_TO_TYPE(le32_to_cpu(cmd_trb->generic.field[3])); |
@@ -1421,7 +1451,9 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, | |||
1421 | if (cmd->cmd_list.next != &xhci->cmd_list) { | 1451 | if (cmd->cmd_list.next != &xhci->cmd_list) { |
1422 | xhci->current_cmd = list_entry(cmd->cmd_list.next, | 1452 | xhci->current_cmd = list_entry(cmd->cmd_list.next, |
1423 | struct xhci_command, cmd_list); | 1453 | struct xhci_command, cmd_list); |
1424 | mod_timer(&xhci->cmd_timer, jiffies + XHCI_CMD_DEFAULT_TIMEOUT); | 1454 | xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT); |
1455 | } else if (xhci->current_cmd == cmd) { | ||
1456 | xhci->current_cmd = NULL; | ||
1425 | } | 1457 | } |
1426 | 1458 | ||
1427 | event_handled: | 1459 | event_handled: |
@@ -1939,8 +1971,9 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
1939 | struct xhci_ep_ctx *ep_ctx; | 1971 | struct xhci_ep_ctx *ep_ctx; |
1940 | u32 trb_comp_code; | 1972 | u32 trb_comp_code; |
1941 | u32 remaining, requested; | 1973 | u32 remaining, requested; |
1942 | bool on_data_stage; | 1974 | u32 trb_type; |
1943 | 1975 | ||
1976 | trb_type = TRB_FIELD_TO_TYPE(le32_to_cpu(ep_trb->generic.field[3])); | ||
1944 | slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags)); | 1977 | slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags)); |
1945 | xdev = xhci->devs[slot_id]; | 1978 | xdev = xhci->devs[slot_id]; |
1946 | ep_index = TRB_TO_EP_ID(le32_to_cpu(event->flags)) - 1; | 1979 | ep_index = TRB_TO_EP_ID(le32_to_cpu(event->flags)) - 1; |
@@ -1950,14 +1983,11 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
1950 | requested = td->urb->transfer_buffer_length; | 1983 | requested = td->urb->transfer_buffer_length; |
1951 | remaining = EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); | 1984 | remaining = EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); |
1952 | 1985 | ||
1953 | /* not setup (dequeue), or status stage means we are at data stage */ | ||
1954 | on_data_stage = (ep_trb != ep_ring->dequeue && ep_trb != td->last_trb); | ||
1955 | |||
1956 | switch (trb_comp_code) { | 1986 | switch (trb_comp_code) { |
1957 | case COMP_SUCCESS: | 1987 | case COMP_SUCCESS: |
1958 | if (ep_trb != td->last_trb) { | 1988 | if (trb_type != TRB_STATUS) { |
1959 | xhci_warn(xhci, "WARN: Success on ctrl %s TRB without IOC set?\n", | 1989 | xhci_warn(xhci, "WARN: Success on ctrl %s TRB without IOC set?\n", |
1960 | on_data_stage ? "data" : "setup"); | 1990 | (trb_type == TRB_DATA) ? "data" : "setup"); |
1961 | *status = -ESHUTDOWN; | 1991 | *status = -ESHUTDOWN; |
1962 | break; | 1992 | break; |
1963 | } | 1993 | } |
@@ -1967,15 +1997,25 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
1967 | *status = 0; | 1997 | *status = 0; |
1968 | break; | 1998 | break; |
1969 | case COMP_STOP_SHORT: | 1999 | case COMP_STOP_SHORT: |
1970 | if (on_data_stage) | 2000 | if (trb_type == TRB_DATA || trb_type == TRB_NORMAL) |
1971 | td->urb->actual_length = remaining; | 2001 | td->urb->actual_length = remaining; |
1972 | else | 2002 | else |
1973 | xhci_warn(xhci, "WARN: Stopped Short Packet on ctrl setup or status TRB\n"); | 2003 | xhci_warn(xhci, "WARN: Stopped Short Packet on ctrl setup or status TRB\n"); |
1974 | goto finish_td; | 2004 | goto finish_td; |
1975 | case COMP_STOP: | 2005 | case COMP_STOP: |
1976 | if (on_data_stage) | 2006 | switch (trb_type) { |
2007 | case TRB_SETUP: | ||
2008 | td->urb->actual_length = 0; | ||
2009 | goto finish_td; | ||
2010 | case TRB_DATA: | ||
2011 | case TRB_NORMAL: | ||
1977 | td->urb->actual_length = requested - remaining; | 2012 | td->urb->actual_length = requested - remaining; |
1978 | goto finish_td; | 2013 | goto finish_td; |
2014 | default: | ||
2015 | xhci_warn(xhci, "WARN: unexpected TRB Type %d\n", | ||
2016 | trb_type); | ||
2017 | goto finish_td; | ||
2018 | } | ||
1979 | case COMP_STOP_INVAL: | 2019 | case COMP_STOP_INVAL: |
1980 | goto finish_td; | 2020 | goto finish_td; |
1981 | default: | 2021 | default: |
@@ -1987,7 +2027,7 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
1987 | /* else fall through */ | 2027 | /* else fall through */ |
1988 | case COMP_STALL: | 2028 | case COMP_STALL: |
1989 | /* Did we transfer part of the data (middle) phase? */ | 2029 | /* Did we transfer part of the data (middle) phase? */ |
1990 | if (on_data_stage) | 2030 | if (trb_type == TRB_DATA || trb_type == TRB_NORMAL) |
1991 | td->urb->actual_length = requested - remaining; | 2031 | td->urb->actual_length = requested - remaining; |
1992 | else if (!td->urb_length_set) | 2032 | else if (!td->urb_length_set) |
1993 | td->urb->actual_length = 0; | 2033 | td->urb->actual_length = 0; |
@@ -1995,14 +2035,15 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
1995 | } | 2035 | } |
1996 | 2036 | ||
1997 | /* stopped at setup stage, no data transferred */ | 2037 | /* stopped at setup stage, no data transferred */ |
1998 | if (ep_trb == ep_ring->dequeue) | 2038 | if (trb_type == TRB_SETUP) |
1999 | goto finish_td; | 2039 | goto finish_td; |
2000 | 2040 | ||
2001 | /* | 2041 | /* |
2002 | * if on data stage then update the actual_length of the URB and flag it | 2042 | * if on data stage then update the actual_length of the URB and flag it |
2003 | * as set, so it won't be overwritten in the event for the last TRB. | 2043 | * as set, so it won't be overwritten in the event for the last TRB. |
2004 | */ | 2044 | */ |
2005 | if (on_data_stage) { | 2045 | if (trb_type == TRB_DATA || |
2046 | trb_type == TRB_NORMAL) { | ||
2006 | td->urb_length_set = true; | 2047 | td->urb_length_set = true; |
2007 | td->urb->actual_length = requested - remaining; | 2048 | td->urb->actual_length = requested - remaining; |
2008 | xhci_dbg(xhci, "Waiting for status stage event\n"); | 2049 | xhci_dbg(xhci, "Waiting for status stage event\n"); |
@@ -3790,9 +3831,9 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd, | |||
3790 | 3831 | ||
3791 | /* if there are no other commands queued we start the timeout timer */ | 3832 | /* if there are no other commands queued we start the timeout timer */ |
3792 | if (xhci->cmd_list.next == &cmd->cmd_list && | 3833 | if (xhci->cmd_list.next == &cmd->cmd_list && |
3793 | !timer_pending(&xhci->cmd_timer)) { | 3834 | !delayed_work_pending(&xhci->cmd_timer)) { |
3794 | xhci->current_cmd = cmd; | 3835 | xhci->current_cmd = cmd; |
3795 | mod_timer(&xhci->cmd_timer, jiffies + XHCI_CMD_DEFAULT_TIMEOUT); | 3836 | xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT); |
3796 | } | 3837 | } |
3797 | 3838 | ||
3798 | queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3, | 3839 | queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3, |
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 1cd56417cbec..0c8deb9ed42d 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -3787,8 +3787,10 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev, | |||
3787 | 3787 | ||
3788 | mutex_lock(&xhci->mutex); | 3788 | mutex_lock(&xhci->mutex); |
3789 | 3789 | ||
3790 | if (xhci->xhc_state) /* dying, removing or halted */ | 3790 | if (xhci->xhc_state) { /* dying, removing or halted */ |
3791 | ret = -ESHUTDOWN; | ||
3791 | goto out; | 3792 | goto out; |
3793 | } | ||
3792 | 3794 | ||
3793 | if (!udev->slot_id) { | 3795 | if (!udev->slot_id) { |
3794 | xhci_dbg_trace(xhci, trace_xhci_dbg_address, | 3796 | xhci_dbg_trace(xhci, trace_xhci_dbg_address, |
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 8ccc11a974b8..2d7b6374b58d 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -1568,7 +1568,8 @@ struct xhci_hcd { | |||
1568 | #define CMD_RING_STATE_STOPPED (1 << 2) | 1568 | #define CMD_RING_STATE_STOPPED (1 << 2) |
1569 | struct list_head cmd_list; | 1569 | struct list_head cmd_list; |
1570 | unsigned int cmd_ring_reserved_trbs; | 1570 | unsigned int cmd_ring_reserved_trbs; |
1571 | struct timer_list cmd_timer; | 1571 | struct delayed_work cmd_timer; |
1572 | struct completion cmd_ring_stop_completion; | ||
1572 | struct xhci_command *current_cmd; | 1573 | struct xhci_command *current_cmd; |
1573 | struct xhci_ring *event_ring; | 1574 | struct xhci_ring *event_ring; |
1574 | struct xhci_erst erst; | 1575 | struct xhci_erst erst; |
@@ -1934,7 +1935,7 @@ void xhci_queue_config_ep_quirk(struct xhci_hcd *xhci, | |||
1934 | unsigned int slot_id, unsigned int ep_index, | 1935 | unsigned int slot_id, unsigned int ep_index, |
1935 | struct xhci_dequeue_state *deq_state); | 1936 | struct xhci_dequeue_state *deq_state); |
1936 | void xhci_stop_endpoint_command_watchdog(unsigned long arg); | 1937 | void xhci_stop_endpoint_command_watchdog(unsigned long arg); |
1937 | void xhci_handle_command_timeout(unsigned long data); | 1938 | void xhci_handle_command_timeout(struct work_struct *work); |
1938 | 1939 | ||
1939 | void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id, | 1940 | void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id, |
1940 | unsigned int ep_index, unsigned int stream_id); | 1941 | unsigned int ep_index, unsigned int stream_id); |
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index 310238c6b5cd..896798071817 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c | |||
@@ -469,6 +469,7 @@ static const struct musb_platform_ops bfin_ops = { | |||
469 | .init = bfin_musb_init, | 469 | .init = bfin_musb_init, |
470 | .exit = bfin_musb_exit, | 470 | .exit = bfin_musb_exit, |
471 | 471 | ||
472 | .fifo_offset = bfin_fifo_offset, | ||
472 | .readb = bfin_readb, | 473 | .readb = bfin_readb, |
473 | .writeb = bfin_writeb, | 474 | .writeb = bfin_writeb, |
474 | .readw = bfin_readw, | 475 | .readw = bfin_readw, |
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 9e226468a13e..fca288bbc800 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c | |||
@@ -2050,6 +2050,7 @@ struct musb_pending_work { | |||
2050 | struct list_head node; | 2050 | struct list_head node; |
2051 | }; | 2051 | }; |
2052 | 2052 | ||
2053 | #ifdef CONFIG_PM | ||
2053 | /* | 2054 | /* |
2054 | * Called from musb_runtime_resume(), musb_resume(), and | 2055 | * Called from musb_runtime_resume(), musb_resume(), and |
2055 | * musb_queue_resume_work(). Callers must take musb->lock. | 2056 | * musb_queue_resume_work(). Callers must take musb->lock. |
@@ -2077,6 +2078,7 @@ static int musb_run_resume_work(struct musb *musb) | |||
2077 | 2078 | ||
2078 | return error; | 2079 | return error; |
2079 | } | 2080 | } |
2081 | #endif | ||
2080 | 2082 | ||
2081 | /* | 2083 | /* |
2082 | * Called to run work if device is active or else queue the work to happen | 2084 | * Called to run work if device is active or else queue the work to happen |
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index a611e2f67bdc..ade902ea1221 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h | |||
@@ -216,6 +216,7 @@ struct musb_platform_ops { | |||
216 | void (*pre_root_reset_end)(struct musb *musb); | 216 | void (*pre_root_reset_end)(struct musb *musb); |
217 | void (*post_root_reset_end)(struct musb *musb); | 217 | void (*post_root_reset_end)(struct musb *musb); |
218 | int (*phy_callback)(enum musb_vbus_id_status status); | 218 | int (*phy_callback)(enum musb_vbus_id_status status); |
219 | void (*clear_ep_rxintr)(struct musb *musb, int epnum); | ||
219 | }; | 220 | }; |
220 | 221 | ||
221 | /* | 222 | /* |
@@ -626,6 +627,12 @@ static inline void musb_platform_post_root_reset_end(struct musb *musb) | |||
626 | musb->ops->post_root_reset_end(musb); | 627 | musb->ops->post_root_reset_end(musb); |
627 | } | 628 | } |
628 | 629 | ||
630 | static inline void musb_platform_clear_ep_rxintr(struct musb *musb, int epnum) | ||
631 | { | ||
632 | if (musb->ops->clear_ep_rxintr) | ||
633 | musb->ops->clear_ep_rxintr(musb, epnum); | ||
634 | } | ||
635 | |||
629 | /* | 636 | /* |
630 | * gets the "dr_mode" property from DT and converts it into musb_mode | 637 | * gets the "dr_mode" property from DT and converts it into musb_mode |
631 | * if the property is not found or not recognized returns MUSB_OTG | 638 | * if the property is not found or not recognized returns MUSB_OTG |
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index feae1561b9ab..9f125e179acd 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c | |||
@@ -267,6 +267,17 @@ static void otg_timer(unsigned long _musb) | |||
267 | pm_runtime_put_autosuspend(dev); | 267 | pm_runtime_put_autosuspend(dev); |
268 | } | 268 | } |
269 | 269 | ||
270 | void dsps_musb_clear_ep_rxintr(struct musb *musb, int epnum) | ||
271 | { | ||
272 | u32 epintr; | ||
273 | struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent); | ||
274 | const struct dsps_musb_wrapper *wrp = glue->wrp; | ||
275 | |||
276 | /* musb->lock might already been held */ | ||
277 | epintr = (1 << epnum) << wrp->rxep_shift; | ||
278 | musb_writel(musb->ctrl_base, wrp->epintr_status, epintr); | ||
279 | } | ||
280 | |||
270 | static irqreturn_t dsps_interrupt(int irq, void *hci) | 281 | static irqreturn_t dsps_interrupt(int irq, void *hci) |
271 | { | 282 | { |
272 | struct musb *musb = hci; | 283 | struct musb *musb = hci; |
@@ -622,6 +633,7 @@ static struct musb_platform_ops dsps_ops = { | |||
622 | 633 | ||
623 | .set_mode = dsps_musb_set_mode, | 634 | .set_mode = dsps_musb_set_mode, |
624 | .recover = dsps_musb_recover, | 635 | .recover = dsps_musb_recover, |
636 | .clear_ep_rxintr = dsps_musb_clear_ep_rxintr, | ||
625 | }; | 637 | }; |
626 | 638 | ||
627 | static u64 musb_dmamask = DMA_BIT_MASK(32); | 639 | static u64 musb_dmamask = DMA_BIT_MASK(32); |
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index f6cdbad00dac..ac3a4952abb4 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c | |||
@@ -2374,12 +2374,11 @@ static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh) | |||
2374 | int is_in = usb_pipein(urb->pipe); | 2374 | int is_in = usb_pipein(urb->pipe); |
2375 | int status = 0; | 2375 | int status = 0; |
2376 | u16 csr; | 2376 | u16 csr; |
2377 | struct dma_channel *dma = NULL; | ||
2377 | 2378 | ||
2378 | musb_ep_select(regs, hw_end); | 2379 | musb_ep_select(regs, hw_end); |
2379 | 2380 | ||
2380 | if (is_dma_capable()) { | 2381 | if (is_dma_capable()) { |
2381 | struct dma_channel *dma; | ||
2382 | |||
2383 | dma = is_in ? ep->rx_channel : ep->tx_channel; | 2382 | dma = is_in ? ep->rx_channel : ep->tx_channel; |
2384 | if (dma) { | 2383 | if (dma) { |
2385 | status = ep->musb->dma_controller->channel_abort(dma); | 2384 | status = ep->musb->dma_controller->channel_abort(dma); |
@@ -2395,10 +2394,9 @@ static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh) | |||
2395 | /* giveback saves bulk toggle */ | 2394 | /* giveback saves bulk toggle */ |
2396 | csr = musb_h_flush_rxfifo(ep, 0); | 2395 | csr = musb_h_flush_rxfifo(ep, 0); |
2397 | 2396 | ||
2398 | /* REVISIT we still get an irq; should likely clear the | 2397 | /* clear the endpoint's irq status here to avoid bogus irqs */ |
2399 | * endpoint's irq status here to avoid bogus irqs. | 2398 | if (is_dma_capable() && dma) |
2400 | * clearing that status is platform-specific... | 2399 | musb_platform_clear_ep_rxintr(musb, ep->epnum); |
2401 | */ | ||
2402 | } else if (ep->epnum) { | 2400 | } else if (ep->epnum) { |
2403 | musb_h_tx_flush_fifo(ep); | 2401 | musb_h_tx_flush_fifo(ep); |
2404 | csr = musb_readw(epio, MUSB_TXCSR); | 2402 | csr = musb_readw(epio, MUSB_TXCSR); |
diff --git a/drivers/usb/musb/musbhsdma.h b/drivers/usb/musb/musbhsdma.h index f7b13fd25257..a3dcbd55e436 100644 --- a/drivers/usb/musb/musbhsdma.h +++ b/drivers/usb/musb/musbhsdma.h | |||
@@ -157,5 +157,5 @@ struct musb_dma_controller { | |||
157 | void __iomem *base; | 157 | void __iomem *base; |
158 | u8 channel_count; | 158 | u8 channel_count; |
159 | u8 used_channels; | 159 | u8 used_channels; |
160 | u8 irq; | 160 | int irq; |
161 | }; | 161 | }; |
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index 5f17a3b9916d..80260b08398b 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c | |||
@@ -50,6 +50,7 @@ | |||
50 | #define CYBERJACK_PRODUCT_ID 0x0100 | 50 | #define CYBERJACK_PRODUCT_ID 0x0100 |
51 | 51 | ||
52 | /* Function prototypes */ | 52 | /* Function prototypes */ |
53 | static int cyberjack_attach(struct usb_serial *serial); | ||
53 | static int cyberjack_port_probe(struct usb_serial_port *port); | 54 | static int cyberjack_port_probe(struct usb_serial_port *port); |
54 | static int cyberjack_port_remove(struct usb_serial_port *port); | 55 | static int cyberjack_port_remove(struct usb_serial_port *port); |
55 | static int cyberjack_open(struct tty_struct *tty, | 56 | static int cyberjack_open(struct tty_struct *tty, |
@@ -77,6 +78,7 @@ static struct usb_serial_driver cyberjack_device = { | |||
77 | .description = "Reiner SCT Cyberjack USB card reader", | 78 | .description = "Reiner SCT Cyberjack USB card reader", |
78 | .id_table = id_table, | 79 | .id_table = id_table, |
79 | .num_ports = 1, | 80 | .num_ports = 1, |
81 | .attach = cyberjack_attach, | ||
80 | .port_probe = cyberjack_port_probe, | 82 | .port_probe = cyberjack_port_probe, |
81 | .port_remove = cyberjack_port_remove, | 83 | .port_remove = cyberjack_port_remove, |
82 | .open = cyberjack_open, | 84 | .open = cyberjack_open, |
@@ -100,6 +102,14 @@ struct cyberjack_private { | |||
100 | short wrsent; /* Data already sent */ | 102 | short wrsent; /* Data already sent */ |
101 | }; | 103 | }; |
102 | 104 | ||
105 | static int cyberjack_attach(struct usb_serial *serial) | ||
106 | { | ||
107 | if (serial->num_bulk_out < serial->num_ports) | ||
108 | return -ENODEV; | ||
109 | |||
110 | return 0; | ||
111 | } | ||
112 | |||
103 | static int cyberjack_port_probe(struct usb_serial_port *port) | 113 | static int cyberjack_port_probe(struct usb_serial_port *port) |
104 | { | 114 | { |
105 | struct cyberjack_private *priv; | 115 | struct cyberjack_private *priv; |
diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c index 8282a6a18fee..22f23a429a95 100644 --- a/drivers/usb/serial/f81534.c +++ b/drivers/usb/serial/f81534.c | |||
@@ -1237,6 +1237,7 @@ static int f81534_attach(struct usb_serial *serial) | |||
1237 | static int f81534_port_probe(struct usb_serial_port *port) | 1237 | static int f81534_port_probe(struct usb_serial_port *port) |
1238 | { | 1238 | { |
1239 | struct f81534_port_private *port_priv; | 1239 | struct f81534_port_private *port_priv; |
1240 | int ret; | ||
1240 | 1241 | ||
1241 | port_priv = devm_kzalloc(&port->dev, sizeof(*port_priv), GFP_KERNEL); | 1242 | port_priv = devm_kzalloc(&port->dev, sizeof(*port_priv), GFP_KERNEL); |
1242 | if (!port_priv) | 1243 | if (!port_priv) |
@@ -1246,10 +1247,11 @@ static int f81534_port_probe(struct usb_serial_port *port) | |||
1246 | mutex_init(&port_priv->mcr_mutex); | 1247 | mutex_init(&port_priv->mcr_mutex); |
1247 | 1248 | ||
1248 | /* Assign logic-to-phy mapping */ | 1249 | /* Assign logic-to-phy mapping */ |
1249 | port_priv->phy_num = f81534_logic_to_phy_port(port->serial, port); | 1250 | ret = f81534_logic_to_phy_port(port->serial, port); |
1250 | if (port_priv->phy_num < 0 || port_priv->phy_num >= F81534_NUM_PORT) | 1251 | if (ret < 0) |
1251 | return -ENODEV; | 1252 | return ret; |
1252 | 1253 | ||
1254 | port_priv->phy_num = ret; | ||
1253 | usb_set_serial_port_data(port, port_priv); | 1255 | usb_set_serial_port_data(port, port_priv); |
1254 | dev_dbg(&port->dev, "%s: port_number: %d, phy_num: %d\n", __func__, | 1256 | dev_dbg(&port->dev, "%s: port_number: %d, phy_num: %d\n", __func__, |
1255 | port->port_number, port_priv->phy_num); | 1257 | port->port_number, port_priv->phy_num); |
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 97cabf803c2f..b2f2e87aed94 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c | |||
@@ -1043,6 +1043,7 @@ static int garmin_write_bulk(struct usb_serial_port *port, | |||
1043 | "%s - usb_submit_urb(write bulk) failed with status = %d\n", | 1043 | "%s - usb_submit_urb(write bulk) failed with status = %d\n", |
1044 | __func__, status); | 1044 | __func__, status); |
1045 | count = status; | 1045 | count = status; |
1046 | kfree(buffer); | ||
1046 | } | 1047 | } |
1047 | 1048 | ||
1048 | /* we are done with this urb, so let the host driver | 1049 | /* we are done with this urb, so let the host driver |
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index dcc0c58aaad5..d50e5773483f 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -2751,6 +2751,11 @@ static int edge_startup(struct usb_serial *serial) | |||
2751 | EDGE_COMPATIBILITY_MASK1, | 2751 | EDGE_COMPATIBILITY_MASK1, |
2752 | EDGE_COMPATIBILITY_MASK2 }; | 2752 | EDGE_COMPATIBILITY_MASK2 }; |
2753 | 2753 | ||
2754 | if (serial->num_bulk_in < 1 || serial->num_interrupt_in < 1) { | ||
2755 | dev_err(&serial->interface->dev, "missing endpoints\n"); | ||
2756 | return -ENODEV; | ||
2757 | } | ||
2758 | |||
2754 | dev = serial->dev; | 2759 | dev = serial->dev; |
2755 | 2760 | ||
2756 | /* create our private serial structure */ | 2761 | /* create our private serial structure */ |
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index c339163698eb..9a0db2965fbb 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c | |||
@@ -1499,8 +1499,7 @@ static int do_boot_mode(struct edgeport_serial *serial, | |||
1499 | 1499 | ||
1500 | dev_dbg(dev, "%s - Download successful -- Device rebooting...\n", __func__); | 1500 | dev_dbg(dev, "%s - Download successful -- Device rebooting...\n", __func__); |
1501 | 1501 | ||
1502 | /* return an error on purpose */ | 1502 | return 1; |
1503 | return -ENODEV; | ||
1504 | } | 1503 | } |
1505 | 1504 | ||
1506 | stayinbootmode: | 1505 | stayinbootmode: |
@@ -1508,7 +1507,7 @@ stayinbootmode: | |||
1508 | dev_dbg(dev, "%s - STAYING IN BOOT MODE\n", __func__); | 1507 | dev_dbg(dev, "%s - STAYING IN BOOT MODE\n", __func__); |
1509 | serial->product_info.TiMode = TI_MODE_BOOT; | 1508 | serial->product_info.TiMode = TI_MODE_BOOT; |
1510 | 1509 | ||
1511 | return 0; | 1510 | return 1; |
1512 | } | 1511 | } |
1513 | 1512 | ||
1514 | static int ti_do_config(struct edgeport_port *port, int feature, int on) | 1513 | static int ti_do_config(struct edgeport_port *port, int feature, int on) |
@@ -2546,6 +2545,13 @@ static int edge_startup(struct usb_serial *serial) | |||
2546 | int status; | 2545 | int status; |
2547 | u16 product_id; | 2546 | u16 product_id; |
2548 | 2547 | ||
2548 | /* Make sure we have the required endpoints when in download mode. */ | ||
2549 | if (serial->interface->cur_altsetting->desc.bNumEndpoints > 1) { | ||
2550 | if (serial->num_bulk_in < serial->num_ports || | ||
2551 | serial->num_bulk_out < serial->num_ports) | ||
2552 | return -ENODEV; | ||
2553 | } | ||
2554 | |||
2549 | /* create our private serial structure */ | 2555 | /* create our private serial structure */ |
2550 | edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL); | 2556 | edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL); |
2551 | if (!edge_serial) | 2557 | if (!edge_serial) |
@@ -2553,14 +2559,18 @@ static int edge_startup(struct usb_serial *serial) | |||
2553 | 2559 | ||
2554 | mutex_init(&edge_serial->es_lock); | 2560 | mutex_init(&edge_serial->es_lock); |
2555 | edge_serial->serial = serial; | 2561 | edge_serial->serial = serial; |
2562 | INIT_DELAYED_WORK(&edge_serial->heartbeat_work, edge_heartbeat_work); | ||
2556 | usb_set_serial_data(serial, edge_serial); | 2563 | usb_set_serial_data(serial, edge_serial); |
2557 | 2564 | ||
2558 | status = download_fw(edge_serial); | 2565 | status = download_fw(edge_serial); |
2559 | if (status) { | 2566 | if (status < 0) { |
2560 | kfree(edge_serial); | 2567 | kfree(edge_serial); |
2561 | return status; | 2568 | return status; |
2562 | } | 2569 | } |
2563 | 2570 | ||
2571 | if (status > 0) | ||
2572 | return 1; /* bind but do not register any ports */ | ||
2573 | |||
2564 | product_id = le16_to_cpu( | 2574 | product_id = le16_to_cpu( |
2565 | edge_serial->serial->dev->descriptor.idProduct); | 2575 | edge_serial->serial->dev->descriptor.idProduct); |
2566 | 2576 | ||
@@ -2572,7 +2582,6 @@ static int edge_startup(struct usb_serial *serial) | |||
2572 | } | 2582 | } |
2573 | } | 2583 | } |
2574 | 2584 | ||
2575 | INIT_DELAYED_WORK(&edge_serial->heartbeat_work, edge_heartbeat_work); | ||
2576 | edge_heartbeat_schedule(edge_serial); | 2585 | edge_heartbeat_schedule(edge_serial); |
2577 | 2586 | ||
2578 | return 0; | 2587 | return 0; |
@@ -2580,6 +2589,9 @@ static int edge_startup(struct usb_serial *serial) | |||
2580 | 2589 | ||
2581 | static void edge_disconnect(struct usb_serial *serial) | 2590 | static void edge_disconnect(struct usb_serial *serial) |
2582 | { | 2591 | { |
2592 | struct edgeport_serial *edge_serial = usb_get_serial_data(serial); | ||
2593 | |||
2594 | cancel_delayed_work_sync(&edge_serial->heartbeat_work); | ||
2583 | } | 2595 | } |
2584 | 2596 | ||
2585 | static void edge_release(struct usb_serial *serial) | 2597 | static void edge_release(struct usb_serial *serial) |
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index 344b4eea4bd5..d57fb5199218 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c | |||
@@ -68,6 +68,16 @@ struct iuu_private { | |||
68 | u32 clk; | 68 | u32 clk; |
69 | }; | 69 | }; |
70 | 70 | ||
71 | static int iuu_attach(struct usb_serial *serial) | ||
72 | { | ||
73 | unsigned char num_ports = serial->num_ports; | ||
74 | |||
75 | if (serial->num_bulk_in < num_ports || serial->num_bulk_out < num_ports) | ||
76 | return -ENODEV; | ||
77 | |||
78 | return 0; | ||
79 | } | ||
80 | |||
71 | static int iuu_port_probe(struct usb_serial_port *port) | 81 | static int iuu_port_probe(struct usb_serial_port *port) |
72 | { | 82 | { |
73 | struct iuu_private *priv; | 83 | struct iuu_private *priv; |
@@ -1196,6 +1206,7 @@ static struct usb_serial_driver iuu_device = { | |||
1196 | .tiocmset = iuu_tiocmset, | 1206 | .tiocmset = iuu_tiocmset, |
1197 | .set_termios = iuu_set_termios, | 1207 | .set_termios = iuu_set_termios, |
1198 | .init_termios = iuu_init_termios, | 1208 | .init_termios = iuu_init_termios, |
1209 | .attach = iuu_attach, | ||
1199 | .port_probe = iuu_port_probe, | 1210 | .port_probe = iuu_port_probe, |
1200 | .port_remove = iuu_port_remove, | 1211 | .port_remove = iuu_port_remove, |
1201 | }; | 1212 | }; |
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index e49ad0c63ad8..83523fcf6fb9 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c | |||
@@ -699,6 +699,19 @@ MODULE_FIRMWARE("keyspan_pda/keyspan_pda.fw"); | |||
699 | MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw"); | 699 | MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw"); |
700 | #endif | 700 | #endif |
701 | 701 | ||
702 | static int keyspan_pda_attach(struct usb_serial *serial) | ||
703 | { | ||
704 | unsigned char num_ports = serial->num_ports; | ||
705 | |||
706 | if (serial->num_bulk_out < num_ports || | ||
707 | serial->num_interrupt_in < num_ports) { | ||
708 | dev_err(&serial->interface->dev, "missing endpoints\n"); | ||
709 | return -ENODEV; | ||
710 | } | ||
711 | |||
712 | return 0; | ||
713 | } | ||
714 | |||
702 | static int keyspan_pda_port_probe(struct usb_serial_port *port) | 715 | static int keyspan_pda_port_probe(struct usb_serial_port *port) |
703 | { | 716 | { |
704 | 717 | ||
@@ -776,6 +789,7 @@ static struct usb_serial_driver keyspan_pda_device = { | |||
776 | .break_ctl = keyspan_pda_break_ctl, | 789 | .break_ctl = keyspan_pda_break_ctl, |
777 | .tiocmget = keyspan_pda_tiocmget, | 790 | .tiocmget = keyspan_pda_tiocmget, |
778 | .tiocmset = keyspan_pda_tiocmset, | 791 | .tiocmset = keyspan_pda_tiocmset, |
792 | .attach = keyspan_pda_attach, | ||
779 | .port_probe = keyspan_pda_port_probe, | 793 | .port_probe = keyspan_pda_port_probe, |
780 | .port_remove = keyspan_pda_port_remove, | 794 | .port_remove = keyspan_pda_port_remove, |
781 | }; | 795 | }; |
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 2363654cafc9..813035f51fe7 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
@@ -51,6 +51,7 @@ | |||
51 | 51 | ||
52 | 52 | ||
53 | /* Function prototypes */ | 53 | /* Function prototypes */ |
54 | static int kobil_attach(struct usb_serial *serial); | ||
54 | static int kobil_port_probe(struct usb_serial_port *probe); | 55 | static int kobil_port_probe(struct usb_serial_port *probe); |
55 | static int kobil_port_remove(struct usb_serial_port *probe); | 56 | static int kobil_port_remove(struct usb_serial_port *probe); |
56 | static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port); | 57 | static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port); |
@@ -86,6 +87,7 @@ static struct usb_serial_driver kobil_device = { | |||
86 | .description = "KOBIL USB smart card terminal", | 87 | .description = "KOBIL USB smart card terminal", |
87 | .id_table = id_table, | 88 | .id_table = id_table, |
88 | .num_ports = 1, | 89 | .num_ports = 1, |
90 | .attach = kobil_attach, | ||
89 | .port_probe = kobil_port_probe, | 91 | .port_probe = kobil_port_probe, |
90 | .port_remove = kobil_port_remove, | 92 | .port_remove = kobil_port_remove, |
91 | .ioctl = kobil_ioctl, | 93 | .ioctl = kobil_ioctl, |
@@ -113,6 +115,16 @@ struct kobil_private { | |||
113 | }; | 115 | }; |
114 | 116 | ||
115 | 117 | ||
118 | static int kobil_attach(struct usb_serial *serial) | ||
119 | { | ||
120 | if (serial->num_interrupt_out < serial->num_ports) { | ||
121 | dev_err(&serial->interface->dev, "missing interrupt-out endpoint\n"); | ||
122 | return -ENODEV; | ||
123 | } | ||
124 | |||
125 | return 0; | ||
126 | } | ||
127 | |||
116 | static int kobil_port_probe(struct usb_serial_port *port) | 128 | static int kobil_port_probe(struct usb_serial_port *port) |
117 | { | 129 | { |
118 | struct usb_serial *serial = port->serial; | 130 | struct usb_serial *serial = port->serial; |
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index d52caa03679c..91bc170b408a 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c | |||
@@ -65,8 +65,6 @@ struct moschip_port { | |||
65 | struct urb *write_urb_pool[NUM_URBS]; | 65 | struct urb *write_urb_pool[NUM_URBS]; |
66 | }; | 66 | }; |
67 | 67 | ||
68 | static struct usb_serial_driver moschip7720_2port_driver; | ||
69 | |||
70 | #define USB_VENDOR_ID_MOSCHIP 0x9710 | 68 | #define USB_VENDOR_ID_MOSCHIP 0x9710 |
71 | #define MOSCHIP_DEVICE_ID_7720 0x7720 | 69 | #define MOSCHIP_DEVICE_ID_7720 0x7720 |
72 | #define MOSCHIP_DEVICE_ID_7715 0x7715 | 70 | #define MOSCHIP_DEVICE_ID_7715 0x7715 |
@@ -970,25 +968,6 @@ static void mos7720_bulk_out_data_callback(struct urb *urb) | |||
970 | tty_port_tty_wakeup(&mos7720_port->port->port); | 968 | tty_port_tty_wakeup(&mos7720_port->port->port); |
971 | } | 969 | } |
972 | 970 | ||
973 | /* | ||
974 | * mos77xx_probe | ||
975 | * this function installs the appropriate read interrupt endpoint callback | ||
976 | * depending on whether the device is a 7720 or 7715, thus avoiding costly | ||
977 | * run-time checks in the high-frequency callback routine itself. | ||
978 | */ | ||
979 | static int mos77xx_probe(struct usb_serial *serial, | ||
980 | const struct usb_device_id *id) | ||
981 | { | ||
982 | if (id->idProduct == MOSCHIP_DEVICE_ID_7715) | ||
983 | moschip7720_2port_driver.read_int_callback = | ||
984 | mos7715_interrupt_callback; | ||
985 | else | ||
986 | moschip7720_2port_driver.read_int_callback = | ||
987 | mos7720_interrupt_callback; | ||
988 | |||
989 | return 0; | ||
990 | } | ||
991 | |||
992 | static int mos77xx_calc_num_ports(struct usb_serial *serial) | 971 | static int mos77xx_calc_num_ports(struct usb_serial *serial) |
993 | { | 972 | { |
994 | u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); | 973 | u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); |
@@ -1917,6 +1896,11 @@ static int mos7720_startup(struct usb_serial *serial) | |||
1917 | u16 product; | 1896 | u16 product; |
1918 | int ret_val; | 1897 | int ret_val; |
1919 | 1898 | ||
1899 | if (serial->num_bulk_in < 2 || serial->num_bulk_out < 2) { | ||
1900 | dev_err(&serial->interface->dev, "missing bulk endpoints\n"); | ||
1901 | return -ENODEV; | ||
1902 | } | ||
1903 | |||
1920 | product = le16_to_cpu(serial->dev->descriptor.idProduct); | 1904 | product = le16_to_cpu(serial->dev->descriptor.idProduct); |
1921 | dev = serial->dev; | 1905 | dev = serial->dev; |
1922 | 1906 | ||
@@ -1941,19 +1925,18 @@ static int mos7720_startup(struct usb_serial *serial) | |||
1941 | tmp->interrupt_in_endpointAddress; | 1925 | tmp->interrupt_in_endpointAddress; |
1942 | serial->port[1]->interrupt_in_urb = NULL; | 1926 | serial->port[1]->interrupt_in_urb = NULL; |
1943 | serial->port[1]->interrupt_in_buffer = NULL; | 1927 | serial->port[1]->interrupt_in_buffer = NULL; |
1928 | |||
1929 | if (serial->port[0]->interrupt_in_urb) { | ||
1930 | struct urb *urb = serial->port[0]->interrupt_in_urb; | ||
1931 | |||
1932 | urb->complete = mos7715_interrupt_callback; | ||
1933 | } | ||
1944 | } | 1934 | } |
1945 | 1935 | ||
1946 | /* setting configuration feature to one */ | 1936 | /* setting configuration feature to one */ |
1947 | usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | 1937 | usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), |
1948 | (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5000); | 1938 | (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5000); |
1949 | 1939 | ||
1950 | /* start the interrupt urb */ | ||
1951 | ret_val = usb_submit_urb(serial->port[0]->interrupt_in_urb, GFP_KERNEL); | ||
1952 | if (ret_val) | ||
1953 | dev_err(&dev->dev, | ||
1954 | "%s - Error %d submitting control urb\n", | ||
1955 | __func__, ret_val); | ||
1956 | |||
1957 | #ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT | 1940 | #ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT |
1958 | if (product == MOSCHIP_DEVICE_ID_7715) { | 1941 | if (product == MOSCHIP_DEVICE_ID_7715) { |
1959 | ret_val = mos7715_parport_init(serial); | 1942 | ret_val = mos7715_parport_init(serial); |
@@ -1961,6 +1944,13 @@ static int mos7720_startup(struct usb_serial *serial) | |||
1961 | return ret_val; | 1944 | return ret_val; |
1962 | } | 1945 | } |
1963 | #endif | 1946 | #endif |
1947 | /* start the interrupt urb */ | ||
1948 | ret_val = usb_submit_urb(serial->port[0]->interrupt_in_urb, GFP_KERNEL); | ||
1949 | if (ret_val) { | ||
1950 | dev_err(&dev->dev, "failed to submit interrupt urb: %d\n", | ||
1951 | ret_val); | ||
1952 | } | ||
1953 | |||
1964 | /* LSR For Port 1 */ | 1954 | /* LSR For Port 1 */ |
1965 | read_mos_reg(serial, 0, MOS7720_LSR, &data); | 1955 | read_mos_reg(serial, 0, MOS7720_LSR, &data); |
1966 | dev_dbg(&dev->dev, "LSR:%x\n", data); | 1956 | dev_dbg(&dev->dev, "LSR:%x\n", data); |
@@ -1970,6 +1960,8 @@ static int mos7720_startup(struct usb_serial *serial) | |||
1970 | 1960 | ||
1971 | static void mos7720_release(struct usb_serial *serial) | 1961 | static void mos7720_release(struct usb_serial *serial) |
1972 | { | 1962 | { |
1963 | usb_kill_urb(serial->port[0]->interrupt_in_urb); | ||
1964 | |||
1973 | #ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT | 1965 | #ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT |
1974 | /* close the parallel port */ | 1966 | /* close the parallel port */ |
1975 | 1967 | ||
@@ -2019,11 +2011,6 @@ static int mos7720_port_probe(struct usb_serial_port *port) | |||
2019 | if (!mos7720_port) | 2011 | if (!mos7720_port) |
2020 | return -ENOMEM; | 2012 | return -ENOMEM; |
2021 | 2013 | ||
2022 | /* Initialize all port interrupt end point to port 0 int endpoint. | ||
2023 | * Our device has only one interrupt endpoint common to all ports. | ||
2024 | */ | ||
2025 | port->interrupt_in_endpointAddress = | ||
2026 | port->serial->port[0]->interrupt_in_endpointAddress; | ||
2027 | mos7720_port->port = port; | 2014 | mos7720_port->port = port; |
2028 | 2015 | ||
2029 | usb_set_serial_port_data(port, mos7720_port); | 2016 | usb_set_serial_port_data(port, mos7720_port); |
@@ -2053,7 +2040,6 @@ static struct usb_serial_driver moschip7720_2port_driver = { | |||
2053 | .close = mos7720_close, | 2040 | .close = mos7720_close, |
2054 | .throttle = mos7720_throttle, | 2041 | .throttle = mos7720_throttle, |
2055 | .unthrottle = mos7720_unthrottle, | 2042 | .unthrottle = mos7720_unthrottle, |
2056 | .probe = mos77xx_probe, | ||
2057 | .attach = mos7720_startup, | 2043 | .attach = mos7720_startup, |
2058 | .release = mos7720_release, | 2044 | .release = mos7720_release, |
2059 | .port_probe = mos7720_port_probe, | 2045 | .port_probe = mos7720_port_probe, |
@@ -2067,7 +2053,7 @@ static struct usb_serial_driver moschip7720_2port_driver = { | |||
2067 | .chars_in_buffer = mos7720_chars_in_buffer, | 2053 | .chars_in_buffer = mos7720_chars_in_buffer, |
2068 | .break_ctl = mos7720_break, | 2054 | .break_ctl = mos7720_break, |
2069 | .read_bulk_callback = mos7720_bulk_in_callback, | 2055 | .read_bulk_callback = mos7720_bulk_in_callback, |
2070 | .read_int_callback = NULL /* dynamically assigned in probe() */ | 2056 | .read_int_callback = mos7720_interrupt_callback, |
2071 | }; | 2057 | }; |
2072 | 2058 | ||
2073 | static struct usb_serial_driver * const serial_drivers[] = { | 2059 | static struct usb_serial_driver * const serial_drivers[] = { |
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 9a220b8e810f..ea27fb23967a 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
@@ -214,7 +214,6 @@ MODULE_DEVICE_TABLE(usb, id_table); | |||
214 | 214 | ||
215 | struct moschip_port { | 215 | struct moschip_port { |
216 | int port_num; /*Actual port number in the device(1,2,etc) */ | 216 | int port_num; /*Actual port number in the device(1,2,etc) */ |
217 | struct urb *write_urb; /* write URB for this port */ | ||
218 | struct urb *read_urb; /* read URB for this port */ | 217 | struct urb *read_urb; /* read URB for this port */ |
219 | __u8 shadowLCR; /* last LCR value received */ | 218 | __u8 shadowLCR; /* last LCR value received */ |
220 | __u8 shadowMCR; /* last MCR value received */ | 219 | __u8 shadowMCR; /* last MCR value received */ |
@@ -1037,9 +1036,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1037 | serial, | 1036 | serial, |
1038 | serial->port[0]->interrupt_in_urb->interval); | 1037 | serial->port[0]->interrupt_in_urb->interval); |
1039 | 1038 | ||
1040 | /* start interrupt read for mos7840 * | 1039 | /* start interrupt read for mos7840 */ |
1041 | * will continue as long as mos7840 is connected */ | ||
1042 | |||
1043 | response = | 1040 | response = |
1044 | usb_submit_urb(serial->port[0]->interrupt_in_urb, | 1041 | usb_submit_urb(serial->port[0]->interrupt_in_urb, |
1045 | GFP_KERNEL); | 1042 | GFP_KERNEL); |
@@ -1186,7 +1183,6 @@ static void mos7840_close(struct usb_serial_port *port) | |||
1186 | } | 1183 | } |
1187 | } | 1184 | } |
1188 | 1185 | ||
1189 | usb_kill_urb(mos7840_port->write_urb); | ||
1190 | usb_kill_urb(mos7840_port->read_urb); | 1186 | usb_kill_urb(mos7840_port->read_urb); |
1191 | mos7840_port->read_urb_busy = false; | 1187 | mos7840_port->read_urb_busy = false; |
1192 | 1188 | ||
@@ -1199,12 +1195,6 @@ static void mos7840_close(struct usb_serial_port *port) | |||
1199 | } | 1195 | } |
1200 | } | 1196 | } |
1201 | 1197 | ||
1202 | if (mos7840_port->write_urb) { | ||
1203 | /* if this urb had a transfer buffer already (old tx) free it */ | ||
1204 | kfree(mos7840_port->write_urb->transfer_buffer); | ||
1205 | usb_free_urb(mos7840_port->write_urb); | ||
1206 | } | ||
1207 | |||
1208 | Data = 0x0; | 1198 | Data = 0x0; |
1209 | mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); | 1199 | mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); |
1210 | 1200 | ||
@@ -2113,6 +2103,17 @@ static int mos7840_calc_num_ports(struct usb_serial *serial) | |||
2113 | return mos7840_num_ports; | 2103 | return mos7840_num_ports; |
2114 | } | 2104 | } |
2115 | 2105 | ||
2106 | static int mos7840_attach(struct usb_serial *serial) | ||
2107 | { | ||
2108 | if (serial->num_bulk_in < serial->num_ports || | ||
2109 | serial->num_bulk_out < serial->num_ports) { | ||
2110 | dev_err(&serial->interface->dev, "missing endpoints\n"); | ||
2111 | return -ENODEV; | ||
2112 | } | ||
2113 | |||
2114 | return 0; | ||
2115 | } | ||
2116 | |||
2116 | static int mos7840_port_probe(struct usb_serial_port *port) | 2117 | static int mos7840_port_probe(struct usb_serial_port *port) |
2117 | { | 2118 | { |
2118 | struct usb_serial *serial = port->serial; | 2119 | struct usb_serial *serial = port->serial; |
@@ -2388,6 +2389,7 @@ static struct usb_serial_driver moschip7840_4port_device = { | |||
2388 | .tiocmset = mos7840_tiocmset, | 2389 | .tiocmset = mos7840_tiocmset, |
2389 | .tiocmiwait = usb_serial_generic_tiocmiwait, | 2390 | .tiocmiwait = usb_serial_generic_tiocmiwait, |
2390 | .get_icount = usb_serial_generic_get_icount, | 2391 | .get_icount = usb_serial_generic_get_icount, |
2392 | .attach = mos7840_attach, | ||
2391 | .port_probe = mos7840_port_probe, | 2393 | .port_probe = mos7840_port_probe, |
2392 | .port_remove = mos7840_port_remove, | 2394 | .port_remove = mos7840_port_remove, |
2393 | .read_bulk_callback = mos7840_bulk_in_callback, | 2395 | .read_bulk_callback = mos7840_bulk_in_callback, |
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index f6c6900bccf0..a180b17d2432 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c | |||
@@ -38,6 +38,7 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
38 | const unsigned char *buf, int count); | 38 | const unsigned char *buf, int count); |
39 | static int omninet_write_room(struct tty_struct *tty); | 39 | static int omninet_write_room(struct tty_struct *tty); |
40 | static void omninet_disconnect(struct usb_serial *serial); | 40 | static void omninet_disconnect(struct usb_serial *serial); |
41 | static int omninet_attach(struct usb_serial *serial); | ||
41 | static int omninet_port_probe(struct usb_serial_port *port); | 42 | static int omninet_port_probe(struct usb_serial_port *port); |
42 | static int omninet_port_remove(struct usb_serial_port *port); | 43 | static int omninet_port_remove(struct usb_serial_port *port); |
43 | 44 | ||
@@ -56,6 +57,7 @@ static struct usb_serial_driver zyxel_omninet_device = { | |||
56 | .description = "ZyXEL - omni.net lcd plus usb", | 57 | .description = "ZyXEL - omni.net lcd plus usb", |
57 | .id_table = id_table, | 58 | .id_table = id_table, |
58 | .num_ports = 1, | 59 | .num_ports = 1, |
60 | .attach = omninet_attach, | ||
59 | .port_probe = omninet_port_probe, | 61 | .port_probe = omninet_port_probe, |
60 | .port_remove = omninet_port_remove, | 62 | .port_remove = omninet_port_remove, |
61 | .open = omninet_open, | 63 | .open = omninet_open, |
@@ -104,6 +106,17 @@ struct omninet_data { | |||
104 | __u8 od_outseq; /* Sequence number for bulk_out URBs */ | 106 | __u8 od_outseq; /* Sequence number for bulk_out URBs */ |
105 | }; | 107 | }; |
106 | 108 | ||
109 | static int omninet_attach(struct usb_serial *serial) | ||
110 | { | ||
111 | /* The second bulk-out endpoint is used for writing. */ | ||
112 | if (serial->num_bulk_out < 2) { | ||
113 | dev_err(&serial->interface->dev, "missing endpoints\n"); | ||
114 | return -ENODEV; | ||
115 | } | ||
116 | |||
117 | return 0; | ||
118 | } | ||
119 | |||
107 | static int omninet_port_probe(struct usb_serial_port *port) | 120 | static int omninet_port_probe(struct usb_serial_port *port) |
108 | { | 121 | { |
109 | struct omninet_data *od; | 122 | struct omninet_data *od; |
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c index a4b88bc038b6..b8bf52bf7a94 100644 --- a/drivers/usb/serial/oti6858.c +++ b/drivers/usb/serial/oti6858.c | |||
@@ -134,6 +134,7 @@ static int oti6858_chars_in_buffer(struct tty_struct *tty); | |||
134 | static int oti6858_tiocmget(struct tty_struct *tty); | 134 | static int oti6858_tiocmget(struct tty_struct *tty); |
135 | static int oti6858_tiocmset(struct tty_struct *tty, | 135 | static int oti6858_tiocmset(struct tty_struct *tty, |
136 | unsigned int set, unsigned int clear); | 136 | unsigned int set, unsigned int clear); |
137 | static int oti6858_attach(struct usb_serial *serial); | ||
137 | static int oti6858_port_probe(struct usb_serial_port *port); | 138 | static int oti6858_port_probe(struct usb_serial_port *port); |
138 | static int oti6858_port_remove(struct usb_serial_port *port); | 139 | static int oti6858_port_remove(struct usb_serial_port *port); |
139 | 140 | ||
@@ -158,6 +159,7 @@ static struct usb_serial_driver oti6858_device = { | |||
158 | .write_bulk_callback = oti6858_write_bulk_callback, | 159 | .write_bulk_callback = oti6858_write_bulk_callback, |
159 | .write_room = oti6858_write_room, | 160 | .write_room = oti6858_write_room, |
160 | .chars_in_buffer = oti6858_chars_in_buffer, | 161 | .chars_in_buffer = oti6858_chars_in_buffer, |
162 | .attach = oti6858_attach, | ||
161 | .port_probe = oti6858_port_probe, | 163 | .port_probe = oti6858_port_probe, |
162 | .port_remove = oti6858_port_remove, | 164 | .port_remove = oti6858_port_remove, |
163 | }; | 165 | }; |
@@ -324,6 +326,20 @@ static void send_data(struct work_struct *work) | |||
324 | usb_serial_port_softint(port); | 326 | usb_serial_port_softint(port); |
325 | } | 327 | } |
326 | 328 | ||
329 | static int oti6858_attach(struct usb_serial *serial) | ||
330 | { | ||
331 | unsigned char num_ports = serial->num_ports; | ||
332 | |||
333 | if (serial->num_bulk_in < num_ports || | ||
334 | serial->num_bulk_out < num_ports || | ||
335 | serial->num_interrupt_in < num_ports) { | ||
336 | dev_err(&serial->interface->dev, "missing endpoints\n"); | ||
337 | return -ENODEV; | ||
338 | } | ||
339 | |||
340 | return 0; | ||
341 | } | ||
342 | |||
327 | static int oti6858_port_probe(struct usb_serial_port *port) | 343 | static int oti6858_port_probe(struct usb_serial_port *port) |
328 | { | 344 | { |
329 | struct oti6858_private *priv; | 345 | struct oti6858_private *priv; |
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index ae682e4eeaef..46fca6b75846 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -220,9 +220,17 @@ static int pl2303_probe(struct usb_serial *serial, | |||
220 | static int pl2303_startup(struct usb_serial *serial) | 220 | static int pl2303_startup(struct usb_serial *serial) |
221 | { | 221 | { |
222 | struct pl2303_serial_private *spriv; | 222 | struct pl2303_serial_private *spriv; |
223 | unsigned char num_ports = serial->num_ports; | ||
223 | enum pl2303_type type = TYPE_01; | 224 | enum pl2303_type type = TYPE_01; |
224 | unsigned char *buf; | 225 | unsigned char *buf; |
225 | 226 | ||
227 | if (serial->num_bulk_in < num_ports || | ||
228 | serial->num_bulk_out < num_ports || | ||
229 | serial->num_interrupt_in < num_ports) { | ||
230 | dev_err(&serial->interface->dev, "missing endpoints\n"); | ||
231 | return -ENODEV; | ||
232 | } | ||
233 | |||
226 | spriv = kzalloc(sizeof(*spriv), GFP_KERNEL); | 234 | spriv = kzalloc(sizeof(*spriv), GFP_KERNEL); |
227 | if (!spriv) | 235 | if (!spriv) |
228 | return -ENOMEM; | 236 | return -ENOMEM; |
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c index 659cb8606bd9..5709cc93b083 100644 --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c | |||
@@ -408,16 +408,12 @@ static void qt2_close(struct usb_serial_port *port) | |||
408 | { | 408 | { |
409 | struct usb_serial *serial; | 409 | struct usb_serial *serial; |
410 | struct qt2_port_private *port_priv; | 410 | struct qt2_port_private *port_priv; |
411 | unsigned long flags; | ||
412 | int i; | 411 | int i; |
413 | 412 | ||
414 | serial = port->serial; | 413 | serial = port->serial; |
415 | port_priv = usb_get_serial_port_data(port); | 414 | port_priv = usb_get_serial_port_data(port); |
416 | 415 | ||
417 | spin_lock_irqsave(&port_priv->urb_lock, flags); | ||
418 | usb_kill_urb(port_priv->write_urb); | 416 | usb_kill_urb(port_priv->write_urb); |
419 | port_priv->urb_in_use = false; | ||
420 | spin_unlock_irqrestore(&port_priv->urb_lock, flags); | ||
421 | 417 | ||
422 | /* flush the port transmit buffer */ | 418 | /* flush the port transmit buffer */ |
423 | i = usb_control_msg(serial->dev, | 419 | i = usb_control_msg(serial->dev, |
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c index ef0dbf0703c5..475e6c31b266 100644 --- a/drivers/usb/serial/spcp8x5.c +++ b/drivers/usb/serial/spcp8x5.c | |||
@@ -154,6 +154,19 @@ static int spcp8x5_probe(struct usb_serial *serial, | |||
154 | return 0; | 154 | return 0; |
155 | } | 155 | } |
156 | 156 | ||
157 | static int spcp8x5_attach(struct usb_serial *serial) | ||
158 | { | ||
159 | unsigned char num_ports = serial->num_ports; | ||
160 | |||
161 | if (serial->num_bulk_in < num_ports || | ||
162 | serial->num_bulk_out < num_ports) { | ||
163 | dev_err(&serial->interface->dev, "missing endpoints\n"); | ||
164 | return -ENODEV; | ||
165 | } | ||
166 | |||
167 | return 0; | ||
168 | } | ||
169 | |||
157 | static int spcp8x5_port_probe(struct usb_serial_port *port) | 170 | static int spcp8x5_port_probe(struct usb_serial_port *port) |
158 | { | 171 | { |
159 | const struct usb_device_id *id = usb_get_serial_data(port->serial); | 172 | const struct usb_device_id *id = usb_get_serial_data(port->serial); |
@@ -477,6 +490,7 @@ static struct usb_serial_driver spcp8x5_device = { | |||
477 | .tiocmget = spcp8x5_tiocmget, | 490 | .tiocmget = spcp8x5_tiocmget, |
478 | .tiocmset = spcp8x5_tiocmset, | 491 | .tiocmset = spcp8x5_tiocmset, |
479 | .probe = spcp8x5_probe, | 492 | .probe = spcp8x5_probe, |
493 | .attach = spcp8x5_attach, | ||
480 | .port_probe = spcp8x5_port_probe, | 494 | .port_probe = spcp8x5_port_probe, |
481 | .port_remove = spcp8x5_port_remove, | 495 | .port_remove = spcp8x5_port_remove, |
482 | }; | 496 | }; |
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 8db9d071d940..64b85b8dedf3 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -579,6 +579,13 @@ static int ti_startup(struct usb_serial *serial) | |||
579 | goto free_tdev; | 579 | goto free_tdev; |
580 | } | 580 | } |
581 | 581 | ||
582 | if (serial->num_bulk_in < serial->num_ports || | ||
583 | serial->num_bulk_out < serial->num_ports) { | ||
584 | dev_err(&serial->interface->dev, "missing endpoints\n"); | ||
585 | status = -ENODEV; | ||
586 | goto free_tdev; | ||
587 | } | ||
588 | |||
582 | return 0; | 589 | return 0; |
583 | 590 | ||
584 | free_tdev: | 591 | free_tdev: |
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index af3c7eecff91..16cc18369111 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h | |||
@@ -2109,6 +2109,13 @@ UNUSUAL_DEV( 0x152d, 0x2566, 0x0114, 0x0114, | |||
2109 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 2109 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
2110 | US_FL_BROKEN_FUA ), | 2110 | US_FL_BROKEN_FUA ), |
2111 | 2111 | ||
2112 | /* Reported-by George Cherian <george.cherian@cavium.com> */ | ||
2113 | UNUSUAL_DEV(0x152d, 0x9561, 0x0000, 0x9999, | ||
2114 | "JMicron", | ||
2115 | "JMS56x", | ||
2116 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | ||
2117 | US_FL_NO_REPORT_OPCODES), | ||
2118 | |||
2112 | /* | 2119 | /* |
2113 | * Entrega Technologies U1-SC25 (later Xircom PortGear PGSCSI) | 2120 | * Entrega Technologies U1-SC25 (later Xircom PortGear PGSCSI) |
2114 | * and Mac USB Dock USB-SCSI */ | 2121 | * and Mac USB Dock USB-SCSI */ |
diff --git a/include/uapi/linux/usb/functionfs.h b/include/uapi/linux/usb/functionfs.h index acc63697a0cc..b2a31a55a612 100644 --- a/include/uapi/linux/usb/functionfs.h +++ b/include/uapi/linux/usb/functionfs.h | |||
@@ -93,6 +93,7 @@ struct usb_ext_prop_desc { | |||
93 | * | 0 | magic | LE32 | FUNCTIONFS_DESCRIPTORS_MAGIC_V2 | | 93 | * | 0 | magic | LE32 | FUNCTIONFS_DESCRIPTORS_MAGIC_V2 | |
94 | * | 4 | length | LE32 | length of the whole data chunk | | 94 | * | 4 | length | LE32 | length of the whole data chunk | |
95 | * | 8 | flags | LE32 | combination of functionfs_flags | | 95 | * | 8 | flags | LE32 | combination of functionfs_flags | |
96 | * | | eventfd | LE32 | eventfd file descriptor | | ||
96 | * | | fs_count | LE32 | number of full-speed descriptors | | 97 | * | | fs_count | LE32 | number of full-speed descriptors | |
97 | * | | hs_count | LE32 | number of high-speed descriptors | | 98 | * | | hs_count | LE32 | number of high-speed descriptors | |
98 | * | | ss_count | LE32 | number of super-speed descriptors | | 99 | * | | ss_count | LE32 | number of super-speed descriptors | |