Skip to content

Commit c24eb8d

Browse files
committed
Merge tag 'usb-5.19-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB driver fixes from Greg KH: "Here are some small USB driver fixes and new device ids for 5.19-rc4 for a few small reported issues. They include: - new usb-serial driver ids - MAINTAINERS file update to properly catch the USB dts files - dt-bindings fixes for reported build warnings - xhci driver fixes for reported problems - typec Kconfig dependancy fix - raw_gadget fuzzing fixes found by syzbot - chipidea driver bugfix - usb gadget uvc bugfix All of these have been in linux-next with no reported issues" * tag 'usb-5.19-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usb: chipidea: udc: check request status before setting device address USB: gadget: Fix double-free bug in raw_gadget driver xhci-pci: Allow host runtime PM as default for Intel Meteor Lake xHCI xhci-pci: Allow host runtime PM as default for Intel Raptor Lake xHCI xhci: turn off port power in shutdown xhci: Keep interrupt disabled in initialization until host is running. USB: serial: option: add Quectel RM500K module support USB: serial: option: add Quectel EM05-G modem USB: serial: pl2303: add support for more HXN (G) types usb: typec: wcove: Drop wrong dependency to INTEL_SOC_PMIC usb: gadget: uvc: fix list double add in uvcg_video_pump dt-bindings: usb: ehci: Increase the number of PHYs dt-bindings: usb: ohci: Increase the number of PHYs usb: gadget: Fix non-unique driver names in raw-gadget driver MAINTAINERS: add include/dt-bindings/usb to USB SUBSYSTEM USB: serial: option: add Telit LE910Cx 0x1250 composition
2 parents cb84318 + b24346a commit c24eb8d

File tree

13 files changed

+124
-48
lines changed

13 files changed

+124
-48
lines changed

Documentation/devicetree/bindings/usb/generic-ehci.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ properties:
136136
Phandle of a companion.
137137

138138
phys:
139-
maxItems: 1
139+
minItems: 1
140+
maxItems: 3
140141

141142
phy-names:
142143
const: usb

Documentation/devicetree/bindings/usb/generic-ohci.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ properties:
103103
Overrides the detected port count
104104

105105
phys:
106-
maxItems: 1
106+
minItems: 1
107+
maxItems: 3
107108

108109
phy-names:
109110
const: usb

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20749,6 +20749,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
2074920749
F: Documentation/devicetree/bindings/usb/
2075020750
F: Documentation/usb/
2075120751
F: drivers/usb/
20752+
F: include/dt-bindings/usb/
2075220753
F: include/linux/usb.h
2075320754
F: include/linux/usb/
2075420755

drivers/usb/chipidea/udc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,9 @@ isr_setup_status_complete(struct usb_ep *ep, struct usb_request *req)
10481048
struct ci_hdrc *ci = req->context;
10491049
unsigned long flags;
10501050

1051+
if (req->status < 0)
1052+
return;
1053+
10511054
if (ci->setaddr) {
10521055
hw_usb_set_address(ci, ci->address);
10531056
ci->setaddr = false;

drivers/usb/gadget/function/uvc_video.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,9 @@ static void uvcg_video_pump(struct work_struct *work)
424424
uvcg_queue_cancel(queue, 0);
425425
break;
426426
}
427+
428+
/* Endpoint now owns the request */
429+
req = NULL;
427430
video->req_int_count++;
428431
}
429432

drivers/usb/gadget/legacy/raw_gadget.c

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/ctype.h>
1212
#include <linux/debugfs.h>
1313
#include <linux/delay.h>
14+
#include <linux/idr.h>
1415
#include <linux/kref.h>
1516
#include <linux/miscdevice.h>
1617
#include <linux/module.h>
@@ -36,6 +37,9 @@ MODULE_LICENSE("GPL");
3637

3738
/*----------------------------------------------------------------------*/
3839

40+
static DEFINE_IDA(driver_id_numbers);
41+
#define DRIVER_DRIVER_NAME_LENGTH_MAX 32
42+
3943
#define RAW_EVENT_QUEUE_SIZE 16
4044

