Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'usb-4.18-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB fixes from Greg KH:
"Here are a number of USB fixes and new device ids for 4.18-rc7.

The largest number are a bunch of gadget driver fixes that got delayed
in being submitted earlier due to vacation schedules, but nothing
really huge is present in them. There are some new device ids and some
PHY driver fixes that were connected to some USB ones. Full details
are in the shortlog.

All have been in linux-next for a while with no reported issues"

* tag 'usb-4.18-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (28 commits)
usb: core: handle hub C_PORT_OVER_CURRENT condition
usb: xhci: Fix memory leak in xhci_endpoint_reset()
usb: typec: tcpm: Fix sink PDO starting index for PPS APDO selection
usb: gadget: f_fs: Only return delayed status when len is 0
usb: gadget: f_uac2: fix endianness of 'struct cntrl_*_lay3'
usb: dwc2: Fix inefficient copy of unaligned buffers
usb: dwc2: Fix DMA alignment to start at allocated boundary
usb: dwc3: rockchip: Fix PHY documentation links.
tools: usb: ffs-test: Fix build on big endian systems
usb: gadget: aspeed: Workaround memory ordering issue
usb: dwc3: gadget: remove redundant variable maxpacket
usb: dwc2: avoid NULL dereferences
usb/phy: fix PPC64 build errors in phy-fsl-usb.c
usb: dwc2: host: do not delay retries for CONTROL IN transfers
usb: gadget: u_audio: protect stream runtime fields with stream spinlock
usb: gadget: u_audio: remove cached period bytes value
usb: gadget: u_audio: remove caching of stream buffer parameters
usb: gadget: u_audio: update hw_ptr in iso_complete after data copied
usb: gadget: u_audio: fix pcm/card naming in g_audio_setup()
usb: gadget: f_uac2: fix error handling in afunc_bind (again)
...

