Skip to content

Commit e9a61af

Browse files
committed
Merge tag 'usb-5.7-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are a number of USB driver fixes for 5.7-rc3. Nothing huge, just the usual collection of: - xhci fixes - gadget driver fixes - syzkaller fuzzing fixes - new device ids and DT bindings - new quirks added for broken devices A few of the gadget driver fixes show up twice here as they were applied to my branch, and also by Felipe to his branch which I then pulled in as we got out of sync a bit. All of these have been in linux-next with no reported issues" * tag 'usb-5.7-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (33 commits) USB: sisusbvga: Change port variable from signed to unsigned usb-storage: Add unusual_devs entry for JMicron JMS566 USB: hub: Revert commit bd0e6c9 ("usb: hub: try old enumeration scheme first for high speed devices") USB: hub: Fix handling of connect changes during sleep usb: typec: altmode: Fix typec_altmode_get_partner sometimes returning an invalid pointer xhci: Don't clear hub TT buffer on ep0 protocol stall xhci: prevent bus suspend if a roothub port detected a over-current condition xhci: Fix handling halted endpoint even if endpoint ring appears empty usb: raw-gadget: Fix copy_to/from_user() checks usb: raw-gadget: fix raw_event_queue_fetch locking usb: gadget: udc: atmel: Fix vbus disconnect handling usb: dwc3: gadget: Fix request completion check USB: Add USB_QUIRK_DELAY_CTRL_MSG and USB_QUIRK_DELAY_INIT for Corsair K70 RGB RAPIDFIRE phy: tegra: Select USB_COMMON for usb_get_maximum_speed() usb: typec: tcpm: Ignore CC and vbus changes in PORT_RESET change usb: f_fs: Clear OS Extended descriptor counts to zero in ffs_data_reset() cdc-acm: introduce a cool down cdc-acm: close race betrween suspend() and acm_softint UAS: fix deadlock in error handling and PM flushing work UAS: no use logging any details in case of ENODEV ...
2 parents c5f3378 + 2df7405 commit e9a61af

File tree

29 files changed

+349
-121
lines changed

29 files changed

+349
-121
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5187,8 +5187,7 @@
51875187

51885188
usbcore.old_scheme_first=
51895189
[USB] Start with the old device initialization
5190-
scheme, applies only to low and full-speed devices
5191-
(default 0 = off).
5190+
scheme (default 0 = off).
51925191

51935192
usbcore.usbfs_memory_mb=
51945193
[USB] Memory limit (in MB) for buffers allocated by

Documentation/devicetree/bindings/usb/renesas,usb3-peri.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ properties:
1818
- renesas,r8a774c0-usb3-peri # RZ/G2E
1919
- renesas,r8a7795-usb3-peri # R-Car H3
2020
- renesas,r8a7796-usb3-peri # R-Car M3-W
21+
- renesas,r8a77961-usb3-peri # R-Car M3-W+
2122
- renesas,r8a77965-usb3-peri # R-Car M3-N
2223
- renesas,r8a77990-usb3-peri # R-Car E3
2324
- const: renesas,rcar-gen3-usb3-peri

Documentation/devicetree/bindings/usb/renesas,usbhs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ properties:
4040
- renesas,usbhs-r8a774c0 # RZ/G2E
4141
- renesas,usbhs-r8a7795 # R-Car H3
4242
- renesas,usbhs-r8a7796 # R-Car M3-W
43+
- renesas,usbhs-r8a77961 # R-Car M3-W+
4344
- renesas,usbhs-r8a77965 # R-Car M3-N
4445
- renesas,usbhs-r8a77990 # R-Car E3
4546
- renesas,usbhs-r8a77995 # R-Car D3

