Skip to content

Commit 2c01c3d

Browse files
committed
Merge tag 'usb-6.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are a handful of small USB driver fixes for 6.10-rc6 to resolve some reported issues. Included in here are: - typec driver bugfixes - usb gadget driver reverts for commits that were reported to have problems - resource leak bugfix - gadget driver bugfixes - dwc3 driver bugfixes - usb atm driver bugfix for when syzbot got loose on it All of these have been in linux-next this week with no reported issues" * tag 'usb-6.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usb: dwc3: core: Workaround for CSR read timeout Revert "usb: gadget: u_ether: Replace netif_stop_queue with netif_device_detach" Revert "usb: gadget: u_ether: Re-attach netif device to mirror detachment" usb: gadget: aspeed_udc: fix device address configuration usb: dwc3: core: remove lock of otg mode during gadget suspend/resume to avoid deadlock usb: typec: ucsi: glink: fix child node release in probe function usb: musb: da8xx: fix a resource leak in probe() usb: typec: ucsi_acpi: Add LG Gram quirk usb: ucsi: stm32: fix command completion handling usb: atm: cxacru: fix endpoint checking in cxacru_bind() usb: gadget: printer: fix races against disable usb: gadget: printer: SS+ support
2 parents 3ffea9a + fc1d1a7 commit 2c01c3d

File tree

9 files changed

+152
-29
lines changed

9 files changed

+152
-29
lines changed

drivers/usb/atm/cxacru.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,7 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
11311131
struct cxacru_data *instance;
11321132
struct usb_device *usb_dev = interface_to_usbdev(intf);
11331133
struct usb_host_endpoint *cmd_ep = usb_dev->ep_in[CXACRU_EP_CMD];
1134+
struct usb_endpoint_descriptor *in, *out;
11341135
int ret;
11351136

11361137
/* instance init */
@@ -1177,6 +1178,19 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
11771178
goto fail;
11781179
}
11791180

