Skip to content

Commit 809be62

Browse files
committed
Merge tag 'usb-6.8-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB driver fixes from Greg KH: "Here are a bunch of small USB driver fixes for 6.8-rc3. Included in here are: - new usb-serial driver ids - new dwc3 driver id added - typec driver change revert - ncm gadget driver endian bugfix - xhci bugfixes for a number of reported issues - usb hub bugfix for alternate settings - ulpi driver debugfs memory leak fix - chipidea driver bugfix - usb gadget driver fixes All of these have been in linux-next for a while with no reported issues" * tag 'usb-6.8-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (24 commits) USB: serial: option: add Fibocom FM101-GL variant USB: serial: qcserial: add new usb-id for Dell Wireless DW5826e USB: serial: cp210x: add ID for IMST iM871A-USB usb: typec: tcpm: fix the PD disabled case usb: ucsi_acpi: Quirk to ack a connector change ack cmd usb: ucsi_acpi: Fix command completion handling usb: ucsi: Add missing ppm_lock usb: ulpi: Fix debugfs directory leak Revert "usb: typec: tcpm: fix cc role at port reset" usb: gadget: pch_udc: fix an Excess kernel-doc warning usb: f_mass_storage: forbid async queue when shutdown happen USB: hub: check for alternate port before enabling A_ALT_HNP_SUPPORT usb: chipidea: core: handle power lost in workqueue usb: dwc3: gadget: Fix NULL pointer dereference in dwc3_gadget_suspend usb: dwc3: pci: add support for the Intel Arrow Lake-H usb: core: Prevent null pointer dereference in update_port_device_state xhci: handle isoc Babble and Buffer Overrun events properly xhci: process isoc TD properly when there was a transaction error mid TD. xhci: fix off by one check when adding a secondary interrupter. xhci: fix possible null pointer dereference at secondary interrupter removal ...
2 parents bdda52c + ad834c7 commit 809be62

File tree

21 files changed

+267
-90
lines changed

21 files changed

+267
-90
lines changed

Documentation/usb/gadget-testing.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -448,17 +448,17 @@ Function-specific configfs interface
448448
The function name to use when creating the function directory is "ncm".
449449
The NCM function provides these attributes in its function directory:
450450

451-
=============== ==================================================
452-
ifname network device interface name associated with this
453-
function instance
454-
qmult queue length multiplier for high and super speed
455-
host_addr MAC address of host's end of this
456-
Ethernet over USB link
457-
dev_addr MAC address of device's end of this
458-
Ethernet over USB link
459-
max_segment_size Segment size required for P2P connections. This
460-
will set MTU to (max_segment_size - 14 bytes)
461-
=============== ==================================================
451+
======================= ==================================================
452+
ifname network device interface name associated with this
453+
function instance
454+
qmult queue length multiplier for high and super speed
455+
host_addr MAC address of host's end of this
456+
Ethernet over USB link
457+
dev_addr MAC address of device's end of this
458+
Ethernet over USB link
459+
max_segment_size Segment size required for P2P connections. This
460+
will set MTU to 14 bytes
461+
======================= ==================================================
462462

463463
and after creating the functions/ncm.<instance name> they contain default
464464
values: qmult is 5, dev_addr and host_addr are randomly selected.