Documentation/devicetree/bindings/usb/usb-xhci.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Required properties:
1616
- "renesas,xhci-r8a7791" for r8a7791 SoC
1717
- "renesas,xhci-r8a7793" for r8a7793 SoC
1818
- "renesas,xhci-r8a7795" for r8a7795 SoC
19-
- "renesas,xhci-r8a7796" for r8a7796 SoC
19+
- "renesas,xhci-r8a7796" for r8a77960 SoC
20+
- "renesas,xhci-r8a77961" for r8a77961 SoC
2021
- "renesas,xhci-r8a77965" for r8a77965 SoC
2122
- "renesas,xhci-r8a77990" for r8a77990 SoC
2223
- "renesas,rcar-gen2-xhci" for a generic R-Car Gen2 or RZ/G1 compatible

drivers/phy/tegra/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22
config PHY_TEGRA_XUSB
33
tristate "NVIDIA Tegra XUSB pad controller driver"
4-
depends on ARCH_TEGRA
4+
depends on ARCH_TEGRA && USB_SUPPORT
5+
select USB_COMMON
56
select USB_CONN_GPIO
67
select USB_PHY
78
help

drivers/usb/class/cdc-acm.c

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,12 @@ static void acm_ctrl_irq(struct urb *urb)
412412

413413
exit:
414414
retval = usb_submit_urb(urb, GFP_ATOMIC);
415-
if (retval && retval != -EPERM)
415+
if (retval && retval != -EPERM && retval != -ENODEV)
416416
dev_err(&acm->control->dev,
417417
"%s - usb_submit_urb failed: %d\n", __func__, retval);
418+
else
419+
dev_vdbg(&acm->control->dev,
420+
"control resubmission terminated %d\n", retval);
418421
}
419422

420423
static int acm_submit_read_urb(struct acm *acm, int index, gfp_t mem_flags)
@@ -430,6 +433,8 @@ static int acm_submit_read_urb(struct acm *acm, int index, gfp_t mem_flags)
430433
dev_err(&acm->data->dev,
431434
"urb %d failed submission with %d\n",
432435
index, res);
436+
} else {
437+
dev_vdbg(&acm->data->dev, "intended failure %d\n", res);
433438
}
434439
set_bit(index, &acm->read_urbs_free);
435440
return res;
@@ -471,6 +476,7 @@ static void acm_read_bulk_callback(struct urb *urb)
471476
int status = urb->status;
472477
bool stopped = false;
473478
bool stalled = false;
479+
bool cooldown = false;
474480