1181+
if (usb_endpoint_xfer_int(&cmd_ep->desc))
1182+
ret = usb_find_common_endpoints(intf->cur_altsetting,
1183+
NULL, NULL, &in, &out);
1184+
else
1185+
ret = usb_find_common_endpoints(intf->cur_altsetting,
1186+
&in, &out, NULL, NULL);
1187+
1188+
if (ret) {
1189+
usb_err(usbatm_instance, "cxacru_bind: interface has incorrect endpoints\n");
1190+
ret = -ENODEV;
1191+
goto fail;
1192+
}
1193+
11801194
if ((cmd_ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
11811195
== USB_ENDPOINT_XFER_INT) {
11821196
usb_fill_int_urb(instance->rcv_urb,

drivers/usb/dwc3/core.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -957,12 +957,16 @@ static bool dwc3_core_is_valid(struct dwc3 *dwc)
957957

958958
static void dwc3_core_setup_global_control(struct dwc3 *dwc)
959959
{
960+
unsigned int power_opt;
961+
unsigned int hw_mode;
960962
u32 reg;
961963

962964
reg = dwc3_readl(dwc->regs, DWC3_GCTL);
963965
reg &= ~DWC3_GCTL_SCALEDOWN_MASK;
966+
hw_mode = DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0);
967+
power_opt = DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1);
964968

965-
switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) {
969+
switch (power_opt) {
966970
case DWC3_GHWPARAMS1_EN_PWROPT_CLK:
967971
/**
968972
* WORKAROUND: DWC3 revisions between 2.10a and 2.50a have an
@@ -995,6 +999,20 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc)
995999
break;
9961000
}
9971001

1002+
/*
1003+
* This is a workaround for STAR#4846132, which only affects
1004+
* DWC_usb31 version2.00a operating in host mode.
1005+
*
1006+
* There is a problem in DWC_usb31 version 2.00a operating
1007+
* in host mode that would cause a CSR read timeout When CSR
1008+
* read coincides with RAM Clock Gating Entry. By disable
1009+
* Clock Gating, sacrificing power consumption for normal
1010+
* operation.
1011+
*/
1012+
if (power_opt != DWC3_GHWPARAMS1_EN_PWROPT_NO &&
1013+
hw_mode != DWC3_GHWPARAMS0_MODE_GADGET && DWC3_VER_IS(DWC31, 200A))
1014+
reg |= DWC3_GCTL_DSBLCLKGTNG;
1015+
9981016
/* check if current dwc3 is on simulation board */
9991017
if (dwc->hwparams.hwparams6 & DWC3_GHWPARAMS6_EN_FPGA) {
10001018
dev_info(dwc->dev, "Running with FPGA optimizations\n");
@@ -2250,7 +2268,6 @@ static int dwc3_core_init_for_resume(struct dwc3 *dwc)
22502268

22512269
static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
22522270
{
2253-
unsigned long flags;
22542271
u32 reg;
22552272
int i;
22562273

@@ -2293,9 +2310,7 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
22932310
break;
22942311

22952312
if (dwc->current_otg_role == DWC3_OTG_ROLE_DEVICE) {
2296-
spin_lock_irqsave(&dwc->lock, flags);
22972313
dwc3_gadget_suspend(dwc);
2298-
spin_unlock_irqrestore(&dwc->lock, flags);
22992314
synchronize_irq(dwc->irq_gadget);
23002315
}
23012316

@@ -2312,7 +2327,6 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
23122327

23132328
static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
23142329
{
2315-
unsigned long flags;
23162330
int ret;
23172331
u32 reg;
23182332
int i;
@@ -2366,9 +2380,7 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
23662380
if (dwc->current_otg_role == DWC3_OTG_ROLE_HOST) {
23672381
dwc3_otg_host_init(dwc);
23682382
} else if (dwc->current_otg_role == DWC3_OTG_ROLE_DEVICE) {
2369-
spin_lock_irqsave(&dwc->lock, flags);
23702383
dwc3_gadget_resume(dwc);
2371-
spin_unlock_irqrestore(&dwc->lock, flags);
23722384
}
23732385

23742386
break;

drivers/usb/gadget/function/f_printer.c

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ static inline struct usb_endpoint_descriptor *ep_desc(struct usb_gadget *gadget,
213213
struct usb_endpoint_descriptor *ss)
214214
{
215215
switch (gadget->speed) {
216+
case USB_SPEED_SUPER_PLUS:
216217
case USB_SPEED_SUPER:
217218
return ss;
218219
case USB_SPEED_HIGH:
@@ -449,18 +450,18 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr)
449450
mutex_lock(&dev->lock_printer_io);
450451
spin_lock_irqsave(&dev->lock, flags);
451452

452-
if (dev->interface < 0) {
453-
spin_unlock_irqrestore(&dev->lock, flags);
454-
mutex_unlock(&dev->lock_printer_io);
455-
return -ENODEV;
456-
}
453+
if (dev->interface < 0)
454+
goto out_disabled;
457455

458456
/* We will use this flag later to check if a printer reset happened
459457
* after we turn interrupts back on.
460458
*/
461459
dev->reset_printer = 0;
462460

463461
setup_rx_reqs(dev);
462+
/* this dropped the lock - need to retest */
463+
if (dev->interface < 0)
464+
goto out_disabled;
464465

465466
bytes_copied = 0;
466467
current_rx_req = dev->current_rx_req;
@@ -494,6 +495,8 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr)
494495
wait_event_interruptible(dev->rx_wait,
495496
(likely(!list_empty(&dev->rx_buffers))));
496497
spin_lock_irqsave(&dev->lock, flags);
498+
if (dev->interface < 0)
499+
goto out_disabled;
497500
}
498501

499502
/* We have data to return then copy it to the caller's buffer.*/
@@ -537,6 +540,9 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr)
537540
return -EAGAIN;
538541
}
539542

543+
if (dev->interface < 0)
544+
goto out_disabled;
545+
540546
/* If we not returning all the data left in this RX request
541547
* buffer then adjust the amount of data left in the buffer.
542548
* Othewise if we are done with this RX request buffer then
@@ -566,6 +572,11 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr)
566572
return bytes_copied;
567573
else
568574
return -EAGAIN;
575+
576+
out_disabled:
577+
spin_unlock_irqrestore(&dev->lock, flags);
578+
mutex_unlock(&dev->lock_printer_io);
579+
return -ENODEV;
569580
}
570581

571582
static ssize_t
@@ -586,11 +597,8 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
586597
mutex_lock(&dev->lock_printer_io);
587598
spin_lock_irqsave(&dev->lock, flags);
588599

589-
if (dev->interface < 0) {
590-
spin_unlock_irqrestore(&dev->lock, flags);
591-
mutex_unlock(&dev->lock_printer_io);
592-
return -ENODEV;
593-
}
600+
if (dev->interface < 0)
601+
goto out_disabled;
594602

595603
/* Check if a printer reset happens while we have interrupts on */
596604
dev->reset_printer = 0;
@@ -613,6 +621,8 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
613621
wait_event_interruptible(dev->tx_wait,
614622
(likely(!list_empty(&dev->tx_reqs))));
615623
spin_lock_irqsave(&dev->lock, flags);
624+
if (dev->interface < 0)
625+
goto out_disabled;
616626
}
617627

618628
while (likely(!list_empty(&dev->tx_reqs)) && len) {
@@ -662,6 +672,9 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
662672
return -EAGAIN;
663673
}
664674

675+
if (dev->interface < 0)
676+
goto out_disabled;
677+
665678
list_add(&req->list, &dev->tx_reqs_active);
666679

667680
/* here, we unlock, and only unlock, to avoid deadlock. */
@@ -674,6 +687,8 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
674687
mutex_unlock(&dev->lock_printer_io);
675688
return -EAGAIN;
676689
}
690+
if (dev->interface < 0)
691+
goto out_disabled;
677692
}
678693

