aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-07-22 11:55:16 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-07-22 11:55:16 -0400
commit55fd939e8ee4538c3b66a28975dcc3beb96f80ba (patch)
treed378a35decdb2ba4e5d0f90579342a7a0bdaf87f
parentbcb53e5769227813b7878df1ec9d329b0bd68f74 (diff)
parentd6f5f071f1e13cadecf8aef1faa7e5d6fbc9f33b (diff)
Merge tag 'usb-4.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are some small USB fixes for 4.13-rc2. The usual batch, gadget fixes for reported issues, as well as xhci fixes, and a small random collection of other fixes for reported issues. All have been in linux-next with no reported issues" * tag 'usb-4.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (25 commits) xhci: fix memleak in xhci_run() usb: xhci: fix spinlock recursion for USB2 test mode xhci: fix 20000ms port resume timeout usb: xhci: Issue stop EP command only when the EP state is running xhci: Bad Ethernet performance plugged in ASM1042A host xhci: Fix NULL pointer dereference when cleaning up streams for removed host usb: renesas_usbhs: gadget: disable all eps when the driver stops usb: renesas_usbhs: fix usbhsc_resume() for !USBHSF_RUNTIME_PWCTRL usb: gadget: udc: renesas_usb3: protect usb3_ep->started in usb3_start_pipen() usb: gadget: udc: renesas_usb3: fix zlp transfer by the dmac usb: gadget: udc: renesas_usb3: fix free size in renesas_usb3_dma_free_prd() usb: gadget: f_uac2: endianness fixes. usb: gadget: f_uac1: endianness fixes. include: usb: audio: specify exact endiannes of descriptors usb: gadget: udc: start_udc() can be static usb: dwc2: gadget: On USB RESET reset device address to zero usb: storage: return on error to avoid a null pointer dereference usb: typec: include linux/device.h in ucsi.h USB: cdc-acm: add device-id for quirky printer usb: dwc3: gadget: only unmap requests from DMA if mapped ...
-rw-r--r--drivers/usb/class/cdc-acm.c3
-rw-r--r--drivers/usb/dwc2/gadget.c3
-rw-r--r--drivers/usb/dwc3/core.c6
-rw-r--r--drivers/usb/dwc3/dwc3-omap.c18
-rw-r--r--drivers/usb/dwc3/gadget.c8
-rw-r--r--drivers/usb/gadget/function/f_mass_storage.c2
-rw-r--r--drivers/usb/gadget/function/f_uac1.c20
-rw-r--r--drivers/usb/gadget/function/f_uac2.c25
-rw-r--r--drivers/usb/gadget/udc/Kconfig5
-rw-r--r--drivers/usb/gadget/udc/renesas_usb3.c14
-rw-r--r--drivers/usb/gadget/udc/snps_udc_plat.c6
-rw-r--r--drivers/usb/host/pci-quirks.c54
-rw-r--r--drivers/usb/host/pci-quirks.h2
-rw-r--r--drivers/usb/host/xhci-hub.c14
-rw-r--r--drivers/usb/host/xhci-pci.c6
-rw-r--r--drivers/usb/host/xhci-ring.c11
-rw-r--r--drivers/usb/host/xhci.c10
-rw-r--r--drivers/usb/host/xhci.h1
-rw-r--r--drivers/usb/renesas_usbhs/common.c4
-rw-r--r--drivers/usb/renesas_usbhs/mod_gadget.c31
-rw-r--r--drivers/usb/storage/isd200.c5
-rw-r--r--drivers/usb/typec/ucsi/ucsi.h1
-rw-r--r--include/linux/usb/audio-v2.h14
-rw-r--r--include/uapi/linux/usb/audio.h6
24 files changed, 197 insertions, 72 deletions
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 5357d83bbda2..5e056064259c 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1829,6 +1829,9 @@ static const struct usb_device_id acm_ids[] = {
1829 { USB_DEVICE(0x1576, 0x03b1), /* Maretron USB100 */ 1829 { USB_DEVICE(0x1576, 0x03b1), /* Maretron USB100 */
1830 .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */ 1830 .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
1831 }, 1831 },
1832 { USB_DEVICE(0xfff0, 0x0100), /* DATECS FP-2000 */
1833 .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
1834 },
1832 1835
1833 { USB_DEVICE(0x2912, 0x0001), /* ATOL FPrint */ 1836 { USB_DEVICE(0x2912, 0x0001), /* ATOL FPrint */
1834 .driver_info = CLEAR_HALT_CONDITIONS, 1837 .driver_info = CLEAR_HALT_CONDITIONS,
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index bc3b3fda5000..c4066cd77e47 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3573,6 +3573,9 @@ irq_retry:
3573 /* Report disconnection if it is not already done. */ 3573 /* Report disconnection if it is not already done. */
3574 dwc2_hsotg_disconnect(hsotg); 3574 dwc2_hsotg_disconnect(hsotg);
3575 3575
3576 /* Reset device address to zero */
3577 __bic32(hsotg->regs + DCFG, DCFG_DEVADDR_MASK);
3578
3576 if (usb_status & GOTGCTL_BSESVLD && connected) 3579 if (usb_status & GOTGCTL_BSESVLD && connected)
3577 dwc2_hsotg_core_init_disconnected(hsotg, true); 3580 dwc2_hsotg_core_init_disconnected(hsotg, true);
3578 } 3581 }
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 326b302fc440..03474d3575ab 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -766,15 +766,15 @@ static int dwc3_core_init(struct dwc3 *dwc)
766 dwc->maximum_speed = USB_SPEED_HIGH; 766 dwc->maximum_speed = USB_SPEED_HIGH;
767 } 767 }
768 768
769 ret = dwc3_core_soft_reset(dwc); 769 ret = dwc3_core_get_phy(dwc);
770 if (ret) 770 if (ret)
771 goto err0; 771 goto err0;
772 772
773 ret = dwc3_phy_setup(dwc); 773 ret = dwc3_core_soft_reset(dwc);
774 if (ret) 774 if (ret)
775 goto err0; 775 goto err0;
776 776
777 ret = dwc3_core_get_phy(dwc); 777 ret = dwc3_phy_setup(dwc);
778 if (ret) 778 if (ret)
779 goto err0; 779 goto err0;
780 780
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 98926504b55b..f5aaa0cf3873 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -512,15 +512,6 @@ static int dwc3_omap_probe(struct platform_device *pdev)
512 512
513 /* check the DMA Status */ 513 /* check the DMA Status */
514 reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG); 514 reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG);
515 irq_set_status_flags(omap->irq, IRQ_NOAUTOEN);
516 ret = devm_request_threaded_irq(dev, omap->irq, dwc3_omap_interrupt,
517 dwc3_omap_interrupt_thread, IRQF_SHARED,
518 "dwc3-omap", omap);
519 if (ret) {
520 dev_err(dev, "failed to request IRQ #%d --> %d\n",
521 omap->irq, ret);
522 goto err1;
523 }
524 515
525 ret = dwc3_omap_extcon_register(omap); 516 ret = dwc3_omap_extcon_register(omap);
526 if (ret < 0) 517 if (ret < 0)
@@ -532,8 +523,15 @@ static int dwc3_omap_probe(struct platform_device *pdev)
532 goto err1; 523 goto err1;
533 } 524 }
534 525
526 ret = devm_request_threaded_irq(dev, omap->irq, dwc3_omap_interrupt,
527 dwc3_omap_interrupt_thread, IRQF_SHARED,
528 "dwc3-omap", omap);
529 if (ret) {
530 dev_err(dev, "failed to request IRQ #%d --> %d\n",
531 omap->irq, ret);
532 goto err1;
533 }
535 dwc3_omap_enable_irqs(omap); 534 dwc3_omap_enable_irqs(omap);
536 enable_irq(omap->irq);
537 return 0; 535 return 0;
538 536
539err1: 537err1:
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 9e41605a276b..6b299c7b7656 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -191,14 +191,16 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
191 191
192 req->started = false; 192 req->started = false;
193 list_del(&req->list); 193 list_del(&req->list);
194 req->trb = NULL;
195 req->remaining = 0; 194 req->remaining = 0;
196 195
197 if (req->request.status == -EINPROGRESS) 196 if (req->request.status == -EINPROGRESS)
198 req->request.status = status; 197 req->request.status = status;
199 198
200 usb_gadget_unmap_request_by_dev(dwc->sysdev, 199 if (req->trb)
201 &req->request, req->direction); 200 usb_gadget_unmap_request_by_dev(dwc->sysdev,
201 &req->request, req->direction);
202
203 req->trb = NULL;
202 204
203 trace_dwc3_gadget_giveback(req); 205 trace_dwc3_gadget_giveback(req);
204 206
diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
index e80b9c123a9d..f95bddd6513f 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -2490,7 +2490,7 @@ static int fsg_main_thread(void *common_)
2490 int i; 2490 int i;
2491 2491
2492 down_write(&common->filesem); 2492 down_write(&common->filesem);
2493 for (i = 0; i < ARRAY_SIZE(common->luns); --i) { 2493 for (i = 0; i < ARRAY_SIZE(common->luns); i++) {
2494 struct fsg_lun *curlun = common->luns[i]; 2494 struct fsg_lun *curlun = common->luns[i];
2495 if (!curlun || !fsg_lun_is_open(curlun)) 2495 if (!curlun || !fsg_lun_is_open(curlun))
2496 continue; 2496 continue;
diff --git a/drivers/usb/gadget/function/f_uac1.c b/drivers/usb/gadget/function/f_uac1.c
index 8656f84e17d9..29efbedc91f9 100644
--- a/drivers/usb/gadget/function/f_uac1.c
+++ b/drivers/usb/gadget/function/f_uac1.c
@@ -92,9 +92,9 @@ static struct uac_input_terminal_descriptor usb_out_it_desc = {
92 .bDescriptorType = USB_DT_CS_INTERFACE, 92 .bDescriptorType = USB_DT_CS_INTERFACE,
93 .bDescriptorSubtype = UAC_INPUT_TERMINAL, 93 .bDescriptorSubtype = UAC_INPUT_TERMINAL,
94 .bTerminalID = USB_OUT_IT_ID, 94 .bTerminalID = USB_OUT_IT_ID,
95 .wTerminalType = UAC_TERMINAL_STREAMING, 95 .wTerminalType = cpu_to_le16(UAC_TERMINAL_STREAMING),
96 .bAssocTerminal = 0, 96 .bAssocTerminal = 0,
97 .wChannelConfig = 0x3, 97 .wChannelConfig = cpu_to_le16(0x3),
98}; 98};
99 99
100#define IO_OUT_OT_ID 2 100#define IO_OUT_OT_ID 2
@@ -103,7 +103,7 @@ static struct uac1_output_terminal_descriptor io_out_ot_desc = {
103 .bDescriptorType = USB_DT_CS_INTERFACE, 103 .bDescriptorType = USB_DT_CS_INTERFACE,
104 .bDescriptorSubtype = UAC_OUTPUT_TERMINAL, 104 .bDescriptorSubtype = UAC_OUTPUT_TERMINAL,
105 .bTerminalID = IO_OUT_OT_ID, 105 .bTerminalID = IO_OUT_OT_ID,
106 .wTerminalType = UAC_OUTPUT_TERMINAL_SPEAKER, 106 .wTerminalType = cpu_to_le16(UAC_OUTPUT_TERMINAL_SPEAKER),
107 .bAssocTerminal = 0, 107 .bAssocTerminal = 0,
108 .bSourceID = USB_OUT_IT_ID, 108 .bSourceID = USB_OUT_IT_ID,
109}; 109};
@@ -114,9 +114,9 @@ static struct uac_input_terminal_descriptor io_in_it_desc = {
114 .bDescriptorType = USB_DT_CS_INTERFACE, 114 .bDescriptorType = USB_DT_CS_INTERFACE,
115 .bDescriptorSubtype = UAC_INPUT_TERMINAL, 115 .bDescriptorSubtype = UAC_INPUT_TERMINAL,
116 .bTerminalID = IO_IN_IT_ID, 116 .bTerminalID = IO_IN_IT_ID,
117 .wTerminalType = UAC_INPUT_TERMINAL_MICROPHONE, 117 .wTerminalType = cpu_to_le16(UAC_INPUT_TERMINAL_MICROPHONE),
118 .bAssocTerminal = 0, 118 .bAssocTerminal = 0,
119 .wChannelConfig = 0x3, 119 .wChannelConfig = cpu_to_le16(0x3),
120}; 120};
121 121
122#define USB_IN_OT_ID 4 122#define USB_IN_OT_ID 4
@@ -125,7 +125,7 @@ static struct uac1_output_terminal_descriptor usb_in_ot_desc = {
125 .bDescriptorType = USB_DT_CS_INTERFACE, 125 .bDescriptorType = USB_DT_CS_INTERFACE,
126 .bDescriptorSubtype = UAC_OUTPUT_TERMINAL, 126 .bDescriptorSubtype = UAC_OUTPUT_TERMINAL,
127 .bTerminalID = USB_IN_OT_ID, 127 .bTerminalID = USB_IN_OT_ID,
128 .wTerminalType = UAC_TERMINAL_STREAMING, 128 .wTerminalType = cpu_to_le16(UAC_TERMINAL_STREAMING),
129 .bAssocTerminal = 0, 129 .bAssocTerminal = 0,
130 .bSourceID = IO_IN_IT_ID, 130 .bSourceID = IO_IN_IT_ID,
131}; 131};
@@ -174,7 +174,7 @@ static struct uac1_as_header_descriptor as_out_header_desc = {
174 .bDescriptorSubtype = UAC_AS_GENERAL, 174 .bDescriptorSubtype = UAC_AS_GENERAL,
175 .bTerminalLink = USB_OUT_IT_ID, 175 .bTerminalLink = USB_OUT_IT_ID,
176 .bDelay = 1, 176 .bDelay = 1,
177 .wFormatTag = UAC_FORMAT_TYPE_I_PCM, 177 .wFormatTag = cpu_to_le16(UAC_FORMAT_TYPE_I_PCM),
178}; 178};
179 179
180static struct uac1_as_header_descriptor as_in_header_desc = { 180static struct uac1_as_header_descriptor as_in_header_desc = {
@@ -183,7 +183,7 @@ static struct uac1_as_header_descriptor as_in_header_desc = {
183 .bDescriptorSubtype = UAC_AS_GENERAL, 183 .bDescriptorSubtype = UAC_AS_GENERAL,
184 .bTerminalLink = USB_IN_OT_ID, 184 .bTerminalLink = USB_IN_OT_ID,
185 .bDelay = 1, 185 .bDelay = 1,
186 .wFormatTag = UAC_FORMAT_TYPE_I_PCM, 186 .wFormatTag = cpu_to_le16(UAC_FORMAT_TYPE_I_PCM),
187}; 187};
188 188
189DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(1); 189DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(1);
@@ -606,8 +606,8 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f)
606 if (status) 606 if (status)
607 goto fail; 607 goto fail;
608 608
609 audio->out_ep_maxpsize = as_out_ep_desc.wMaxPacketSize; 609 audio->out_ep_maxpsize = le16_to_cpu(as_out_ep_desc.wMaxPacketSize);
610 audio->in_ep_maxpsize = as_in_ep_desc.wMaxPacketSize; 610 audio->in_ep_maxpsize = le16_to_cpu(as_in_ep_desc.wMaxPacketSize);
611 audio->params.c_chmask = audio_opts->c_chmask; 611 audio->params.c_chmask = audio_opts->c_chmask;
612 audio->params.c_srate = audio_opts->c_srate; 612 audio->params.c_srate = audio_opts->c_srate;
613 audio->params.c_ssize = audio_opts->c_ssize; 613 audio->params.c_ssize = audio_opts->c_ssize;
diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
index 9082ce261e70..f05c3f3e6103 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -168,7 +168,7 @@ static struct uac2_input_terminal_descriptor usb_out_it_desc = {
168 .bAssocTerminal = 0, 168 .bAssocTerminal = 0,
169 .bCSourceID = USB_OUT_CLK_ID, 169 .bCSourceID = USB_OUT_CLK_ID,
170 .iChannelNames = 0, 170 .iChannelNames = 0,
171 .bmControls = (CONTROL_RDWR << COPY_CTRL), 171 .bmControls = cpu_to_le16(CONTROL_RDWR << COPY_CTRL),
172}; 172};
173 173
174/* Input Terminal for I/O-In */ 174/* Input Terminal for I/O-In */
@@ -182,7 +182,7 @@ static struct uac2_input_terminal_descriptor io_in_it_desc = {
182 .bAssocTerminal = 0, 182 .bAssocTerminal = 0,
183 .bCSourceID = USB_IN_CLK_ID, 183 .bCSourceID = USB_IN_CLK_ID,
184 .iChannelNames = 0, 184 .iChannelNames = 0,
185 .bmControls = (CONTROL_RDWR << COPY_CTRL), 185 .bmControls = cpu_to_le16(CONTROL_RDWR << COPY_CTRL),
186}; 186};
187 187
188/* Ouput Terminal for USB_IN */ 188/* Ouput Terminal for USB_IN */
@@ -196,7 +196,7 @@ static struct uac2_output_terminal_descriptor usb_in_ot_desc = {
196 .bAssocTerminal = 0, 196 .bAssocTerminal = 0,
197 .bSourceID = IO_IN_IT_ID, 197 .bSourceID = IO_IN_IT_ID,
198 .bCSourceID = USB_IN_CLK_ID, 198 .bCSourceID = USB_IN_CLK_ID,
199 .bmControls = (CONTROL_RDWR << COPY_CTRL), 199 .bmControls = cpu_to_le16(CONTROL_RDWR << COPY_CTRL),
200}; 200};
201 201
202/* Ouput Terminal for I/O-Out */ 202/* Ouput Terminal for I/O-Out */
@@ -210,7 +210,7 @@ static struct uac2_output_terminal_descriptor io_out_ot_desc = {
210 .bAssocTerminal = 0, 210 .bAssocTerminal = 0,
211 .bSourceID = USB_OUT_IT_ID, 211 .bSourceID = USB_OUT_IT_ID,
212 .bCSourceID = USB_OUT_CLK_ID, 212 .bCSourceID = USB_OUT_CLK_ID,
213 .bmControls = (CONTROL_RDWR << COPY_CTRL), 213 .bmControls = cpu_to_le16(CONTROL_RDWR << COPY_CTRL),
214}; 214};
215 215
216static struct uac2_ac_header_descriptor ac_hdr_desc = { 216static struct uac2_ac_header_descriptor ac_hdr_desc = {
@@ -220,9 +220,10 @@ static struct uac2_ac_header_descriptor ac_hdr_desc = {
220 .bDescriptorSubtype = UAC_MS_HEADER, 220 .bDescriptorSubtype = UAC_MS_HEADER,
221 .bcdADC = cpu_to_le16(0x200), 221 .bcdADC = cpu_to_le16(0x200),
222 .bCategory = UAC2_FUNCTION_IO_BOX, 222 .bCategory = UAC2_FUNCTION_IO_BOX,
223 .wTotalLength = sizeof in_clk_src_desc + sizeof out_clk_src_desc 223 .wTotalLength = cpu_to_le16(sizeof in_clk_src_desc
224 + sizeof usb_out_it_desc + sizeof io_in_it_desc 224 + sizeof out_clk_src_desc + sizeof usb_out_it_desc
225 + sizeof usb_in_ot_desc + sizeof io_out_ot_desc, 225 + sizeof io_in_it_desc + sizeof usb_in_ot_desc
226 + sizeof io_out_ot_desc),
226 .bmControls = 0, 227 .bmControls = 0,
227}; 228};
228 229
@@ -569,10 +570,12 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
569 return ret; 570 return ret;
570 } 571 }
571 572
572 agdev->in_ep_maxpsize = max(fs_epin_desc.wMaxPacketSize, 573 agdev->in_ep_maxpsize = max_t(u16,
573 hs_epin_desc.wMaxPacketSize); 574 le16_to_cpu(fs_epin_desc.wMaxPacketSize),
574 agdev->out_ep_maxpsize = max(fs_epout_desc.wMaxPacketSize, 575 le16_to_cpu(hs_epin_desc.wMaxPacketSize));
575 hs_epout_desc.wMaxPacketSize); 576 agdev->out_ep_maxpsize = max_t(u16,
577 le16_to_cpu(fs_epout_desc.wMaxPacketSize),
578 le16_to_cpu(hs_epout_desc.wMaxPacketSize));
576 579
577 hs_epout_desc.bEndpointAddress = fs_epout_desc.bEndpointAddress; 580 hs_epout_desc.bEndpointAddress = fs_epout_desc.bEndpointAddress;
578 hs_epin_desc.bEndpointAddress = fs_epin_desc.bEndpointAddress; 581 hs_epin_desc.bEndpointAddress = fs_epin_desc.bEndpointAddress;
diff --git a/drivers/usb/gadget/udc/Kconfig b/drivers/usb/gadget/udc/Kconfig
index 9ffb11ec9ed9..7cd5c969fcbe 100644
--- a/drivers/usb/gadget/udc/Kconfig
+++ b/drivers/usb/gadget/udc/Kconfig
@@ -192,7 +192,7 @@ config USB_RENESAS_USBHS_UDC
192config USB_RENESAS_USB3 192config USB_RENESAS_USB3
193 tristate 'Renesas USB3.0 Peripheral controller' 193 tristate 'Renesas USB3.0 Peripheral controller'
194 depends on ARCH_RENESAS || COMPILE_TEST 194 depends on ARCH_RENESAS || COMPILE_TEST
195 depends on EXTCON 195 depends on EXTCON && HAS_DMA
196 help 196 help
197 Renesas USB3.0 Peripheral controller is a USB peripheral controller 197 Renesas USB3.0 Peripheral controller is a USB peripheral controller
198 that supports super, high, and full speed USB 3.0 data transfers. 198 that supports super, high, and full speed USB 3.0 data transfers.
@@ -257,6 +257,7 @@ config USB_MV_U3D
257 257
258config USB_SNP_CORE 258config USB_SNP_CORE
259 depends on (USB_AMD5536UDC || USB_SNP_UDC_PLAT) 259 depends on (USB_AMD5536UDC || USB_SNP_UDC_PLAT)
260 depends on HAS_DMA
260 tristate 261 tristate
261 help 262 help
262 This enables core driver support for Synopsys USB 2.0 Device 263 This enables core driver support for Synopsys USB 2.0 Device
@@ -271,7 +272,7 @@ config USB_SNP_CORE
271 272
272config USB_SNP_UDC_PLAT 273config USB_SNP_UDC_PLAT
273 tristate "Synopsys USB 2.0 Device controller" 274 tristate "Synopsys USB 2.0 Device controller"
274 depends on (USB_GADGET && OF) 275 depends on USB_GADGET && OF && HAS_DMA
275 select USB_GADGET_DUALSPEED 276 select USB_GADGET_DUALSPEED
276 select USB_SNP_CORE 277 select USB_SNP_CORE
277 default ARCH_BCM_IPROC 278 default ARCH_BCM_IPROC
diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index d8278322d5ac..62dc9c7798e7 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -89,6 +89,9 @@
89 89
90/* USB_COM_CON */ 90/* USB_COM_CON */
91#define USB_COM_CON_CONF BIT(24) 91#define USB_COM_CON_CONF BIT(24)
92#define USB_COM_CON_PN_WDATAIF_NL BIT(23)
93#define USB_COM_CON_PN_RDATAIF_NL BIT(22)
94#define USB_COM_CON_PN_LSTTR_PP BIT(21)
92#define USB_COM_CON_SPD_MODE BIT(17) 95#define USB_COM_CON_SPD_MODE BIT(17)
93#define USB_COM_CON_EP0_EN BIT(16) 96#define USB_COM_CON_EP0_EN BIT(16)
94#define USB_COM_CON_DEV_ADDR_SHIFT 8 97#define USB_COM_CON_DEV_ADDR_SHIFT 8
@@ -686,6 +689,9 @@ static void renesas_usb3_init_controller(struct renesas_usb3 *usb3)
686{ 689{
687 usb3_init_axi_bridge(usb3); 690 usb3_init_axi_bridge(usb3);
688 usb3_init_epc_registers(usb3); 691 usb3_init_epc_registers(usb3);
692 usb3_set_bit(usb3, USB_COM_CON_PN_WDATAIF_NL |
693 USB_COM_CON_PN_RDATAIF_NL | USB_COM_CON_PN_LSTTR_PP,
694 USB3_USB_COM_CON);
689 usb3_write(usb3, USB_OTG_IDMON, USB3_USB_OTG_INT_STA); 695 usb3_write(usb3, USB_OTG_IDMON, USB3_USB_OTG_INT_STA);
690 usb3_write(usb3, USB_OTG_IDMON, USB3_USB_OTG_INT_ENA); 696 usb3_write(usb3, USB_OTG_IDMON, USB3_USB_OTG_INT_ENA);
691 697
@@ -1369,7 +1375,7 @@ static int renesas_usb3_dma_free_prd(struct renesas_usb3 *usb3,
1369 1375
1370 usb3_for_each_dma(usb3, dma, i) { 1376 usb3_for_each_dma(usb3, dma, i) {
1371 if (dma->prd) { 1377 if (dma->prd) {
1372 dma_free_coherent(dev, USB3_DMA_MAX_XFER_SIZE, 1378 dma_free_coherent(dev, USB3_DMA_PRD_SIZE,
1373 dma->prd, dma->prd_dma); 1379 dma->prd, dma->prd_dma);
1374 dma->prd = NULL; 1380 dma->prd = NULL;
1375 } 1381 }
@@ -1409,12 +1415,12 @@ static void usb3_start_pipen(struct renesas_usb3_ep *usb3_ep,
1409 int ret = -EAGAIN; 1415 int ret = -EAGAIN;
1410 u32 enable_bits = 0; 1416 u32 enable_bits = 0;
1411 1417
1418 spin_lock_irqsave(&usb3->lock, flags);
1412 if (usb3_ep->halt || usb3_ep->started) 1419 if (usb3_ep->halt || usb3_ep->started)
1413 return; 1420 goto out;
1414 if (usb3_req != usb3_req_first) 1421 if (usb3_req != usb3_req_first)
1415 return; 1422 goto out;
1416 1423
1417 spin_lock_irqsave(&usb3->lock, flags);
1418 if (usb3_pn_change(usb3, usb3_ep->num) < 0) 1424 if (usb3_pn_change(usb3, usb3_ep->num) < 0)
1419 goto out; 1425 goto out;
1420 1426
diff --git a/drivers/usb/gadget/udc/snps_udc_plat.c b/drivers/usb/gadget/udc/snps_udc_plat.c
index 2e11f19e07ae..f7b4d0f159e4 100644
--- a/drivers/usb/gadget/udc/snps_udc_plat.c
+++ b/drivers/usb/gadget/udc/snps_udc_plat.c
@@ -28,7 +28,7 @@
28/* description */ 28/* description */
29#define UDC_MOD_DESCRIPTION "Synopsys UDC platform driver" 29#define UDC_MOD_DESCRIPTION "Synopsys UDC platform driver"
30 30
31void start_udc(struct udc *udc) 31static void start_udc(struct udc *udc)
32{ 32{
33 if (udc->driver) { 33 if (udc->driver) {
34 dev_info(udc->dev, "Connecting...\n"); 34 dev_info(udc->dev, "Connecting...\n");
@@ -38,7 +38,7 @@ void start_udc(struct udc *udc)
38 } 38 }
39} 39}
40 40
41void stop_udc(struct udc *udc) 41static void stop_udc(struct udc *udc)
42{ 42{
43 int tmp; 43 int tmp;
44 u32 reg; 44 u32 reg;
@@ -76,7 +76,7 @@ void stop_udc(struct udc *udc)
76 dev_info(udc->dev, "Device disconnected\n"); 76 dev_info(udc->dev, "Device disconnected\n");
77} 77}
78 78
79void udc_drd_work(struct work_struct *work) 79static void udc_drd_work(struct work_struct *work)
80{ 80{
81 struct udc *udc; 81 struct udc *udc;
82 82
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index a9a1e4c40480..c8989c62a262 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -77,6 +77,16 @@
77#define USB_INTEL_USB3_PSSEN 0xD8 77#define USB_INTEL_USB3_PSSEN 0xD8
78#define USB_INTEL_USB3PRM 0xDC 78#define USB_INTEL_USB3PRM 0xDC
79 79
80/* ASMEDIA quirk use */
81#define ASMT_DATA_WRITE0_REG 0xF8
82#define ASMT_DATA_WRITE1_REG 0xFC
83#define ASMT_CONTROL_REG 0xE0
84#define ASMT_CONTROL_WRITE_BIT 0x02
85#define ASMT_WRITEREG_CMD 0x10423
86#define ASMT_FLOWCTL_ADDR 0xFA30
87#define ASMT_FLOWCTL_DATA 0xBA
88#define ASMT_PSEUDO_DATA 0
89
80/* 90/*
81 * amd_chipset_gen values represent AMD different chipset generations 91 * amd_chipset_gen values represent AMD different chipset generations
82 */ 92 */
@@ -412,6 +422,50 @@ void usb_amd_quirk_pll_disable(void)
412} 422}
413EXPORT_SYMBOL_GPL(usb_amd_quirk_pll_disable); 423EXPORT_SYMBOL_GPL(usb_amd_quirk_pll_disable);
414 424
425static int usb_asmedia_wait_write(struct pci_dev *pdev)
426{
427 unsigned long retry_count;
428 unsigned char value;
429
430 for (retry_count = 1000; retry_count > 0; --retry_count) {
431
432 pci_read_config_byte(pdev, ASMT_CONTROL_REG, &value);
433
434 if (value == 0xff) {
435 dev_err(&pdev->dev, "%s: check_ready ERROR", __func__);
436 return -EIO;
437 }
438
439 if ((value & ASMT_CONTROL_WRITE_BIT) == 0)
440 return 0;
441
442 usleep_range(40, 60);
443 }
444
445 dev_warn(&pdev->dev, "%s: check_write_ready timeout", __func__);
446 return -ETIMEDOUT;
447}
448
449void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev)
450{
451 if (usb_asmedia_wait_write(pdev) != 0)
452 return;
453
454 /* send command and address to device */
455 pci_write_config_dword(pdev, ASMT_DATA_WRITE0_REG, ASMT_WRITEREG_CMD);
456 pci_write_config_dword(pdev, ASMT_DATA_WRITE1_REG, ASMT_FLOWCTL_ADDR);
457 pci_write_config_byte(pdev, ASMT_CONTROL_REG, ASMT_CONTROL_WRITE_BIT);
458
459 if (usb_asmedia_wait_write(pdev) != 0)
460 return;
461
462 /* send data to device */
463 pci_write_config_dword(pdev, ASMT_DATA_WRITE0_REG, ASMT_FLOWCTL_DATA);
464 pci_write_config_dword(pdev, ASMT_DATA_WRITE1_REG, ASMT_PSEUDO_DATA);
465 pci_write_config_byte(pdev, ASMT_CONTROL_REG, ASMT_CONTROL_WRITE_BIT);
466}
467EXPORT_SYMBOL_GPL(usb_asmedia_modifyflowcontrol);
468
415void usb_amd_quirk_pll_enable(void) 469void usb_amd_quirk_pll_enable(void)
416{ 470{
417 usb_amd_quirk_pll(0); 471 usb_amd_quirk_pll(0);
diff --git a/drivers/usb/host/pci-quirks.h b/drivers/usb/host/pci-quirks.h
index 0222195bd5b0..655994480198 100644
--- a/drivers/usb/host/pci-quirks.h
+++ b/drivers/usb/host/pci-quirks.h
@@ -11,6 +11,7 @@ bool usb_amd_prefetch_quirk(void);
11void usb_amd_dev_put(void); 11void usb_amd_dev_put(void);
12void usb_amd_quirk_pll_disable(void); 12void usb_amd_quirk_pll_disable(void);
13void usb_amd_quirk_pll_enable(void); 13void usb_amd_quirk_pll_enable(void);
14void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev);
14void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev); 15void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev);
15void usb_disable_xhci_ports(struct pci_dev *xhci_pdev); 16void usb_disable_xhci_ports(struct pci_dev *xhci_pdev);
16void sb800_prefetch(struct device *dev, int on); 17void sb800_prefetch(struct device *dev, int on);
@@ -18,6 +19,7 @@ void sb800_prefetch(struct device *dev, int on);
18struct pci_dev; 19struct pci_dev;
19static inline void usb_amd_quirk_pll_disable(void) {} 20static inline void usb_amd_quirk_pll_disable(void) {}
20static inline void usb_amd_quirk_pll_enable(void) {} 21static inline void usb_amd_quirk_pll_enable(void) {}
22static inline void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev) {}
21static inline void usb_amd_dev_put(void) {} 23static inline void usb_amd_dev_put(void) {}
22static inline void usb_disable_xhci_ports(struct pci_dev *xhci_pdev) {} 24static inline void usb_disable_xhci_ports(struct pci_dev *xhci_pdev) {}
23static inline void sb800_prefetch(struct device *dev, int on) {} 25static inline void sb800_prefetch(struct device *dev, int on) {}
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 1adae9eab831..00721e8807ab 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -398,14 +398,21 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend)
398 spin_lock_irqsave(&xhci->lock, flags); 398 spin_lock_irqsave(&xhci->lock, flags);
399 for (i = LAST_EP_INDEX; i > 0; i--) { 399 for (i = LAST_EP_INDEX; i > 0; i--) {
400 if (virt_dev->eps[i].ring && virt_dev->eps[i].ring->dequeue) { 400 if (virt_dev->eps[i].ring && virt_dev->eps[i].ring->dequeue) {
401 struct xhci_ep_ctx *ep_ctx;
401 struct xhci_command *command; 402 struct xhci_command *command;
403
404 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->out_ctx, i);
405
406 /* Check ep is running, required by AMD SNPS 3.1 xHC */
407 if (GET_EP_CTX_STATE(ep_ctx) != EP_STATE_RUNNING)
408 continue;
409
402 command = xhci_alloc_command(xhci, false, false, 410 command = xhci_alloc_command(xhci, false, false,
403 GFP_NOWAIT); 411 GFP_NOWAIT);
404 if (!command) { 412 if (!command) {
405 spin_unlock_irqrestore(&xhci->lock, flags); 413 spin_unlock_irqrestore(&xhci->lock, flags);
406 xhci_free_command(xhci, cmd); 414 xhci_free_command(xhci, cmd);
407 return -ENOMEM; 415 return -ENOMEM;
408
409 } 416 }
410 xhci_queue_stop_endpoint(xhci, command, slot_id, i, 417 xhci_queue_stop_endpoint(xhci, command, slot_id, i,
411 suspend); 418 suspend);
@@ -603,12 +610,14 @@ static int xhci_enter_test_mode(struct xhci_hcd *xhci,
603 610
604 /* Disable all Device Slots */ 611 /* Disable all Device Slots */
605 xhci_dbg(xhci, "Disable all slots\n"); 612 xhci_dbg(xhci, "Disable all slots\n");
613 spin_unlock_irqrestore(&xhci->lock, *flags);
606 for (i = 1; i <= HCS_MAX_SLOTS(xhci->hcs_params1); i++) { 614 for (i = 1; i <= HCS_MAX_SLOTS(xhci->hcs_params1); i++) {
607 retval = xhci_disable_slot(xhci, NULL, i); 615 retval = xhci_disable_slot(xhci, NULL, i);
608 if (retval) 616 if (retval)
609 xhci_err(xhci, "Failed to disable slot %d, %d. Enter test mode anyway\n", 617 xhci_err(xhci, "Failed to disable slot %d, %d. Enter test mode anyway\n",
610 i, retval); 618 i, retval);
611 } 619 }
620 spin_lock_irqsave(&xhci->lock, *flags);
612 /* Put all ports to the Disable state by clear PP */ 621 /* Put all ports to the Disable state by clear PP */
613 xhci_dbg(xhci, "Disable all port (PP = 0)\n"); 622 xhci_dbg(xhci, "Disable all port (PP = 0)\n");
614 /* Power off USB3 ports*/ 623 /* Power off USB3 ports*/
@@ -897,6 +906,9 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
897 clear_bit(wIndex, &bus_state->resuming_ports); 906 clear_bit(wIndex, &bus_state->resuming_ports);
898 907
899 set_bit(wIndex, &bus_state->rexit_ports); 908 set_bit(wIndex, &bus_state->rexit_ports);
909
910 xhci_test_and_clear_bit(xhci, port_array, wIndex,
911 PORT_PLC);
900 xhci_set_link_state(xhci, port_array, wIndex, 912 xhci_set_link_state(xhci, port_array, wIndex,
901 XDEV_U0); 913 XDEV_U0);
902 914
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 53882e2babbb..5b0fa553c8bc 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -59,6 +59,8 @@
59#define PCI_DEVICE_ID_AMD_PROMONTORYA_2 0x43bb 59#define PCI_DEVICE_ID_AMD_PROMONTORYA_2 0x43bb
60#define PCI_DEVICE_ID_AMD_PROMONTORYA_1 0x43bc 60#define PCI_DEVICE_ID_AMD_PROMONTORYA_1 0x43bc
61 61
62#define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI 0x1142
63
62static const char hcd_name[] = "xhci_hcd"; 64static const char hcd_name[] = "xhci_hcd";
63 65
64static struct hc_driver __read_mostly xhci_pci_hc_driver; 66static struct hc_driver __read_mostly xhci_pci_hc_driver;
@@ -217,6 +219,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
217 pdev->device == 0x1142) 219 pdev->device == 0x1142)
218 xhci->quirks |= XHCI_TRUST_TX_LENGTH; 220 xhci->quirks |= XHCI_TRUST_TX_LENGTH;
219 221
222 if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
223 pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI)
224 xhci->quirks |= XHCI_ASMEDIA_MODIFY_FLOWCONTROL;
225
220 if (pdev->vendor == PCI_VENDOR_ID_TI && pdev->device == 0x8241) 226 if (pdev->vendor == PCI_VENDOR_ID_TI && pdev->device == 0x8241)
221 xhci->quirks |= XHCI_LIMIT_ENDPOINT_INTERVAL_7; 227 xhci->quirks |= XHCI_LIMIT_ENDPOINT_INTERVAL_7;
222 228
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index c50c902d009e..cc368ad2b51e 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -864,13 +864,16 @@ static void xhci_kill_endpoint_urbs(struct xhci_hcd *xhci,
864 (ep->ep_state & EP_GETTING_NO_STREAMS)) { 864 (ep->ep_state & EP_GETTING_NO_STREAMS)) {
865 int stream_id; 865 int stream_id;
866 866
867 for (stream_id = 0; stream_id < ep->stream_info->num_streams; 867 for (stream_id = 1; stream_id < ep->stream_info->num_streams;
868 stream_id++) { 868 stream_id++) {
869 ring = ep->stream_info->stream_rings[stream_id];
870 if (!ring)
871 continue;
872
869 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, 873 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
870 "Killing URBs for slot ID %u, ep index %u, stream %u", 874 "Killing URBs for slot ID %u, ep index %u, stream %u",
871 slot_id, ep_index, stream_id + 1); 875 slot_id, ep_index, stream_id);
872 xhci_kill_ring_urbs(xhci, 876 xhci_kill_ring_urbs(xhci, ring);
873 ep->stream_info->stream_rings[stream_id]);
874 } 877 }
875 } else { 878 } else {
876 ring = ep->ring; 879 ring = ep->ring;
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 56f85df013db..b2ff1ff1a02f 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -198,6 +198,9 @@ int xhci_reset(struct xhci_hcd *xhci)
198 if (ret) 198 if (ret)
199 return ret; 199 return ret;
200 200
201 if (xhci->quirks & XHCI_ASMEDIA_MODIFY_FLOWCONTROL)
202 usb_asmedia_modifyflowcontrol(to_pci_dev(xhci_to_hcd(xhci)->self.controller));
203
201 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 204 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
202 "Wait for controller to be ready for doorbell rings"); 205 "Wait for controller to be ready for doorbell rings");
203 /* 206 /*
@@ -622,8 +625,10 @@ int xhci_run(struct usb_hcd *hcd)
622 if (!command) 625 if (!command)
623 return -ENOMEM; 626 return -ENOMEM;
624 627
625 xhci_queue_vendor_command(xhci, command, 0, 0, 0, 628 ret = xhci_queue_vendor_command(xhci, command, 0, 0, 0,
626 TRB_TYPE(TRB_NEC_GET_FW)); 629 TRB_TYPE(TRB_NEC_GET_FW));
630 if (ret)
631 xhci_free_command(xhci, command);
627 } 632 }
628 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 633 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
629 "Finished xhci_run for USB2 roothub"); 634 "Finished xhci_run for USB2 roothub");
@@ -1085,6 +1090,9 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1085 if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && !comp_timer_running) 1090 if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && !comp_timer_running)
1086 compliance_mode_recovery_timer_init(xhci); 1091 compliance_mode_recovery_timer_init(xhci);
1087 1092
1093 if (xhci->quirks & XHCI_ASMEDIA_MODIFY_FLOWCONTROL)
1094 usb_asmedia_modifyflowcontrol(to_pci_dev(hcd->self.controller));
1095
1088 /* Re-enable port polling. */ 1096 /* Re-enable port polling. */
1089 xhci_dbg(xhci, "%s: starting port polling.\n", __func__); 1097 xhci_dbg(xhci, "%s: starting port polling.\n", __func__);
1090 set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); 1098 set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 3c6da1f93c84..e3e935291ed6 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1820,6 +1820,7 @@ struct xhci_hcd {
1820#define XHCI_BROKEN_PORT_PED (1 << 25) 1820#define XHCI_BROKEN_PORT_PED (1 << 25)
1821#define XHCI_LIMIT_ENDPOINT_INTERVAL_7 (1 << 26) 1821#define XHCI_LIMIT_ENDPOINT_INTERVAL_7 (1 << 26)
1822#define XHCI_U2_DISABLE_WAKE (1 << 27) 1822#define XHCI_U2_DISABLE_WAKE (1 << 27)
1823#define XHCI_ASMEDIA_MODIFY_FLOWCONTROL (1 << 28)
1823 1824
1824 unsigned int num_active_eps; 1825 unsigned int num_active_eps;
1825 unsigned int limit_active_eps; 1826 unsigned int limit_active_eps;
diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 623c51300393..f0ce304c5aaf 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -752,8 +752,10 @@ static int usbhsc_resume(struct device *dev)
752 struct usbhs_priv *priv = dev_get_drvdata(dev); 752 struct usbhs_priv *priv = dev_get_drvdata(dev);
753 struct platform_device *pdev = usbhs_priv_to_pdev(priv); 753 struct platform_device *pdev = usbhs_priv_to_pdev(priv);
754 754
755 if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) 755 if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) {
756 usbhsc_power_ctrl(priv, 1); 756 usbhsc_power_ctrl(priv, 1);
757 usbhs_mod_autonomy_mode(priv);
758 }
757 759
758 usbhs_platform_call(priv, phy_reset, pdev); 760 usbhs_platform_call(priv, phy_reset, pdev);
759 761
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
index 5bc7a6138855..93fba9033b00 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -37,6 +37,7 @@ struct usbhsg_gpriv;
37struct usbhsg_uep { 37struct usbhsg_uep {
38 struct usb_ep ep; 38 struct usb_ep ep;
39 struct usbhs_pipe *pipe; 39 struct usbhs_pipe *pipe;
40 spinlock_t lock; /* protect the pipe */
40 41
41 char ep_name[EP_NAME_SIZE]; 42 char ep_name[EP_NAME_SIZE];
42 43
@@ -636,10 +637,16 @@ usbhsg_ep_enable_end:
636static int usbhsg_ep_disable(struct usb_ep *ep) 637static int usbhsg_ep_disable(struct usb_ep *ep)
637{ 638{
638 struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep); 639 struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep);
639 struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep); 640 struct usbhs_pipe *pipe;
641 unsigned long flags;
642 int ret = 0;
640 643
641 if (!pipe) 644 spin_lock_irqsave(&uep->lock, flags);
642 return -EINVAL; 645 pipe = usbhsg_uep_to_pipe(uep);
646 if (!pipe) {
647 ret = -EINVAL;
648 goto out;
649 }
643 650
644 usbhsg_pipe_disable(uep); 651 usbhsg_pipe_disable(uep);
645 usbhs_pipe_free(pipe); 652 usbhs_pipe_free(pipe);
@@ -647,6 +654,9 @@ static int usbhsg_ep_disable(struct usb_ep *ep)
647 uep->pipe->mod_private = NULL; 654 uep->pipe->mod_private = NULL;
648 uep->pipe = NULL; 655 uep->pipe = NULL;
649 656
657out:
658 spin_unlock_irqrestore(&uep->lock, flags);
659
650 return 0; 660 return 0;
651} 661}
652 662
@@ -696,8 +706,11 @@ static int usbhsg_ep_dequeue(struct usb_ep *ep, struct usb_request *req)
696{ 706{
697 struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep); 707 struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep);
698 struct usbhsg_request *ureq = usbhsg_req_to_ureq(req); 708 struct usbhsg_request *ureq = usbhsg_req_to_ureq(req);
699 struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep); 709 struct usbhs_pipe *pipe;
710 unsigned long flags;
700 711
712 spin_lock_irqsave(&uep->lock, flags);
713 pipe = usbhsg_uep_to_pipe(uep);
701 if (pipe) 714 if (pipe)
702 usbhs_pkt_pop(pipe, usbhsg_ureq_to_pkt(ureq)); 715 usbhs_pkt_pop(pipe, usbhsg_ureq_to_pkt(ureq));
703 716
@@ -706,6 +719,7 @@ static int usbhsg_ep_dequeue(struct usb_ep *ep, struct usb_request *req)
706 * even if the pipe is NULL. 719 * even if the pipe is NULL.
707 */ 720 */
708 usbhsg_queue_pop(uep, ureq, -ECONNRESET); 721 usbhsg_queue_pop(uep, ureq, -ECONNRESET);
722 spin_unlock_irqrestore(&uep->lock, flags);
709 723
710 return 0; 724 return 0;
711} 725}
@@ -852,10 +866,10 @@ static int usbhsg_try_stop(struct usbhs_priv *priv, u32 status)
852{ 866{
853 struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv); 867 struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv);
854 struct usbhs_mod *mod = usbhs_mod_get_current(priv); 868 struct usbhs_mod *mod = usbhs_mod_get_current(priv);
855 struct usbhsg_uep *dcp = usbhsg_gpriv_to_dcp(gpriv); 869 struct usbhsg_uep *uep;
856 struct device *dev = usbhs_priv_to_dev(priv); 870 struct device *dev = usbhs_priv_to_dev(priv);
857 unsigned long flags; 871 unsigned long flags;
858 int ret = 0; 872 int ret = 0, i;
859 873
860 /******************** spin lock ********************/ 874 /******************** spin lock ********************/
861 usbhs_lock(priv, flags); 875 usbhs_lock(priv, flags);
@@ -887,7 +901,9 @@ static int usbhsg_try_stop(struct usbhs_priv *priv, u32 status)
887 usbhs_sys_set_test_mode(priv, 0); 901 usbhs_sys_set_test_mode(priv, 0);
888 usbhs_sys_function_ctrl(priv, 0); 902 usbhs_sys_function_ctrl(priv, 0);
889 903
890 usbhsg_ep_disable(&dcp->ep); 904 /* disable all eps */
905 usbhsg_for_each_uep_with_dcp(uep, gpriv, i)
906 usbhsg_ep_disable(&uep->ep);
891 907
892 dev_dbg(dev, "stop gadget\n"); 908 dev_dbg(dev, "stop gadget\n");
893 909
@@ -1069,6 +1085,7 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
1069 ret = -ENOMEM; 1085 ret = -ENOMEM;
1070 goto usbhs_mod_gadget_probe_err_gpriv; 1086 goto usbhs_mod_gadget_probe_err_gpriv;
1071 } 1087 }
1088 spin_lock_init(&uep->lock);
1072 1089
1073 gpriv->transceiver = usb_get_phy(USB_PHY_TYPE_UNDEFINED); 1090 gpriv->transceiver = usb_get_phy(USB_PHY_TYPE_UNDEFINED);
1074 dev_info(dev, "%stransceiver found\n", 1091 dev_info(dev, "%stransceiver found\n",
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
index fba4005dd737..6a7720e66595 100644
--- a/drivers/usb/storage/isd200.c
+++ b/drivers/usb/storage/isd200.c
@@ -1529,8 +1529,11 @@ static void isd200_ata_command(struct scsi_cmnd *srb, struct us_data *us)
1529 1529
1530 /* Make sure driver was initialized */ 1530 /* Make sure driver was initialized */
1531 1531
1532 if (us->extra == NULL) 1532 if (us->extra == NULL) {
1533 usb_stor_dbg(us, "ERROR Driver not initialized\n"); 1533 usb_stor_dbg(us, "ERROR Driver not initialized\n");
1534 srb->result = DID_ERROR << 16;
1535 return;
1536 }
1534 1537
1535 scsi_set_resid(srb, 0); 1538 scsi_set_resid(srb, 0);
1536 /* scsi_bufflen might change in protocol translation to ata */ 1539 /* scsi_bufflen might change in protocol translation to ata */
diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h
index 6b0d2f0918c6..8a88f45822e3 100644
--- a/drivers/usb/typec/ucsi/ucsi.h
+++ b/drivers/usb/typec/ucsi/ucsi.h
@@ -3,6 +3,7 @@
3#define __DRIVER_USB_TYPEC_UCSI_H 3#define __DRIVER_USB_TYPEC_UCSI_H
4 4
5#include <linux/bitops.h> 5#include <linux/bitops.h>
6#include <linux/device.h>
6#include <linux/types.h> 7#include <linux/types.h>
7 8
8/* -------------------------------------------------------------------------- */ 9/* -------------------------------------------------------------------------- */
diff --git a/include/linux/usb/audio-v2.h b/include/linux/usb/audio-v2.h
index c5f2158ab00e..fd73bc0e9027 100644
--- a/include/linux/usb/audio-v2.h
+++ b/include/linux/usb/audio-v2.h
@@ -115,13 +115,13 @@ struct uac2_input_terminal_descriptor {
115 __u8 bDescriptorType; 115 __u8 bDescriptorType;
116 __u8 bDescriptorSubtype; 116 __u8 bDescriptorSubtype;
117 __u8 bTerminalID; 117 __u8 bTerminalID;
118 __u16 wTerminalType; 118 __le16 wTerminalType;
119 __u8 bAssocTerminal; 119 __u8 bAssocTerminal;
120 __u8 bCSourceID; 120 __u8 bCSourceID;
121 __u8 bNrChannels; 121 __u8 bNrChannels;
122 __u32 bmChannelConfig; 122 __le32 bmChannelConfig;
123 __u8 iChannelNames; 123 __u8 iChannelNames;
124 __u16 bmControls; 124 __le16 bmControls;
125 __u8 iTerminal; 125 __u8 iTerminal;
126} __attribute__((packed)); 126} __attribute__((packed));
127 127
@@ -132,11 +132,11 @@ struct uac2_output_terminal_descriptor {
132 __u8 bDescriptorType; 132 __u8 bDescriptorType;
133 __u8 bDescriptorSubtype; 133 __u8 bDescriptorSubtype;
134 __u8 bTerminalID; 134 __u8 bTerminalID;
135 __u16 wTerminalType; 135 __le16 wTerminalType;
136 __u8 bAssocTerminal; 136 __u8 bAssocTerminal;
137 __u8 bSourceID; 137 __u8 bSourceID;
138 __u8 bCSourceID; 138 __u8 bCSourceID;
139 __u16 bmControls; 139 __le16 bmControls;
140 __u8 iTerminal; 140 __u8 iTerminal;
141} __attribute__((packed)); 141} __attribute__((packed));
142 142
@@ -164,9 +164,9 @@ struct uac2_as_header_descriptor {
164 __u8 bTerminalLink; 164 __u8 bTerminalLink;
165 __u8 bmControls; 165 __u8 bmControls;
166 __u8 bFormatType; 166 __u8 bFormatType;
167 __u32 bmFormats; 167 __le32 bmFormats;
168 __u8 bNrChannels; 168 __u8 bNrChannels;
169 __u32 bmChannelConfig; 169 __le32 bmChannelConfig;
170 __u8 iChannelNames; 170 __u8 iChannelNames;
171} __attribute__((packed)); 171} __attribute__((packed));
172 172
diff --git a/include/uapi/linux/usb/audio.h b/include/uapi/linux/usb/audio.h
index d2314be4f0c0..a4680a5bf5dd 100644
--- a/include/uapi/linux/usb/audio.h
+++ b/include/uapi/linux/usb/audio.h
@@ -333,7 +333,7 @@ struct uac_processing_unit_descriptor {
333 __u8 bDescriptorType; 333 __u8 bDescriptorType;
334 __u8 bDescriptorSubtype; 334 __u8 bDescriptorSubtype;
335 __u8 bUnitID; 335 __u8 bUnitID;
336 __u16 wProcessType; 336 __le16 wProcessType;
337 __u8 bNrInPins; 337 __u8 bNrInPins;
338 __u8 baSourceID[]; 338 __u8 baSourceID[];
339} __attribute__ ((packed)); 339} __attribute__ ((packed));
@@ -491,8 +491,8 @@ struct uac_format_type_ii_ext_descriptor {
491 __u8 bDescriptorType; 491 __u8 bDescriptorType;
492 __u8 bDescriptorSubtype; 492 __u8 bDescriptorSubtype;
493 __u8 bFormatType; 493 __u8 bFormatType;
494 __u16 wMaxBitRate; 494 __le16 wMaxBitRate;
495 __u16 wSamplesPerFrame; 495 __le16 wSamplesPerFrame;
496 __u8 bHeaderLength; 496 __u8 bHeaderLength;
497 __u8 bSideBandProtocol; 497 __u8 bSideBandProtocol;
498} __attribute__((packed)); 498} __attribute__((packed));