Skip to content

Commit 3a69c9e

Browse files
committed
Merge tag 'usb-5.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "The USB sub-maintainers woke up this past week and sent a bunch of tiny fixes. Here are a lot of small patches that that resolve a bunch of reported issues in the USB core, drivers, serial drivers, gadget drivers, and of course, xhci :) All of these have been in linux-next with no reported issues" * tag 'usb-5.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (31 commits) usb: dwc3: gadget: fix race when disabling ep with cancelled xfers usb: cdns3: gadget: Fix g_audio use case when connected to Super-Speed host usb: cdns3: gadget: reset EP_CLAIMED flag while unloading USB: serial: whiteheat: fix line-speed endianness USB: serial: whiteheat: fix potential slab corruption USB: gadget: Reject endpoints with 0 maxpacket value UAS: Revert commit 3ae62a4 ("UAS: fix alignment of scatter/gather segments") usb-storage: Revert commit 747668d ("usb-storage: Set virt_boundary_mask to avoid SG overflows") usbip: Fix free of unallocated memory in vhci tx usbip: tools: Fix read_usb_vudc_device() error path handling usb: xhci: fix __le32/__le64 accessors in debugfs code usb: xhci: fix Immediate Data Transfer endianness xhci: Fix use-after-free regression in xhci clear hub TT implementation USB: ldusb: fix control-message timeout USB: ldusb: use unsigned size format specifiers USB: ldusb: fix ring-buffer locking USB: Skip endpoints with 0 maxpacket length usb: cdns3: gadget: Don't manage pullups usb: dwc3: remove the call trace of USBx_GFLADJ usb: gadget: configfs: fix concurrent issue between composite APIs ...
2 parents 56cfd25 + d8eca64 commit 3a69c9e

File tree

27 files changed

+267
-97
lines changed

27 files changed

+267
-97
lines changed

drivers/usb/cdns3/gadget.c

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,8 +2329,6 @@ static void cdns3_gadget_config(struct cdns3_device *priv_dev)
23292329
writel(USB_CONF_CLK2OFFDS | USB_CONF_L1DS, &regs->usb_conf);
23302330

23312331
cdns3_configure_dmult(priv_dev, NULL);
2332-
2333-
cdns3_gadget_pullup(&priv_dev->gadget, 1);
23342332
}
23352333

23362334
/**
@@ -2345,9 +2343,35 @@ static int cdns3_gadget_udc_start(struct usb_gadget *gadget,
23452343
{
23462344
struct cdns3_device *priv_dev = gadget_to_cdns3_device(gadget);
23472345
unsigned long flags;
2346+
enum usb_device_speed max_speed = driver->max_speed;
23482347

23492348
spin_lock_irqsave(&priv_dev->lock, flags);
23502349
priv_dev->gadget_driver = driver;
2350+
2351+
/* limit speed if necessary */
2352+
max_speed = min(driver->max_speed, gadget->max_speed);
2353+
2354+
switch (max_speed) {
2355+
case USB_SPEED_FULL:
2356+
writel(USB_CONF_SFORCE_FS, &priv_dev->regs->usb_conf);
2357+
writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf);
2358+
break;
2359+
case USB_SPEED_HIGH:
2360+
writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf);
2361+
break;
2362+
case USB_SPEED_SUPER:
2363+
break;
2364+
default:
2365+
dev_err(priv_dev->dev,
2366+
"invalid maximum_speed parameter %d\n",
2367+
max_speed);
2368+
/* fall through */
2369+
case USB_SPEED_UNKNOWN:
2370+
/* default to superspeed */
2371+
max_speed = USB_SPEED_SUPER;
2372+
break;
2373+
}
2374+
23512375
cdns3_gadget_config(priv_dev);
23522376
spin_unlock_irqrestore(&priv_dev->lock, flags);
23532377
return 0;
@@ -2381,6 +2405,8 @@ static int cdns3_gadget_udc_stop(struct usb_gadget *gadget)
23812405
writel(EP_CMD_EPRST, &priv_dev->regs->ep_cmd);
23822406
readl_poll_timeout_atomic(&priv_dev->regs->ep_cmd, val,
23832407
!(val & EP_CMD_EPRST), 1, 100);
2408+
2409+
priv_ep->flags &= ~EP_CLAIMED;
23842410
}
23852411

