Skip to content

Commit 69237f8

Browse files
committed
Merge tag 'usb-7.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here is a large chunk of USB driver fixes for 7.0-rc4. Included in here are: - usb gadget reverts due to reported issues, and then a follow-on fix to hopefully resolve the reported overall problem - xhci driver fixes - dwc3 driver fixes - usb core "killable" bulk message api addition to fix a usbtmc driver bug where userspace could hang the driver for forever - small USB driver fixes for reported issues - new usb device quirks All except the last USB device quirk change have been in linux-next with no reported issues. That one came in too late, and is 'obviously correct' :)" * tag 'usb-7.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (35 commits) USB: ezcap401 needs USB_QUIRK_NO_BOS to function on 10gbs usb speed usb: roles: get usb role switch from parent only for usb-b-connector Revert "tcpm: allow looking for role_sw device in the main node" usb: gadget: f_ncm: Fix net_device lifecycle with device_move Revert "usb: gadget: u_ether: add gether_opts for config caching" Revert "usb: gadget: u_ether: use <linux/hex.h> header file" Revert "usb: gadget: u_ether: Add auto-cleanup helper for freeing net_device" Revert "usb: gadget: f_ncm: align net_device lifecycle with bind/unbind" Revert "usb: legacy: ncm: Fix NPE in gncm_bind" Revert "usb: gadget: f_ncm: Fix atomic context locking issue" usb: typec: altmode/displayport: set displayport signaling rate in configure message usb: dwc3: pci: add support for the Intel Nova Lake -H usb/core/quirks: Add Huawei ME906S-device to wakeup quirk usb: gadget: uvc: fix interval_duration calculation xhci: Fix NULL pointer dereference when reading portli debugfs files usb: xhci: Prevent interrupt storm on host controller error (HCE) usb: xhci: Fix memory leak in xhci_disable_slot() usb: class: cdc-wdm: fix reordering issue in read code path usb: renesas_usbhs: fix use-after-free in ISR during device removal usb: cdc-acm: Restore CAP_BRK functionnality to CH343 ...
2 parents 5c75125 + d0d9b1f commit 69237f8

31 files changed

Lines changed: 330 additions & 369 deletions

File tree

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8196,6 +8196,9 @@ Kernel parameters
81968196
p = USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT
81978197
(Reduce timeout of the SET_ADDRESS
81988198
request from 5000 ms to 500 ms);
8199+
q = USB_QUIRK_FORCE_ONE_CONFIG (Device
8200+
claims zero configurations,
8201+
forcing to 1);
81998202
Example: quirks=0781:5580:bk,0a5c:5834:gij
82008203

82018204
usbhid.mousepoll=

drivers/usb/class/cdc-acm.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,8 @@ static int acm_probe(struct usb_interface *intf,
13791379
acm->ctrl_caps = h.usb_cdc_acm_descriptor->bmCapabilities;
13801380
if (quirks & NO_CAP_LINE)
13811381
acm->ctrl_caps &= ~USB_CDC_CAP_LINE;
1382+
if (quirks & MISSING_CAP_BRK)
1383+
acm->ctrl_caps |= USB_CDC_CAP_BRK;
13821384
acm->ctrlsize = ctrlsize;
13831385
acm->readsize = readsize;
13841386
acm->rx_buflimit = num_rx_buf;
@@ -2002,6 +2004,9 @@ static const struct usb_device_id acm_ids[] = {
20022004
.driver_info = IGNORE_DEVICE,
20032005
},
20042006

2007+
/* CH343 supports CAP_BRK, but doesn't advertise it */
2008+
{ USB_DEVICE(0x1a86, 0x55d3), .driver_info = MISSING_CAP_BRK, },
2009+
20052010
/* control interfaces without any protocol set */
20062011
{ USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
20072012
USB_CDC_PROTO_NONE) },

drivers/usb/class/cdc-acm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,4 @@ struct acm {
113113
#define CLEAR_HALT_CONDITIONS BIT(5)
114114
#define SEND_ZERO_PACKET BIT(6)
115115
#define DISABLE_ECHO BIT(7)
116+
#define MISSING_CAP_BRK BIT(8)

drivers/usb/class/cdc-wdm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ static void wdm_in_callback(struct urb *urb)
225225
/* we may already be in overflow */
226226
if (!test_bit(WDM_OVERFLOW, &desc->flags)) {
227227
memmove(desc->ubuf + desc->length, desc->inbuf, length);
228-
desc->length += length;
228+
smp_wmb(); /* against wdm_read() */
229+
WRITE_ONCE(desc->length, desc->length + length);
229230
}
230231
}
231232
skip_error:
@@ -533,6 +534,7 @@ static ssize_t wdm_read
533534
return -ERESTARTSYS;
534535