drivers/usb/chipidea/ci.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ struct hw_bank {
176176
* @enabled_otg_timer_bits: bits of enabled otg timers
177177
* @next_otg_timer: next nearest enabled timer to be expired
178178
* @work: work for role changing
179+
* @power_lost_work: work for power lost handling
179180
* @wq: workqueue thread
180181
* @qh_pool: allocation pool for queue heads
181182
* @td_pool: allocation pool for transfer descriptors
@@ -226,6 +227,7 @@ struct ci_hdrc {
226227
enum otg_fsm_timer next_otg_timer;
227228
struct usb_role_switch *role_switch;
228229
struct work_struct work;
230+
struct work_struct power_lost_work;
229231
struct workqueue_struct *wq;
230232

231233
struct dma_pool *qh_pool;

drivers/usb/chipidea/core.c

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,27 @@ static int ci_extcon_register(struct ci_hdrc *ci)
856856
return 0;
857857
}
858858

859+
static void ci_power_lost_work(struct work_struct *work)
860+
{
861+
struct ci_hdrc *ci = container_of(work, struct ci_hdrc, power_lost_work);
862+
enum ci_role role;
863+
864+
disable_irq_nosync(ci->irq);
865+
pm_runtime_get_sync(ci->dev);
866+
if (!ci_otg_is_fsm_mode(ci)) {
867+
role = ci_get_role(ci);
868+
869+
if (ci->role != role) {
870+
ci_handle_id_switch(ci);
871+
} else if (role == CI_ROLE_GADGET) {
872+
if (ci->is_otg && hw_read_otgsc(ci, OTGSC_BSV))
873+
usb_gadget_vbus_connect(&ci->gadget);
874+
}
875+
}
876+
pm_runtime_put_sync(ci->dev);
877+
enable_irq(ci->irq);
878+
}
879+
859880
static DEFINE_IDA(ci_ida);
860881

861882
struct platform_device *ci_hdrc_add_device(struct device *dev,
@@ -1045,6 +1066,8 @@ static int ci_hdrc_probe(struct platform_device *pdev)
10451066

10461067
spin_lock_init(&ci->lock);
10471068
mutex_init(&ci->mutex);
1069+
INIT_WORK(&ci->power_lost_work, ci_power_lost_work);
1070+
10481071
ci->dev = dev;
10491072
ci->platdata = dev_get_platdata(dev);
10501073
ci->imx28_write_fix = !!(ci->platdata->flags &
@@ -1396,25 +1419,6 @@ static int ci_suspend(struct device *dev)
13961419
return 0;
13971420
}
13981421

1399-
static void ci_handle_power_lost(struct ci_hdrc *ci)
1400-
{
1401-
enum ci_role role;
1402-
1403-
disable_irq_nosync(ci->irq);
1404-
if (!ci_otg_is_fsm_mode(ci)) {
1405-
role = ci_get_role(ci);
1406-
1407-
if (ci->role != role) {
1408-
ci_handle_id_switch(ci);
1409-
} else if (role == CI_ROLE_GADGET) {
1410-
if (ci->is_otg && hw_read_otgsc(ci, OTGSC_BSV))
1411-
usb_gadget_vbus_connect(&ci->gadget);
1412-
}
1413-
}
1414-
1415-
enable_irq(ci->irq);
1416-
}
1417-
14181422
static int ci_resume(struct device *dev)
14191423
{
14201424
struct ci_hdrc *ci = dev_get_drvdata(dev);
@@ -1446,7 +1450,7 @@ static int ci_resume(struct device *dev)
14461450
ci_role(ci)->resume(ci, power_lost);
14471451

14481452
if (power_lost)
1449-
ci_handle_power_lost(ci);
1453+
queue_work(system_freezable_wq, &ci->power_lost_work);
14501454

14511455
if (ci->supports_runtime_pm) {
14521456
pm_runtime_disable(dev);

drivers/usb/common/ulpi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi)
301301
return ret;
302302
}
303303

304-
root = debugfs_create_dir(dev_name(dev), ulpi_root);
304+
root = debugfs_create_dir(dev_name(&ulpi->dev), ulpi_root);
305305
debugfs_create_file("regs", 0444, root, ulpi, &ulpi_regs_fops);
306306

307307
dev_dbg(&ulpi->dev, "registered ULPI PHY: vendor %04x, product %04x\n",

drivers/usb/core/hub.c

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,9 +2053,19 @@ static void update_port_device_state(struct usb_device *udev)
20532053

20542054
if (udev->parent) {
20552055
hub = usb_hub_to_struct_hub(udev->parent);
2056-
port_dev = hub->ports[udev->portnum - 1];
2057-
WRITE_ONCE(port_dev->state, udev->state);
2058-
sysfs_notify_dirent(port_dev->state_kn);
2056+
2057+
/*
2058+
* The Link Layer Validation System Driver (lvstest)
2059+
* has a test step to unbind the hub before running the
2060+
* rest of the procedure. This triggers hub_disconnect
2061+
* which will set the hub's maxchild to 0, further
2062+
* resulting in usb_hub_to_struct_hub returning NULL.
2063+
*/
2064+
if (hub) {
2065+
port_dev = hub->ports[udev->portnum - 1];
2066+
WRITE_ONCE(port_dev->state, udev->state);
2067+
sysfs_notify_dirent(port_dev->state_kn);
2068+
}
20592069
}
20602070
}
20612071

@@ -2388,17 +2398,25 @@ static int usb_enumerate_device_otg(struct usb_device *udev)
23882398
}
23892399
} else if (desc->bLength == sizeof
23902400
(struct usb_otg_descriptor)) {
2391-
/* Set a_alt_hnp_support for legacy otg device */
2392-
err = usb_control_msg(udev,
2393-
usb_sndctrlpipe(udev, 0),
2394-
USB_REQ_SET_FEATURE, 0,
2395-
USB_DEVICE_A_ALT_HNP_SUPPORT,
2396-
0, NULL, 0,
2397-
USB_CTRL_SET_TIMEOUT);
2398-
if (err < 0)
2399-
dev_err(&udev->dev,
2400-
"set a_alt_hnp_support failed: %d\n",
2401-
err);
2401+
/*
2402+
* We are operating on a legacy OTP device
2403+
* These should be told that they are operating
2404+
* on the wrong port if we have another port that does
2405+
* support HNP
2406+
*/
2407+
if (bus->otg_port != 0) {
2408+
/* Set a_alt_hnp_support for legacy otg device */
2409+
err = usb_control_msg(udev,
2410+
usb_sndctrlpipe(udev, 0),
2411+
USB_REQ_SET_FEATURE, 0,
2412+
USB_DEVICE_A_ALT_HNP_SUPPORT,
2413+
0, NULL, 0,
2414+
USB_CTRL_SET_TIMEOUT);
2415+
if (err < 0)
2416+
dev_err(&udev->dev,
2417+
"set a_alt_hnp_support failed: %d\n",
2418+
err);
2419+
}
24022420
}
24032421
}
24042422
#endif