23862412
/* disable interrupt for device */
@@ -2575,12 +2601,7 @@ static int cdns3_gadget_start(struct cdns3 *cdns)
25752601
/* Check the maximum_speed parameter */
25762602
switch (max_speed) {
25772603
case USB_SPEED_FULL:
2578-
writel(USB_CONF_SFORCE_FS, &priv_dev->regs->usb_conf);
2579-
writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf);
2580-
break;
25812604
case USB_SPEED_HIGH:
2582-
writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf);
2583-
break;
25842605
case USB_SPEED_SUPER:
25852606
break;
25862607
default:
@@ -2713,8 +2734,6 @@ static int cdns3_gadget_suspend(struct cdns3 *cdns, bool do_wakeup)
27132734
/* disable interrupt for device */
27142735
writel(0, &priv_dev->regs->usb_ien);
27152736

2716-
cdns3_gadget_pullup(&priv_dev->gadget, 0);
2717-
27182737
return 0;
27192738
}
27202739

drivers/usb/cdns3/host-export.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#ifdef CONFIG_USB_CDNS3_HOST
1313

1414
int cdns3_host_init(struct cdns3 *cdns);
15-
void cdns3_host_exit(struct cdns3 *cdns);
1615

1716
#else
1817

drivers/usb/cdns3/host.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/platform_device.h>
1313
#include "core.h"
1414
#include "drd.h"
15+
#include "host-export.h"
1516

1617
static int __cdns3_host_init(struct cdns3 *cdns)
1718
{

drivers/usb/core/config.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,11 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
348348

349349
/* Validate the wMaxPacketSize field */
350350
maxp = usb_endpoint_maxp(&endpoint->desc);
351+
if (maxp == 0) {
352+
dev_warn(ddev, "config %d interface %d altsetting %d endpoint 0x%X has wMaxPacketSize 0, skipping\n",
353+
cfgno, inum, asnum, d->bEndpointAddress);
354+
goto skip_to_next_endpoint_or_interface_descriptor;
355+
}
351356

352357
/* Find the highest legal maxpacket size for this endpoint */
353358
i = 0; /* additional transactions per microframe */

drivers/usb/dwc3/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ config USB_DWC3_MESON_G12A
102102
depends on ARCH_MESON || COMPILE_TEST
103103
default USB_DWC3
104104
select USB_ROLE_SWITCH
105+
select REGMAP_MMIO
105106
help
106107
Support USB2/3 functionality in Amlogic G12A platforms.
107108
Say 'Y' or 'M' if you have one such device.

drivers/usb/dwc3/core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,7 @@ static void dwc3_frame_length_adjustment(struct dwc3 *dwc)
312312

313313
reg = dwc3_readl(dwc->regs, DWC3_GFLADJ);
314314
dft = reg & DWC3_GFLADJ_30MHZ_MASK;
315-
if (!dev_WARN_ONCE(dwc->dev, dft == dwc->fladj,
316-
"request value same as default, ignoring\n")) {
315+
if (dft != dwc->fladj) {
317316
reg &= ~DWC3_GFLADJ_30MHZ_MASK;
318317
reg |= DWC3_GFLADJ_30MHZ_SDBND_SEL | dwc->fladj;
319318
dwc3_writel(dwc->regs, DWC3_GFLADJ, reg);

drivers/usb/dwc3/dwc3-pci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ static int dwc3_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
258258

259259
ret = platform_device_add_properties(dwc->dwc3, p);
260260
if (ret < 0)
261-
return ret;
261+
goto err;
262262

263263
ret = dwc3_pci_quirks(dwc);
264264
if (ret)

drivers/usb/dwc3/gadget.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,12 @@ static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep)
707707

708708
dwc3_gadget_giveback(dep, req, -ESHUTDOWN);
709709
}
710+
711+
while (!list_empty(&dep->cancelled_list)) {
712+
req = next_request(&dep->cancelled_list);
713+
714+
dwc3_gadget_giveback(dep, req, -ESHUTDOWN);
715+
}
710716
}
711717