535536
cntr = READ_ONCE(desc->length);
537+
smp_rmb(); /* against wdm_in_callback() */
536538
if (cntr == 0) {
537539
desc->read = 0;
538540
retry:

drivers/usb/class/usbtmc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ static int usbtmc488_ioctl_trigger(struct usbtmc_file_data *file_data)
727727
buffer[1] = data->bTag;
728728
buffer[2] = ~data->bTag;
729729

730-
retval = usb_bulk_msg(data->usb_dev,
730+
retval = usb_bulk_msg_killable(data->usb_dev,
731731
usb_sndbulkpipe(data->usb_dev,
732732
data->bulk_out),
733733
buffer, USBTMC_HEADER_SIZE,
@@ -1347,7 +1347,7 @@ static int send_request_dev_dep_msg_in(struct usbtmc_file_data *file_data,
13471347
buffer[11] = 0; /* Reserved */
13481348

13491349
/* Send bulk URB */
1350-
retval = usb_bulk_msg(data->usb_dev,
1350+
retval = usb_bulk_msg_killable(data->usb_dev,
13511351
usb_sndbulkpipe(data->usb_dev,
13521352
data->bulk_out),
13531353
buffer, USBTMC_HEADER_SIZE,
@@ -1419,7 +1419,7 @@ static ssize_t usbtmc_read(struct file *filp, char __user *buf,
14191419
actual = 0;
14201420

14211421
/* Send bulk URB */
1422-
retval = usb_bulk_msg(data->usb_dev,
1422+
retval = usb_bulk_msg_killable(data->usb_dev,
14231423
usb_rcvbulkpipe(data->usb_dev,
14241424
data->bulk_in),
14251425
buffer, bufsize, &actual,

drivers/usb/core/config.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,11 @@ int usb_get_configuration(struct usb_device *dev)
927927
dev->descriptor.bNumConfigurations = ncfg = USB_MAXCONFIG;
928928
}
929929

930-
if (ncfg < 1) {
930+
if (ncfg < 1 && dev->quirks & USB_QUIRK_FORCE_ONE_CONFIG) {
931+
dev_info(ddev, "Device claims zero configurations, forcing to 1\n");
932+
dev->descriptor.bNumConfigurations = 1;
933+
ncfg = 1;
934+
} else if (ncfg < 1) {
931935
dev_err(ddev, "no configurations\n");
932936
return -EINVAL;
933937
}

drivers/usb/core/message.c

Lines changed: 79 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,19 @@ static void usb_api_blocking_completion(struct urb *urb)
4242

4343

4444
/*
45-
* Starts urb and waits for completion or timeout. Note that this call
46-
* is NOT interruptible. Many device driver i/o requests should be
47-
* interruptible and therefore these drivers should implement their
48-
* own interruptible routines.
45+
* Starts urb and waits for completion or timeout.
46+
* Whether or not the wait is killable depends on the flag passed in.
47+
* For example, compare usb_bulk_msg() and usb_bulk_msg_killable().
48+
*
49+
* For non-killable waits, we enforce a maximum limit on the timeout value.
4950
*/
50-
static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length)
51+
static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length,
52+
bool killable)
5153
{
5254
struct api_context ctx;
5355
unsigned long expire;
5456
int retval;
57+
long rc;
5558

5659
init_completion(&ctx.done);
5760
urb->context = &ctx;
@@ -60,13 +63,24 @@ static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length)
6063
if (unlikely(retval))
6164
goto out;
6265

63-
expire = timeout ? msecs_to_jiffies(timeout) : MAX_SCHEDULE_TIMEOUT;
64-
if (!wait_for_completion_timeout(&ctx.done, expire)) {
66+
if (!killable && (timeout <= 0 || timeout > USB_MAX_SYNCHRONOUS_TIMEOUT))
67+
timeout = USB_MAX_SYNCHRONOUS_TIMEOUT;
68+
expire = (timeout > 0) ? msecs_to_jiffies(timeout) : MAX_SCHEDULE_TIMEOUT;
69+
if (killable)
70+
rc = wait_for_completion_killable_timeout(&ctx.done, expire);
71+
else
72+
rc = wait_for_completion_timeout(&ctx.done, expire);
73+
if (rc <= 0) {
6574
usb_kill_urb(urb);
66-
retval = (ctx.status == -ENOENT ? -ETIMEDOUT : ctx.status);
75+
if (ctx.status != -ENOENT)
76+
retval = ctx.status;
77+
else if (rc == 0)
78+
retval = -ETIMEDOUT;
79+
else
80+
retval = rc;
6781

6882
dev_dbg(&urb->dev->dev,
69-
"%s timed out on ep%d%s len=%u/%u\n",
83+
"%s timed out or killed on ep%d%s len=%u/%u\n",
7084
current->comm,
7185
usb_endpoint_num(&urb->ep->desc),
7286
usb_urb_dir_in(urb) ? "in" : "out",
@@ -100,7 +114,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
100114
usb_fill_control_urb(urb, usb_dev, pipe, (unsigned char *)cmd, data,
101115
len, usb_api_blocking_completion, NULL);
102116

103-
retv = usb_start_wait_urb(urb, timeout, &length);
117+
retv = usb_start_wait_urb(urb, timeout, &length, false);
104118
if (retv < 0)
105119
return retv;
106120
else
@@ -117,8 +131,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
117131
* @index: USB message index value
118132
* @data: pointer to the data to send
119133
* @size: length in bytes of the data to send
120-
* @timeout: time in msecs to wait for the message to complete before timing
121-
* out (if 0 the wait is forever)
134+
* @timeout: time in msecs to wait for the message to complete before timing out
122135
*
123136
* Context: task context, might sleep.
124137
*
@@ -173,8 +186,7 @@ EXPORT_SYMBOL_GPL(usb_control_msg);
173186
* @index: USB message index value
174187
* @driver_data: pointer to the data to send
175188
* @size: length in bytes of the data to send
176-
* @timeout: time in msecs to wait for the message to complete before timing
177-
* out (if 0 the wait is forever)
189+
* @timeout: time in msecs to wait for the message to complete before timing out
178190
* @memflags: the flags for memory allocation for buffers
179191
*
180192
* Context: !in_interrupt ()
@@ -232,8 +244,7 @@ EXPORT_SYMBOL_GPL(usb_control_msg_send);
232244
* @index: USB message index value
233245
* @driver_data: pointer to the data to be filled in by the message
234246
* @size: length in bytes of the data to be received
235-
* @timeout: time in msecs to wait for the message to complete before timing
236-
* out (if 0 the wait is forever)
247+
* @timeout: time in msecs to wait for the message to complete before timing out
237248
* @memflags: the flags for memory allocation for buffers
238249
*
239250
* Context: !in_interrupt ()
@@ -304,8 +315,7 @@ EXPORT_SYMBOL_GPL(usb_control_msg_recv);
304315
* @len: length in bytes of the data to send
305316
* @actual_length: pointer to a location to put the actual length transferred
306317
* in bytes
307-
* @timeout: time in msecs to wait for the message to complete before
308-
* timing out (if 0 the wait is forever)
318+
* @timeout: time in msecs to wait for the message to complete before timing out
309319
*
310320
* Context: task context, might sleep.
311321
*
@@ -337,8 +347,7 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg);
337347
* @len: length in bytes of the data to send
338348
* @actual_length: pointer to a location to put the actual length transferred
339349
* in bytes
340-
* @timeout: time in msecs to wait for the message to complete before
341-
* timing out (if 0 the wait is forever)
350+
* @timeout: time in msecs to wait for the message to complete before timing out
342351
*
343352
* Context: task context, might sleep.
344353
*
@@ -385,10 +394,59 @@ int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
385394
usb_fill_bulk_urb(urb, usb_dev, pipe, data, len,
386395
usb_api_blocking_completion, NULL);
387396

388-
return usb_start_wait_urb(urb, timeout, actual_length);
397+
return usb_start_wait_urb(urb, timeout, actual_length, false);
389398
}
390399
EXPORT_SYMBOL_GPL(usb_bulk_msg);
391400

401+
/**
402+
* usb_bulk_msg_killable - Builds a bulk urb, sends it off and waits for completion in a killable state
403+
* @usb_dev: pointer to the usb device to send the message to
404+
* @pipe: endpoint "pipe" to send the message to
405+
* @data: pointer to the data to send
406+
* @len: length in bytes of the data to send
407+
* @actual_length: pointer to a location to put the actual length transferred
408+
* in bytes
409+
* @timeout: time in msecs to wait for the message to complete before
410+
* timing out (if <= 0, the wait is as long as possible)
411+
*
412+
* Context: task context, might sleep.
413+
*
414+
* This function is just like usb_blk_msg(), except that it waits in a
415+
* killable state and there is no limit on the timeout length.
416+
*
417+
* Return:
418+
* If successful, 0. Otherwise a negative error number. The number of actual
419+
* bytes transferred will be stored in the @actual_length parameter.
420+
*
421+
*/
422+
int usb_bulk_msg_killable(struct usb_device *usb_dev, unsigned int pipe,
423+
void *data, int len, int *actual_length, int timeout)
424+
{
425+
struct urb *urb;
426+
struct usb_host_endpoint *ep;
427+
428+
ep = usb_pipe_endpoint(usb_dev, pipe);
429+
if (!ep || len < 0)
430+
return -EINVAL;
431+
432+
urb = usb_alloc_urb(0, GFP_KERNEL);
433+
if (!urb)
434+
return -ENOMEM;
435+
436+
if ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
437+
USB_ENDPOINT_XFER_INT) {
438+
pipe = (pipe & ~(3 << 30)) | (PIPE_INTERRUPT << 30);
439+
usb_fill_int_urb(urb, usb_dev, pipe, data, len,
440+
usb_api_blocking_completion, NULL,
441+
ep->desc.bInterval);
442+
} else
443+
usb_fill_bulk_urb(urb, usb_dev, pipe, data, len,
444+
usb_api_blocking_completion, NULL);
445+
446+
return usb_start_wait_urb(urb, timeout, actual_length, true);
447+
}
448+
EXPORT_SYMBOL_GPL(usb_bulk_msg_killable);
449+
392450
/*-------------------------------------------------------------------*/
393451

394452
static void sg_clean(struct usb_sg_request *io)

drivers/usb/core/phy.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,10 @@ int usb_phy_roothub_set_mode(struct usb_phy_roothub *phy_roothub,
200200
list_for_each_entry(roothub_entry, head, list) {
201201
err = phy_set_mode(roothub_entry->phy, mode);
202202
if (err)
203-
goto err_out;
203+
return err;
204204
}
205205

206206
return 0;
207-
208-
err_out:
209-
list_for_each_entry_continue_reverse(roothub_entry, head, list)
210-
phy_power_off(roothub_entry->phy);
211-
212-
return err;
213207
}
214208
EXPORT_SYMBOL_GPL(usb_phy_roothub_set_mode);
215209

drivers/usb/core/quirks.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp)
140140
case 'p':
141141
flags |= USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT;
142142
break;
143+
case 'q':
144+
flags |= USB_QUIRK_FORCE_ONE_CONFIG;
143145
/* Ignore unrecognized flag characters */
144146
}
145147
}
@@ -207,6 +209,10 @@ static const struct usb_device_id usb_quirk_list[] = {
207209
/* HP v222w 16GB Mini USB Drive */
208210
{ USB_DEVICE(0x03f0, 0x3f40), .driver_info = USB_QUIRK_DELAY_INIT },
209211

212+
/* Huawei 4G LTE module ME906S */
213+
{ USB_DEVICE(0x03f0, 0xa31d), .driver_info =
214+
USB_QUIRK_DISCONNECT_SUSPEND },
215+
210216
/* Creative SB Audigy 2 NX */
211217
{ USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME },
212218

@@ -376,6 +382,9 @@ static const struct usb_device_id usb_quirk_list[] = {
376382
/* SanDisk Extreme 55AE */
377383
{ USB_DEVICE(0x0781, 0x55ae), .driver_info = USB_QUIRK_NO_LPM },
378384

385+
/* Avermedia Live Gamer Ultra 2.1 (GC553G2) - BOS descriptor fetch hangs at SuperSpeed Plus */
386+
{ USB_DEVICE(0x07ca, 0x2553), .driver_info = USB_QUIRK_NO_BOS },
387+
379388
/* Realforce 87U Keyboard */
380389
{ USB_DEVICE(0x0853, 0x011b), .driver_info = USB_QUIRK_NO_LPM },
381390

@@ -436,6 +445,9 @@ static const struct usb_device_id usb_quirk_list[] = {
436445
{ USB_DEVICE(0x0b05, 0x17e0), .driver_info =
437446
USB_QUIRK_IGNORE_REMOTE_WAKEUP },
438447

448+
/* ASUS TUF 4K PRO - BOS descriptor fetch hangs at SuperSpeed Plus */
449+
{ USB_DEVICE(0x0b05, 0x1ab9), .driver_info = USB_QUIRK_NO_BOS },
450+
439451
/* Realtek Semiconductor Corp. Mass Storage Device (Multicard Reader)*/
440452
{ USB_DEVICE(0x0bda, 0x0151), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS },
441453

@@ -564,6 +576,9 @@ static const struct usb_device_id usb_quirk_list[] = {
564576

565577
{ USB_DEVICE(0x2386, 0x350e), .driver_info = USB_QUIRK_NO_LPM },
566578

579+
/* UGREEN 35871 - BOS descriptor fetch hangs at SuperSpeed Plus */
580+
{ USB_DEVICE(0x2b89, 0x5871), .driver_info = USB_QUIRK_NO_BOS },
581+
567582
/* APTIV AUTOMOTIVE HUB */
568583
{ USB_DEVICE(0x2c48, 0x0132), .driver_info =
569584
USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT },
@@ -574,12 +589,18 @@ static const struct usb_device_id usb_quirk_list[] = {
574589
/* Alcor Link AK9563 SC Reader used in 2022 Lenovo ThinkPads */
575590
{ USB_DEVICE(0x2ce3, 0x9563), .driver_info = USB_QUIRK_NO_LPM },
576591

592+
/* ezcap401 - BOS descriptor fetch hangs at SuperSpeed Plus */
593+
{ USB_DEVICE(0x32ed, 0x0401), .driver_info = USB_QUIRK_NO_BOS },
594+
577595
/* DELL USB GEN2 */
578596
{ USB_DEVICE(0x413c, 0xb062), .driver_info = USB_QUIRK_NO_LPM | USB_QUIRK_RESET_RESUME },
579597

580598
/* VCOM device */
581599
{ USB_DEVICE(0x4296, 0x7570), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS },
582600

601+
/* Noji-MCS SmartCard Reader */
602+
{ USB_DEVICE(0x5131, 0x2007), .driver_info = USB_QUIRK_FORCE_ONE_CONFIG },
603+
583604
/* INTEL VALUE SSD */
584605
{ USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME },
585606

drivers/usb/dwc3/dwc3-pci.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#define PCI_DEVICE_ID_INTEL_CNPH 0xa36e
5757
#define PCI_DEVICE_ID_INTEL_CNPV 0xa3b0
5858
#define PCI_DEVICE_ID_INTEL_RPL 0xa70e
59+
#define PCI_DEVICE_ID_INTEL_NVLH 0xd37f
5960
#define PCI_DEVICE_ID_INTEL_PTLH 0xe332
6061
#define PCI_DEVICE_ID_INTEL_PTLH_PCH 0xe37e
6162
#define PCI_DEVICE_ID_INTEL_PTLU 0xe432
@@ -447,6 +448,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
447448
{ PCI_DEVICE_DATA(INTEL, CNPH, &dwc3_pci_intel_swnode) },
448449
{ PCI_DEVICE_DATA(INTEL, CNPV, &dwc3_pci_intel_swnode) },
449450
{ PCI_DEVICE_DATA(INTEL, RPL, &dwc3_pci_intel_swnode) },
451+
{ PCI_DEVICE_DATA(INTEL, NVLH, &dwc3_pci_intel_swnode) },
450452
{ PCI_DEVICE_DATA(INTEL, PTLH, &dwc3_pci_intel_swnode) },
451453
{ PCI_DEVICE_DATA(INTEL, PTLH_PCH, &dwc3_pci_intel_swnode) },
452454
{ PCI_DEVICE_DATA(INTEL, PTLU, &dwc3_pci_intel_swnode) },

0 commit comments

Comments
 (0)