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

Merge tag 'fixes-for-v5.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-linus

Felipe writes:

USB: fixes for v5.6-rc1

DWC3 learned that we can't always depend on Event Status bits. A
problem was solved which would only surface with scatter list on IN
endpoints.

DWC2 got a fix for feature requests (both set and clear) and GetStatus
request.

The serial gadget got a fix for a TX stall bug.

Composite framework now works better for SSP devices.

* tag 'fixes-for-v5.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb:
usb: dwc3: debug: fix string position formatting mixup with ret and len
usb: gadget: serial: fix Tx stall after buffer overflow
usb: gadget: ffs: ffs_aio_cancel(): Save/restore IRQ flags
usb: dwc2: Fix SET/CLEAR_FEATURE and GET_STATUS flows
usb: dwc2: Fix in ISOC request length checking
usb: gadget: composite: Support more than 500mA MaxPower
usb: gadget: composite: Fix bMaxPower for SuperSpeedPlus
usb: gadget: u_audio: Fix high-speed max packet size
usb: dwc3: gadget: Check for IOC/LST bit in TRB->ctrl fields

+56 -36
+23 -17
drivers/usb/dwc2/gadget.c
··· 1083 1083 else 1084 1084 packets = 1; /* send one packet if length is zero. */ 1085 1085 1086 - if (hs_ep->isochronous && length > (hs_ep->mc * hs_ep->ep.maxpacket)) { 1087 - dev_err(hsotg->dev, "req length > maxpacket*mc\n"); 1088 - return; 1089 - } 1090 - 1091 1086 if (dir_in && index != 0) 1092 1087 if (hs_ep->isochronous) 1093 1088 epsize = DXEPTSIZ_MC(packets); ··· 1386 1391 req->actual = 0; 1387 1392 req->status = -EINPROGRESS; 1388 1393 1394 + /* Don't queue ISOC request if length greater than mps*mc */ 1395 + if (hs_ep->isochronous && 1396 + req->length > (hs_ep->mc * hs_ep->ep.maxpacket)) { 1397 + dev_err(hs->dev, "req length > maxpacket*mc\n"); 1398 + return -EINVAL; 1399 + } 1400 + 1389 1401 /* In DDMA mode for ISOC's don't queue request if length greater 1390 1402 * than descriptor limits. 1391 1403 */ ··· 1634 1632 struct dwc2_hsotg_ep *ep0 = hsotg->eps_out[0]; 1635 1633 struct dwc2_hsotg_ep *ep; 1636 1634 __le16 reply; 1635 + u16 status; 1637 1636 int ret; 1638 1637 1639 1638 dev_dbg(hsotg->dev, "%s: USB_REQ_GET_STATUS\n", __func__); ··· 1646 1643 1647 1644 switch (ctrl->bRequestType & USB_RECIP_MASK) { 1648 1645 case USB_RECIP_DEVICE: 1649 - /* 1650 - * bit 0 => self powered 1651 - * bit 1 => remote wakeup 1652 - */ 1653 - reply = cpu_to_le16(0); 1646 + status = 1 << USB_DEVICE_SELF_POWERED; 1647 + status |= hsotg->remote_wakeup_allowed << 1648 + USB_DEVICE_REMOTE_WAKEUP; 1649 + reply = cpu_to_le16(status); 1654 1650 break; 1655 1651 1656 1652 case USB_RECIP_INTERFACE: ··· 1760 1758 case USB_RECIP_DEVICE: 1761 1759 switch (wValue) { 1762 1760 case USB_DEVICE_REMOTE_WAKEUP: 1763 - hsotg->remote_wakeup_allowed = 1; 1761 + if (set) 1762 + hsotg->remote_wakeup_allowed = 1; 1763 + else 1764 + hsotg->remote_wakeup_allowed = 0; 1764 1765 break; 1765 1766 1766 1767 case USB_DEVICE_TEST_MODE: ··· 1773 1768 return -EINVAL; 1774 1769 1775 1770 hsotg->test_mode = wIndex >> 8; 1776 - ret = dwc2_hsotg_send_reply(hsotg, ep0, NULL, 0); 1777 - if (ret) { 1778 - dev_err(hsotg->dev, 1779 - "%s: failed to send reply\n", __func__); 1780 - return ret; 1781 - } 1782 1771 break; 1783 1772 default: 1784 1773 return -ENOENT; 1774 + } 1775 + 1776 + ret = dwc2_hsotg_send_reply(hsotg, ep0, NULL, 0); 1777 + if (ret) { 1778 + dev_err(hsotg->dev, 1779 + "%s: failed to send reply\n", __func__); 1780 + return ret; 1785 1781 } 1786 1782 break; 1787 1783
+2 -1
drivers/usb/dwc3/gadget.c
··· 2429 2429 if (event->status & DEPEVT_STATUS_SHORT && !chain) 2430 2430 return 1; 2431 2431 2432 - if (event->status & DEPEVT_STATUS_IOC) 2432 + if ((trb->ctrl & DWC3_TRB_CTRL_IOC) || 2433 + (trb->ctrl & DWC3_TRB_CTRL_LST)) 2433 2434 return 1; 2434 2435 2435 2436 return 0;
+20 -10
drivers/usb/gadget/composite.c
··· 437 437 val = CONFIG_USB_GADGET_VBUS_DRAW; 438 438 if (!val) 439 439 return 0; 440 - switch (speed) { 441 - case USB_SPEED_SUPER: 442 - return DIV_ROUND_UP(val, 8); 443 - default: 444 - return DIV_ROUND_UP(val, 2); 445 - } 440 + if (speed < USB_SPEED_SUPER) 441 + return min(val, 500U) / 2; 442 + else 443 + /* 444 + * USB 3.x supports up to 900mA, but since 900 isn't divisible 445 + * by 8 the integral division will effectively cap to 896mA. 446 + */ 447 + return min(val, 900U) / 8; 446 448 } 447 449 448 450 static int config_buf(struct usb_configuration *config, ··· 856 854 857 855 /* when we return, be sure our power usage is valid */ 858 856 power = c->MaxPower ? c->MaxPower : CONFIG_USB_GADGET_VBUS_DRAW; 857 + if (gadget->speed < USB_SPEED_SUPER) 858 + power = min(power, 500U); 859 + else 860 + power = min(power, 900U); 859 861 done: 860 862 usb_gadget_vbus_draw(gadget, power); 861 863 if (result >= 0 && cdev->delayed_status) ··· 2286 2280 { 2287 2281 struct usb_composite_dev *cdev = get_gadget_data(gadget); 2288 2282 struct usb_function *f; 2289 - u16 maxpower; 2283 + unsigned maxpower; 2290 2284 2291 2285 /* REVISIT: should we have config level 2292 2286 * suspend/resume callbacks? ··· 2300 2294 f->resume(f); 2301 2295 } 2302 2296 2303 - maxpower = cdev->config->MaxPower; 2297 + maxpower = cdev->config->MaxPower ? 2298 + cdev->config->MaxPower : CONFIG_USB_GADGET_VBUS_DRAW; 2299 + if (gadget->speed < USB_SPEED_SUPER) 2300 + maxpower = min(maxpower, 500U); 2301 + else 2302 + maxpower = min(maxpower, 900U); 2304 2303 2305 - usb_gadget_vbus_draw(gadget, maxpower ? 2306 - maxpower : CONFIG_USB_GADGET_VBUS_DRAW); 2304 + usb_gadget_vbus_draw(gadget, maxpower); 2307 2305 } 2308 2306 2309 2307 cdev->suspended = 0;
+3 -2
drivers/usb/gadget/function/f_fs.c
··· 1162 1162 { 1163 1163 struct ffs_io_data *io_data = kiocb->private; 1164 1164 struct ffs_epfile *epfile = kiocb->ki_filp->private_data; 1165 + unsigned long flags; 1165 1166 int value; 1166 1167 1167 1168 ENTER(); 1168 1169 1169 - spin_lock_irq(&epfile->ffs->eps_lock); 1170 + spin_lock_irqsave(&epfile->ffs->eps_lock, flags); 1170 1171 1171 1172 if (likely(io_data && io_data->ep && io_data->req)) 1172 1173 value = usb_ep_dequeue(io_data->ep, io_data->req); 1173 1174 else 1174 1175 value = -EINVAL; 1175 1176 1176 - spin_unlock_irq(&epfile->ffs->eps_lock); 1177 + spin_unlock_irqrestore(&epfile->ffs->eps_lock, flags); 1177 1178 1178 1179 return value; 1179 1180 }
+5 -5
drivers/usb/gadget/function/u_audio.c
··· 361 361 ep = audio_dev->out_ep; 362 362 prm = &uac->c_prm; 363 363 config_ep_by_speed(gadget, &audio_dev->func, ep); 364 - req_len = prm->max_psize; 364 + req_len = ep->maxpacket; 365 365 366 366 prm->ep_enabled = true; 367 367 usb_ep_enable(ep); ··· 379 379 req->context = &prm->ureq[i]; 380 380 req->length = req_len; 381 381 req->complete = u_audio_iso_complete; 382 - req->buf = prm->rbuf + i * prm->max_psize; 382 + req->buf = prm->rbuf + i * ep->maxpacket; 383 383 } 384 384 385 385 if (usb_ep_queue(ep, prm->ureq[i].req, GFP_ATOMIC)) ··· 430 430 uac->p_pktsize = min_t(unsigned int, 431 431 uac->p_framesize * 432 432 (params->p_srate / uac->p_interval), 433 - prm->max_psize); 433 + ep->maxpacket); 434 434 435 - if (uac->p_pktsize < prm->max_psize) 435 + if (uac->p_pktsize < ep->maxpacket) 436 436 uac->p_pktsize_residue = uac->p_framesize * 437 437 (params->p_srate % uac->p_interval); 438 438 else ··· 457 457 req->context = &prm->ureq[i]; 458 458 req->length = req_len; 459 459 req->complete = u_audio_iso_complete; 460 - req->buf = prm->rbuf + i * prm->max_psize; 460 + req->buf = prm->rbuf + i * ep->maxpacket; 461 461 } 462 462 463 463 if (usb_ep_queue(ep, prm->ureq[i].req, GFP_ATOMIC))
+3 -1
drivers/usb/gadget/function/u_serial.c
··· 561 561 port->n_read = 0; 562 562 started = gs_start_rx(port); 563 563 564 - /* unblock any pending writes into our circular buffer */ 565 564 if (started) { 565 + gs_start_tx(port); 566 + /* Unblock any pending writes into our circular buffer, in case 567 + * we didn't in gs_start_tx() */ 566 568 tty_wakeup(port->port.tty); 567 569 } else { 568 570 gs_free_requests(ep, head, &port->read_allocated);