475481
dev_vdbg(&acm->data->dev, "got urb %d, len %d, status %d\n",
476482
rb->index, urb->actual_length, status);
@@ -497,6 +503,14 @@ static void acm_read_bulk_callback(struct urb *urb)
497503
__func__, status);
498504
stopped = true;
499505
break;
506+
case -EOVERFLOW:
507+
case -EPROTO:
508+
dev_dbg(&acm->data->dev,
509+
"%s - cooling babbling device\n", __func__);
510+
usb_mark_last_busy(acm->dev);
511+
set_bit(rb->index, &acm->urbs_in_error_delay);
512+
cooldown = true;
513+
break;
500514
default:
501515
dev_dbg(&acm->data->dev,
502516
"%s - nonzero urb status received: %d\n",
@@ -518,9 +532,11 @@ static void acm_read_bulk_callback(struct urb *urb)
518532
*/
519533
smp_mb__after_atomic();
520534

521-
if (stopped || stalled) {
535+
if (stopped || stalled || cooldown) {
522536
if (stalled)
523537
schedule_work(&acm->work);
538+
else if (cooldown)
539+
schedule_delayed_work(&acm->dwork, HZ / 2);
524540
return;
525541
}
526542

@@ -557,14 +573,20 @@ static void acm_softint(struct work_struct *work)
557573
struct acm *acm = container_of(work, struct acm, work);
558574

559575
if (test_bit(EVENT_RX_STALL, &acm->flags)) {
560-
if (!(usb_autopm_get_interface(acm->data))) {
576+
smp_mb(); /* against acm_suspend() */
577+
if (!acm->susp_count) {
561578
for (i = 0; i < acm->rx_buflimit; i++)
562579
usb_kill_urb(acm->read_urbs[i]);
563580
usb_clear_halt(acm->dev, acm->in);
564581
acm_submit_read_urbs(acm, GFP_KERNEL);
565-
usb_autopm_put_interface(acm->data);
582+
clear_bit(EVENT_RX_STALL, &acm->flags);
566583
}
567-
clear_bit(EVENT_RX_STALL, &acm->flags);
584+
}
585+
586+
if (test_and_clear_bit(ACM_ERROR_DELAY, &acm->flags)) {
587+
for (i = 0; i < ACM_NR; i++)
588+
if (test_and_clear_bit(i, &acm->urbs_in_error_delay))
589+
acm_submit_read_urb(acm, i, GFP_NOIO);
568590
}
569591

570592
if (test_and_clear_bit(EVENT_TTY_WAKEUP, &acm->flags))
@@ -1333,6 +1355,7 @@ static int acm_probe(struct usb_interface *intf,
13331355
acm->readsize = readsize;
13341356
acm->rx_buflimit = num_rx_buf;
13351357
INIT_WORK(&acm->work, acm_softint);
1358+
INIT_DELAYED_WORK(&acm->dwork, acm_softint);
13361359
init_waitqueue_head(&acm->wioctl);
13371360
spin_lock_init(&acm->write_lock);
13381361
spin_lock_init(&acm->read_lock);
@@ -1542,6 +1565,7 @@ static void acm_disconnect(struct usb_interface *intf)
15421565

15431566
acm_kill_urbs(acm);
15441567
cancel_work_sync(&acm->work);
1568+
cancel_delayed_work_sync(&acm->dwork);
15451569

15461570
tty_unregister_device(acm_tty_driver, acm->minor);
15471571

@@ -1584,6 +1608,8 @@ static int acm_suspend(struct usb_interface *intf, pm_message_t message)
15841608

15851609
acm_kill_urbs(acm);
15861610
cancel_work_sync(&acm->work);
1611+
cancel_delayed_work_sync(&acm->dwork);
1612+
acm->urbs_in_error_delay = 0;
15871613

15881614
return 0;
15891615
}

drivers/usb/class/cdc-acm.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,11 @@ struct acm {
109109
# define EVENT_TTY_WAKEUP 0
110110
# define EVENT_RX_STALL 1
111111
# define ACM_THROTTLED 2
112+
# define ACM_ERROR_DELAY 3
113+
unsigned long urbs_in_error_delay; /* these need to be restarted after a delay */
112114
struct usb_cdc_line_coding line; /* bits, stop, parity */
113-
struct work_struct work; /* work queue entry for line discipline waking up */
115+
struct work_struct work; /* work queue entry for various purposes*/
116+
struct delayed_work dwork; /* for cool downs needed in error recovery */
114117
unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */
115118
unsigned int ctrlout; /* output control lines (DTR, RTS) */
116119
struct async_icount iocount; /* counters for control line changes */

drivers/usb/core/hub.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,11 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
12231223
#ifdef CONFIG_PM
12241224
udev->reset_resume = 1;
12251225
#endif
1226+
/* Don't set the change_bits when the device
1227+
* was powered off.
1228+
*/
1229+
if (test_bit(port1, hub->power_bits))
1230+
set_bit(port1, hub->change_bits);
12261231

12271232
} else {
12281233
/* The power session is gone; tell hub_wq */
@@ -2723,13 +2728,11 @@ static bool use_new_scheme(struct usb_device *udev, int retry,
27232728
{
27242729
int old_scheme_first_port =
27252730
port_dev->quirks & USB_PORT_QUIRK_OLD_SCHEME;
2726-
int quick_enumeration = (udev->speed == USB_SPEED_HIGH);
27272731

27282732
if (udev->speed >= USB_SPEED_SUPER)
27292733
return false;
27302734

2731-
return USE_NEW_SCHEME(retry, old_scheme_first_port || old_scheme_first
2732-
|| quick_enumeration);
2735+
return USE_NEW_SCHEME(retry, old_scheme_first_port || old_scheme_first);
27332736
}
27342737

27352738
/* Is a USB 3.0 port in the Inactive or Compliance Mode state?
@@ -3088,6 +3091,15 @@ static int check_port_resume_type(struct usb_device *udev,
30883091
if (portchange & USB_PORT_STAT_C_ENABLE)
30893092
usb_clear_port_feature(hub->hdev, port1,
30903093
USB_PORT_FEAT_C_ENABLE);
3094+
3095+
/*
3096+
* Whatever made this reset-resume necessary may have
3097+
* turned on the port1 bit in hub->change_bits. But after
3098+
* a successful reset-resume we want the bit to be clear;
3099+
* if it was on it would indicate that something happened
3100+
* following the reset-resume.
3101+
*/
3102+
clear_bit(port1, hub->change_bits);
30913103
}
30923104

30933105
return status;

drivers/usb/core/message.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,12 +589,13 @@ void usb_sg_cancel(struct usb_sg_request *io)
589589
int i, retval;
590590

591591
spin_lock_irqsave(&io->lock, flags);
592-
if (io->status) {
592+
if (io->status || io->count == 0) {
593593
spin_unlock_irqrestore(&io->lock, flags);
594594
return;
595595
}
596596
/* shut everything down */
597597
io->status = -ECONNRESET;
598+
io->count++; /* Keep the request alive until we're done */
598599
spin_unlock_irqrestore(&io->lock, flags);
599600

600601
for (i = io->entries - 1; i >= 0; --i) {
@@ -608,6 +609,12 @@ void usb_sg_cancel(struct usb_sg_request *io)
608609
dev_warn(&io->dev->dev, "%s, unlink --> %d\n",
609610
__func__, retval);
610611
}
612+
613+
spin_lock_irqsave(&io->lock, flags);
614+
io->count--;
615+
if (!io->count)
616+
complete(&io->complete);
617+
spin_unlock_irqrestore(&io->lock, flags);
611618
}
612619
EXPORT_SYMBOL_GPL(usb_sg_cancel);
613620

drivers/usb/core/quirks.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,10 @@ static const struct usb_device_id usb_quirk_list[] = {
430430
/* Corsair K70 LUX */
431431
{ USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT },
432432

433+
/* Corsair K70 RGB RAPDIFIRE */
434+
{ USB_DEVICE(0x1b1c, 0x1b38), .driver_info = USB_QUIRK_DELAY_INIT |
435+
USB_QUIRK_DELAY_CTRL_MSG },
436+
433437
/* MIDI keyboard WORLDE MINI */
434438
{ USB_DEVICE(0x1c75, 0x0204), .driver_info =
435439
USB_QUIRK_CONFIG_INTF_STRINGS },

drivers/usb/dwc3/core.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,14 @@
307307

308308
/* Global TX Fifo Size Register */
309309
#define DWC31_GTXFIFOSIZ_TXFRAMNUM BIT(15) /* DWC_usb31 only */
310-
#define DWC31_GTXFIFOSIZ_TXFDEF(n) ((n) & 0x7fff) /* DWC_usb31 only */
311-
#define DWC3_GTXFIFOSIZ_TXFDEF(n) ((n) & 0xffff)
310+
#define DWC31_GTXFIFOSIZ_TXFDEP(n) ((n) & 0x7fff) /* DWC_usb31 only */
311+
#define DWC3_GTXFIFOSIZ_TXFDEP(n) ((n) & 0xffff)
312312
#define DWC3_GTXFIFOSIZ_TXFSTADDR(n) ((n) & 0xffff0000)
313313

314+
/* Global RX Fifo Size Register */
315+
#define DWC31_GRXFIFOSIZ_RXFDEP(n) ((n) & 0x7fff) /* DWC_usb31 only */
316+
#define DWC3_GRXFIFOSIZ_RXFDEP(n) ((n) & 0xffff)
317+
314318
/* Global Event Size Registers */
315319
#define DWC3_GEVNTSIZ_INTMASK BIT(31)
316320
#define DWC3_GEVNTSIZ_SIZE(n) ((n) & 0xffff)

0 commit comments

Comments
 (0)