679694
spin_unlock_irqrestore(&dev->lock, flags);
@@ -685,6 +700,11 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
685700
return bytes_copied;
686701
else
687702
return -EAGAIN;
703+
704+
out_disabled:
705+
spin_unlock_irqrestore(&dev->lock, flags);
706+
mutex_unlock(&dev->lock_printer_io);
707+
return -ENODEV;
688708
}
689709

690710
static int

drivers/usb/gadget/function/u_ether.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,8 +1163,6 @@ struct net_device *gether_connect(struct gether *link)
11631163
if (netif_running(dev->net))
11641164
eth_start(dev, GFP_ATOMIC);
11651165

1166-
netif_device_attach(dev->net);
1167-
11681166
/* on error, disable any endpoints */
11691167
} else {
11701168
(void) usb_ep_disable(link->out_ep);
@@ -1202,7 +1200,7 @@ void gether_disconnect(struct gether *link)
12021200

12031201
DBG(dev, "%s\n", __func__);
12041202

1205-
netif_device_detach(dev->net);
1203+
netif_stop_queue(dev->net);
12061204
netif_carrier_off(dev->net);
12071205

12081206
/* disable endpoints, forcing (synchronous) completion

drivers/usb/gadget/udc/aspeed_udc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@
6666
#define USB_UPSTREAM_EN BIT(0)
6767

6868
/* Main config reg */
69-
#define UDC_CFG_SET_ADDR(x) ((x) & 0x3f)
70-
#define UDC_CFG_ADDR_MASK (0x3f)
69+
#define UDC_CFG_SET_ADDR(x) ((x) & UDC_CFG_ADDR_MASK)
70+
#define UDC_CFG_ADDR_MASK GENMASK(6, 0)
7171

7272
/* Interrupt ctrl & status reg */
7373
#define UDC_IRQ_EP_POOL_NAK BIT(17)

drivers/usb/musb/da8xx.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ static int da8xx_probe(struct platform_device *pdev)
556556
ret = of_platform_populate(pdev->dev.of_node, NULL,
557557
da8xx_auxdata_lookup, &pdev->dev);
558558
if (ret)
559-
return ret;
559+
goto err_unregister_phy;
560560

561561
pinfo = da8xx_dev_info;
562562
pinfo.parent = &pdev->dev;
@@ -571,9 +571,13 @@ static int da8xx_probe(struct platform_device *pdev)
571571
ret = PTR_ERR_OR_ZERO(glue->musb);
572572
if (ret) {
573573
dev_err(&pdev->dev, "failed to register musb device: %d\n", ret);
574-
usb_phy_generic_unregister(glue->usb_phy);
574+
goto err_unregister_phy;
575575
}
576576

577+
return 0;
578+
579+
err_unregister_phy:
580+
usb_phy_generic_unregister(glue->usb_phy);
577581
return ret;
578582
}
579583