4145
struct raw_event_queue {
@@ -161,6 +165,9 @@ struct raw_dev {
161165
/* Reference to misc device: */
162166
struct device *dev;
163167

168+
/* Make driver names unique */
169+
int driver_id_number;
170+
164171
/* Protected by lock: */
165172
enum dev_state state;
166173
bool gadget_registered;
@@ -189,6 +196,7 @@ static struct raw_dev *dev_new(void)
189196
spin_lock_init(&dev->lock);
190197
init_completion(&dev->ep0_done);
191198
raw_event_queue_init(&dev->queue);
199+
dev->driver_id_number = -1;
192200
return dev;
193201
}
194202

@@ -199,6 +207,9 @@ static void dev_free(struct kref *kref)
199207

200208
kfree(dev->udc_name);
201209
kfree(dev->driver.udc_name);
210+
kfree(dev->driver.driver.name);
211+
if (dev->driver_id_number >= 0)
212+
ida_free(&driver_id_numbers, dev->driver_id_number);
202213
if (dev->req) {
203214
if (dev->ep0_urb_queued)
204215
usb_ep_dequeue(dev->gadget->ep0, dev->req);
@@ -419,9 +430,11 @@ static int raw_release(struct inode *inode, struct file *fd)
419430
static int raw_ioctl_init(struct raw_dev *dev, unsigned long value)
420431
{
421432
int ret = 0;
433+
int driver_id_number;
422434
struct usb_raw_init arg;
423435
char *udc_driver_name;
424436
char *udc_device_name;
437+
char *driver_driver_name;
425438
unsigned long flags;
426439

427440
if (copy_from_user(&arg, (void __user *)value, sizeof(arg)))
@@ -440,36 +453,43 @@ static int raw_ioctl_init(struct raw_dev *dev, unsigned long value)
440453
return -EINVAL;
441454
}
442455

456+
driver_id_number = ida_alloc(&driver_id_numbers, GFP_KERNEL);
457+
if (driver_id_number < 0)
458+
return driver_id_number;
459+
460+
driver_driver_name = kmalloc(DRIVER_DRIVER_NAME_LENGTH_MAX, GFP_KERNEL);
461+
if (!driver_driver_name) {
462+
ret = -ENOMEM;
463+
goto out_free_driver_id_number;
464+
}
465+
snprintf(driver_driver_name, DRIVER_DRIVER_NAME_LENGTH_MAX,
466+
DRIVER_NAME ".%d", driver_id_number);
467+
443468
udc_driver_name = kmalloc(UDC_NAME_LENGTH_MAX, GFP_KERNEL);
444-
if (!udc_driver_name)
445-
return -ENOMEM;
469+
if (!udc_driver_name) {
470+
ret = -ENOMEM;
471+
goto out_free_driver_driver_name;
472+
}
446473
ret = strscpy(udc_driver_name, &arg.driver_name[0],
447474
UDC_NAME_LENGTH_MAX);
448-
if (ret < 0) {
449-
kfree(udc_driver_name);
450-
return ret;
451-
}
475+
if (ret < 0)
476+
goto out_free_udc_driver_name;
452477
ret = 0;
453478

454479
udc_device_name = kmalloc(UDC_NAME_LENGTH_MAX, GFP_KERNEL);
455480
if (!udc_device_name) {
456-
kfree(udc_driver_name);
457-
return -ENOMEM;
481+
ret = -ENOMEM;
482+
goto out_free_udc_driver_name;
458483
}
459484
ret = strscpy(udc_device_name, &arg.device_name[0],
460485
UDC_NAME_LENGTH_MAX);
461-
if (ret < 0) {
462-
kfree(udc_driver_name);
463-
kfree(udc_device_name);
464-
return ret;
465-
}
486+
if (ret < 0)
487+
goto out_free_udc_device_name;
466488
ret = 0;
467489

468490
spin_lock_irqsave(&dev->lock, flags);
469491
if (dev->state != STATE_DEV_OPENED) {
470492
dev_dbg(dev->dev, "fail, device is not opened\n");
471-
kfree(udc_driver_name);
472-
kfree(udc_device_name);
473493
ret = -EINVAL;
474494
goto out_unlock;
475495
}
@@ -484,14 +504,25 @@ static int raw_ioctl_init(struct raw_dev *dev, unsigned long value)
484504
dev->driver.suspend = gadget_suspend;
485505
dev->driver.resume = gadget_resume;
486506
dev->driver.reset = gadget_reset;
487-
dev->driver.driver.name = DRIVER_NAME;
507+
dev->driver.driver.name = driver_driver_name;
488508
dev->driver.udc_name = udc_device_name;
489509
dev->driver.match_existing_only = 1;
510+
dev->driver_id_number = driver_id_number;
490511

491512
dev->state = STATE_DEV_INITIALIZED;
513+
spin_unlock_irqrestore(&dev->lock, flags);
514+
return ret;
492515

493516
out_unlock:
494517
spin_unlock_irqrestore(&dev->lock, flags);
518+
out_free_udc_device_name:
519+
kfree(udc_device_name);
520+
out_free_udc_driver_name:
521+
kfree(udc_driver_name);
522+
out_free_driver_driver_name:
523+
kfree(driver_driver_name);
524+
out_free_driver_id_number:
525+
ida_free(&driver_id_numbers, driver_id_number);
495526
return ret;
496527
}
497528

drivers/usb/host/xhci-hub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ struct xhci_hub *xhci_get_rhub(struct usb_hcd *hcd)
652652
* It will release and re-aquire the lock while calling ACPI
653653
* method.
654654
*/
655-
static void xhci_set_port_power(struct xhci_hcd *xhci, struct usb_hcd *hcd,
655+
void xhci_set_port_power(struct xhci_hcd *xhci, struct usb_hcd *hcd,
656656
u16 index, bool on, unsigned long *flags)
657657
__must_hold(&xhci->lock)
658658
{

drivers/usb/host/xhci-pci.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
#define PCI_DEVICE_ID_INTEL_ALDER_LAKE_XHCI 0x461e
6262
#define PCI_DEVICE_ID_INTEL_ALDER_LAKE_N_XHCI 0x464e
6363
#define PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI 0x51ed
64+
#define PCI_DEVICE_ID_INTEL_RAPTOR_LAKE_XHCI 0xa71e
65+
#define PCI_DEVICE_ID_INTEL_METEOR_LAKE_XHCI 0x7ec0
6466

6567
#define PCI_DEVICE_ID_AMD_RENOIR_XHCI 0x1639
6668
#define PCI_DEVICE_ID_AMD_PROMONTORYA_4 0x43b9
@@ -269,7 +271,9 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
269271
pdev->device == PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_XHCI ||
270272
pdev->device == PCI_DEVICE_ID_INTEL_ALDER_LAKE_XHCI ||
271273
pdev->device == PCI_DEVICE_ID_INTEL_ALDER_LAKE_N_XHCI ||
272-
pdev->device == PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI))
274+
pdev->device == PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI ||
275+
pdev->device == PCI_DEVICE_ID_INTEL_RAPTOR_LAKE_XHCI ||
276+
pdev->device == PCI_DEVICE_ID_INTEL_METEOR_LAKE_XHCI))
273277
xhci->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW;
274278

