diff options
-rw-r--r-- | Documentation/devicetree/bindings/usb/dwc2.txt | 5 | ||||
-rw-r--r-- | drivers/usb/chipidea/host.c | 2 | ||||
-rw-r--r-- | drivers/usb/dwc2/core.c | 11 | ||||
-rw-r--r-- | drivers/usb/dwc2/core.h | 7 | ||||
-rw-r--r-- | drivers/usb/dwc2/gadget.c | 53 | ||||
-rw-r--r-- | drivers/usb/dwc3/gadget.c | 26 | ||||
-rw-r--r-- | drivers/usb/gadget/function/f_fs.c | 107 | ||||
-rw-r--r-- | drivers/usb/gadget/function/u_ether.c | 5 | ||||
-rw-r--r-- | drivers/usb/gadget/udc/atmel_usba_udc.c | 2 | ||||
-rw-r--r-- | drivers/usb/host/ehci-platform.c | 2 | ||||
-rw-r--r-- | drivers/usb/host/ohci-at91.c | 9 | ||||
-rw-r--r-- | drivers/usb/host/ohci-hcd.c | 2 | ||||
-rw-r--r-- | drivers/usb/host/xhci-hub.c | 41 | ||||
-rw-r--r-- | drivers/usb/host/xhci-pci.c | 10 | ||||
-rw-r--r-- | drivers/usb/host/xhci.h | 3 | ||||
-rw-r--r-- | drivers/usb/musb/musb_gadget.c | 4 | ||||
-rw-r--r-- | drivers/usb/musb/omap2430.c | 7 | ||||
-rw-r--r-- | drivers/usb/renesas_usbhs/rcar3.c | 8 | ||||
-rw-r--r-- | drivers/usb/serial/cp210x.c | 4 | ||||
-rw-r--r-- | drivers/usb/serial/ftdi_sio.c | 3 | ||||
-rw-r--r-- | drivers/usb/serial/ftdi_sio_ids.h | 5 | ||||
-rw-r--r-- | drivers/usb/serial/usb-serial.c | 3 | ||||
-rw-r--r-- | drivers/usb/wusbcore/crypto.c | 61 |
23 files changed, 296 insertions, 84 deletions
diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt b/Documentation/devicetree/bindings/usb/dwc2.txt index 455f2c310a1b..2c30a5479069 100644 --- a/Documentation/devicetree/bindings/usb/dwc2.txt +++ b/Documentation/devicetree/bindings/usb/dwc2.txt | |||
@@ -28,10 +28,7 @@ Refer to phy/phy-bindings.txt for generic phy consumer properties | |||
28 | - g-use-dma: enable dma usage in gadget driver. | 28 | - g-use-dma: enable dma usage in gadget driver. |
29 | - g-rx-fifo-size: size of rx fifo size in gadget mode. | 29 | - g-rx-fifo-size: size of rx fifo size in gadget mode. |
30 | - g-np-tx-fifo-size: size of non-periodic tx fifo size in gadget mode. | 30 | - g-np-tx-fifo-size: size of non-periodic tx fifo size in gadget mode. |
31 | 31 | - g-tx-fifo-size: size of periodic tx fifo per endpoint (except ep0) in gadget mode. | |
32 | Deprecated properties: | ||
33 | - g-tx-fifo-size: size of periodic tx fifo per endpoint (except ep0) | ||
34 | in gadget mode. | ||
35 | 32 | ||
36 | Example: | 33 | Example: |
37 | 34 | ||
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 96ae69502c86..111b0e0b8698 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c | |||
@@ -188,6 +188,8 @@ static void host_stop(struct ci_hdrc *ci) | |||
188 | 188 | ||
189 | if (hcd) { | 189 | if (hcd) { |
190 | usb_remove_hcd(hcd); | 190 | usb_remove_hcd(hcd); |
191 | ci->role = CI_ROLE_END; | ||
192 | synchronize_irq(ci->irq); | ||
191 | usb_put_hcd(hcd); | 193 | usb_put_hcd(hcd); |
192 | if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci) && | 194 | if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci) && |
193 | (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON)) | 195 | (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON)) |
diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index fa9b26b91507..4c0fa0b17353 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c | |||
@@ -463,9 +463,18 @@ static void dwc2_clear_force_mode(struct dwc2_hsotg *hsotg) | |||
463 | */ | 463 | */ |
464 | void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg) | 464 | void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg) |
465 | { | 465 | { |
466 | bool ret; | ||
467 | |||
466 | switch (hsotg->dr_mode) { | 468 | switch (hsotg->dr_mode) { |
467 | case USB_DR_MODE_HOST: | 469 | case USB_DR_MODE_HOST: |
468 | dwc2_force_mode(hsotg, true); | 470 | ret = dwc2_force_mode(hsotg, true); |
471 | /* | ||
472 | * NOTE: This is required for some rockchip soc based | ||
473 | * platforms on their host-only dwc2. | ||
474 | */ | ||
475 | if (!ret) | ||
476 | msleep(50); | ||
477 | |||
469 | break; | 478 | break; |
470 | case USB_DR_MODE_PERIPHERAL: | 479 | case USB_DR_MODE_PERIPHERAL: |
471 | dwc2_force_mode(hsotg, false); | 480 | dwc2_force_mode(hsotg, false); |
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index aad4107ef927..2a21a0414b1d 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h | |||
@@ -259,6 +259,13 @@ enum dwc2_lx_state { | |||
259 | DWC2_L3, /* Off state */ | 259 | DWC2_L3, /* Off state */ |
260 | }; | 260 | }; |
261 | 261 | ||
262 | /* | ||
263 | * Gadget periodic tx fifo sizes as used by legacy driver | ||
264 | * EP0 is not included | ||
265 | */ | ||
266 | #define DWC2_G_P_LEGACY_TX_FIFO_SIZE {256, 256, 256, 256, 768, 768, 768, \ | ||
267 | 768, 0, 0, 0, 0, 0, 0, 0} | ||
268 | |||
262 | /* Gadget ep0 states */ | 269 | /* Gadget ep0 states */ |
263 | enum dwc2_ep0_state { | 270 | enum dwc2_ep0_state { |
264 | DWC2_EP0_SETUP, | 271 | DWC2_EP0_SETUP, |
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 4cd6403a7566..24fbebc9b409 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c | |||
@@ -186,10 +186,9 @@ static void dwc2_hsotg_ctrl_epint(struct dwc2_hsotg *hsotg, | |||
186 | */ | 186 | */ |
187 | static void dwc2_hsotg_init_fifo(struct dwc2_hsotg *hsotg) | 187 | static void dwc2_hsotg_init_fifo(struct dwc2_hsotg *hsotg) |
188 | { | 188 | { |
189 | unsigned int fifo; | 189 | unsigned int ep; |
190 | unsigned int addr; | 190 | unsigned int addr; |
191 | int timeout; | 191 | int timeout; |
192 | u32 dptxfsizn; | ||
193 | u32 val; | 192 | u32 val; |
194 | 193 | ||
195 | /* Reset fifo map if not correctly cleared during previous session */ | 194 | /* Reset fifo map if not correctly cleared during previous session */ |
@@ -217,16 +216,16 @@ static void dwc2_hsotg_init_fifo(struct dwc2_hsotg *hsotg) | |||
217 | * them to endpoints dynamically according to maxpacket size value of | 216 | * them to endpoints dynamically according to maxpacket size value of |
218 | * given endpoint. | 217 | * given endpoint. |
219 | */ | 218 | */ |
220 | for (fifo = 1; fifo < MAX_EPS_CHANNELS; fifo++) { | 219 | for (ep = 1; ep < MAX_EPS_CHANNELS; ep++) { |
221 | dptxfsizn = dwc2_readl(hsotg->regs + DPTXFSIZN(fifo)); | 220 | if (!hsotg->g_tx_fifo_sz[ep]) |
222 | 221 | continue; | |
223 | val = (dptxfsizn & FIFOSIZE_DEPTH_MASK) | addr; | 222 | val = addr; |
224 | addr += dptxfsizn >> FIFOSIZE_DEPTH_SHIFT; | 223 | val |= hsotg->g_tx_fifo_sz[ep] << FIFOSIZE_DEPTH_SHIFT; |
225 | 224 | WARN_ONCE(addr + hsotg->g_tx_fifo_sz[ep] > hsotg->fifo_mem, | |
226 | if (addr > hsotg->fifo_mem) | 225 | "insufficient fifo memory"); |
227 | break; | 226 | addr += hsotg->g_tx_fifo_sz[ep]; |
228 | 227 | ||
229 | dwc2_writel(val, hsotg->regs + DPTXFSIZN(fifo)); | 228 | dwc2_writel(val, hsotg->regs + DPTXFSIZN(ep)); |
230 | } | 229 | } |
231 | 230 | ||
232 | /* | 231 | /* |
@@ -3807,10 +3806,36 @@ static void dwc2_hsotg_dump(struct dwc2_hsotg *hsotg) | |||
3807 | static void dwc2_hsotg_of_probe(struct dwc2_hsotg *hsotg) | 3806 | static void dwc2_hsotg_of_probe(struct dwc2_hsotg *hsotg) |
3808 | { | 3807 | { |
3809 | struct device_node *np = hsotg->dev->of_node; | 3808 | struct device_node *np = hsotg->dev->of_node; |
3809 | u32 len = 0; | ||
3810 | u32 i = 0; | ||
3810 | 3811 | ||
3811 | /* Enable dma if requested in device tree */ | 3812 | /* Enable dma if requested in device tree */ |
3812 | hsotg->g_using_dma = of_property_read_bool(np, "g-use-dma"); | 3813 | hsotg->g_using_dma = of_property_read_bool(np, "g-use-dma"); |
3813 | 3814 | ||
3815 | /* | ||
3816 | * Register TX periodic fifo size per endpoint. | ||
3817 | * EP0 is excluded since it has no fifo configuration. | ||
3818 | */ | ||
3819 | if (!of_find_property(np, "g-tx-fifo-size", &len)) | ||
3820 | goto rx_fifo; | ||
3821 | |||
3822 | len /= sizeof(u32); | ||
3823 | |||
3824 | /* Read tx fifo sizes other than ep0 */ | ||
3825 | if (of_property_read_u32_array(np, "g-tx-fifo-size", | ||
3826 | &hsotg->g_tx_fifo_sz[1], len)) | ||
3827 | goto rx_fifo; | ||
3828 | |||
3829 | /* Add ep0 */ | ||
3830 | len++; | ||
3831 | |||
3832 | /* Make remaining TX fifos unavailable */ | ||
3833 | if (len < MAX_EPS_CHANNELS) { | ||
3834 | for (i = len; i < MAX_EPS_CHANNELS; i++) | ||
3835 | hsotg->g_tx_fifo_sz[i] = 0; | ||
3836 | } | ||
3837 | |||
3838 | rx_fifo: | ||
3814 | /* Register RX fifo size */ | 3839 | /* Register RX fifo size */ |
3815 | of_property_read_u32(np, "g-rx-fifo-size", &hsotg->g_rx_fifo_sz); | 3840 | of_property_read_u32(np, "g-rx-fifo-size", &hsotg->g_rx_fifo_sz); |
3816 | 3841 | ||
@@ -3832,10 +3857,13 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq) | |||
3832 | struct device *dev = hsotg->dev; | 3857 | struct device *dev = hsotg->dev; |
3833 | int epnum; | 3858 | int epnum; |
3834 | int ret; | 3859 | int ret; |
3860 | int i; | ||
3861 | u32 p_tx_fifo[] = DWC2_G_P_LEGACY_TX_FIFO_SIZE; | ||
3835 | 3862 | ||
3836 | /* Initialize to legacy fifo configuration values */ | 3863 | /* Initialize to legacy fifo configuration values */ |
3837 | hsotg->g_rx_fifo_sz = 2048; | 3864 | hsotg->g_rx_fifo_sz = 2048; |
3838 | hsotg->g_np_g_tx_fifo_sz = 1024; | 3865 | hsotg->g_np_g_tx_fifo_sz = 1024; |
3866 | memcpy(&hsotg->g_tx_fifo_sz[1], p_tx_fifo, sizeof(p_tx_fifo)); | ||
3839 | /* Device tree specific probe */ | 3867 | /* Device tree specific probe */ |
3840 | dwc2_hsotg_of_probe(hsotg); | 3868 | dwc2_hsotg_of_probe(hsotg); |
3841 | 3869 | ||
@@ -3853,6 +3881,9 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq) | |||
3853 | dev_dbg(dev, "NonPeriodic TXFIFO size: %d\n", | 3881 | dev_dbg(dev, "NonPeriodic TXFIFO size: %d\n", |
3854 | hsotg->g_np_g_tx_fifo_sz); | 3882 | hsotg->g_np_g_tx_fifo_sz); |
3855 | dev_dbg(dev, "RXFIFO size: %d\n", hsotg->g_rx_fifo_sz); | 3883 | dev_dbg(dev, "RXFIFO size: %d\n", hsotg->g_rx_fifo_sz); |
3884 | for (i = 0; i < MAX_EPS_CHANNELS; i++) | ||
3885 | dev_dbg(dev, "Periodic TXFIFO%2d size: %d\n", i, | ||
3886 | hsotg->g_tx_fifo_sz[i]); | ||
3856 | 3887 | ||
3857 | hsotg->gadget.max_speed = USB_SPEED_HIGH; | 3888 | hsotg->gadget.max_speed = USB_SPEED_HIGH; |
3858 | hsotg->gadget.ops = &dwc2_hsotg_gadget_ops; | 3889 | hsotg->gadget.ops = &dwc2_hsotg_gadget_ops; |
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 07cc8929f271..1dfa56a5f1c5 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
@@ -783,6 +783,7 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, | |||
783 | req->trb = trb; | 783 | req->trb = trb; |
784 | req->trb_dma = dwc3_trb_dma_offset(dep, trb); | 784 | req->trb_dma = dwc3_trb_dma_offset(dep, trb); |
785 | req->first_trb_index = dep->trb_enqueue; | 785 | req->first_trb_index = dep->trb_enqueue; |
786 | dep->queued_requests++; | ||
786 | } | 787 | } |
787 | 788 | ||
788 | dwc3_ep_inc_enq(dep); | 789 | dwc3_ep_inc_enq(dep); |
@@ -833,8 +834,6 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, | |||
833 | 834 | ||
834 | trb->ctrl |= DWC3_TRB_CTRL_HWO; | 835 | trb->ctrl |= DWC3_TRB_CTRL_HWO; |
835 | 836 | ||
836 | dep->queued_requests++; | ||
837 | |||
838 | trace_dwc3_prepare_trb(dep, trb); | 837 | trace_dwc3_prepare_trb(dep, trb); |
839 | } | 838 | } |
840 | 839 | ||
@@ -1074,9 +1073,17 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) | |||
1074 | 1073 | ||
1075 | list_add_tail(&req->list, &dep->pending_list); | 1074 | list_add_tail(&req->list, &dep->pending_list); |
1076 | 1075 | ||
1077 | if (usb_endpoint_xfer_isoc(dep->endpoint.desc) && | 1076 | /* |
1078 | dep->flags & DWC3_EP_PENDING_REQUEST) { | 1077 | * NOTICE: Isochronous endpoints should NEVER be prestarted. We must |
1079 | if (list_empty(&dep->started_list)) { | 1078 | * wait for a XferNotReady event so we will know what's the current |
1079 | * (micro-)frame number. | ||
1080 | * | ||
1081 | * Without this trick, we are very, very likely gonna get Bus Expiry | ||
1082 | * errors which will force us issue EndTransfer command. | ||
1083 | */ | ||
1084 | if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) { | ||
1085 | if ((dep->flags & DWC3_EP_PENDING_REQUEST) && | ||
1086 | list_empty(&dep->started_list)) { | ||
1080 | dwc3_stop_active_transfer(dwc, dep->number, true); | 1087 | dwc3_stop_active_transfer(dwc, dep->number, true); |
1081 | dep->flags = DWC3_EP_ENABLED; | 1088 | dep->flags = DWC3_EP_ENABLED; |
1082 | } | 1089 | } |
@@ -1861,8 +1868,11 @@ static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep, | |||
1861 | unsigned int s_pkt = 0; | 1868 | unsigned int s_pkt = 0; |
1862 | unsigned int trb_status; | 1869 | unsigned int trb_status; |
1863 | 1870 | ||
1864 | dep->queued_requests--; | ||
1865 | dwc3_ep_inc_deq(dep); | 1871 | dwc3_ep_inc_deq(dep); |
1872 | |||
1873 | if (req->trb == trb) | ||
1874 | dep->queued_requests--; | ||
1875 | |||
1866 | trace_dwc3_complete_trb(dep, trb); | 1876 | trace_dwc3_complete_trb(dep, trb); |
1867 | 1877 | ||
1868 | /* | 1878 | /* |
@@ -2980,7 +2990,7 @@ err3: | |||
2980 | kfree(dwc->setup_buf); | 2990 | kfree(dwc->setup_buf); |
2981 | 2991 | ||
2982 | err2: | 2992 | err2: |
2983 | dma_free_coherent(dwc->dev, sizeof(*dwc->ep0_trb), | 2993 | dma_free_coherent(dwc->dev, sizeof(*dwc->ep0_trb) * 2, |
2984 | dwc->ep0_trb, dwc->ep0_trb_addr); | 2994 | dwc->ep0_trb, dwc->ep0_trb_addr); |
2985 | 2995 | ||
2986 | err1: | 2996 | err1: |
@@ -3005,7 +3015,7 @@ void dwc3_gadget_exit(struct dwc3 *dwc) | |||
3005 | kfree(dwc->setup_buf); | 3015 | kfree(dwc->setup_buf); |
3006 | kfree(dwc->zlp_buf); | 3016 | kfree(dwc->zlp_buf); |
3007 | 3017 | ||
3008 | dma_free_coherent(dwc->dev, sizeof(*dwc->ep0_trb), | 3018 | dma_free_coherent(dwc->dev, sizeof(*dwc->ep0_trb) * 2, |
3009 | dwc->ep0_trb, dwc->ep0_trb_addr); | 3019 | dwc->ep0_trb, dwc->ep0_trb_addr); |
3010 | 3020 | ||
3011 | dma_free_coherent(dwc->dev, sizeof(*dwc->ctrl_req), | 3021 | dma_free_coherent(dwc->dev, sizeof(*dwc->ctrl_req), |
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 54ad100af35b..e40d47d47d82 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c | |||
@@ -136,8 +136,60 @@ struct ffs_epfile { | |||
136 | /* | 136 | /* |
137 | * Buffer for holding data from partial reads which may happen since | 137 | * Buffer for holding data from partial reads which may happen since |
138 | * we’re rounding user read requests to a multiple of a max packet size. | 138 | * we’re rounding user read requests to a multiple of a max packet size. |
139 | * | ||
140 | * The pointer is initialised with NULL value and may be set by | ||
141 | * __ffs_epfile_read_data function to point to a temporary buffer. | ||
142 | * | ||
143 | * In normal operation, calls to __ffs_epfile_read_buffered will consume | ||
144 | * data from said buffer and eventually free it. Importantly, while the | ||
145 | * function is using the buffer, it sets the pointer to NULL. This is | ||
146 | * all right since __ffs_epfile_read_data and __ffs_epfile_read_buffered | ||
147 | * can never run concurrently (they are synchronised by epfile->mutex) | ||
148 | * so the latter will not assign a new value to the pointer. | ||
149 | * | ||
150 | * Meanwhile ffs_func_eps_disable frees the buffer (if the pointer is | ||
151 | * valid) and sets the pointer to READ_BUFFER_DROP value. This special | ||
152 | * value is crux of the synchronisation between ffs_func_eps_disable and | ||
153 | * __ffs_epfile_read_data. | ||
154 | * | ||
155 | * Once __ffs_epfile_read_data is about to finish it will try to set the | ||
156 | * pointer back to its old value (as described above), but seeing as the | ||
157 | * pointer is not-NULL (namely READ_BUFFER_DROP) it will instead free | ||
158 | * the buffer. | ||
159 | * | ||
160 | * == State transitions == | ||
161 | * | ||
162 | * • ptr == NULL: (initial state) | ||
163 | * â—¦ __ffs_epfile_read_buffer_free: go to ptr == DROP | ||
164 | * â—¦ __ffs_epfile_read_buffered: nop | ||
165 | * â—¦ __ffs_epfile_read_data allocates temp buffer: go to ptr == buf | ||
166 | * ◦ reading finishes: n/a, not in ‘and reading’ state | ||
167 | * • ptr == DROP: | ||
168 | * â—¦ __ffs_epfile_read_buffer_free: nop | ||
169 | * â—¦ __ffs_epfile_read_buffered: go to ptr == NULL | ||
170 | * â—¦ __ffs_epfile_read_data allocates temp buffer: free buf, nop | ||
171 | * ◦ reading finishes: n/a, not in ‘and reading’ state | ||
172 | * • ptr == buf: | ||
173 | * â—¦ __ffs_epfile_read_buffer_free: free buf, go to ptr == DROP | ||
174 | * â—¦ __ffs_epfile_read_buffered: go to ptr == NULL and reading | ||
175 | * â—¦ __ffs_epfile_read_data: n/a, __ffs_epfile_read_buffered | ||
176 | * is always called first | ||
177 | * ◦ reading finishes: n/a, not in ‘and reading’ state | ||
178 | * • ptr == NULL and reading: | ||
179 | * â—¦ __ffs_epfile_read_buffer_free: go to ptr == DROP and reading | ||
180 | * â—¦ __ffs_epfile_read_buffered: n/a, mutex is held | ||
181 | * â—¦ __ffs_epfile_read_data: n/a, mutex is held | ||
182 | * ◦ reading finishes and … | ||
183 | * … all data read: free buf, go to ptr == NULL | ||
184 | * … otherwise: go to ptr == buf and reading | ||
185 | * • ptr == DROP and reading: | ||
186 | * â—¦ __ffs_epfile_read_buffer_free: nop | ||
187 | * â—¦ __ffs_epfile_read_buffered: n/a, mutex is held | ||
188 | * â—¦ __ffs_epfile_read_data: n/a, mutex is held | ||
189 | * â—¦ reading finishes: free buf, go to ptr == DROP | ||
139 | */ | 190 | */ |
140 | struct ffs_buffer *read_buffer; /* P: epfile->mutex */ | 191 | struct ffs_buffer *read_buffer; |
192 | #define READ_BUFFER_DROP ((struct ffs_buffer *)ERR_PTR(-ESHUTDOWN)) | ||
141 | 193 | ||
142 | char name[5]; | 194 | char name[5]; |
143 | 195 | ||
@@ -736,25 +788,47 @@ static void ffs_epfile_async_io_complete(struct usb_ep *_ep, | |||
736 | schedule_work(&io_data->work); | 788 | schedule_work(&io_data->work); |
737 | } | 789 | } |
738 | 790 | ||
791 | static void __ffs_epfile_read_buffer_free(struct ffs_epfile *epfile) | ||
792 | { | ||
793 | /* | ||
794 | * See comment in struct ffs_epfile for full read_buffer pointer | ||
795 | * synchronisation story. | ||
796 | */ | ||
797 | struct ffs_buffer *buf = xchg(&epfile->read_buffer, READ_BUFFER_DROP); | ||
798 | if (buf && buf != READ_BUFFER_DROP) | ||
799 | kfree(buf); | ||
800 | } | ||
801 | |||
739 | /* Assumes epfile->mutex is held. */ | 802 | /* Assumes epfile->mutex is held. */ |
740 | static ssize_t __ffs_epfile_read_buffered(struct ffs_epfile *epfile, | 803 | static ssize_t __ffs_epfile_read_buffered(struct ffs_epfile *epfile, |
741 | struct iov_iter *iter) | 804 | struct iov_iter *iter) |
742 | { | 805 | { |
743 | struct ffs_buffer *buf = epfile->read_buffer; | 806 | /* |
807 | * Null out epfile->read_buffer so ffs_func_eps_disable does not free | ||
808 | * the buffer while we are using it. See comment in struct ffs_epfile | ||
809 | * for full read_buffer pointer synchronisation story. | ||
810 | */ | ||
811 | struct ffs_buffer *buf = xchg(&epfile->read_buffer, NULL); | ||
744 | ssize_t ret; | 812 | ssize_t ret; |
745 | if (!buf) | 813 | if (!buf || buf == READ_BUFFER_DROP) |
746 | return 0; | 814 | return 0; |
747 | 815 | ||
748 | ret = copy_to_iter(buf->data, buf->length, iter); | 816 | ret = copy_to_iter(buf->data, buf->length, iter); |
749 | if (buf->length == ret) { | 817 | if (buf->length == ret) { |
750 | kfree(buf); | 818 | kfree(buf); |
751 | epfile->read_buffer = NULL; | 819 | return ret; |
752 | } else if (unlikely(iov_iter_count(iter))) { | 820 | } |
821 | |||
822 | if (unlikely(iov_iter_count(iter))) { | ||
753 | ret = -EFAULT; | 823 | ret = -EFAULT; |
754 | } else { | 824 | } else { |
755 | buf->length -= ret; | 825 | buf->length -= ret; |
756 | buf->data += ret; | 826 | buf->data += ret; |
757 | } | 827 | } |
828 | |||
829 | if (cmpxchg(&epfile->read_buffer, NULL, buf)) | ||
830 | kfree(buf); | ||
831 | |||
758 | return ret; | 832 | return ret; |
759 | } | 833 | } |
760 | 834 | ||
@@ -783,7 +857,15 @@ static ssize_t __ffs_epfile_read_data(struct ffs_epfile *epfile, | |||
783 | buf->length = data_len; | 857 | buf->length = data_len; |
784 | buf->data = buf->storage; | 858 | buf->data = buf->storage; |
785 | memcpy(buf->storage, data + ret, data_len); | 859 | memcpy(buf->storage, data + ret, data_len); |
786 | epfile->read_buffer = buf; | 860 | |
861 | /* | ||
862 | * At this point read_buffer is NULL or READ_BUFFER_DROP (if | ||
863 | * ffs_func_eps_disable has been called in the meanwhile). See comment | ||
864 | * in struct ffs_epfile for full read_buffer pointer synchronisation | ||
865 | * story. | ||
866 | */ | ||
867 | if (unlikely(cmpxchg(&epfile->read_buffer, NULL, buf))) | ||
868 | kfree(buf); | ||
787 | 869 | ||
788 | return ret; | 870 | return ret; |
789 | } | 871 | } |
@@ -1097,8 +1179,7 @@ ffs_epfile_release(struct inode *inode, struct file *file) | |||
1097 | 1179 | ||
1098 | ENTER(); | 1180 | ENTER(); |
1099 | 1181 | ||
1100 | kfree(epfile->read_buffer); | 1182 | __ffs_epfile_read_buffer_free(epfile); |
1101 | epfile->read_buffer = NULL; | ||
1102 | ffs_data_closed(epfile->ffs); | 1183 | ffs_data_closed(epfile->ffs); |
1103 | 1184 | ||
1104 | return 0; | 1185 | return 0; |
@@ -1724,24 +1805,20 @@ static void ffs_func_eps_disable(struct ffs_function *func) | |||
1724 | unsigned count = func->ffs->eps_count; | 1805 | unsigned count = func->ffs->eps_count; |
1725 | unsigned long flags; | 1806 | unsigned long flags; |
1726 | 1807 | ||
1808 | spin_lock_irqsave(&func->ffs->eps_lock, flags); | ||
1727 | do { | 1809 | do { |
1728 | if (epfile) | ||
1729 | mutex_lock(&epfile->mutex); | ||
1730 | spin_lock_irqsave(&func->ffs->eps_lock, flags); | ||
1731 | /* pending requests get nuked */ | 1810 | /* pending requests get nuked */ |
1732 | if (likely(ep->ep)) | 1811 | if (likely(ep->ep)) |
1733 | usb_ep_disable(ep->ep); | 1812 | usb_ep_disable(ep->ep); |
1734 | ++ep; | 1813 | ++ep; |
1735 | spin_unlock_irqrestore(&func->ffs->eps_lock, flags); | ||
1736 | 1814 | ||
1737 | if (epfile) { | 1815 | if (epfile) { |
1738 | epfile->ep = NULL; | 1816 | epfile->ep = NULL; |
1739 | kfree(epfile->read_buffer); | 1817 | __ffs_epfile_read_buffer_free(epfile); |
1740 | epfile->read_buffer = NULL; | ||
1741 | mutex_unlock(&epfile->mutex); | ||
1742 | ++epfile; | 1818 | ++epfile; |
1743 | } | 1819 | } |
1744 | } while (--count); | 1820 | } while (--count); |
1821 | spin_unlock_irqrestore(&func->ffs->eps_lock, flags); | ||
1745 | } | 1822 | } |
1746 | 1823 | ||
1747 | static int ffs_func_eps_enable(struct ffs_function *func) | 1824 | static int ffs_func_eps_enable(struct ffs_function *func) |
diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c index 9c8c9ed1dc9e..fe1811650dbc 100644 --- a/drivers/usb/gadget/function/u_ether.c +++ b/drivers/usb/gadget/function/u_ether.c | |||
@@ -590,8 +590,9 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb, | |||
590 | 590 | ||
591 | /* throttle high/super speed IRQ rate back slightly */ | 591 | /* throttle high/super speed IRQ rate back slightly */ |
592 | if (gadget_is_dualspeed(dev->gadget)) | 592 | if (gadget_is_dualspeed(dev->gadget)) |
593 | req->no_interrupt = (dev->gadget->speed == USB_SPEED_HIGH || | 593 | req->no_interrupt = (((dev->gadget->speed == USB_SPEED_HIGH || |
594 | dev->gadget->speed == USB_SPEED_SUPER) | 594 | dev->gadget->speed == USB_SPEED_SUPER)) && |
595 | !list_empty(&dev->tx_reqs)) | ||
595 | ? ((atomic_read(&dev->tx_qlen) % dev->qmult) != 0) | 596 | ? ((atomic_read(&dev->tx_qlen) % dev->qmult) != 0) |
596 | : 0; | 597 | : 0; |
597 | 598 | ||
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c index bb1f6c8f0f01..45bc997d0711 100644 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c | |||
@@ -1978,7 +1978,7 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev, | |||
1978 | dev_err(&pdev->dev, "of_probe: name error(%d)\n", ret); | 1978 | dev_err(&pdev->dev, "of_probe: name error(%d)\n", ret); |
1979 | goto err; | 1979 | goto err; |
1980 | } | 1980 | } |
1981 | ep->ep.name = name; | 1981 | ep->ep.name = kasprintf(GFP_KERNEL, "ep%d", ep->index); |
1982 | 1982 | ||
1983 | ep->ep_regs = udc->regs + USBA_EPT_BASE(i); | 1983 | ep->ep_regs = udc->regs + USBA_EPT_BASE(i); |
1984 | ep->dma_regs = udc->regs + USBA_DMA_BASE(i); | 1984 | ep->dma_regs = udc->regs + USBA_DMA_BASE(i); |
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index 876dca4fc216..a268d9e8d6cf 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c | |||
@@ -39,7 +39,7 @@ | |||
39 | 39 | ||
40 | #define DRIVER_DESC "EHCI generic platform driver" | 40 | #define DRIVER_DESC "EHCI generic platform driver" |
41 | #define EHCI_MAX_CLKS 4 | 41 | #define EHCI_MAX_CLKS 4 |
42 | #define EHCI_MAX_RSTS 3 | 42 | #define EHCI_MAX_RSTS 4 |
43 | #define hcd_to_ehci_priv(h) ((struct ehci_platform_priv *)hcd_to_ehci(h)->priv) | 43 | #define hcd_to_ehci_priv(h) ((struct ehci_platform_priv *)hcd_to_ehci(h)->priv) |
44 | 44 | ||
45 | struct ehci_platform_priv { | 45 | struct ehci_platform_priv { |
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index 5b5880c0ae19..b38a228134df 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c | |||
@@ -221,6 +221,12 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver, | |||
221 | ohci->num_ports = board->ports; | 221 | ohci->num_ports = board->ports; |
222 | at91_start_hc(pdev); | 222 | at91_start_hc(pdev); |
223 | 223 | ||
224 | /* | ||
225 | * The RemoteWakeupConnected bit has to be set explicitly | ||
226 | * before calling ohci_run. The reset value of this bit is 0. | ||
227 | */ | ||
228 | ohci->hc_control = OHCI_CTRL_RWC; | ||
229 | |||
224 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); | 230 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); |
225 | if (retval == 0) { | 231 | if (retval == 0) { |
226 | device_wakeup_enable(hcd->self.controller); | 232 | device_wakeup_enable(hcd->self.controller); |
@@ -677,9 +683,6 @@ ohci_hcd_at91_drv_suspend(struct device *dev) | |||
677 | * REVISIT: some boards will be able to turn VBUS off... | 683 | * REVISIT: some boards will be able to turn VBUS off... |
678 | */ | 684 | */ |
679 | if (!ohci_at91->wakeup) { | 685 | if (!ohci_at91->wakeup) { |
680 | ohci->hc_control = ohci_readl(ohci, &ohci->regs->control); | ||
681 | ohci->hc_control &= OHCI_CTRL_RWC; | ||
682 | ohci_writel(ohci, ohci->hc_control, &ohci->regs->control); | ||
683 | ohci->rh_state = OHCI_RH_HALTED; | 686 | ohci->rh_state = OHCI_RH_HALTED; |
684 | 687 | ||
685 | /* flush the writes */ | 688 | /* flush the writes */ |
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 1700908b84ef..86612ac3fda2 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
@@ -72,7 +72,7 @@ | |||
72 | static const char hcd_name [] = "ohci_hcd"; | 72 | static const char hcd_name [] = "ohci_hcd"; |
73 | 73 | ||
74 | #define STATECHANGE_DELAY msecs_to_jiffies(300) | 74 | #define STATECHANGE_DELAY msecs_to_jiffies(300) |
75 | #define IO_WATCHDOG_DELAY msecs_to_jiffies(250) | 75 | #define IO_WATCHDOG_DELAY msecs_to_jiffies(275) |
76 | 76 | ||
77 | #include "ohci.h" | 77 | #include "ohci.h" |
78 | #include "pci-quirks.h" | 78 | #include "pci-quirks.h" |
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 730b9fd26685..0ef16900efed 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c | |||
@@ -1166,7 +1166,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
1166 | xhci_set_link_state(xhci, port_array, wIndex, | 1166 | xhci_set_link_state(xhci, port_array, wIndex, |
1167 | XDEV_RESUME); | 1167 | XDEV_RESUME); |
1168 | spin_unlock_irqrestore(&xhci->lock, flags); | 1168 | spin_unlock_irqrestore(&xhci->lock, flags); |
1169 | msleep(20); | 1169 | msleep(USB_RESUME_TIMEOUT); |
1170 | spin_lock_irqsave(&xhci->lock, flags); | 1170 | spin_lock_irqsave(&xhci->lock, flags); |
1171 | xhci_set_link_state(xhci, port_array, wIndex, | 1171 | xhci_set_link_state(xhci, port_array, wIndex, |
1172 | XDEV_U0); | 1172 | XDEV_U0); |
@@ -1355,6 +1355,35 @@ int xhci_bus_suspend(struct usb_hcd *hcd) | |||
1355 | return 0; | 1355 | return 0; |
1356 | } | 1356 | } |
1357 | 1357 | ||
1358 | /* | ||
1359 | * Workaround for missing Cold Attach Status (CAS) if device re-plugged in S3. | ||
1360 | * warm reset a USB3 device stuck in polling or compliance mode after resume. | ||
1361 | * See Intel 100/c230 series PCH specification update Doc #332692-006 Errata #8 | ||
1362 | */ | ||
1363 | static bool xhci_port_missing_cas_quirk(int port_index, | ||
1364 | __le32 __iomem **port_array) | ||
1365 | { | ||
1366 | u32 portsc; | ||
1367 | |||
1368 | portsc = readl(port_array[port_index]); | ||
1369 | |||
1370 | /* if any of these are set we are not stuck */ | ||
1371 | if (portsc & (PORT_CONNECT | PORT_CAS)) | ||
1372 | return false; | ||
1373 | |||
1374 | if (((portsc & PORT_PLS_MASK) != XDEV_POLLING) && | ||
1375 | ((portsc & PORT_PLS_MASK) != XDEV_COMP_MODE)) | ||
1376 | return false; | ||
1377 | |||
1378 | /* clear wakeup/change bits, and do a warm port reset */ | ||
1379 | portsc &= ~(PORT_RWC_BITS | PORT_CEC | PORT_WAKE_BITS); | ||
1380 | portsc |= PORT_WR; | ||
1381 | writel(portsc, port_array[port_index]); | ||
1382 | /* flush write */ | ||
1383 | readl(port_array[port_index]); | ||
1384 | return true; | ||
1385 | } | ||
1386 | |||
1358 | int xhci_bus_resume(struct usb_hcd *hcd) | 1387 | int xhci_bus_resume(struct usb_hcd *hcd) |
1359 | { | 1388 | { |
1360 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); | 1389 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); |
@@ -1392,6 +1421,14 @@ int xhci_bus_resume(struct usb_hcd *hcd) | |||
1392 | u32 temp; | 1421 | u32 temp; |
1393 | 1422 | ||
1394 | temp = readl(port_array[port_index]); | 1423 | temp = readl(port_array[port_index]); |
1424 | |||
1425 | /* warm reset CAS limited ports stuck in polling/compliance */ | ||
1426 | if ((xhci->quirks & XHCI_MISSING_CAS) && | ||
1427 | (hcd->speed >= HCD_USB3) && | ||
1428 | xhci_port_missing_cas_quirk(port_index, port_array)) { | ||
1429 | xhci_dbg(xhci, "reset stuck port %d\n", port_index); | ||
1430 | continue; | ||
1431 | } | ||
1395 | if (DEV_SUPERSPEED_ANY(temp)) | 1432 | if (DEV_SUPERSPEED_ANY(temp)) |
1396 | temp &= ~(PORT_RWC_BITS | PORT_CEC | PORT_WAKE_BITS); | 1433 | temp &= ~(PORT_RWC_BITS | PORT_CEC | PORT_WAKE_BITS); |
1397 | else | 1434 | else |
@@ -1410,7 +1447,7 @@ int xhci_bus_resume(struct usb_hcd *hcd) | |||
1410 | 1447 | ||
1411 | if (need_usb2_u3_exit) { | 1448 | if (need_usb2_u3_exit) { |
1412 | spin_unlock_irqrestore(&xhci->lock, flags); | 1449 | spin_unlock_irqrestore(&xhci->lock, flags); |
1413 | msleep(20); | 1450 | msleep(USB_RESUME_TIMEOUT); |
1414 | spin_lock_irqsave(&xhci->lock, flags); | 1451 | spin_lock_irqsave(&xhci->lock, flags); |
1415 | } | 1452 | } |
1416 | 1453 | ||
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index d7b0f97abbad..e96ae80d107e 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c | |||
@@ -45,11 +45,13 @@ | |||
45 | 45 | ||
46 | #define PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI 0x8c31 | 46 | #define PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI 0x8c31 |
47 | #define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31 | 47 | #define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31 |
48 | #define PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_XHCI 0x9cb1 | ||
48 | #define PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI 0x22b5 | 49 | #define PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI 0x22b5 |
49 | #define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI 0xa12f | 50 | #define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI 0xa12f |
50 | #define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f | 51 | #define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f |
51 | #define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8 | 52 | #define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8 |
52 | #define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8 | 53 | #define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8 |
54 | #define PCI_DEVICE_ID_INTEL_APL_XHCI 0x5aa8 | ||
53 | 55 | ||
54 | static const char hcd_name[] = "xhci_hcd"; | 56 | static const char hcd_name[] = "xhci_hcd"; |
55 | 57 | ||
@@ -153,7 +155,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) | |||
153 | xhci->quirks |= XHCI_SPURIOUS_REBOOT; | 155 | xhci->quirks |= XHCI_SPURIOUS_REBOOT; |
154 | } | 156 | } |
155 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && | 157 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && |
156 | pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI) { | 158 | (pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI || |
159 | pdev->device == PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_XHCI)) { | ||
157 | xhci->quirks |= XHCI_SPURIOUS_REBOOT; | 160 | xhci->quirks |= XHCI_SPURIOUS_REBOOT; |
158 | xhci->quirks |= XHCI_SPURIOUS_WAKEUP; | 161 | xhci->quirks |= XHCI_SPURIOUS_WAKEUP; |
159 | } | 162 | } |
@@ -169,6 +172,11 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) | |||
169 | pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI) { | 172 | pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI) { |
170 | xhci->quirks |= XHCI_SSIC_PORT_UNUSED; | 173 | xhci->quirks |= XHCI_SSIC_PORT_UNUSED; |
171 | } | 174 | } |
175 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && | ||
176 | (pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || | ||
177 | pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI)) | ||
178 | xhci->quirks |= XHCI_MISSING_CAS; | ||
179 | |||
172 | if (pdev->vendor == PCI_VENDOR_ID_ETRON && | 180 | if (pdev->vendor == PCI_VENDOR_ID_ETRON && |
173 | pdev->device == PCI_DEVICE_ID_EJ168) { | 181 | pdev->device == PCI_DEVICE_ID_EJ168) { |
174 | xhci->quirks |= XHCI_RESET_ON_RESUME; | 182 | xhci->quirks |= XHCI_RESET_ON_RESUME; |
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index b2c1dc5dc0f3..f945380035d0 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -314,6 +314,8 @@ struct xhci_op_regs { | |||
314 | #define XDEV_U2 (0x2 << 5) | 314 | #define XDEV_U2 (0x2 << 5) |
315 | #define XDEV_U3 (0x3 << 5) | 315 | #define XDEV_U3 (0x3 << 5) |
316 | #define XDEV_INACTIVE (0x6 << 5) | 316 | #define XDEV_INACTIVE (0x6 << 5) |
317 | #define XDEV_POLLING (0x7 << 5) | ||
318 | #define XDEV_COMP_MODE (0xa << 5) | ||
317 | #define XDEV_RESUME (0xf << 5) | 319 | #define XDEV_RESUME (0xf << 5) |
318 | /* true: port has power (see HCC_PPC) */ | 320 | /* true: port has power (see HCC_PPC) */ |
319 | #define PORT_POWER (1 << 9) | 321 | #define PORT_POWER (1 << 9) |
@@ -1653,6 +1655,7 @@ struct xhci_hcd { | |||
1653 | #define XHCI_MTK_HOST (1 << 21) | 1655 | #define XHCI_MTK_HOST (1 << 21) |
1654 | #define XHCI_SSIC_PORT_UNUSED (1 << 22) | 1656 | #define XHCI_SSIC_PORT_UNUSED (1 << 22) |
1655 | #define XHCI_NO_64BIT_SUPPORT (1 << 23) | 1657 | #define XHCI_NO_64BIT_SUPPORT (1 << 23) |
1658 | #define XHCI_MISSING_CAS (1 << 24) | ||
1656 | unsigned int num_active_eps; | 1659 | unsigned int num_active_eps; |
1657 | unsigned int limit_active_eps; | 1660 | unsigned int limit_active_eps; |
1658 | /* There are two roothubs to keep track of bus suspend info for */ | 1661 | /* There are two roothubs to keep track of bus suspend info for */ |
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index bff4869a57cd..4042ea017985 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c | |||
@@ -1255,6 +1255,7 @@ static int musb_gadget_queue(struct usb_ep *ep, struct usb_request *req, | |||
1255 | 1255 | ||
1256 | map_dma_buffer(request, musb, musb_ep); | 1256 | map_dma_buffer(request, musb, musb_ep); |
1257 | 1257 | ||
1258 | pm_runtime_get_sync(musb->controller); | ||
1258 | spin_lock_irqsave(&musb->lock, lockflags); | 1259 | spin_lock_irqsave(&musb->lock, lockflags); |
1259 | 1260 | ||
1260 | /* don't queue if the ep is down */ | 1261 | /* don't queue if the ep is down */ |
@@ -1275,6 +1276,9 @@ static int musb_gadget_queue(struct usb_ep *ep, struct usb_request *req, | |||
1275 | 1276 | ||
1276 | unlock: | 1277 | unlock: |
1277 | spin_unlock_irqrestore(&musb->lock, lockflags); | 1278 | spin_unlock_irqrestore(&musb->lock, lockflags); |
1279 | pm_runtime_mark_last_busy(musb->controller); | ||
1280 | pm_runtime_put_autosuspend(musb->controller); | ||
1281 | |||
1278 | return status; | 1282 | return status; |
1279 | } | 1283 | } |
1280 | 1284 | ||
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 1ab6973d4f61..cc1225485509 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c | |||
@@ -287,6 +287,7 @@ static int omap2430_musb_init(struct musb *musb) | |||
287 | } | 287 | } |
288 | musb->isr = omap2430_musb_interrupt; | 288 | musb->isr = omap2430_musb_interrupt; |
289 | phy_init(musb->phy); | 289 | phy_init(musb->phy); |
290 | phy_power_on(musb->phy); | ||
290 | 291 | ||
291 | l = musb_readl(musb->mregs, OTG_INTERFSEL); | 292 | l = musb_readl(musb->mregs, OTG_INTERFSEL); |
292 | 293 | ||
@@ -323,8 +324,6 @@ static void omap2430_musb_enable(struct musb *musb) | |||
323 | struct musb_hdrc_platform_data *pdata = dev_get_platdata(dev); | 324 | struct musb_hdrc_platform_data *pdata = dev_get_platdata(dev); |
324 | struct omap_musb_board_data *data = pdata->board_data; | 325 | struct omap_musb_board_data *data = pdata->board_data; |
325 | 326 | ||
326 | if (!WARN_ON(!musb->phy)) | ||
327 | phy_power_on(musb->phy); | ||
328 | 327 | ||
329 | switch (glue->status) { | 328 | switch (glue->status) { |
330 | 329 | ||
@@ -361,9 +360,6 @@ static void omap2430_musb_disable(struct musb *musb) | |||
361 | struct device *dev = musb->controller; | 360 | struct device *dev = musb->controller; |
362 | struct omap2430_glue *glue = dev_get_drvdata(dev->parent); | 361 | struct omap2430_glue *glue = dev_get_drvdata(dev->parent); |
363 | 362 | ||
364 | if (!WARN_ON(!musb->phy)) | ||
365 | phy_power_off(musb->phy); | ||
366 | |||
367 | if (glue->status != MUSB_UNKNOWN) | 363 | if (glue->status != MUSB_UNKNOWN) |
368 | omap_control_usb_set_mode(glue->control_otghs, | 364 | omap_control_usb_set_mode(glue->control_otghs, |
369 | USB_MODE_DISCONNECT); | 365 | USB_MODE_DISCONNECT); |
@@ -375,6 +371,7 @@ static int omap2430_musb_exit(struct musb *musb) | |||
375 | struct omap2430_glue *glue = dev_get_drvdata(dev->parent); | 371 | struct omap2430_glue *glue = dev_get_drvdata(dev->parent); |
376 | 372 | ||
377 | omap2430_low_level_exit(musb); | 373 | omap2430_low_level_exit(musb); |
374 | phy_power_off(musb->phy); | ||
378 | phy_exit(musb->phy); | 375 | phy_exit(musb->phy); |
379 | musb->phy = NULL; | 376 | musb->phy = NULL; |
380 | cancel_work_sync(&glue->omap_musb_mailbox_work); | 377 | cancel_work_sync(&glue->omap_musb_mailbox_work); |
diff --git a/drivers/usb/renesas_usbhs/rcar3.c b/drivers/usb/renesas_usbhs/rcar3.c index 1d70add926f0..d544b331c9f2 100644 --- a/drivers/usb/renesas_usbhs/rcar3.c +++ b/drivers/usb/renesas_usbhs/rcar3.c | |||
@@ -9,6 +9,7 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/delay.h> | ||
12 | #include <linux/io.h> | 13 | #include <linux/io.h> |
13 | #include "common.h" | 14 | #include "common.h" |
14 | #include "rcar3.h" | 15 | #include "rcar3.h" |
@@ -35,10 +36,13 @@ static int usbhs_rcar3_power_ctrl(struct platform_device *pdev, | |||
35 | 36 | ||
36 | usbhs_write32(priv, UGCTRL2, UGCTRL2_RESERVED_3 | UGCTRL2_USB0SEL_OTG); | 37 | usbhs_write32(priv, UGCTRL2, UGCTRL2_RESERVED_3 | UGCTRL2_USB0SEL_OTG); |
37 | 38 | ||
38 | if (enable) | 39 | if (enable) { |
39 | usbhs_bset(priv, LPSTS, LPSTS_SUSPM, LPSTS_SUSPM); | 40 | usbhs_bset(priv, LPSTS, LPSTS_SUSPM, LPSTS_SUSPM); |
40 | else | 41 | /* The controller on R-Car Gen3 needs to wait up to 45 usec */ |
42 | udelay(45); | ||
43 | } else { | ||
41 | usbhs_bset(priv, LPSTS, LPSTS_SUSPM, 0); | 44 | usbhs_bset(priv, LPSTS, LPSTS_SUSPM, 0); |
45 | } | ||
42 | 46 | ||
43 | return 0; | 47 | return 0; |
44 | } | 48 | } |
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index 54a4de0efdba..f61477bed3a8 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c | |||
@@ -1077,7 +1077,9 @@ static int cp210x_tiocmget(struct tty_struct *tty) | |||
1077 | u8 control; | 1077 | u8 control; |
1078 | int result; | 1078 | int result; |
1079 | 1079 | ||
1080 | cp210x_read_u8_reg(port, CP210X_GET_MDMSTS, &control); | 1080 | result = cp210x_read_u8_reg(port, CP210X_GET_MDMSTS, &control); |
1081 | if (result) | ||
1082 | return result; | ||
1081 | 1083 | ||
1082 | result = ((control & CONTROL_DTR) ? TIOCM_DTR : 0) | 1084 | result = ((control & CONTROL_DTR) ? TIOCM_DTR : 0) |
1083 | |((control & CONTROL_RTS) ? TIOCM_RTS : 0) | 1085 | |((control & CONTROL_RTS) ? TIOCM_RTS : 0) |
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index b2d767e743fc..0ff7f38d7800 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -986,7 +986,8 @@ static const struct usb_device_id id_table_combined[] = { | |||
986 | /* ekey Devices */ | 986 | /* ekey Devices */ |
987 | { USB_DEVICE(FTDI_VID, FTDI_EKEY_CONV_USB_PID) }, | 987 | { USB_DEVICE(FTDI_VID, FTDI_EKEY_CONV_USB_PID) }, |
988 | /* Infineon Devices */ | 988 | /* Infineon Devices */ |
989 | { USB_DEVICE_INTERFACE_NUMBER(INFINEON_VID, INFINEON_TRIBOARD_PID, 1) }, | 989 | { USB_DEVICE_INTERFACE_NUMBER(INFINEON_VID, INFINEON_TRIBOARD_TC1798_PID, 1) }, |
990 | { USB_DEVICE_INTERFACE_NUMBER(INFINEON_VID, INFINEON_TRIBOARD_TC2X7_PID, 1) }, | ||
990 | /* GE Healthcare devices */ | 991 | /* GE Healthcare devices */ |
991 | { USB_DEVICE(GE_HEALTHCARE_VID, GE_HEALTHCARE_NEMO_TRACKER_PID) }, | 992 | { USB_DEVICE(GE_HEALTHCARE_VID, GE_HEALTHCARE_NEMO_TRACKER_PID) }, |
992 | /* Active Research (Actisense) devices */ | 993 | /* Active Research (Actisense) devices */ |
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h index f87a938cf005..21011c0a4c64 100644 --- a/drivers/usb/serial/ftdi_sio_ids.h +++ b/drivers/usb/serial/ftdi_sio_ids.h | |||
@@ -626,8 +626,9 @@ | |||
626 | /* | 626 | /* |
627 | * Infineon Technologies | 627 | * Infineon Technologies |
628 | */ | 628 | */ |
629 | #define INFINEON_VID 0x058b | 629 | #define INFINEON_VID 0x058b |
630 | #define INFINEON_TRIBOARD_PID 0x0028 /* DAS JTAG TriBoard TC1798 V1.0 */ | 630 | #define INFINEON_TRIBOARD_TC1798_PID 0x0028 /* DAS JTAG TriBoard TC1798 V1.0 */ |
631 | #define INFINEON_TRIBOARD_TC2X7_PID 0x0043 /* DAS JTAG TriBoard TC2X7 V1.0 */ | ||
631 | 632 | ||
632 | /* | 633 | /* |
633 | * Acton Research Corp. | 634 | * Acton Research Corp. |
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index d213cf44a7e4..4a037b4a79cf 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -1078,7 +1078,8 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
1078 | 1078 | ||
1079 | serial->disconnected = 0; | 1079 | serial->disconnected = 0; |
1080 | 1080 | ||
1081 | usb_serial_console_init(serial->port[0]->minor); | 1081 | if (num_ports > 0) |
1082 | usb_serial_console_init(serial->port[0]->minor); | ||
1082 | exit: | 1083 | exit: |
1083 | module_put(type->driver.owner); | 1084 | module_put(type->driver.owner); |
1084 | return 0; | 1085 | return 0; |
diff --git a/drivers/usb/wusbcore/crypto.c b/drivers/usb/wusbcore/crypto.c index 79b2b628066d..79451f7ef1b7 100644 --- a/drivers/usb/wusbcore/crypto.c +++ b/drivers/usb/wusbcore/crypto.c | |||
@@ -133,6 +133,13 @@ static void bytewise_xor(void *_bo, const void *_bi1, const void *_bi2, | |||
133 | bo[itr] = bi1[itr] ^ bi2[itr]; | 133 | bo[itr] = bi1[itr] ^ bi2[itr]; |
134 | } | 134 | } |
135 | 135 | ||
136 | /* Scratch space for MAC calculations. */ | ||
137 | struct wusb_mac_scratch { | ||
138 | struct aes_ccm_b0 b0; | ||
139 | struct aes_ccm_b1 b1; | ||
140 | struct aes_ccm_a ax; | ||
141 | }; | ||
142 | |||
136 | /* | 143 | /* |
137 | * CC-MAC function WUSB1.0[6.5] | 144 | * CC-MAC function WUSB1.0[6.5] |
138 | * | 145 | * |
@@ -197,16 +204,15 @@ static void bytewise_xor(void *_bo, const void *_bi1, const void *_bi2, | |||
197 | * what sg[4] is for. Maybe there is a smarter way to do this. | 204 | * what sg[4] is for. Maybe there is a smarter way to do this. |
198 | */ | 205 | */ |
199 | static int wusb_ccm_mac(struct crypto_skcipher *tfm_cbc, | 206 | static int wusb_ccm_mac(struct crypto_skcipher *tfm_cbc, |
200 | struct crypto_cipher *tfm_aes, void *mic, | 207 | struct crypto_cipher *tfm_aes, |
208 | struct wusb_mac_scratch *scratch, | ||
209 | void *mic, | ||
201 | const struct aes_ccm_nonce *n, | 210 | const struct aes_ccm_nonce *n, |
202 | const struct aes_ccm_label *a, const void *b, | 211 | const struct aes_ccm_label *a, const void *b, |
203 | size_t blen) | 212 | size_t blen) |
204 | { | 213 | { |
205 | int result = 0; | 214 | int result = 0; |
206 | SKCIPHER_REQUEST_ON_STACK(req, tfm_cbc); | 215 | SKCIPHER_REQUEST_ON_STACK(req, tfm_cbc); |
207 | struct aes_ccm_b0 b0; | ||
208 | struct aes_ccm_b1 b1; | ||
209 | struct aes_ccm_a ax; | ||
210 | struct scatterlist sg[4], sg_dst; | 216 | struct scatterlist sg[4], sg_dst; |
211 | void *dst_buf; | 217 | void *dst_buf; |
212 | size_t dst_size; | 218 | size_t dst_size; |
@@ -218,16 +224,17 @@ static int wusb_ccm_mac(struct crypto_skcipher *tfm_cbc, | |||
218 | * These checks should be compile time optimized out | 224 | * These checks should be compile time optimized out |
219 | * ensure @a fills b1's mac_header and following fields | 225 | * ensure @a fills b1's mac_header and following fields |
220 | */ | 226 | */ |
221 | WARN_ON(sizeof(*a) != sizeof(b1) - sizeof(b1.la)); | 227 | WARN_ON(sizeof(*a) != sizeof(scratch->b1) - sizeof(scratch->b1.la)); |
222 | WARN_ON(sizeof(b0) != sizeof(struct aes_ccm_block)); | 228 | WARN_ON(sizeof(scratch->b0) != sizeof(struct aes_ccm_block)); |
223 | WARN_ON(sizeof(b1) != sizeof(struct aes_ccm_block)); | 229 | WARN_ON(sizeof(scratch->b1) != sizeof(struct aes_ccm_block)); |
224 | WARN_ON(sizeof(ax) != sizeof(struct aes_ccm_block)); | 230 | WARN_ON(sizeof(scratch->ax) != sizeof(struct aes_ccm_block)); |
225 | 231 | ||
226 | result = -ENOMEM; | 232 | result = -ENOMEM; |
227 | zero_padding = blen % sizeof(struct aes_ccm_block); | 233 | zero_padding = blen % sizeof(struct aes_ccm_block); |
228 | if (zero_padding) | 234 | if (zero_padding) |
229 | zero_padding = sizeof(struct aes_ccm_block) - zero_padding; | 235 | zero_padding = sizeof(struct aes_ccm_block) - zero_padding; |
230 | dst_size = blen + sizeof(b0) + sizeof(b1) + zero_padding; | 236 | dst_size = blen + sizeof(scratch->b0) + sizeof(scratch->b1) + |
237 | zero_padding; | ||
231 | dst_buf = kzalloc(dst_size, GFP_KERNEL); | 238 | dst_buf = kzalloc(dst_size, GFP_KERNEL); |
232 | if (!dst_buf) | 239 | if (!dst_buf) |
233 | goto error_dst_buf; | 240 | goto error_dst_buf; |
@@ -235,9 +242,9 @@ static int wusb_ccm_mac(struct crypto_skcipher *tfm_cbc, | |||
235 | memset(iv, 0, sizeof(iv)); | 242 | memset(iv, 0, sizeof(iv)); |
236 | 243 | ||
237 | /* Setup B0 */ | 244 | /* Setup B0 */ |
238 | b0.flags = 0x59; /* Format B0 */ | 245 | scratch->b0.flags = 0x59; /* Format B0 */ |
239 | b0.ccm_nonce = *n; | 246 | scratch->b0.ccm_nonce = *n; |
240 | b0.lm = cpu_to_be16(0); /* WUSB1.0[6.5] sez l(m) is 0 */ | 247 | scratch->b0.lm = cpu_to_be16(0); /* WUSB1.0[6.5] sez l(m) is 0 */ |
241 | 248 | ||
242 | /* Setup B1 | 249 | /* Setup B1 |
243 | * | 250 | * |
@@ -246,12 +253,12 @@ static int wusb_ccm_mac(struct crypto_skcipher *tfm_cbc, | |||
246 | * 14'--after clarification, it means to use A's contents | 253 | * 14'--after clarification, it means to use A's contents |
247 | * for MAC Header, EO, sec reserved and padding. | 254 | * for MAC Header, EO, sec reserved and padding. |
248 | */ | 255 | */ |
249 | b1.la = cpu_to_be16(blen + 14); | 256 | scratch->b1.la = cpu_to_be16(blen + 14); |
250 | memcpy(&b1.mac_header, a, sizeof(*a)); | 257 | memcpy(&scratch->b1.mac_header, a, sizeof(*a)); |
251 | 258 | ||
252 | sg_init_table(sg, ARRAY_SIZE(sg)); | 259 | sg_init_table(sg, ARRAY_SIZE(sg)); |
253 | sg_set_buf(&sg[0], &b0, sizeof(b0)); | 260 | sg_set_buf(&sg[0], &scratch->b0, sizeof(scratch->b0)); |
254 | sg_set_buf(&sg[1], &b1, sizeof(b1)); | 261 | sg_set_buf(&sg[1], &scratch->b1, sizeof(scratch->b1)); |
255 | sg_set_buf(&sg[2], b, blen); | 262 | sg_set_buf(&sg[2], b, blen); |
256 | /* 0 if well behaved :) */ | 263 | /* 0 if well behaved :) */ |
257 | sg_set_buf(&sg[3], bzero, zero_padding); | 264 | sg_set_buf(&sg[3], bzero, zero_padding); |
@@ -276,11 +283,12 @@ static int wusb_ccm_mac(struct crypto_skcipher *tfm_cbc, | |||
276 | * POS Crypto API: size is assumed to be AES's block size. | 283 | * POS Crypto API: size is assumed to be AES's block size. |
277 | * Thanks for documenting it -- tip taken from airo.c | 284 | * Thanks for documenting it -- tip taken from airo.c |
278 | */ | 285 | */ |
279 | ax.flags = 0x01; /* as per WUSB 1.0 spec */ | 286 | scratch->ax.flags = 0x01; /* as per WUSB 1.0 spec */ |
280 | ax.ccm_nonce = *n; | 287 | scratch->ax.ccm_nonce = *n; |
281 | ax.counter = 0; | 288 | scratch->ax.counter = 0; |
282 | crypto_cipher_encrypt_one(tfm_aes, (void *)&ax, (void *)&ax); | 289 | crypto_cipher_encrypt_one(tfm_aes, (void *)&scratch->ax, |
283 | bytewise_xor(mic, &ax, iv, 8); | 290 | (void *)&scratch->ax); |
291 | bytewise_xor(mic, &scratch->ax, iv, 8); | ||
284 | result = 8; | 292 | result = 8; |
285 | error_cbc_crypt: | 293 | error_cbc_crypt: |
286 | kfree(dst_buf); | 294 | kfree(dst_buf); |
@@ -303,6 +311,7 @@ ssize_t wusb_prf(void *out, size_t out_size, | |||
303 | struct aes_ccm_nonce n = *_n; | 311 | struct aes_ccm_nonce n = *_n; |
304 | struct crypto_skcipher *tfm_cbc; | 312 | struct crypto_skcipher *tfm_cbc; |
305 | struct crypto_cipher *tfm_aes; | 313 | struct crypto_cipher *tfm_aes; |
314 | struct wusb_mac_scratch *scratch; | ||
306 | u64 sfn = 0; | 315 | u64 sfn = 0; |
307 | __le64 sfn_le; | 316 | __le64 sfn_le; |
308 | 317 | ||
@@ -329,17 +338,25 @@ ssize_t wusb_prf(void *out, size_t out_size, | |||
329 | printk(KERN_ERR "E: can't set AES key: %d\n", (int)result); | 338 | printk(KERN_ERR "E: can't set AES key: %d\n", (int)result); |
330 | goto error_setkey_aes; | 339 | goto error_setkey_aes; |
331 | } | 340 | } |
341 | scratch = kmalloc(sizeof(*scratch), GFP_KERNEL); | ||
342 | if (!scratch) { | ||
343 | result = -ENOMEM; | ||
344 | goto error_alloc_scratch; | ||
345 | } | ||
332 | 346 | ||
333 | for (bitr = 0; bitr < (len + 63) / 64; bitr++) { | 347 | for (bitr = 0; bitr < (len + 63) / 64; bitr++) { |
334 | sfn_le = cpu_to_le64(sfn++); | 348 | sfn_le = cpu_to_le64(sfn++); |
335 | memcpy(&n.sfn, &sfn_le, sizeof(n.sfn)); /* n.sfn++... */ | 349 | memcpy(&n.sfn, &sfn_le, sizeof(n.sfn)); /* n.sfn++... */ |
336 | result = wusb_ccm_mac(tfm_cbc, tfm_aes, out + bytes, | 350 | result = wusb_ccm_mac(tfm_cbc, tfm_aes, scratch, out + bytes, |
337 | &n, a, b, blen); | 351 | &n, a, b, blen); |
338 | if (result < 0) | 352 | if (result < 0) |
339 | goto error_ccm_mac; | 353 | goto error_ccm_mac; |
340 | bytes += result; | 354 | bytes += result; |
341 | } | 355 | } |
342 | result = bytes; | 356 | result = bytes; |
357 | |||
358 | kfree(scratch); | ||
359 | error_alloc_scratch: | ||
343 | error_ccm_mac: | 360 | error_ccm_mac: |
344 | error_setkey_aes: | 361 | error_setkey_aes: |
345 | crypto_free_cipher(tfm_aes); | 362 | crypto_free_cipher(tfm_aes); |