Skip to content

Commit e67da28

Browse files
committed
Merge tag 'usb-6.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB / Thunderbolt fixes from Greg KH: "Here are a number of small USB and Thunderbolt driver fixes and new device id changes for 6.2-rc5. Included in here are: - thunderbolt bugfixes for reported problems - new usb-serial driver ids added - onboard_hub usb driver fixes for much-reported problems - xhci bugfixes - typec bugfixes - ehci-fsl driver module alias fix - iowarrior header size fix - usb gadget driver fixes All of these, except for the iowarrior fix, have been in linux-next with no reported issues. The iowarrior fix passed the 0-day testing and is a one digit change based on a reported problem in the driver (which was written to a spec, not the real device that is now available)" * tag 'usb-6.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (40 commits) USB: misc: iowarrior: fix up header size for USB_DEVICE_ID_CODEMERCS_IOW100 usb: host: ehci-fsl: Fix module alias usb: dwc3: fix extcon dependency usb: core: hub: disable autosuspend for TI TUSB8041 USB: fix misleading usb_set_intfdata() kernel doc usb: gadget: f_ncm: fix potential NULL ptr deref in ncm_bitrate() USB: gadget: Add ID numbers to configfs-gadget driver names usb: typec: tcpm: Fix altmode re-registration causes sysfs create fail usb: gadget: g_webcam: Send color matching descriptor per frame usb: typec: altmodes/displayport: Use proper macro for pin assignment check usb: typec: altmodes/displayport: Fix pin assignment calculation usb: typec: altmodes/displayport: Add pin assignment helper usb: gadget: f_fs: Ensure ep0req is dequeued before free_request usb: gadget: f_fs: Prevent race during ffs_ep0_queue_wait usb: misc: onboard_hub: Move 'attach' work to the driver usb: misc: onboard_hub: Invert driver registration order usb: ucsi: Ensure connector delayed work items are flushed usb: musb: fix error return code in omap2430_probe() usb: chipidea: core: fix possible constant 0 if use IS_ERR(ci->role_switch) xhci: Detect lpm incapable xHC USB3 roothub ports from ACPI tables ...
2 parents 83cd5fd + 14ff746 commit e67da28

File tree

31 files changed

+334
-84
lines changed

31 files changed

+334
-84
lines changed

drivers/thunderbolt/retimer.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -427,21 +427,14 @@ int tb_retimer_scan(struct tb_port *port, bool add)
427427
{
428428
u32 status[TB_MAX_RETIMER_INDEX + 1] = {};
429429
int ret, i, last_idx = 0;
430-
struct usb4_port *usb4;
431-
432-
usb4 = port->usb4;
433-
if (!usb4)
434-
return 0;
435-
436-
pm_runtime_get_sync(&usb4->dev);
437430

438431
/*
439432
* Send broadcast RT to make sure retimer indices facing this
440433
* port are set.
441434
*/
442435
ret = usb4_port_enumerate_retimers(port);
443436
if (ret)
444-
goto out;
437+
return ret;
445438

446439
/*
447440
* Enable sideband channel for each retimer. We can do this
@@ -471,12 +464,11 @@ int tb_retimer_scan(struct tb_port *port, bool add)
471464
break;
472465
}
473466

474-
if (!last_idx) {
475-
ret = 0;
476-
goto out;
477-
}
467+
if (!last_idx)
468+
return 0;
478469

479470
/* Add on-board retimers if they do not exist already */
471+
ret = 0;
480472
for (i = 1; i <= last_idx; i++) {
481473
struct tb_retimer *rt;
482474

@@ -490,10 +482,6 @@ int tb_retimer_scan(struct tb_port *port, bool add)
490482
}
491483
}
492484

493-
out:
494-
pm_runtime_mark_last_busy(&usb4->dev);
495-
pm_runtime_put_autosuspend(&usb4->dev);
496-
497485
return ret;
498486
}
499487

drivers/thunderbolt/tb.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -628,11 +628,15 @@ static void tb_scan_port(struct tb_port *port)
628628
* Downstream switch is reachable through two ports.
629629
* Only scan on the primary port (link_nr == 0).
630630
*/
631+
632+
if (port->usb4)
633+
pm_runtime_get_sync(&port->usb4->dev);
634+
631635
if (tb_wait_for_port(port, false) <= 0)
632-
return;
636+
goto out_rpm_put;
633637
if (port->remote) {
634638
tb_port_dbg(port, "port already has a remote\n");
635-
return;
639+
goto out_rpm_put;
636640
}
637641