275279
if (pdev->vendor == PCI_VENDOR_ID_ETRON &&

drivers/usb/host/xhci.c

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -611,15 +611,37 @@ static int xhci_init(struct usb_hcd *hcd)
611611

612612
static int xhci_run_finished(struct xhci_hcd *xhci)
613613
{
614+
unsigned long flags;
615+
u32 temp;
616+
617+
/*
618+
* Enable interrupts before starting the host (xhci 4.2 and 5.5.2).
619+
* Protect the short window before host is running with a lock
620+
*/
621+
spin_lock_irqsave(&xhci->lock, flags);
622+
623+
xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Enable interrupts");
624+
temp = readl(&xhci->op_regs->command);
625+
temp |= (CMD_EIE);
626+
writel(temp, &xhci->op_regs->command);
627+
628+
xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Enable primary interrupter");
629+
temp = readl(&xhci->ir_set->irq_pending);
630+
writel(ER_IRQ_ENABLE(temp), &xhci->ir_set->irq_pending);
631+
614632
if (xhci_start(xhci)) {
615633
xhci_halt(xhci);
634+
spin_unlock_irqrestore(&xhci->lock, flags);
616635
return -ENODEV;
617636
}
637+
618638
xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
619639

620640
if (xhci->quirks & XHCI_NEC_HOST)
621641
xhci_ring_cmd_db(xhci);
622642

643+
spin_unlock_irqrestore(&xhci->lock, flags);
644+
623645
return 0;
624646
}
625647

@@ -668,19 +690,6 @@ int xhci_run(struct usb_hcd *hcd)
668690
temp |= (xhci->imod_interval / 250) & ER_IRQ_INTERVAL_MASK;
669691
writel(temp, &xhci->ir_set->irq_control);
670692

671-
/* Set the HCD state before we enable the irqs */
672-
temp = readl(&xhci->op_regs->command);
673-
temp |= (CMD_EIE);
674-
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
675-
"// Enable interrupts, cmd = 0x%x.", temp);
676-
writel(temp, &xhci->op_regs->command);
677-
678-
temp = readl(&xhci->ir_set->irq_pending);
679-
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
680-
"// Enabling event ring interrupter %p by writing 0x%x to irq_pending",
681-
xhci->ir_set, (unsigned int) ER_IRQ_ENABLE(temp));
682-
writel(ER_IRQ_ENABLE(temp), &xhci->ir_set->irq_pending);
683-
684693
if (xhci->quirks & XHCI_NEC_HOST) {
685694
struct xhci_command *command;
686695

@@ -782,6 +791,8 @@ static void xhci_stop(struct usb_hcd *hcd)
782791
void xhci_shutdown(struct usb_hcd *hcd)
783792
{
784793
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
794+
unsigned long flags;
795+
int i;
785796

786797
if (xhci->quirks & XHCI_SPURIOUS_REBOOT)
787798
usb_disable_xhci_ports(to_pci_dev(hcd->self.sysdev));
@@ -797,12 +808,21 @@ void xhci_shutdown(struct usb_hcd *hcd)
797808
del_timer_sync(&xhci->shared_hcd->rh_timer);
798809
}
799810

800-
spin_lock_irq(&xhci->lock);
811+
spin_lock_irqsave(&xhci->lock, flags);
801812
xhci_halt(xhci);
813+
814+
/* Power off USB2 ports*/
815+
for (i = 0; i < xhci->usb2_rhub.num_ports; i++)
816+
xhci_set_port_power(xhci, xhci->main_hcd, i, false, &flags);
817+
818+
/* Power off USB3 ports*/
819+
for (i = 0; i < xhci->usb3_rhub.num_ports; i++)
820+
xhci_set_port_power(xhci, xhci->shared_hcd, i, false, &flags);
821+
802822
/* Workaround for spurious wakeups at shutdown with HSW */
803823
if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
804824
xhci_reset(xhci, XHCI_RESET_SHORT_USEC);
805-
spin_unlock_irq(&xhci->lock);
825+
spin_unlock_irqrestore(&xhci->lock, flags);
806826

807827
xhci_cleanup_msix(xhci);
808828

drivers/usb/host/xhci.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2196,6 +2196,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex,
21962196
int xhci_hub_status_data(struct usb_hcd *hcd, char *buf);
21972197
int xhci_find_raw_port_number(struct usb_hcd *hcd, int port1);
21982198
struct xhci_hub *xhci_get_rhub(struct usb_hcd *hcd);
2199+
void xhci_set_port_power(struct xhci_hcd *xhci, struct usb_hcd *hcd, u16 index,
2200+
bool on, unsigned long *flags);
21992201

22002202
void xhci_hc_died(struct xhci_hcd *xhci);
22012203

0 commit comments

Comments
 (0)