drivers/usb/typec/ucsi/ucsi_acpi.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct ucsi_acpi {
2525
unsigned long flags;
2626
#define UCSI_ACPI_COMMAND_PENDING 1
2727
#define UCSI_ACPI_ACK_PENDING 2
28+
#define UCSI_ACPI_CHECK_BOGUS_EVENT 3
2829
guid_t guid;
2930
u64 cmd;
3031
};
@@ -128,6 +129,58 @@ static const struct ucsi_operations ucsi_zenbook_ops = {
128129
.async_write = ucsi_acpi_async_write
129130
};
130131

132+
static int ucsi_gram_read(struct ucsi *ucsi, unsigned int offset,
133+
void *val, size_t val_len)
134+
{
135+
u16 bogus_change = UCSI_CONSTAT_POWER_LEVEL_CHANGE |
136+
UCSI_CONSTAT_PDOS_CHANGE;
137+
struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi);
138+
struct ucsi_connector_status *status;
139+
int ret;
140+
141+
ret = ucsi_acpi_read(ucsi, offset, val, val_len);
142+
if (ret < 0)
143+
return ret;
144+
145+
if (UCSI_COMMAND(ua->cmd) == UCSI_GET_CONNECTOR_STATUS &&
146+
test_bit(UCSI_ACPI_CHECK_BOGUS_EVENT, &ua->flags) &&
147+
offset == UCSI_MESSAGE_IN) {
148+
status = (struct ucsi_connector_status *)val;
149+
150+
/* Clear the bogus change */
151+
if (status->change == bogus_change)
152+
status->change = 0;
153+
154+
clear_bit(UCSI_ACPI_CHECK_BOGUS_EVENT, &ua->flags);
155+
}
156+
157+
return ret;
158+
}
159+
160+
static int ucsi_gram_sync_write(struct ucsi *ucsi, unsigned int offset,
161+
const void *val, size_t val_len)
162+
{
163+
struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi);
164+
int ret;
165+
166+
ret = ucsi_acpi_sync_write(ucsi, offset, val, val_len);
167+
if (ret < 0)
168+
return ret;
169+
170+
if (UCSI_COMMAND(ua->cmd) == UCSI_GET_PDOS &&
171+
ua->cmd & UCSI_GET_PDOS_PARTNER_PDO(1) &&
172+
ua->cmd & UCSI_GET_PDOS_SRC_PDOS)
173+
set_bit(UCSI_ACPI_CHECK_BOGUS_EVENT, &ua->flags);
174+
175+
return ret;
176+
}
177+
178+
static const struct ucsi_operations ucsi_gram_ops = {
179+
.read = ucsi_gram_read,
180+
.sync_write = ucsi_gram_sync_write,
181+
.async_write = ucsi_acpi_async_write
182+
};
183+
131184
static const struct dmi_system_id ucsi_acpi_quirks[] = {
132185
{
133186
.matches = {
@@ -136,6 +189,14 @@ static const struct dmi_system_id ucsi_acpi_quirks[] = {
136189
},
137190
.driver_data = (void *)&ucsi_zenbook_ops,
138191
},
192+
{
193+
.matches = {
194+
DMI_MATCH(DMI_SYS_VENDOR, "LG Electronics"),
195+
DMI_MATCH(DMI_PRODUCT_FAMILY, "LG gram PC"),
196+
DMI_MATCH(DMI_PRODUCT_NAME, "90Q"),
197+
},
198+
.driver_data = (void *)&ucsi_gram_ops,
199+
},
139200
{ }
140201
};
141202

drivers/usb/typec/ucsi/ucsi_glink.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ static int pmic_glink_ucsi_probe(struct auxiliary_device *adev,
372372
ret = fwnode_property_read_u32(fwnode, "reg", &port);
373373
if (ret < 0) {
374374
dev_err(dev, "missing reg property of %pOFn\n", fwnode);
375+
fwnode_handle_put(fwnode);
375376
return ret;
376377
}
377378

@@ -386,9 +387,11 @@ static int pmic_glink_ucsi_probe(struct auxiliary_device *adev,
386387
if (!desc)
387388
continue;
388389

389-
if (IS_ERR(desc))
390+
if (IS_ERR(desc)) {
391+
fwnode_handle_put(fwnode);
390392
return dev_err_probe(dev, PTR_ERR(desc),
391393
"unable to acquire orientation gpio\n");
394+
}
392395
ucsi->port_orientation[port] = desc;
393396
}
394397

0 commit comments

Comments
 (0)