Skip to content

Commit 60e70ec

Browse files
committed
Merge tag 'fixes-for-v4.14-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-linus
Felipe writes: usb: fixes for v4.14-rc2 First set of fixes for the gadget side. Not much this time around, things have been rather calm. In no order whatsoever, this pull request contains: - A DMA starvation fix on dwc3 caused by some recent changes to how we map/unmap requests - A build error fix on the snps_udc_plat.c driver - A fix for how to we call ->udc_set_speed() - Spinlock recursion fix on the printer gadget - Removal of pointless comparisons on dummy driver
2 parents bd7a3fe + 7661ca0 commit 60e70ec

File tree

5 files changed

+19
-8
lines changed

5 files changed

+19
-8
lines changed

drivers/usb/dwc3/ep0.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,8 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
990990
DWC3_TRBCTL_CONTROL_DATA,
991991
true);
992992

993+
req->trb = &dwc->ep0_trb[dep->trb_enqueue - 1];
994+
993995
/* Now prepare one extra TRB to align transfer size */
994996
dwc3_ep0_prepare_one_trb(dep, dwc->bounce_addr,
995997
maxpacket - rem,
@@ -1015,6 +1017,8 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
10151017
DWC3_TRBCTL_CONTROL_DATA,
10161018
true);
10171019

1020+
req->trb = &dwc->ep0_trb[dep->trb_enqueue - 1];
1021+
10181022
/* Now prepare one extra TRB to align transfer size */
10191023
dwc3_ep0_prepare_one_trb(dep, dwc->bounce_addr,
10201024
0, DWC3_TRBCTL_CONTROL_DATA,
@@ -1029,6 +1033,9 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
10291033
dwc3_ep0_prepare_one_trb(dep, req->request.dma,
10301034
req->request.length, DWC3_TRBCTL_CONTROL_DATA,
10311035
false);
1036+
1037+
req->trb = &dwc->ep0_trb[dep->trb_enqueue];
1038+
10321039
ret = dwc3_ep0_start_trans(dep);
10331040
}
10341041

drivers/usb/gadget/function/f_printer.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
555555
size_t size; /* Amount of data in a TX request. */
556556
size_t bytes_copied = 0;
557557
struct usb_request *req;
558+
int value;
558559

559560
DBG(dev, "printer_write trying to send %d bytes\n", (int)len);
560561

@@ -634,7 +635,11 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
634635
return -EAGAIN;
635636
}
636637

637-
if (usb_ep_queue(dev->in_ep, req, GFP_ATOMIC)) {
638+
/* here, we unlock, and only unlock, to avoid deadlock. */
639+
spin_unlock(&dev->lock);
640+
value = usb_ep_queue(dev->in_ep, req, GFP_ATOMIC);
641+
spin_lock(&dev->lock);
642+
if (value) {
638643
list_add(&req->list, &dev->tx_reqs);
639644
spin_unlock_irqrestore(&dev->lock, flags);
640645
mutex_unlock(&dev->lock_printer_io);

drivers/usb/gadget/udc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ config USB_SNP_CORE
273273
config USB_SNP_UDC_PLAT
274274
tristate "Synopsys USB 2.0 Device controller"
275275
depends on USB_GADGET && OF && HAS_DMA
276+
depends on EXTCON || EXTCON=n
276277
select USB_GADGET_DUALSPEED
277278
select USB_SNP_CORE
278279
default ARCH_BCM_IPROC

drivers/usb/gadget/udc/core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,8 +1320,7 @@ static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *dri
13201320
udc->dev.driver = &driver->driver;
13211321
udc->gadget->dev.driver = &driver->driver;
13221322

1323-
if (driver->max_speed < udc->gadget->max_speed)
1324-
usb_gadget_udc_set_speed(udc, driver->max_speed);
1323+
usb_gadget_udc_set_speed(udc, driver->max_speed);
13251324

13261325
ret = driver->bind(udc->gadget, driver);
13271326
if (ret)

drivers/usb/gadget/udc/dummy_hcd.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,10 @@ static void set_link_state_by_speed(struct dummy_hcd *dum_hcd)
375375
USB_PORT_STAT_CONNECTION) == 0)
376376
dum_hcd->port_status |=
377377
(USB_PORT_STAT_C_CONNECTION << 16);
378-
if ((dum_hcd->port_status &
379-
USB_PORT_STAT_ENABLE) == 1 &&
380-
(dum_hcd->port_status &
381-
USB_SS_PORT_LS_U0) == 1 &&
382-
dum_hcd->rh_state != DUMMY_RH_SUSPENDED)
378+
if ((dum_hcd->port_status & USB_PORT_STAT_ENABLE) &&
379+
(dum_hcd->port_status &
380+
USB_PORT_STAT_LINK_STATE) == USB_SS_PORT_LS_U0 &&
381+
dum_hcd->rh_state != DUMMY_RH_SUSPENDED)
383382
dum_hcd->active = 1;
384383
}
385384
} else {

0 commit comments

Comments
 (0)