712718
/**

drivers/usb/gadget/composite.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,14 +2170,18 @@ void composite_dev_cleanup(struct usb_composite_dev *cdev)
21702170
usb_ep_dequeue(cdev->gadget->ep0, cdev->os_desc_req);
21712171

21722172
kfree(cdev->os_desc_req->buf);
2173+
cdev->os_desc_req->buf = NULL;
21732174
usb_ep_free_request(cdev->gadget->ep0, cdev->os_desc_req);
2175+
cdev->os_desc_req = NULL;
21742176
}
21752177
if (cdev->req) {
21762178
if (cdev->setup_pending)
21772179
usb_ep_dequeue(cdev->gadget->ep0, cdev->req);
21782180

21792181
kfree(cdev->req->buf);
2182+
cdev->req->buf = NULL;
21802183
usb_ep_free_request(cdev->gadget->ep0, cdev->req);
2184+
cdev->req = NULL;
21812185
}
21822186
cdev->next_string_id = 0;
21832187
device_remove_file(&cdev->gadget->dev, &dev_attr_suspended);

drivers/usb/gadget/configfs.c

Lines changed: 105 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ struct gadget_info {
6161
bool use_os_desc;
6262
char b_vendor_code;
6363
char qw_sign[OS_STRING_QW_SIGN_LEN];
64+
spinlock_t spinlock;
65+
bool unbind;
6466
};
6567

6668
static inline struct gadget_info *to_gadget_info(struct config_item *item)
@@ -1244,6 +1246,7 @@ static int configfs_composite_bind(struct usb_gadget *gadget,
12441246
int ret;
12451247

12461248
/* the gi->lock is hold by the caller */
1249+
gi->unbind = 0;
12471250
cdev->gadget = gadget;
12481251
set_gadget_data(gadget, cdev);
12491252
ret = composite_dev_prepare(composite, cdev);
@@ -1376,31 +1379,128 @@ static void configfs_composite_unbind(struct usb_gadget *gadget)
13761379
{
13771380
struct usb_composite_dev *cdev;
13781381
struct gadget_info *gi;
1382+
unsigned long flags;
13791383

13801384
/* the gi->lock is hold by the caller */
13811385

13821386
cdev = get_gadget_data(gadget);
13831387
gi = container_of(cdev, struct gadget_info, cdev);
1388+
spin_lock_irqsave(&gi->spinlock, flags);
1389+
gi->unbind = 1;
1390+
spin_unlock_irqrestore(&gi->spinlock, flags);
13841391

13851392
kfree(otg_desc[0]);
13861393
otg_desc[0] = NULL;
13871394
purge_configs_funcs(gi);
13881395
composite_dev_cleanup(cdev);
13891396
usb_ep_autoconfig_reset(cdev->gadget);
1397+
spin_lock_irqsave(&gi->spinlock, flags);
13901398
cdev->gadget = NULL;
13911399
set_gadget_data(gadget, NULL);
1400+
spin_unlock_irqrestore(&gi->spinlock, flags);
1401+
}
1402+
1403+
static int configfs_composite_setup(struct usb_gadget *gadget,
1404+
const struct usb_ctrlrequest *ctrl)
1405+
{
1406+
struct usb_composite_dev *cdev;
1407+
struct gadget_info *gi;
1408+
unsigned long flags;
1409+
int ret;
1410+
1411+
cdev = get_gadget_data(gadget);
1412+
if (!cdev)
1413+
return 0;
1414+
1415+
gi = container_of(cdev, struct gadget_info, cdev);
1416+
spin_lock_irqsave(&gi->spinlock, flags);
1417+
cdev = get_gadget_data(gadget);
1418+
if (!cdev || gi->unbind) {
1419+
spin_unlock_irqrestore(&gi->spinlock, flags);
1420+
return 0;
1421+
}
1422+
1423+
ret = composite_setup(gadget, ctrl);
1424+
spin_unlock_irqrestore(&gi->spinlock, flags);
1425+
return ret;
1426+
}
1427+
1428+
static void configfs_composite_disconnect(struct usb_gadget *gadget)
1429+
{
1430+
struct usb_composite_dev *cdev;
1431+
struct gadget_info *gi;
1432+
unsigned long flags;
1433+
1434+
cdev = get_gadget_data(gadget);
1435+
if (!cdev)
1436+
return;
1437+
1438+
gi = container_of(cdev, struct gadget_info, cdev);
1439+
spin_lock_irqsave(&gi->spinlock, flags);
1440+
cdev = get_gadget_data(gadget);
1441+
if (!cdev || gi->unbind) {
1442+
spin_unlock_irqrestore(&gi->spinlock, flags);
1443+
return;
1444+
}
1445+
1446+
composite_disconnect(gadget);
1447+
spin_unlock_irqrestore(&gi->spinlock, flags);
1448+
}
1449+
1450+
static void configfs_composite_suspend(struct usb_gadget *gadget)
1451+
{
1452+
struct usb_composite_dev *cdev;
1453+
struct gadget_info *gi;
1454+
unsigned long flags;
1455+
1456+
cdev = get_gadget_data(gadget);
1457+
if (!cdev)
1458+
return;
1459+
1460+
gi = container_of(cdev, struct gadget_info, cdev);
1461+
spin_lock_irqsave(&gi->spinlock, flags);
1462+
cdev = get_gadget_data(gadget);
1463+
if (!cdev || gi->unbind) {
1464+
spin_unlock_irqrestore(&gi->spinlock, flags);
1465+
return;
1466+
}
1467+
1468+
composite_suspend(gadget);
1469+
spin_unlock_irqrestore(&gi->spinlock, flags);
1470+
}
1471+
1472+
static void configfs_composite_resume(struct usb_gadget *gadget)
1473+
{
1474+
struct usb_composite_dev *cdev;
1475+
struct gadget_info *gi;
1476+
unsigned long flags;
1477+
1478+
cdev = get_gadget_data(gadget);
1479+
if (!cdev)
1480+
return;
1481+
1482+
gi = container_of(cdev, struct gadget_info, cdev);
1483+
spin_lock_irqsave(&gi->spinlock, flags);
1484+
cdev = get_gadget_data(gadget);
1485+
if (!cdev || gi->unbind) {
1486+
spin_unlock_irqrestore(&gi->spinlock, flags);
1487+
return;
1488+
}
1489+
1490+
composite_resume(gadget);
1491+
spin_unlock_irqrestore(&gi->spinlock, flags);
13921492
}
13931493

13941494
static const struct usb_gadget_driver configfs_driver_template = {
13951495
.bind = configfs_composite_bind,
13961496
.unbind = configfs_composite_unbind,
13971497

1398-
.setup = composite_setup,
1399-
.reset = composite_disconnect,
1400-
.disconnect = composite_disconnect,
1498+
.setup = configfs_composite_setup,
1499+
.reset = configfs_composite_disconnect,
1500+
.disconnect = configfs_composite_disconnect,
14011501

1402-
.suspend = composite_suspend,
1403-
.resume = composite_resume,
1502+
.suspend = configfs_composite_suspend,
1503+
.resume = configfs_composite_resume,
14041504

14051505
.max_speed = USB_SPEED_SUPER,
14061506
.driver = {

0 commit comments

Comments
 (0)