drivers/usb/dwc3/dwc3-pci.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
#define PCI_DEVICE_ID_INTEL_MTLP 0x7ec1
5252
#define PCI_DEVICE_ID_INTEL_MTLS 0x7f6f
5353
#define PCI_DEVICE_ID_INTEL_MTL 0x7e7e
54+
#define PCI_DEVICE_ID_INTEL_ARLH 0x7ec1
55+
#define PCI_DEVICE_ID_INTEL_ARLH_PCH 0x777e
5456
#define PCI_DEVICE_ID_INTEL_TGL 0x9a15
5557
#define PCI_DEVICE_ID_AMD_MR 0x163a
5658

@@ -421,6 +423,8 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
421423
{ PCI_DEVICE_DATA(INTEL, MTLP, &dwc3_pci_intel_swnode) },
422424
{ PCI_DEVICE_DATA(INTEL, MTL, &dwc3_pci_intel_swnode) },
423425
{ PCI_DEVICE_DATA(INTEL, MTLS, &dwc3_pci_intel_swnode) },
426+
{ PCI_DEVICE_DATA(INTEL, ARLH, &dwc3_pci_intel_swnode) },
427+
{ PCI_DEVICE_DATA(INTEL, ARLH_PCH, &dwc3_pci_intel_swnode) },
424428
{ PCI_DEVICE_DATA(INTEL, TGL, &dwc3_pci_intel_swnode) },
425429

426430
{ PCI_DEVICE_DATA(AMD, NL_USB, &dwc3_pci_amd_swnode) },

drivers/usb/dwc3/gadget.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4709,15 +4709,13 @@ int dwc3_gadget_suspend(struct dwc3 *dwc)
47094709
unsigned long flags;
47104710
int ret;
47114711

4712-
if (!dwc->gadget_driver)
4713-
return 0;
4714-
47154712
ret = dwc3_gadget_soft_disconnect(dwc);
47164713
if (ret)
47174714
goto err;
47184715

47194716
spin_lock_irqsave(&dwc->lock, flags);
4720-
dwc3_disconnect_gadget(dwc);
4717+
if (dwc->gadget_driver)
4718+
dwc3_disconnect_gadget(dwc);
47214719
spin_unlock_irqrestore(&dwc->lock, flags);
47224720

47234721
return 0;