+187 -135
+2 -1
Documentation/devicetree/bindings/usb/rockchip,dwc3.txt
··· 16 16 the node is not important. The content of the node is defined in dwc3.txt. 17 17 18 18 Phy documentation is provided in the following places: 19 - Documentation/devicetree/bindings/phy/qcom-dwc3-usb-phy.txt 19 + Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.txt - USB2.0 PHY 20 + Documentation/devicetree/bindings/phy/phy-rockchip-typec.txt - Type-C PHY 20 21 21 22 Example device nodes: 22 23
+4
drivers/phy/broadcom/phy-brcm-usb-init.c
··· 962 962 { 963 963 void __iomem *ctrl = params->ctrl_regs; 964 964 965 + USB_CTRL_UNSET(ctrl, USB30_PCTL, PHY3_IDDQ_OVERRIDE); 966 + /* 1 millisecond - for USB clocks to settle down */ 967 + usleep_range(1000, 2000); 968 + 965 969 if (BRCM_ID(params->family_id) == 0x7366) { 966 970 /* 967 971 * The PHY3_SOFT_RESETB bits default to the wrong state.
+2 -2
drivers/phy/motorola/phy-mapphone-mdm6600.c
··· 182 182 ddata = container_of(work, struct phy_mdm6600, status_work.work); 183 183 dev = ddata->dev; 184 184 185 - error = gpiod_get_array_value_cansleep(PHY_MDM6600_NR_CMD_LINES, 185 + error = gpiod_get_array_value_cansleep(PHY_MDM6600_NR_STATUS_LINES, 186 186 ddata->status_gpios->desc, 187 187 values); 188 188 if (error) 189 189 return; 190 190 191 - for (i = 0; i < PHY_MDM6600_NR_CMD_LINES; i++) { 191 + for (i = 0; i < PHY_MDM6600_NR_STATUS_LINES; i++) { 192 192 val |= values[i] << i; 193 193 dev_dbg(ddata->dev, "XXX %s: i: %i values[i]: %i val: %i\n", 194 194 __func__, i, values[i], val);
+1 -8
drivers/usb/chipidea/Kconfig
··· 3 3 depends on ((USB_EHCI_HCD && USB_GADGET) || (USB_EHCI_HCD && !USB_GADGET) || (!USB_EHCI_HCD && USB_GADGET)) && HAS_DMA 4 4 select EXTCON 5 5 select RESET_CONTROLLER 6 + select USB_ULPI_BUS 6 7 help 7 8 Say Y here if your system has a dual role high speed USB 8 9 controller based on ChipIdea silicon IP. It supports: ··· 39 38 help 40 39 Say Y here to enable host controller functionality of the 41 40 ChipIdea driver. 42 - 43 - config USB_CHIPIDEA_ULPI 44 - bool "ChipIdea ULPI PHY support" 45 - depends on USB_ULPI_BUS=y || USB_ULPI_BUS=USB_CHIPIDEA 46 - help 47 - Say Y here if you have a ULPI PHY attached to your ChipIdea 48 - controller. 49 - 50 41 endif
+1 -2
drivers/usb/chipidea/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc.o 3 3 4 - ci_hdrc-y := core.o otg.o debug.o 4 + ci_hdrc-y := core.o otg.o debug.o ulpi.o 5 5 ci_hdrc-$(CONFIG_USB_CHIPIDEA_UDC) += udc.o 6 6 ci_hdrc-$(CONFIG_USB_CHIPIDEA_HOST) += host.o 7 7 ci_hdrc-$(CONFIG_USB_OTG_FSM) += otg_fsm.o 8 - ci_hdrc-$(CONFIG_USB_CHIPIDEA_ULPI) += ulpi.o 9 8 10 9 # Glue/Bridge layers go here 11 10
-8
drivers/usb/chipidea/ci.h
··· 240 240 241 241 struct ci_hdrc_platform_data *platdata; 242 242 int vbus_active; 243 - #ifdef CONFIG_USB_CHIPIDEA_ULPI 244 243 struct ulpi *ulpi; 245 244 struct ulpi_ops ulpi_ops; 246 - #endif 247 245 struct phy *phy; 248 246 /* old usb_phy interface */ 249 247 struct usb_phy *usb_phy; ··· 424 426 #endif 425 427 } 426 428 427 - #if IS_ENABLED(CONFIG_USB_CHIPIDEA_ULPI) 428 429 int ci_ulpi_init(struct ci_hdrc *ci); 429 430 void ci_ulpi_exit(struct ci_hdrc *ci); 430 431 int ci_ulpi_resume(struct ci_hdrc *ci); 431 - #else 432 - static inline int ci_ulpi_init(struct ci_hdrc *ci) { return 0; } 433 - static inline void ci_ulpi_exit(struct ci_hdrc *ci) { } 434 - static inline int ci_ulpi_resume(struct ci_hdrc *ci) { return 0; } 435 - #endif 436 432 437 433 u32 hw_read_intr_enable(struct ci_hdrc *ci); 438 434
+3
drivers/usb/chipidea/ulpi.c
··· 95 95 { 96 96 int cnt = 100000; 97 97 98 + if (ci->platdata->phy_mode != USBPHY_INTERFACE_MODE_ULPI) 99 + return 0; 100 + 98 101 while (cnt-- > 0) { 99 102 if (hw_read(ci, OP_ULPI_VIEWPORT, ULPI_SYNC_STATE)) 100 103 return 0;
+3
drivers/usb/class/cdc-acm.c
··· 1831 1831 { USB_DEVICE(0x09d8, 0x0320), /* Elatec GmbH TWN3 */ 1832 1832 .driver_info = NO_UNION_NORMAL, /* has misplaced union descriptor */ 1833 1833 }, 1834 + { USB_DEVICE(0x0ca6, 0xa050), /* Castles VEGA3000 */ 1835 + .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */ 1836 + }, 1834 1837 1835 1838 { USB_DEVICE(0x2912, 0x0001), /* ATOL FPrint */ 1836 1839 .driver_info = CLEAR_HALT_CONDITIONS,
+6 -2
drivers/usb/core/hub.c
··· 1142 1142 1143 1143 if (!udev || udev->state == USB_STATE_NOTATTACHED) { 1144 1144 /* Tell hub_wq to disconnect the device or 1145 - * check for a new connection 1145 + * check for a new connection or over current condition. 1146 + * Based on USB2.0 Spec Section 11.12.5, 1147 + * C_PORT_OVER_CURRENT could be set while 1148 + * PORT_OVER_CURRENT is not. So check for any of them. 1146 1149 */ 1147 1150 if (udev || (portstatus & USB_PORT_STAT_CONNECTION) || 1148 - (portstatus & USB_PORT_STAT_OVERCURRENT)) 1151 + (portstatus & USB_PORT_STAT_OVERCURRENT) || 1152 + (portchange & USB_PORT_STAT_C_OVERCURRENT)) 1149 1153 set_bit(port1, hub->change_bits); 1150 1154 1151 1155 } else if (portstatus & USB_PORT_STAT_ENABLE) {
+3 -3
drivers/usb/dwc2/gadget.c
··· 3430 3430 for (idx = 1; idx < hsotg->num_of_eps; idx++) { 3431 3431 hs_ep = hsotg->eps_in[idx]; 3432 3432 /* Proceed only unmasked ISOC EPs */ 3433 - if (!hs_ep->isochronous || (BIT(idx) & ~daintmsk)) 3433 + if ((BIT(idx) & ~daintmsk) || !hs_ep->isochronous) 3434 3434 continue; 3435 3435 3436 3436 epctrl = dwc2_readl(hsotg->regs + DIEPCTL(idx)); ··· 3476 3476 for (idx = 1; idx < hsotg->num_of_eps; idx++) { 3477 3477 hs_ep = hsotg->eps_out[idx]; 3478 3478 /* Proceed only unmasked ISOC EPs */ 3479 - if (!hs_ep->isochronous || (BIT(idx) & ~daintmsk)) 3479 + if ((BIT(idx) & ~daintmsk) || !hs_ep->isochronous) 3480 3480 continue; 3481 3481 3482 3482 epctrl = dwc2_readl(hsotg->regs + DOEPCTL(idx)); ··· 3650 3650 for (idx = 1; idx < hsotg->num_of_eps; idx++) { 3651 3651 hs_ep = hsotg->eps_out[idx]; 3652 3652 /* Proceed only unmasked ISOC EPs */ 3653 - if (!hs_ep->isochronous || (BIT(idx) & ~daintmsk)) 3653 + if ((BIT(idx) & ~daintmsk) || !hs_ep->isochronous) 3654 3654 continue; 3655 3655 3656 3656 epctrl = dwc2_readl(hsotg->regs + DOEPCTL(idx));
+31 -23
drivers/usb/dwc2/hcd.c
··· 2665 2665 2666 2666 #define DWC2_USB_DMA_ALIGN 4 2667 2667 2668 - struct dma_aligned_buffer { 2669 - void *kmalloc_ptr; 2670 - void *old_xfer_buffer; 2671 - u8 data[0]; 2672 - }; 2673 - 2674 2668 static void dwc2_free_dma_aligned_buffer(struct urb *urb) 2675 2669 { 2676 - struct dma_aligned_buffer *temp; 2670 + void *stored_xfer_buffer; 2671 + size_t length; 2677 2672 2678 2673 if (!(urb->transfer_flags & URB_ALIGNED_TEMP_BUFFER)) 2679 2674 return; 2680 2675 2681 - temp = container_of(urb->transfer_buffer, 2682 - struct dma_aligned_buffer, data); 2676 + /* Restore urb->transfer_buffer from the end of the allocated area */ 2677 + memcpy(&stored_xfer_buffer, urb->transfer_buffer + 2678 + urb->transfer_buffer_length, sizeof(urb->transfer_buffer)); 2683 2679 2684 - if (usb_urb_dir_in(urb)) 2685 - memcpy(temp->old_xfer_buffer, temp->data, 2686 - urb->transfer_buffer_length); 2687 - urb->transfer_buffer = temp->old_xfer_buffer; 2688 - kfree(temp->kmalloc_ptr); 2680 + if (usb_urb_dir_in(urb)) { 2681 + if (usb_pipeisoc(urb->pipe)) 2682 + length = urb->transfer_buffer_length; 2683 + else 2684 + length = urb->actual_length; 2685 + 2686 + memcpy(stored_xfer_buffer, urb->transfer_buffer, length); 2687 + } 2688 + kfree(urb->transfer_buffer); 2689 + urb->transfer_buffer = stored_xfer_buffer; 2689 2690 2690 2691 urb->transfer_flags &= ~URB_ALIGNED_TEMP_BUFFER; 2691 2692 } 2692 2693 2693 2694 static int dwc2_alloc_dma_aligned_buffer(struct urb *urb, gfp_t mem_flags) 2694 2695 { 2695 - struct dma_aligned_buffer *temp, *kmalloc_ptr; 2696 + void *kmalloc_ptr; 2696 2697 size_t kmalloc_size; 2697 2698 2698 2699 if (urb->num_sgs || urb->sg || ··· 2701 2700 !((uintptr_t)urb->transfer_buffer & (DWC2_USB_DMA_ALIGN - 1))) 2702 2701 return 0; 2703 2702 2704 - /* Allocate a buffer with enough padding for alignment */ 2703 + /* 2704 + * Allocate a buffer with enough padding for original transfer_buffer 2705 + * pointer. This allocation is guaranteed to be aligned properly for 2706 + * DMA 2707 + */ 2705 2708 kmalloc_size = urb->transfer_buffer_length + 2706 - sizeof(struct dma_aligned_buffer) + DWC2_USB_DMA_ALIGN - 1; 2709 + sizeof(urb->transfer_buffer); 2707 2710 2708 2711 kmalloc_ptr = kmalloc(kmalloc_size, mem_flags); 2709 2712 if (!kmalloc_ptr) 2710 2713 return -ENOMEM; 2711 2714 2712 - /* Position our struct dma_aligned_buffer such that data is aligned */ 2713 - temp = PTR_ALIGN(kmalloc_ptr + 1, DWC2_USB_DMA_ALIGN) - 1; 2714 - temp->kmalloc_ptr = kmalloc_ptr; 2715 - temp->old_xfer_buffer = urb->transfer_buffer; 2715 + /* 2716 + * Position value of original urb->transfer_buffer pointer to the end 2717 + * of allocation for later referencing 2718 + */ 2719 + memcpy(kmalloc_ptr + urb->transfer_buffer_length, 2720 + &urb->transfer_buffer, sizeof(urb->transfer_buffer)); 2721 + 2716 2722 if (usb_urb_dir_out(urb)) 2717 - memcpy(temp->data, urb->transfer_buffer, 2723 + memcpy(kmalloc_ptr, urb->transfer_buffer, 2718 2724 urb->transfer_buffer_length); 2719 - urb->transfer_buffer = temp->data; 2725 + urb->transfer_buffer = kmalloc_ptr; 2720 2726 2721 2727 urb->transfer_flags |= URB_ALIGNED_TEMP_BUFFER; 2722 2728
+7 -2
drivers/usb/dwc2/hcd_intr.c
··· 1231 1231 * avoid interrupt storms we'll wait before retrying if we've got 1232 1232 * several NAKs. If we didn't do this we'd retry directly from the 1233 1233 * interrupt handler and could end up quickly getting another 1234 - * interrupt (another NAK), which we'd retry. 1234 + * interrupt (another NAK), which we'd retry. Note that we do not 1235 + * delay retries for IN parts of control requests, as those are expected 1236 + * to complete fairly quickly, and if we delay them we risk confusing 1237 + * the device and cause it issue STALL. 1235 1238 * 1236 1239 * Note that in DMA mode software only gets involved to re-send NAKed 1237 1240 * transfers for split transactions, so we only need to apply this ··· 1247 1244 qtd->error_count = 0; 1248 1245 qtd->complete_split = 0; 1249 1246 qtd->num_naks++; 1250 - qtd->qh->want_wait = qtd->num_naks >= DWC2_NAKS_BEFORE_DELAY; 1247 + qtd->qh->want_wait = qtd->num_naks >= DWC2_NAKS_BEFORE_DELAY && 1248 + !(chan->ep_type == USB_ENDPOINT_XFER_CONTROL && 1249 + chan->ep_is_in); 1251 1250 dwc2_halt_channel(hsotg, chan, qtd, DWC2_HC_XFER_NAK); 1252 1251 goto handle_nak_done; 1253 1252 }
-3
drivers/usb/dwc3/ep0.c
··· 973 973 ret = dwc3_ep0_start_trans(dep); 974 974 } else if (IS_ALIGNED(req->request.length, dep->endpoint.maxpacket) && 975 975 req->request.length && req->request.zero) { 976 - u32 maxpacket; 977 976 978 977 ret = usb_gadget_map_request_by_dev(dwc->sysdev, 979 978 &req->request, dep->number); 980 979 if (ret) 981 980 return; 982 - 983 - maxpacket = dep->endpoint.maxpacket; 984 981 985 982 /* prepare normal TRB */ 986 983 dwc3_ep0_prepare_one_trb(dep, req->request.dma,
-1
drivers/usb/gadget/composite.c
··· 1819 1819 if (cdev->use_os_string && cdev->os_desc_config && 1820 1820 (ctrl->bRequestType & USB_TYPE_VENDOR) && 1821 1821 ctrl->bRequest == cdev->b_vendor_code) { 1822 - struct usb_request *req; 1823 1822 struct usb_configuration *os_desc_cfg; 1824 1823 u8 *buf; 1825 1824 int interface;
+1 -1
drivers/usb/gadget/function/f_fs.c
··· 3263 3263 __ffs_event_add(ffs, FUNCTIONFS_SETUP); 3264 3264 spin_unlock_irqrestore(&ffs->ev.waitq.lock, flags); 3265 3265 3266 - return USB_GADGET_DELAYED_STATUS; 3266 + return creq->wLength == 0 ? USB_GADGET_DELAYED_STATUS : 0; 3267 3267 } 3268 3268 3269 3269 static bool ffs_func_req_match(struct usb_function *f,
+12 -12
drivers/usb/gadget/function/f_uac2.c
··· 438 438 }; 439 439 440 440 struct cntrl_cur_lay3 { 441 - __u32 dCUR; 441 + __le32 dCUR; 442 442 }; 443 443 444 444 struct cntrl_range_lay3 { 445 - __u16 wNumSubRanges; 446 - __u32 dMIN; 447 - __u32 dMAX; 448 - __u32 dRES; 445 + __le16 wNumSubRanges; 446 + __le32 dMIN; 447 + __le32 dMAX; 448 + __le32 dRES; 449 449 } __packed; 450 450 451 451 static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts, ··· 559 559 agdev->out_ep = usb_ep_autoconfig(gadget, &fs_epout_desc); 560 560 if (!agdev->out_ep) { 561 561 dev_err(dev, "%s:%d Error!\n", __func__, __LINE__); 562 - return ret; 562 + return -ENODEV; 563 563 } 564 564 565 565 agdev->in_ep = usb_ep_autoconfig(gadget, &fs_epin_desc); 566 566 if (!agdev->in_ep) { 567 567 dev_err(dev, "%s:%d Error!\n", __func__, __LINE__); 568 - return ret; 568 + return -ENODEV; 569 569 } 570 570 571 571 agdev->in_ep_maxpsize = max_t(u16, ··· 703 703 memset(&c, 0, sizeof(struct cntrl_cur_lay3)); 704 704 705 705 if (entity_id == USB_IN_CLK_ID) 706 - c.dCUR = p_srate; 706 + c.dCUR = cpu_to_le32(p_srate); 707 707 else if (entity_id == USB_OUT_CLK_ID) 708 - c.dCUR = c_srate; 708 + c.dCUR = cpu_to_le32(c_srate); 709 709 710 710 value = min_t(unsigned, w_length, sizeof c); 711 711 memcpy(req->buf, &c, value); ··· 742 742 743 743 if (control_selector == UAC2_CS_CONTROL_SAM_FREQ) { 744 744 if (entity_id == USB_IN_CLK_ID) 745 - r.dMIN = p_srate; 745 + r.dMIN = cpu_to_le32(p_srate); 746 746 else if (entity_id == USB_OUT_CLK_ID) 747 - r.dMIN = c_srate; 747 + r.dMIN = cpu_to_le32(c_srate); 748 748 else 749 749 return -EOPNOTSUPP; 750 750 751 751 r.dMAX = r.dMIN; 752 752 r.dRES = 0; 753 - r.wNumSubRanges = 1; 753 + r.wNumSubRanges = cpu_to_le16(1); 754 754 755 755 value = min_t(unsigned, w_length, sizeof r); 756 756 memcpy(req->buf, &r, value);
+33 -55
drivers/usb/gadget/function/u_audio.c
··· 32 32 struct uac_rtd_params { 33 33 struct snd_uac_chip *uac; /* parent chip */ 34 34 bool ep_enabled; /* if the ep is enabled */ 35 - /* Size of the ring buffer */ 36 - size_t dma_bytes; 37 - unsigned char *dma_area; 38 35 39 36 struct snd_pcm_substream *ss; 40 37 ··· 39 42 ssize_t hw_ptr; 40 43 41 44 void *rbuf; 42 - 43 - size_t period_size; 44 45 45 46 unsigned max_psize; /* MaxPacketSize of endpoint */ 46 47 struct uac_req *ureq; ··· 79 84 static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req) 80 85 { 81 86 unsigned pending; 82 - unsigned long flags; 87 + unsigned long flags, flags2; 83 88 unsigned int hw_ptr; 84 - bool update_alsa = false; 85 89 int status = req->status; 86 90 struct uac_req *ur = req->context; 87 91 struct snd_pcm_substream *substream; 92 + struct snd_pcm_runtime *runtime; 88 93 struct uac_rtd_params *prm = ur->pp; 89 94 struct snd_uac_chip *uac = prm->uac; 90 95 ··· 105 110 /* Do nothing if ALSA isn't active */ 106 111 if (!substream) 107 112 goto exit; 113 + 114 + snd_pcm_stream_lock_irqsave(substream, flags2); 115 + 116 + runtime = substream->runtime; 117 + if (!runtime || !snd_pcm_running(substream)) { 118 + snd_pcm_stream_unlock_irqrestore(substream, flags2); 119 + goto exit; 120 + } 108 121 109 122 spin_lock_irqsave(&prm->lock, flags); 110 123 ··· 140 137 req->actual = req->length; 141 138 } 142 139 143 - pending = prm->hw_ptr % prm->period_size; 144 - pending += req->actual; 145 - if (pending >= prm->period_size) 146 - update_alsa = true; 147 - 148 140 hw_ptr = prm->hw_ptr; 149 - prm->hw_ptr = (prm->hw_ptr + req->actual) % prm->dma_bytes; 150 141 151 142 spin_unlock_irqrestore(&prm->lock, flags); 152 143 153 144 /* Pack USB load in ALSA ring buffer */ 154 - pending = prm->dma_bytes - hw_ptr; 145 + pending = runtime->dma_bytes - hw_ptr; 155 146 156 147 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 157 148 if (unlikely(pending < req->actual)) { 158 - memcpy(req->buf, prm->dma_area + hw_ptr, pending); 159 - memcpy(req->buf + pending, prm->dma_area, 149 + memcpy(req->buf, runtime->dma_area + hw_ptr, pending); 150 + memcpy(req->buf + pending, runtime->dma_area, 160 151 req->actual - pending); 161 152 } else { 162 - memcpy(req->buf, prm->dma_area + hw_ptr, req->actual); 153 + memcpy(req->buf, runtime->dma_area + hw_ptr, 154 + req->actual); 163 155 } 164 156 } else { 165 157 if (unlikely(pending < req->actual)) { 166 - memcpy(prm->dma_area + hw_ptr, req->buf, pending); 167 - memcpy(prm->dma_area, req->buf + pending, 158 + memcpy(runtime->dma_area + hw_ptr, req->buf, pending); 159 + memcpy(runtime->dma_area, req->buf + pending, 168 160 req->actual - pending); 169 161 } else { 170 - memcpy(prm->dma_area + hw_ptr, req->buf, req->actual); 162 + memcpy(runtime->dma_area + hw_ptr, req->buf, 163 + req->actual); 171 164 } 172 165 } 166 + 167 + spin_lock_irqsave(&prm->lock, flags); 168 + /* update hw_ptr after data is copied to memory */ 169 + prm->hw_ptr = (hw_ptr + req->actual) % runtime->dma_bytes; 170 + hw_ptr = prm->hw_ptr; 171 + spin_unlock_irqrestore(&prm->lock, flags); 172 + snd_pcm_stream_unlock_irqrestore(substream, flags2); 173 + 174 + if ((hw_ptr % snd_pcm_lib_period_bytes(substream)) < req->actual) 175 + snd_pcm_period_elapsed(substream); 173 176 174 177 exit: 175 178 if (usb_ep_queue(ep, req, GFP_ATOMIC)) 176 179 dev_err(uac->card->dev, "%d Error!\n", __LINE__); 177 - 178 - if (update_alsa) 179 - snd_pcm_period_elapsed(substream); 180 180 } 181 181 182 182 static int uac_pcm_trigger(struct snd_pcm_substream *substream, int cmd) ··· 242 236 static int uac_pcm_hw_params(struct snd_pcm_substream *substream, 243 237 struct snd_pcm_hw_params *hw_params) 244 238 { 245 - struct snd_uac_chip *uac = snd_pcm_substream_chip(substream); 246 - struct uac_rtd_params *prm; 247 - int err; 248 - 249 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 250 - prm = &uac->p_prm; 251 - else 252 - prm = &uac->c_prm; 253 - 254 - err = snd_pcm_lib_malloc_pages(substream, 239 + return snd_pcm_lib_malloc_pages(substream, 255 240 params_buffer_bytes(hw_params)); 256 - if (err >= 0) { 257 - prm->dma_bytes = substream->runtime->dma_bytes; 258 - prm->dma_area = substream->runtime->dma_area; 259 - prm->period_size = params_period_bytes(hw_params); 260 - } 261 - 262 - return err; 263 241 } 264 242 265 243 static int uac_pcm_hw_free(struct snd_pcm_substream *substream) 266 244 { 267 - struct snd_uac_chip *uac = snd_pcm_substream_chip(substream); 268 - struct uac_rtd_params *prm; 269 - 270 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 271 - prm = &uac->p_prm; 272 - else 273 - prm = &uac->c_prm; 274 - 275 - prm->dma_area = NULL; 276 - prm->dma_bytes = 0; 277 - prm->period_size = 0; 278 - 279 245 return snd_pcm_lib_free_pages(substream); 280 246 } 281 247 ··· 573 595 if (err < 0) 574 596 goto snd_fail; 575 597 576 - strcpy(pcm->name, pcm_name); 598 + strlcpy(pcm->name, pcm_name, sizeof(pcm->name)); 577 599 pcm->private_data = uac; 578 600 uac->pcm = pcm; 579 601 580 602 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &uac_pcm_ops); 581 603 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &uac_pcm_ops); 582 604 583 - strcpy(card->driver, card_name); 584 - strcpy(card->shortname, card_name); 605 + strlcpy(card->driver, card_name, sizeof(card->driver)); 606 + strlcpy(card->shortname, card_name, sizeof(card->shortname)); 585 607 sprintf(card->longname, "%s %i", card_name, card->dev->id); 586 608 587 609 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
+10 -1
drivers/usb/gadget/udc/aspeed-vhub/ep0.c
··· 108 108 /* Check our state, cancel pending requests if needed */ 109 109 if (ep->ep0.state != ep0_state_token) { 110 110 EPDBG(ep, "wrong state\n"); 111 + ast_vhub_nuke(ep, -EIO); 112 + 113 + /* 114 + * Accept the packet regardless, this seems to happen 115 + * when stalling a SETUP packet that has an OUT data 116 + * phase. 117 + */ 111 118 ast_vhub_nuke(ep, 0); 112 119 goto stall; 113 120 } ··· 219 212 if (chunk && req->req.buf) 220 213 memcpy(ep->buf, req->req.buf + req->req.actual, chunk); 221 214 215 + vhub_dma_workaround(ep->buf); 216 + 222 217 /* Remember chunk size and trigger send */ 223 218 reg = VHUB_EP0_SET_TX_LEN(chunk); 224 219 writel(reg, ep->ep0.ctlstat); ··· 233 224 EPVDBG(ep, "rx prime\n"); 234 225 235 226 /* Prime endpoint for receiving data */ 236 - writel(VHUB_EP0_RX_BUFF_RDY, ep->ep0.ctlstat + AST_VHUB_EP0_CTRL); 227 + writel(VHUB_EP0_RX_BUFF_RDY, ep->ep0.ctlstat); 237 228 } 238 229 239 230 static void ast_vhub_ep0_do_receive(struct ast_vhub_ep *ep, struct ast_vhub_req *req,
+11 -3
drivers/usb/gadget/udc/aspeed-vhub/epn.c
··· 66 66 if (!req->req.dma) { 67 67 68 68 /* For IN transfers, copy data over first */ 69 - if (ep->epn.is_in) 69 + if (ep->epn.is_in) { 70 70 memcpy(ep->buf, req->req.buf + act, chunk); 71 + vhub_dma_workaround(ep->buf); 72 + } 71 73 writel(ep->buf_dma, ep->epn.regs + AST_VHUB_EP_DESC_BASE); 72 - } else 74 + } else { 75 + if (ep->epn.is_in) 76 + vhub_dma_workaround(req->req.buf); 73 77 writel(req->req.dma + act, ep->epn.regs + AST_VHUB_EP_DESC_BASE); 78 + } 74 79 75 80 /* Start DMA */ 76 81 req->active = true; ··· 166 161 static void ast_vhub_epn_kick_desc(struct ast_vhub_ep *ep, 167 162 struct ast_vhub_req *req) 168 163 { 164 + struct ast_vhub_desc *desc = NULL; 169 165 unsigned int act = req->act_count; 170 166 unsigned int len = req->req.length; 171 167 unsigned int chunk; ··· 183 177 184 178 /* While we can create descriptors */ 185 179 while (ast_vhub_count_free_descs(ep) && req->last_desc < 0) { 186 - struct ast_vhub_desc *desc; 187 180 unsigned int d_num; 188 181 189 182 /* Grab next free descriptor */ ··· 231 226 /* Account packet */ 232 227 req->act_count = act = act + chunk; 233 228 } 229 + 230 + if (likely(desc)) 231 + vhub_dma_workaround(desc); 234 232 235 233 /* Tell HW about new descriptors */ 236 234 writel(VHUB_EP_DMA_SET_CPU_WPTR(ep->epn.d_next),
+33
drivers/usb/gadget/udc/aspeed-vhub/vhub.h
··· 462 462 #define DDBG(d, fmt, ...) do { } while(0) 463 463 #endif 464 464 465 + static inline void vhub_dma_workaround(void *addr) 466 + { 467 + /* 468 + * This works around a confirmed HW issue with the Aspeed chip. 469 + * 470 + * The core uses a different bus to memory than the AHB going to 471 + * the USB device controller. Due to the latter having a higher 472 + * priority than the core for arbitration on that bus, it's 473 + * possible for an MMIO to the device, followed by a DMA by the 474 + * device from memory to all be performed and services before 475 + * a previous store to memory gets completed. 476 + * 477 + * This the following scenario can happen: 478 + * 479 + * - Driver writes to a DMA descriptor (Mbus) 480 + * - Driver writes to the MMIO register to start the DMA (AHB) 481 + * - The gadget sees the second write and sends a read of the 482 + * descriptor to the memory controller (Mbus) 483 + * - The gadget hits memory before the descriptor write 484 + * causing it to read an obsolete value. 485 + * 486 + * Thankfully the problem is limited to the USB gadget device, other 487 + * masters in the SoC all have a lower priority than the core, thus 488 + * ensuring that the store by the core arrives first. 489 + * 490 + * The workaround consists of using a dummy read of the memory before 491 + * doing the MMIO writes. This will ensure that the previous writes 492 + * have been "pushed out". 493 + */ 494 + mb(); 495 + (void)__raw_readl((void __iomem *)addr); 496 + } 497 + 465 498 /* core.c */ 466 499 void ast_vhub_done(struct ast_vhub_ep *ep, struct ast_vhub_req *req, 467 500 int status);
+3 -3
drivers/usb/gadget/udc/r8a66597-udc.c
··· 832 832 833 833 r8a66597_bset(r8a66597, XCKE, SYSCFG0); 834 834 835 - msleep(3); 835 + mdelay(3); 836 836 837 837 r8a66597_bset(r8a66597, PLLC, SYSCFG0); 838 838 839 - msleep(1); 839 + mdelay(1); 840 840 841 841 r8a66597_bset(r8a66597, SCKE, SYSCFG0); 842 842 ··· 1190 1190 r8a66597->ep0_req->length = 2; 1191 1191 /* AV: what happens if we get called again before that gets through? */ 1192 1192 spin_unlock(&r8a66597->lock); 1193 - r8a66597_queue(r8a66597->gadget.ep0, r8a66597->ep0_req, GFP_KERNEL); 1193 + r8a66597_queue(r8a66597->gadget.ep0, r8a66597->ep0_req, GFP_ATOMIC); 1194 1194 spin_lock(&r8a66597->lock); 1195 1195 } 1196 1196
+1
drivers/usb/host/xhci.c
··· 3051 3051 if (!list_empty(&ep->ring->td_list)) { 3052 3052 dev_err(&udev->dev, "EP not empty, refuse reset\n"); 3053 3053 spin_unlock_irqrestore(&xhci->lock, flags); 3054 + xhci_free_command(xhci, cfg_cmd); 3054 3055 goto cleanup; 3055 3056 } 3056 3057 xhci_queue_stop_endpoint(xhci, stop_cmd, udev->slot_id, ep_index, 0);
+3 -1
drivers/usb/phy/phy-fsl-usb.c
··· 861 861 if (pdata->init && pdata->init(pdev) != 0) 862 862 return -EINVAL; 863 863 864 + #ifdef CONFIG_PPC32 864 865 if (pdata->big_endian_mmio) { 865 866 _fsl_readl = _fsl_readl_be; 866 867 _fsl_writel = _fsl_writel_be; ··· 869 868 _fsl_readl = _fsl_readl_le; 870 869 _fsl_writel = _fsl_writel_le; 871 870 } 871 + #endif 872 872 873 873 /* request irq */ 874 874 p_otg->irq = platform_get_irq(pdev, 0); ··· 960 958 /* 961 959 * state file in sysfs 962 960 */ 963 - static int show_fsl_usb2_otg_state(struct device *dev, 961 + static ssize_t show_fsl_usb2_otg_state(struct device *dev, 964 962 struct device_attribute *attr, char *buf) 965 963 { 966 964 struct otg_fsm *fsm = &fsl_otg_dev->fsm;
+1 -1
drivers/usb/typec/tcpm.c
··· 2140 2140 * PPS APDO. Again skip the first sink PDO as this will 2141 2141 * always be 5V 3A. 2142 2142 */ 2143 - for (j = i; j < port->nr_snk_pdo; j++) { 2143 + for (j = 1; j < port->nr_snk_pdo; j++) { 2144 2144 pdo = port->snk_pdo[j]; 2145 2145 2146 2146 switch (pdo_type(pdo)) {
+16 -3
tools/usb/ffs-test.c
··· 44 44 45 45 /******************** Little Endian Handling ********************************/ 46 46 47 - #define cpu_to_le16(x) htole16(x) 48 - #define cpu_to_le32(x) htole32(x) 47 + /* 48 + * cpu_to_le16/32 are used when initializing structures, a context where a 49 + * function call is not allowed. To solve this, we code cpu_to_le16/32 in a way 50 + * that allows them to be used when initializing structures. 51 + */ 52 + 53 + #if __BYTE_ORDER == __LITTLE_ENDIAN 54 + #define cpu_to_le16(x) (x) 55 + #define cpu_to_le32(x) (x) 56 + #else 57 + #define cpu_to_le16(x) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)) 58 + #define cpu_to_le32(x) \ 59 + ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \ 60 + (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24)) 61 + #endif 62 + 49 63 #define le32_to_cpu(x) le32toh(x) 50 64 #define le16_to_cpu(x) le16toh(x) 51 - 52 65 53 66 /******************** Messages and Errors ***********************************/ 54 67