Skip to content

Commit fb7d082

Browse files
committed
Merge tag 'usb-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are a number of small USB driver fixes for reported problems. They include: - dwc2 driver fixes - xhci driver fixes - cdnsp driver fixes - typec driver fix - gadget u_ether driver fix - new quirk additions - usb gadget endpoint calculation fix - usb serial new device ids - revert of a xhci-dbg change that broke early debug booting All changes, except for the revert, have been in linux-next with no reported problems. The revert was from yesterday, and it was reported by the developers affected that it resolved their problem" * tag 'usb-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: Revert "usb: early: convert to readl_poll_timeout_atomic()" usb: typec: tcpm: fix tcpm unregister port but leave a pending timer usb: cdnsp: Fix lack of spin_lock_irqsave/spin_lock_restore USB: NO_LPM quirk Lenovo USB-C to Ethernet Adapher(RTL8153-04) usb: xhci: Extend support for runtime power management for AMD's Yellow carp. usb: dwc2: fix STM ID/VBUS detection startup delay in dwc2_driver_probe USB: gadget: bRequestType is a bitfield, not a enum USB: serial: option: add Telit FN990 compositions USB: serial: cp210x: fix CP2105 GPIO registration usb: cdnsp: Fix incorrect status for control request usb: cdnsp: Fix issue in cdnsp_log_ep trace event usb: cdnsp: Fix incorrect calling of cdnsp_died function usb: xhci-mtk: fix list_del warning when enable list debug usb: gadget: u_ether: fix race in setting MAC address in setup phase
2 parents 0f03adc + c4d936e commit fb7d082

File tree

15 files changed

+87
-35
lines changed

15 files changed

+87
-35
lines changed

drivers/usb/cdns3/cdnsp-gadget.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,15 +1541,27 @@ static int cdnsp_gadget_pullup(struct usb_gadget *gadget, int is_on)
15411541
{
15421542
struct cdnsp_device *pdev = gadget_to_cdnsp(gadget);
15431543
struct cdns *cdns = dev_get_drvdata(pdev->dev);
1544+
unsigned long flags;
15441545

15451546
trace_cdnsp_pullup(is_on);
15461547

1548+
/*
1549+
* Disable events handling while controller is being
1550+
* enabled/disabled.
1551+
*/
1552+
disable_irq(cdns->dev_irq);
1553+
spin_lock_irqsave(&pdev->lock, flags);
1554+
15471555
if (!is_on) {
15481556
cdnsp_reset_device(pdev);
15491557
cdns_clear_vbus(cdns);
15501558
} else {
15511559
cdns_set_vbus(cdns);
15521560
}
1561+
1562+
spin_unlock_irqrestore(&pdev->lock, flags);
1563+
enable_irq(cdns->dev_irq);
1564+
15531565
return 0;
15541566
}
15551567

drivers/usb/cdns3/cdnsp-ring.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,8 @@ static void cdnsp_process_ctrl_td(struct cdnsp_device *pdev,
10291029
return;
10301030
}
10311031

1032+
*status = 0;
1033+
10321034
cdnsp_finish_td(pdev, td, event, pep, status);
10331035
}
10341036

@@ -1523,7 +1525,14 @@ irqreturn_t cdnsp_thread_irq_handler(int irq, void *data)
15231525
spin_lock_irqsave(&pdev->lock, flags);
15241526

15251527
if (pdev->cdnsp_state & (CDNSP_STATE_HALTED | CDNSP_STATE_DYING)) {
1526-
cdnsp_died(pdev);
1528+
/*
1529+
* While removing or stopping driver there may still be deferred
1530+
* not handled interrupt which should not be treated as error.
1531+
* Driver should simply ignore it.
1532+
*/
1533+
if (pdev->gadget_driver)
1534+
cdnsp_died(pdev);
1535+
15271536
spin_unlock_irqrestore(&pdev->lock, flags);
15281537
return IRQ_HANDLED;
15291538
}

drivers/usb/cdns3/cdnsp-trace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ DECLARE_EVENT_CLASS(cdnsp_log_ep,
5757
__entry->first_prime_det = pep->stream_info.first_prime_det;
5858
__entry->drbls_count = pep->stream_info.drbls_count;
5959
),
60-
TP_printk("%s: SID: %08x ep state: %x stream: enabled: %d num %d "
60+
TP_printk("%s: SID: %08x, ep state: %x, stream: enabled: %d num %d "
6161
"tds %d, first prime: %d drbls %d",
62-
__get_str(name), __entry->state, __entry->stream_id,
62+
__get_str(name), __entry->stream_id, __entry->state,
6363
__entry->enabled, __entry->num_streams, __entry->td_count,
6464
__entry->first_prime_det, __entry->drbls_count)
6565
);

