Skip to content

Commit 6bfcc5f

Browse files
committed
Merge tag 'usb-6.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are some small USB driver fixes, and new device ids, for 6.14-rc3. Lots of tiny stuff for reported problems, including: - new device ids and quirks - usb hub crash fix found by syzbot - dwc2 driver fix - dwc3 driver fixes - uvc gadget driver fix - cdc-acm driver fixes for a variety of different issues - other tiny bugfixes Almost all of these have been in linux-next this week, and all have passed 0-day testing" * tag 'usb-6.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (25 commits) usb: typec: tcpm: PSSourceOffTimer timeout in PR_Swap enters ERROR_RECOVERY usb: roles: set switch registered flag early on usb: gadget: uvc: Fix unstarted kthread worker USB: quirks: add USB_QUIRK_NO_LPM quirk for Teclast dist usb: gadget: core: flush gadget workqueue after device removal USB: gadget: f_midi: f_midi_complete to call queue_work usb: core: fix pipe creation for get_bMaxPacketSize0 usb: dwc3: Fix timeout issue during controller enter/exit from halt state USB: Add USB_QUIRK_NO_LPM quirk for sony xperia xz1 smartphone USB: cdc-acm: Fill in Renesas R-Car D3 USB Download mode quirk usb: cdc-acm: Fix handling of oversized fragments usb: cdc-acm: Check control transfer buffer size before access usb: xhci: Restore xhci_pci support for Renesas HCs USB: pci-quirks: Fix HCCPARAMS register error for LS7A EHCI USB: serial: option: drop MeiG Smart defines USB: serial: option: fix Telit Cinterion FN990A name USB: serial: option: add Telit Cinterion FN990B compositions USB: serial: option: add MeiG Smart SLM828 usb: gadget: f_midi: fix MIDI Streaming descriptor lengths usb: dwc2: gadget: remove of_node reference upon udc_stop ...
2 parents ba643b6 + 659f5d5 commit 6bfcc5f

File tree

16 files changed

+139
-45
lines changed

16 files changed

+139
-45
lines changed