drivers/usb/dwc3/host.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static int dwc3_host_get_irq(struct dwc3 *dwc)
6161

6262
int dwc3_host_init(struct dwc3 *dwc)
6363
{
64-
struct property_entry props[4];
64+
struct property_entry props[5];
6565
struct platform_device *xhci;
6666
int ret, irq;
6767
int prop_idx = 0;
@@ -89,6 +89,8 @@ int dwc3_host_init(struct dwc3 *dwc)
8989

9090
memset(props, 0, sizeof(struct property_entry) * ARRAY_SIZE(props));
9191

92+
props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-sg-trb-cache-size-quirk");
93+
9294
if (dwc->usb3_lpm_capable)
9395
props[prop_idx++] = PROPERTY_ENTRY_BOOL("usb3-lpm-capable");
9496

drivers/usb/gadget/function/f_mass_storage.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,21 +545,37 @@ static int start_transfer(struct fsg_dev *fsg, struct usb_ep *ep,
545545

546546
static bool start_in_transfer(struct fsg_common *common, struct fsg_buffhd *bh)
547547
{
548+
int rc;
549+
548550
if (!fsg_is_set(common))
549551
return false;
550552
bh->state = BUF_STATE_SENDING;
551-
if (start_transfer(common->fsg, common->fsg->bulk_in, bh->inreq))
553+
rc = start_transfer(common->fsg, common->fsg->bulk_in, bh->inreq);
554+
if (rc) {
552555
bh->state = BUF_STATE_EMPTY;
556+
if (rc == -ESHUTDOWN) {
557+
common->running = 0;
558+
return false;
559+
}
560+
}
553561
return true;
554562
}
555563

556564
static bool start_out_transfer(struct fsg_common *common, struct fsg_buffhd *bh)
557565
{
566+
int rc;
567+
558568
if (!fsg_is_set(common))
559569
return false;
560570
bh->state = BUF_STATE_RECEIVING;
561-
if (start_transfer(common->fsg, common->fsg->bulk_out, bh->outreq))
571+
rc = start_transfer(common->fsg, common->fsg->bulk_out, bh->outreq);
572+
if (rc) {
562573
bh->state = BUF_STATE_FULL;
574+
if (rc == -ESHUTDOWN) {
575+
common->running = 0;
576+
return false;
577+
}
578+
}
563579
return true;
564580
}
565581

drivers/usb/gadget/function/f_ncm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ static inline struct f_ncm *func_to_ncm(struct usb_function *f)
105105

106106
/*
107107
* Although max mtu as dictated by u_ether is 15412 bytes, setting
108-
* max_segment_sizeto 15426 would not be efficient. If user chooses segment
109-
* size to be (>= 8192), then we can't aggregate more than one buffer in each
108+
* max_segment_size to 15426 would not be efficient. If user chooses segment
109+
* size to be (>= 8192), then we can't aggregate more than one buffer in each
110110
* NTB (assuming each packet coming from network layer is >= 8192 bytes) as ep
111111
* maxpacket limit is 16384. So let max_segment_size be limited to 8000 to allow
112112
* at least 2 packets to be aggregated reducing wastage of NTB buffer space
@@ -1489,7 +1489,7 @@ static int ncm_bind(struct usb_configuration *c, struct usb_function *f)
14891489
ncm_data_intf.bInterfaceNumber = status;
14901490
ncm_union_desc.bSlaveInterface0 = status;
14911491

1492-
ecm_desc.wMaxSegmentSize = ncm_opts->max_segment_size;
1492+
ecm_desc.wMaxSegmentSize = cpu_to_le16(ncm_opts->max_segment_size);
14931493

14941494
status = -ENODEV;
14951495

@@ -1685,7 +1685,7 @@ static struct usb_function_instance *ncm_alloc_inst(void)
16851685
kfree(opts);
16861686
return ERR_CAST(net);
16871687
}
1688-
opts->max_segment_size = cpu_to_le16(ETH_FRAME_LEN);
1688+
opts->max_segment_size = ETH_FRAME_LEN;
16891689
INIT_LIST_HEAD(&opts->ncm_os_desc.ext_prop);
16901690

16911691
descs[0] = &opts->ncm_os_desc;

0 commit comments

Comments
 (0)