638642
tb_retimer_scan(port, true);
@@ -647,12 +651,12 @@ static void tb_scan_port(struct tb_port *port)
647651
*/
648652
if (PTR_ERR(sw) == -EIO || PTR_ERR(sw) == -EADDRNOTAVAIL)
649653
tb_scan_xdomain(port);
650-
return;
654+
goto out_rpm_put;
651655
}
652656

653657
if (tb_switch_configure(sw)) {
654658
tb_switch_put(sw);
655-
return;
659+
goto out_rpm_put;
656660
}
657661

658662
/*
@@ -681,7 +685,7 @@ static void tb_scan_port(struct tb_port *port)
681685

682686
if (tb_switch_add(sw)) {
683687
tb_switch_put(sw);
684-
return;
688+
goto out_rpm_put;
685689
}
686690

687691
/* Link the switches using both links if available */
@@ -733,6 +737,12 @@ static void tb_scan_port(struct tb_port *port)
733737

734738
tb_add_dp_resources(sw);
735739
tb_scan_switch(sw);
740+
741+
out_rpm_put:
742+
if (port->usb4) {
743+
pm_runtime_mark_last_busy(&port->usb4->dev);
744+
pm_runtime_put_autosuspend(&port->usb4->dev);
745+
}
736746
}
737747

738748
static void tb_deactivate_and_free_tunnel(struct tb_tunnel *tunnel)