drivers/usb/class/cdc-acm.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ static void acm_process_notification(struct acm *acm, unsigned char *buf)
371371
static void acm_ctrl_irq(struct urb *urb)
372372
{
373373
struct acm *acm = urb->context;
374-
struct usb_cdc_notification *dr = urb->transfer_buffer;
374+
struct usb_cdc_notification *dr;
375375
unsigned int current_size = urb->actual_length;
376376
unsigned int expected_size, copy_size, alloc_size;
377377
int retval;
@@ -398,14 +398,25 @@ static void acm_ctrl_irq(struct urb *urb)
398398

399399
usb_mark_last_busy(acm->dev);
400400

401-
if (acm->nb_index)
401+
if (acm->nb_index == 0) {
402+
/*
403+
* The first chunk of a message must contain at least the
404+
* notification header with the length field, otherwise we
405+
* can't get an expected_size.
406+
*/
407+
if (current_size < sizeof(struct usb_cdc_notification)) {
408+
dev_dbg(&acm->control->dev, "urb too short\n");
409+
goto exit;
410+
}
411+
dr = urb->transfer_buffer;
412+
} else {
402413
dr = (struct usb_cdc_notification *)acm->notification_buffer;
403-
414+
}
404415
/* size = notification-header + (optional) data */
405416
expected_size = sizeof(struct usb_cdc_notification) +
406417
le16_to_cpu(dr->wLength);
407418

408-
if (current_size < expected_size) {
419+
if (acm->nb_index != 0 || current_size < expected_size) {
409420
/* notification is transmitted fragmented, reassemble */
410421
if (acm->nb_size < expected_size) {
411422
u8 *new_buffer;
@@ -1727,13 +1738,16 @@ static const struct usb_device_id acm_ids[] = {
17271738
{ USB_DEVICE(0x0870, 0x0001), /* Metricom GS Modem */
17281739
.driver_info = NO_UNION_NORMAL, /* has no union descriptor */
17291740
},
1730-
{ USB_DEVICE(0x045b, 0x023c), /* Renesas USB Download mode */
1741+
{ USB_DEVICE(0x045b, 0x023c), /* Renesas R-Car H3 USB Download mode */
1742+
.driver_info = DISABLE_ECHO, /* Don't echo banner */
1743+
},
1744+
{ USB_DEVICE(0x045b, 0x0247), /* Renesas R-Car D3 USB Download mode */
17311745
.driver_info = DISABLE_ECHO, /* Don't echo banner */
17321746
},
1733-
{ USB_DEVICE(0x045b, 0x0248), /* Renesas USB Download mode */
1747+
{ USB_DEVICE(0x045b, 0x0248), /* Renesas R-Car M3-N USB Download mode */
17341748
.driver_info = DISABLE_ECHO, /* Don't echo banner */
17351749
},
1736-
{ USB_DEVICE(0x045b, 0x024D), /* Renesas USB Download mode */
1750+
{ USB_DEVICE(0x045b, 0x024D), /* Renesas R-Car E3 USB Download mode */
17371751
.driver_info = DISABLE_ECHO, /* Don't echo banner */
17381752
},
17391753
{ USB_DEVICE(0x0e8d, 0x0003), /* FIREFLY, MediaTek Inc; [email protected] */

drivers/usb/core/hub.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,6 +1848,17 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
18481848
desc = intf->cur_altsetting;
18491849
hdev = interface_to_usbdev(intf);
18501850

1851+
/*
1852+
* The USB 2.0 spec prohibits hubs from having more than one
1853+
* configuration or interface, and we rely on this prohibition.
1854+
* Refuse to accept a device that violates it.
1855+
*/
1856+
if (hdev->descriptor.bNumConfigurations > 1 ||
1857+
hdev->actconfig->desc.bNumInterfaces > 1) {
1858+
dev_err(&intf->dev, "Invalid hub with more than one config or interface\n");
1859+
return -EINVAL;
1860+
}
1861+
18511862
/*
18521863
* Set default autosuspend delay as 0 to speedup bus suspend,
18531864
* based on the below considerations:
@@ -4698,7 +4709,6 @@ void usb_ep0_reinit(struct usb_device *udev)
46984709
EXPORT_SYMBOL_GPL(usb_ep0_reinit);
46994710

47004711
#define usb_sndaddr0pipe() (PIPE_CONTROL << 30)
4701-
#define usb_rcvaddr0pipe() ((PIPE_CONTROL << 30) | USB_DIR_IN)
47024712

47034713
static int hub_set_address(struct usb_device *udev, int devnum)
47044714
{
@@ -4804,7 +4814,7 @@ static int get_bMaxPacketSize0(struct usb_device *udev,
48044814
for (i = 0; i < GET_MAXPACKET0_TRIES; ++i) {
48054815
/* Start with invalid values in case the transfer fails */
48064816
buf->bDescriptorType = buf->bMaxPacketSize0 = 0;
4807-
rc = usb_control_msg(udev, usb_rcvaddr0pipe(),
4817+
rc = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
48084818
USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
48094819
USB_DT_DEVICE << 8, 0,
48104820
buf, size,

drivers/usb/core/quirks.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,9 @@ static const struct usb_device_id usb_quirk_list[] = {
435435
{ USB_DEVICE(0x0c45, 0x7056), .driver_info =
436436
USB_QUIRK_IGNORE_REMOTE_WAKEUP },
437437

438+
/* Sony Xperia XZ1 Compact (lilac) smartphone in fastboot mode */
439+
{ USB_DEVICE(0x0fce, 0x0dde), .driver_info = USB_QUIRK_NO_LPM },
440+
438441
/* Action Semiconductor flash disk */
439442
{ USB_DEVICE(0x10d6, 0x2200), .driver_info =
440443
USB_QUIRK_STRING_FETCH_255 },
@@ -525,6 +528,9 @@ static const struct usb_device_id usb_quirk_list[] = {
525528
/* Blackmagic Design UltraStudio SDI */
526529
{ USB_DEVICE(0x1edb, 0xbd4f), .driver_info = USB_QUIRK_NO_LPM },
527530

531+
/* Teclast disk */
532+
{ USB_DEVICE(0x1f75, 0x0917), .driver_info = USB_QUIRK_NO_LPM },
533+
528534
/* Hauppauge HVR-950q */
529535
{ USB_DEVICE(0x2040, 0x7200), .driver_info =
530536
USB_QUIRK_CONFIG_INTF_STRINGS },

drivers/usb/dwc2/gadget.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4615,6 +4615,7 @@ static int dwc2_hsotg_udc_stop(struct usb_gadget *gadget)
46154615
spin_lock_irqsave(&hsotg->lock, flags);
46164616

46174617
hsotg->driver = NULL;
4618+
hsotg->gadget.dev.of_node = NULL;
46184619
hsotg->gadget.speed = USB_SPEED_UNKNOWN;
46194620
hsotg->enabled = 0;
46204621

drivers/usb/dwc3/core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ struct dwc3_event_buffer {
717717
/**
718718
* struct dwc3_ep - device side endpoint representation
719719
* @endpoint: usb endpoint
720+
* @nostream_work: work for handling bulk NoStream
720721
* @cancelled_list: list of cancelled requests for this endpoint
721722
* @pending_list: list of pending requests for this endpoint
722723
* @started_list: list of started requests on this endpoint

drivers/usb/dwc3/gadget.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2629,10 +2629,38 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on)
26292629
{
26302630
u32 reg;
26312631
u32 timeout = 2000;
2632+
u32 saved_config = 0;
26322633

26332634
if (pm_runtime_suspended(dwc->dev))
26342635
return 0;
26352636

2637+
/*
2638+
* When operating in USB 2.0 speeds (HS/FS), ensure that
2639+
* GUSB2PHYCFG.ENBLSLPM and GUSB2PHYCFG.SUSPHY are cleared before starting
2640+
* or stopping the controller. This resolves timeout issues that occur
2641+
* during frequent role switches between host and device modes.
2642+
*
2643+
* Save and clear these settings, then restore them after completing the
2644+
* controller start or stop sequence.
2645+
*
2646+
* This solution was discovered through experimentation as it is not
2647+
* mentioned in the dwc3 programming guide. It has been tested on an
2648+
* Exynos platforms.
2649+
*/
2650+
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
2651+
if (reg & DWC3_GUSB2PHYCFG_SUSPHY) {
2652+
saved_config |= DWC3_GUSB2PHYCFG_SUSPHY;
2653+
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
2654+
}
2655+
2656+
if (reg & DWC3_GUSB2PHYCFG_ENBLSLPM) {
2657+
saved_config |= DWC3_GUSB2PHYCFG_ENBLSLPM;
2658+
reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM;
2659+
}
2660+
2661+
if (saved_config)
2662+
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
2663+
26362664
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
26372665
if (is_on) {
26382666
if (DWC3_VER_IS_WITHIN(DWC3, ANY, 187A)) {
@@ -2660,6 +2688,12 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on)
26602688
reg &= DWC3_DSTS_DEVCTRLHLT;
26612689
} while (--timeout && !(!is_on ^ !reg));
26622690

2691+
if (saved_config) {
2692+
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
2693+
reg |= saved_config;
2694+
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
2695+
}
2696+
26632697
if (!timeout)
26642698
return -ETIMEDOUT;
26652699

drivers/usb/gadget/function/f_midi.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ f_midi_complete(struct usb_ep *ep, struct usb_request *req)
283283
/* Our transmit completed. See if there's more to go.
284284
* f_midi_transmit eats req, don't queue it again. */
285285
req->length = 0;
286-
f_midi_transmit(midi);
286+
queue_work(system_highpri_wq, &midi->work);
287287
return;
288288
}
289289
break;
@@ -907,6 +907,15 @@ static int f_midi_bind(struct usb_configuration *c, struct usb_function *f)
907907

908908
status = -ENODEV;
909909

910+
/*
911+
* Reset wMaxPacketSize with maximum packet size of FS bulk transfer before
912+
* endpoint claim. This ensures that the wMaxPacketSize does not exceed the
913+
* limit during bind retries where configured dwc3 TX/RX FIFO's maxpacket
914+
* size of 512 bytes for IN/OUT endpoints in support HS speed only.
915+
*/
916+
bulk_in_desc.wMaxPacketSize = cpu_to_le16(64);
917+
bulk_out_desc.wMaxPacketSize = cpu_to_le16(64);
918+
910919
/* allocate instance-specific endpoints */
911920
midi->in_ep = usb_ep_autoconfig(cdev->gadget, &bulk_in_desc);
912921
if (!midi->in_ep)
@@ -1000,11 +1009,11 @@ static int f_midi_bind(struct usb_configuration *c, struct usb_function *f)
10001009
}
10011010

10021011
/* configure the endpoint descriptors ... */
1003-
ms_out_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->in_ports);
1004-
ms_out_desc.bNumEmbMIDIJack = midi->in_ports;
1012+
ms_out_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->out_ports);
1013+
ms_out_desc.bNumEmbMIDIJack = midi->out_ports;
10051014

1006-
ms_in_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->out_ports);
1007-
ms_in_desc.bNumEmbMIDIJack = midi->out_ports;
1015+
ms_in_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->in_ports);
1016+
ms_in_desc.bNumEmbMIDIJack = midi->in_ports;
10081017

10091018
/* ... and add them to the list */
10101019
endpoint_descriptor_index = i;

drivers/usb/gadget/function/uvc_video.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ int uvcg_video_init(struct uvc_video *video, struct uvc_device *uvc)
818818
return -EINVAL;
819819

820820
/* Allocate a kthread for asynchronous hw submit handler. */
821-
video->kworker = kthread_create_worker(0, "UVCG");
821+
video->kworker = kthread_run_worker(0, "UVCG");
822822
if (IS_ERR(video->kworker)) {
823823
uvcg_err(&video->uvc->func, "failed to create UVCG kworker\n");
824824
return PTR_ERR(video->kworker);

drivers/usb/gadget/udc/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1543,8 +1543,8 @@ void usb_del_gadget(struct usb_gadget *gadget)
15431543

15441544
kobject_uevent(&udc->dev.kobj, KOBJ_REMOVE);
15451545
sysfs_remove_link(&udc->dev.kobj, "gadget");
1546-
flush_work(&gadget->work);
15471546
device_del(&gadget->dev);
1547+
flush_work(&gadget->work);
15481548
ida_free(&gadget_id_numbers, gadget->id_number);
15491549
cancel_work_sync(&udc->vbus_work);
15501550
device_unregister(&udc->dev);

drivers/usb/gadget/udc/renesas_usb3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ struct renesas_usb3_request {
310310
struct list_head queue;
311311
};
312312

313-
#define USB3_EP_NAME_SIZE 8
313+
#define USB3_EP_NAME_SIZE 16
314314
struct renesas_usb3_ep {
315315
struct usb_ep ep;
316316
struct renesas_usb3 *usb3;

drivers/usb/host/pci-quirks.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,15 @@ static void quirk_usb_disable_ehci(struct pci_dev *pdev)
958958
* booting from USB disk or using a usb keyboard
959959
*/
960960
hcc_params = readl(base + EHCI_HCC_PARAMS);
961+
962+
/* LS7A EHCI controller doesn't have extended capabilities, the
963+
* EECP (EHCI Extended Capabilities Pointer) field of HCCPARAMS
964+
* register should be 0x0 but it reads as 0xa0. So clear it to
965+
* avoid error messages on boot.
966+
*/
967+
if (pdev->vendor == PCI_VENDOR_ID_LOONGSON && pdev->device == 0x7a14)
968+
hcc_params &= ~(0xffL << 8);
969+
961970
offset = (hcc_params >> 8) & 0xff;
962971
while (offset && --count) {
963972
pci_read_config_dword(pdev, offset, &cap);

drivers/usb/host/xhci-pci.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -653,16 +653,17 @@ int xhci_pci_common_probe(struct pci_dev *dev, const struct pci_device_id *id)
653653
}
654654
EXPORT_SYMBOL_NS_GPL(xhci_pci_common_probe, "xhci");
655655

656-
static const struct pci_device_id pci_ids_reject[] = {
657-
/* handled by xhci-pci-renesas */
656+
/* handled by xhci-pci-renesas if enabled */
657+
static const struct pci_device_id pci_ids_renesas[] = {
658658
{ PCI_DEVICE(PCI_VENDOR_ID_RENESAS, 0x0014) },
659659
{ PCI_DEVICE(PCI_VENDOR_ID_RENESAS, 0x0015) },
660660
{ /* end: all zeroes */ }
661661
};
662662

663663
static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
664664
{
665-
if (pci_match_id(pci_ids_reject, dev))
665+
if (IS_ENABLED(CONFIG_USB_XHCI_PCI_RENESAS) &&
666+
pci_match_id(pci_ids_renesas, dev))
666667
return -ENODEV;
667668

668669
return xhci_pci_common_probe(dev, id);

drivers/usb/phy/phy-generic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop)
212212
if (of_property_read_u32(node, "clock-frequency", &clk_rate))
213213
clk_rate = 0;
214214

215-
needs_clk = of_property_read_bool(node, "clocks");
215+
needs_clk = of_property_present(node, "clocks");
216216
}
217217
nop->gpiod_reset = devm_gpiod_get_optional(dev, "reset",
218218
GPIOD_ASIS);

drivers/usb/roles/class.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,11 @@ usb_role_switch_register(struct device *parent,
387387
dev_set_name(&sw->dev, "%s-role-switch",
388388
desc->name ? desc->name : dev_name(parent));
389389

390+
sw->registered = true;
391+
390392
ret = device_register(&sw->dev);
391393
if (ret) {
394+
sw->registered = false;
392395
put_device(&sw->dev);
393396
return ERR_PTR(ret);
394397
}
@@ -399,8 +402,6 @@ usb_role_switch_register(struct device *parent,
399402
dev_warn(&sw->dev, "failed to add component\n");
400403
}
401404

402-
sw->registered = true;
403-
404405
/* TODO: Symlinks for the host port and the device controller. */
405406

406407
return sw;

0 commit comments

Comments
 (0)