drivers/usb/core/quirks.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,9 @@ static const struct usb_device_id usb_quirk_list[] = {
434434
{ USB_DEVICE(0x1532, 0x0116), .driver_info =
435435
USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
436436

437+
/* Lenovo USB-C to Ethernet Adapter RTL8153-04 */
438+
{ USB_DEVICE(0x17ef, 0x720c), .driver_info = USB_QUIRK_NO_LPM },
439+
437440
/* Lenovo Powered USB-C Travel Hub (4X90S92381, RTL8153 GigE) */
438441
{ USB_DEVICE(0x17ef, 0x721e), .driver_info = USB_QUIRK_NO_LPM },
439442

drivers/usb/dwc2/platform.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,9 @@ static int dwc2_driver_probe(struct platform_device *dev)
575575
ggpio |= GGPIO_STM32_OTG_GCCFG_IDEN;
576576
ggpio |= GGPIO_STM32_OTG_GCCFG_VBDEN;
577577
dwc2_writel(hsotg, ggpio, GGPIO);
578+
579+
/* ID/VBUS detection startup time */
580+
usleep_range(5000, 7000);
578581
}
579582

580583
retval = dwc2_drd_init(hsotg);

drivers/usb/early/xhci-dbc.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <linux/pci_ids.h>
1515
#include <linux/memblock.h>
1616
#include <linux/io.h>
17-
#include <linux/iopoll.h>
1817
#include <asm/pci-direct.h>
1918
#include <asm/fixmap.h>
2019
#include <linux/bcd.h>
@@ -136,9 +135,17 @@ static int handshake(void __iomem *ptr, u32 mask, u32 done, int wait, int delay)
136135
{
137136
u32 result;
138137

139-
return readl_poll_timeout_atomic(ptr, result,
140-
((result & mask) == done),
141-
delay, wait);
138+
/* Can not use readl_poll_timeout_atomic() for early boot things */
139+
do {
140+
result = readl(ptr);
141+
result &= mask;
142+
if (result == done)
143+
return 0;
144+
udelay(delay);
145+
wait -= delay;
146+
} while (wait > 0);
147+
148+
return -ETIMEDOUT;
142149
}
143150

144151
static void __init xdbc_bios_handoff(void)

drivers/usb/gadget/composite.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,14 +1680,14 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
16801680
u8 endp;
16811681

16821682
if (w_length > USB_COMP_EP0_BUFSIZ) {
1683-
if (ctrl->bRequestType == USB_DIR_OUT) {
1684-
goto done;
1685-
} else {
1683+
if (ctrl->bRequestType & USB_DIR_IN) {
16861684
/* Cast away the const, we are going to overwrite on purpose. */
16871685
__le16 *temp = (__le16 *)&ctrl->wLength;
16881686

16891687
*temp = cpu_to_le16(USB_COMP_EP0_BUFSIZ);
16901688
w_length = USB_COMP_EP0_BUFSIZ;
1689+
} else {
1690+
goto done;
16911691
}
16921692
}
16931693

drivers/usb/gadget/function/u_ether.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/etherdevice.h>
1818
#include <linux/ethtool.h>
1919
#include <linux/if_vlan.h>
20+
#include <linux/etherdevice.h>
2021

2122
#include "u_ether.h"
2223

@@ -863,35 +864,30 @@ int gether_register_netdev(struct net_device *net)
863864
{
864865
struct eth_dev *dev;
865866
struct usb_gadget *g;
866-
struct sockaddr sa;
867867
int status;
868868

869869
if (!net->dev.parent)
870870
return -EINVAL;
871871
dev = netdev_priv(net);
872872
g = dev->gadget;
873+
874+
net->addr_assign_type = NET_ADDR_RANDOM;
875+
eth_hw_addr_set(net, dev->dev_mac);
876+
873877
status = register_netdev(net);
874878
if (status < 0) {
875879
dev_dbg(&g->dev, "register_netdev failed, %d\n", status);
876880
return status;
877881
} else {
878882
INFO(dev, "HOST MAC %pM\n", dev->host_mac);
883+
INFO(dev, "MAC %pM\n", dev->dev_mac);
879884

880885
/* two kinds of host-initiated state changes:
881886
* - iff DATA transfer is active, carrier is "on"
882887
* - tx queueing enabled if open *and* carrier is "on"
883888
*/
884889
netif_carrier_off(net);
885890
}
886-
sa.sa_family = net->type;
887-
memcpy(sa.sa_data, dev->dev_mac, ETH_ALEN);
888-
rtnl_lock();
889-
status = dev_set_mac_address(net, &sa, NULL);
890-
rtnl_unlock();
891-
if (status)
892-
pr_warn("cannot set self ethernet address: %d\n", status);
893-
else
894-
INFO(dev, "MAC %pM\n", dev->dev_mac);
895891

896892
return status;
897893
}

drivers/usb/gadget/legacy/dbgp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,14 +346,14 @@ static int dbgp_setup(struct usb_gadget *gadget,
346346
u16 len = 0;
347347

348348
if (length > DBGP_REQ_LEN) {
349-
if (ctrl->bRequestType == USB_DIR_OUT) {
350-
return err;
351-
} else {
349+
if (ctrl->bRequestType & USB_DIR_IN) {
352350
/* Cast away the const, we are going to overwrite on purpose. */
353351
__le16 *temp = (__le16 *)&ctrl->wLength;
354352

355353
*temp = cpu_to_le16(DBGP_REQ_LEN);
356354
length = DBGP_REQ_LEN;
355+
} else {
356+
return err;
357357
}
358358
}
359359

drivers/usb/gadget/legacy/inode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,14 +1334,14 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
13341334
u16 w_length = le16_to_cpu(ctrl->wLength);
13351335

13361336
if (w_length > RBUF_SIZE) {
1337-
if (ctrl->bRequestType == USB_DIR_OUT) {
1338-
return value;
1339-
} else {
1337+
if (ctrl->bRequestType & USB_DIR_IN) {
13401338
/* Cast away the const, we are going to overwrite on purpose. */
13411339
__le16 *temp = (__le16 *)&ctrl->wLength;
13421340

13431341
*temp = cpu_to_le16(RBUF_SIZE);
13441342
w_length = RBUF_SIZE;
1343+
} else {
1344+
return value;
13451345
}
13461346
}
13471347

0 commit comments

Comments
 (0)