drivers/thunderbolt/tunnel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ static void tb_usb3_reclaim_available_bandwidth(struct tb_tunnel *tunnel,
12751275
return;
12761276
} else if (!ret) {
12771277
/* Use maximum link rate if the link valid is not set */
1278-
ret = usb4_usb3_port_max_link_rate(tunnel->src_port);
1278+
ret = tb_usb3_max_link_rate(tunnel->dst_port, tunnel->src_port);
12791279
if (ret < 0) {
12801280
tb_tunnel_warn(tunnel, "failed to read maximum link rate\n");
12811281
return;

drivers/thunderbolt/xdomain.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,12 +1419,19 @@ static int tb_xdomain_get_properties(struct tb_xdomain *xd)
14191419
* registered, we notify the userspace that it has changed.
14201420
*/
14211421
if (!update) {
1422-
struct tb_port *port;
1422+
/*
1423+
* Now disable lane 1 if bonding was not enabled. Do
1424+
* this only if bonding was possible at the beginning
1425+
* (that is we are the connection manager and there are
1426+
* two lanes).
1427+
*/
1428+
if (xd->bonding_possible) {
1429+
struct tb_port *port;
14231430

1424-
/* Now disable lane 1 if bonding was not enabled */
1425-
port = tb_port_at(xd->route, tb_xdomain_parent(xd));
1426-
if (!port->bonded)
1427-
tb_port_disable(port->dual_link_port);
1431+
port = tb_port_at(xd->route, tb_xdomain_parent(xd));
1432+
if (!port->bonded)
1433+
tb_port_disable(port->dual_link_port);
1434+
}
14281435

14291436
if (device_add(&xd->dev)) {
14301437
dev_err(&xd->dev, "failed to add XDomain device\n");

drivers/usb/cdns3/cdns3-gadget.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,6 +2614,7 @@ int cdns3_gadget_ep_dequeue(struct usb_ep *ep,
26142614
u8 req_on_hw_ring = 0;
26152615
unsigned long flags;
26162616
int ret = 0;
2617+
int val;
26172618

26182619
if (!ep || !request || !ep->desc)
26192620
return -EINVAL;
@@ -2649,6 +2650,13 @@ int cdns3_gadget_ep_dequeue(struct usb_ep *ep,
26492650

26502651
/* Update ring only if removed request is on pending_req_list list */
26512652
if (req_on_hw_ring && link_trb) {
2653+
/* Stop DMA */
2654+
writel(EP_CMD_DFLUSH, &priv_dev->regs->ep_cmd);
2655+
2656+
/* wait for DFLUSH cleared */
2657+
readl_poll_timeout_atomic(&priv_dev->regs->ep_cmd, val,
2658+
!(val & EP_CMD_DFLUSH), 1, 1000);
2659+
26522660
link_trb->buffer = cpu_to_le32(TRB_BUFFER(priv_ep->trb_pool_dma +
26532661
((priv_req->end_trb + 1) * TRB_SIZE)));
26542662
link_trb->control = cpu_to_le32((le32_to_cpu(link_trb->control) & TRB_CYCLE) |
@@ -2660,6 +2668,10 @@ int cdns3_gadget_ep_dequeue(struct usb_ep *ep,
26602668

26612669
cdns3_gadget_giveback(priv_ep, priv_req, -ECONNRESET);
26622670

2671+
req = cdns3_next_request(&priv_ep->pending_req_list);
2672+
if (req)
2673+
cdns3_rearm_transfer(priv_ep, 1);
2674+
26632675
not_found:
26642676
spin_unlock_irqrestore(&priv_dev->lock, flags);
26652677
return ret;

drivers/usb/chipidea/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,12 +1294,12 @@ static void ci_extcon_wakeup_int(struct ci_hdrc *ci)
12941294
cable_id = &ci->platdata->id_extcon;
12951295
cable_vbus = &ci->platdata->vbus_extcon;
12961296

1297-
if ((!IS_ERR(cable_id->edev) || !IS_ERR(ci->role_switch))
1297+
if ((!IS_ERR(cable_id->edev) || ci->role_switch)
12981298
&& ci->is_otg &&
12991299
(otgsc & OTGSC_IDIE) && (otgsc & OTGSC_IDIS))
13001300
ci_irq(ci);
13011301

1302-
if ((!IS_ERR(cable_vbus->edev) || !IS_ERR(ci->role_switch))
1302+
if ((!IS_ERR(cable_vbus->edev) || ci->role_switch)
13031303
&& ci->is_otg &&
13041304
(otgsc & OTGSC_BSVIE) && (otgsc & OTGSC_BSVIS))
13051305
ci_irq(ci);

drivers/usb/core/hub.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
#define USB_PRODUCT_USB5534B 0x5534
4545
#define USB_VENDOR_CYPRESS 0x04b4
4646
#define USB_PRODUCT_CY7C65632 0x6570
47+
#define USB_VENDOR_TEXAS_INSTRUMENTS 0x0451
48+
#define USB_PRODUCT_TUSB8041_USB3 0x8140
49+
#define USB_PRODUCT_TUSB8041_USB2 0x8142
4750
#define HUB_QUIRK_CHECK_PORT_AUTOSUSPEND 0x01
4851
#define HUB_QUIRK_DISABLE_AUTOSUSPEND 0x02
4952

@@ -5854,6 +5857,16 @@ static const struct usb_device_id hub_id_table[] = {
58545857
.idVendor = USB_VENDOR_GENESYS_LOGIC,
58555858
.bInterfaceClass = USB_CLASS_HUB,
58565859
.driver_info = HUB_QUIRK_CHECK_PORT_AUTOSUSPEND},
5860+
{ .match_flags = USB_DEVICE_ID_MATCH_VENDOR
5861+
| USB_DEVICE_ID_MATCH_PRODUCT,
5862+
.idVendor = USB_VENDOR_TEXAS_INSTRUMENTS,
5863+
.idProduct = USB_PRODUCT_TUSB8041_USB2,
5864+
.driver_info = HUB_QUIRK_DISABLE_AUTOSUSPEND},
5865+
{ .match_flags = USB_DEVICE_ID_MATCH_VENDOR
5866+
| USB_DEVICE_ID_MATCH_PRODUCT,
5867+
.idVendor = USB_VENDOR_TEXAS_INSTRUMENTS,
5868+
.idProduct = USB_PRODUCT_TUSB8041_USB3,
5869+
.driver_info = HUB_QUIRK_DISABLE_AUTOSUSPEND},
58575870
{ .match_flags = USB_DEVICE_ID_MATCH_DEV_CLASS,
58585871
.bDeviceClass = USB_CLASS_HUB},
58595872
{ .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS,

drivers/usb/core/usb-acpi.c

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,71 @@ bool usb_acpi_power_manageable(struct usb_device *hdev, int index)
3737
}
3838
EXPORT_SYMBOL_GPL(usb_acpi_power_manageable);
3939

40+
#define UUID_USB_CONTROLLER_DSM "ce2ee385-00e6-48cb-9f05-2edb927c4899"
41+
#define USB_DSM_DISABLE_U1_U2_FOR_PORT 5
42+
43+
/**
44+
* usb_acpi_port_lpm_incapable - check if lpm should be disabled for a port.
45+
* @hdev: USB device belonging to the usb hub
46+
* @index: zero based port index
47+
*
48+
* Some USB3 ports may not support USB3 link power management U1/U2 states
49+
* due to different retimer setup. ACPI provides _DSM method which returns 0x01
50+
* if U1 and U2 states should be disabled. Evaluate _DSM with:
51+
* Arg0: UUID = ce2ee385-00e6-48cb-9f05-2edb927c4899
52+
* Arg1: Revision ID = 0
53+
* Arg2: Function Index = 5
54+
* Arg3: (empty)
55+
*
56+
* Return 1 if USB3 port is LPM incapable, negative on error, otherwise 0
57+
*/
58+
59+
int usb_acpi_port_lpm_incapable(struct usb_device *hdev, int index)
60+
{
61+
union acpi_object *obj;
62+
acpi_handle port_handle;
63+
int port1 = index + 1;
64+
guid_t guid;
65+
int ret;
66+
67+
ret = guid_parse(UUID_USB_CONTROLLER_DSM, &guid);
68+
if (ret)
69+
return ret;
70+
71+
port_handle = usb_get_hub_port_acpi_handle(hdev, port1);
72+
if (!port_handle) {
73+
dev_dbg(&hdev->dev, "port-%d no acpi handle\n", port1);
74+
return -ENODEV;
75+
}
76+
77+
if (!acpi_check_dsm(port_handle, &guid, 0,
78+
BIT(USB_DSM_DISABLE_U1_U2_FOR_PORT))) {
79+
dev_dbg(&hdev->dev, "port-%d no _DSM function %d\n",
80+
port1, USB_DSM_DISABLE_U1_U2_FOR_PORT);
81+
return -ENODEV;
82+
}
83+
84+
obj = acpi_evaluate_dsm(port_handle, &guid, 0,
85+
USB_DSM_DISABLE_U1_U2_FOR_PORT, NULL);
86+
87+
if (!obj)
88+
return -ENODEV;
89+
90+
if (obj->type != ACPI_TYPE_INTEGER) {
91+
dev_dbg(&hdev->dev, "evaluate port-%d _DSM failed\n", port1);
92+
ACPI_FREE(obj);
93+
return -EINVAL;
94+
}
95+
96+
if (obj->integer.value == 0x01)
97+
ret = 1;
98+
99+
ACPI_FREE(obj);
100+
101+
return ret;
102+
}
103+
EXPORT_SYMBOL_GPL(usb_acpi_port_lpm_incapable);
104+
40105
/**
41106
* usb_acpi_set_power_state - control usb port's power via acpi power
42107
* resource

drivers/usb/dwc3/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
config USB_DWC3
44
tristate "DesignWare USB3 DRD Core Support"
55
depends on (USB || USB_GADGET) && HAS_DMA
6+
depends on (EXTCON || EXTCON=n)
67
select USB_XHCI_PLATFORM if USB_XHCI_HCD
78
select USB_ROLE_SWITCH if USB_DWC3_DUAL_ROLE
89
help
@@ -44,7 +45,6 @@ config USB_DWC3_GADGET
4445
config USB_DWC3_DUAL_ROLE
4546
bool "Dual Role mode"
4647
depends on ((USB=y || USB=USB_DWC3) && (USB_GADGET=y || USB_GADGET=USB_DWC3))
47-
depends on (EXTCON=y || EXTCON=USB_DWC3)
4848
help
4949
This is the default mode of working of DWC3 controller where
5050
both host and gadget features are enabled.

drivers/usb/gadget/configfs.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ static void gadget_info_attr_release(struct config_item *item)
393393
WARN_ON(!list_empty(&gi->string_list));
394394
WARN_ON(!list_empty(&gi->available_func));
395395
kfree(gi->composite.gadget_driver.function);
396+
kfree(gi->composite.gadget_driver.driver.name);
396397
kfree(gi);
397398
}
398399

@@ -1572,7 +1573,6 @@ static const struct usb_gadget_driver configfs_driver_template = {
15721573
.max_speed = USB_SPEED_SUPER_PLUS,
15731574
.driver = {
15741575
.owner = THIS_MODULE,
1575-
.name = "configfs-gadget",
15761576
},
15771577
.match_existing_only = 1,
15781578
};
@@ -1623,13 +1623,21 @@ static struct config_group *gadgets_make(
16231623

16241624
gi->composite.gadget_driver = configfs_driver_template;
16251625

1626+
gi->composite.gadget_driver.driver.name = kasprintf(GFP_KERNEL,
1627+
"configfs-gadget.%s", name);
1628+
if (!gi->composite.gadget_driver.driver.name)
1629+
goto err;
1630+
16261631
gi->composite.gadget_driver.function = kstrdup(name, GFP_KERNEL);
16271632
gi->composite.name = gi->composite.gadget_driver.function;
16281633

16291634
if (!gi->composite.gadget_driver.function)
1630-
goto err;
1635+
goto out_free_driver_name;
16311636

16321637
return &gi->group;
1638+
1639+
out_free_driver_name:
1640+
kfree(gi->composite.gadget_driver.driver.name);
16331641
err:
16341642
kfree(gi);
16351643
return ERR_PTR(-ENOMEM);

0 commit comments

Comments
 (0)