Skip to content

Commit e4c26fa

Browse files
committed
Merge tag 'usb-5.9-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB/Thunderbolt fixes from Greg KH: "Here are some small USB and Thunderbolt driver fixes for 5.9-rc5. Nothing huge, just a number of bugfixes and new device ids for problems reported: - new USB serial driver ids - bug fixes for syzbot reported problems - typec driver fixes - thunderbolt driver fixes - revert of reported broken commit All of these have been in linux-next with no reported issues" * tag 'usb-5.9-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usb: typec: intel_pmc_mux: Do not configure SBU and HSL Orientation in Alternate modes usb: typec: intel_pmc_mux: Do not configure Altmode HPD High usb: core: fix slab-out-of-bounds Read in read_descriptors Revert "usb: dwc3: meson-g12a: fix shared reset control use" usb: typec: ucsi: acpi: Check the _DEP dependencies usb: typec: intel_pmc_mux: Un-register the USB role switch usb: Fix out of sync data toggle if a configured device is reconfigured USB: serial: option: support dynamic Quectel USB compositions USB: serial: option: add support for SIM7070/SIM7080/SIM7090 modules thunderbolt: Use maximum USB3 link rate when reclaiming if link is not up thunderbolt: Disable ports that are not implemented USB: serial: ftdi_sio: add IDs for Xsens Mti USB converter
2 parents 6c7247f + a29c0ad commit e4c26fa

File tree

11 files changed

+87
-81
lines changed

11 files changed

+87
-81
lines changed

drivers/thunderbolt/switch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ static int tb_init_port(struct tb_port *port)
684684
if (res == -ENODEV) {
685685
tb_dbg(port->sw->tb, " Port %d: not implemented\n",
686686
port->port);
687+
port->disabled = true;
687688
return 0;
688689
}
689690
return res;

drivers/thunderbolt/tb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ struct tb_switch {
186186
* @cap_adap: Offset of the adapter specific capability (%0 if not present)
187187
* @cap_usb4: Offset to the USB4 port capability (%0 if not present)
188188
* @port: Port number on switch
189-
* @disabled: Disabled by eeprom
189+
* @disabled: Disabled by eeprom or enabled but not implemented
190190
* @bonded: true if the port is bonded (two lanes combined as one)
191191
* @dual_link_port: If the switch is connected using two ports, points
192192
* to the other port.

drivers/thunderbolt/tunnel.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -951,10 +951,18 @@ static void tb_usb3_reclaim_available_bandwidth(struct tb_tunnel *tunnel,
951951
int ret, max_rate, allocate_up, allocate_down;
952952

953953
ret = usb4_usb3_port_actual_link_rate(tunnel->src_port);
954-
if (ret <= 0) {
955-
tb_tunnel_warn(tunnel, "tunnel is not up\n");
954+
if (ret < 0) {
955+
tb_tunnel_warn(tunnel, "failed to read actual link rate\n");
956956
return;
957+
} else if (!ret) {
958+
/* Use maximum link rate if the link valid is not set */
959+
ret = usb4_usb3_port_max_link_rate(tunnel->src_port);
960+
if (ret < 0) {
961+
tb_tunnel_warn(tunnel, "failed to read maximum link rate\n");
962+
return;
963+
}
957964
}
965+
958966
/*
959967
* 90% of the max rate can be allocated for isochronous
960968
* transfers.

drivers/usb/core/message.c

Lines changed: 42 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,34 @@ void usb_disable_interface(struct usb_device *dev, struct usb_interface *intf,
12051205
}
12061206
}
12071207

1208+
/*
1209+
* usb_disable_device_endpoints -- Disable all endpoints for a device
1210+
* @dev: the device whose endpoints are being disabled
1211+
* @skip_ep0: 0 to disable endpoint 0, 1 to skip it.
1212+
*/
1213+
static void usb_disable_device_endpoints(struct usb_device *dev, int skip_ep0)
1214+
{
1215+
struct usb_hcd *hcd = bus_to_hcd(dev->bus);
1216+
int i;
1217+
1218+
if (hcd->driver->check_bandwidth) {
1219+
/* First pass: Cancel URBs, leave endpoint pointers intact. */
1220+
for (i = skip_ep0; i < 16; ++i) {
1221+
usb_disable_endpoint(dev, i, false);
1222+
usb_disable_endpoint(dev, i + USB_DIR_IN, false);
1223+
}
1224+
/* Remove endpoints from the host controller internal state */
1225+
mutex_lock(hcd->bandwidth_mutex);
1226+
usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
1227+
mutex_unlock(hcd->bandwidth_mutex);
1228+
}
1229+
/* Second pass: remove endpoint pointers */
1230+
for (i = skip_ep0; i < 16; ++i) {
1231+
usb_disable_endpoint(dev, i, true);
1232+
usb_disable_endpoint(dev, i + USB_DIR_IN, true);
1233+
}
1234+
}
1235+
12081236
/**
12091237
* usb_disable_device - Disable all the endpoints for a USB device
12101238
* @dev: the device whose endpoints are being disabled
@@ -1218,7 +1246,6 @@ void usb_disable_interface(struct usb_device *dev, struct usb_interface *intf,
12181246
void usb_disable_device(struct usb_device *dev, int skip_ep0)
12191247
{
12201248
int i;
1221-
struct usb_hcd *hcd = bus_to_hcd(dev->bus);
12221249

12231250
/* getting rid of interfaces will disconnect
12241251
* any drivers bound to them (a key side effect)
@@ -1264,22 +1291,8 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
12641291

12651292
dev_dbg(&dev->dev, "%s nuking %s URBs\n", __func__,
12661293
skip_ep0 ? "non-ep0" : "all");
1267-
if (hcd->driver->check_bandwidth) {
1268-
/* First pass: Cancel URBs, leave endpoint pointers intact. */
1269-
for (i = skip_ep0; i < 16; ++i) {
1270-
usb_disable_endpoint(dev, i, false);
1271-
usb_disable_endpoint(dev, i + USB_DIR_IN, false);
1272-
}
1273-
/* Remove endpoints from the host controller internal state */
1274-
mutex_lock(hcd->bandwidth_mutex);
1275-
usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
1276-
mutex_unlock(hcd->bandwidth_mutex);
1277-
/* Second pass: remove endpoint pointers */
1278-
}
1279-
for (i = skip_ep0; i < 16; ++i) {
1280-
usb_disable_endpoint(dev, i, true);
1281-
usb_disable_endpoint(dev, i + USB_DIR_IN, true);
1282-
}
1294+
1295+
usb_disable_device_endpoints(dev, skip_ep0);
12831296
}
12841297

12851298
/**
@@ -1522,6 +1535,9 @@ EXPORT_SYMBOL_GPL(usb_set_interface);
15221535
* The caller must own the device lock.
15231536
*
15241537
* Return: Zero on success, else a negative error code.
1538+
*
1539+
* If this routine fails the device will probably be in an unusable state
1540+
* with endpoints disabled, and interfaces only partially enabled.
15251541
*/
15261542
int usb_reset_configuration(struct usb_device *dev)
15271543
{
@@ -1537,10 +1553,7 @@ int usb_reset_configuration(struct usb_device *dev)
15371553
* calls during probe() are fine
15381554
*/
15391555

1540-
for (i = 1; i < 16; ++i) {
1541-
usb_disable_endpoint(dev, i, true);
1542-
usb_disable_endpoint(dev, i + USB_DIR_IN, true);
1543-
}
1556+
usb_disable_device_endpoints(dev, 1); /* skip ep0*/
15441557

15451558
config = dev->actconfig;
15461559
retval = 0;
@@ -1553,34 +1566,10 @@ int usb_reset_configuration(struct usb_device *dev)
15531566
mutex_unlock(hcd->bandwidth_mutex);
15541567
return -ENOMEM;
15551568
}
1556-
/* Make sure we have enough bandwidth for each alternate setting 0 */
1557-
for (i = 0; i < config->desc.bNumInterfaces; i++) {
1558-
struct usb_interface *intf = config->interface[i];
1559-
struct usb_host_interface *alt;
15601569

1561-
alt = usb_altnum_to_altsetting(intf, 0);
1562-
if (!alt)
1563-
alt = &intf->altsetting[0];
1564-
if (alt != intf->cur_altsetting)
1565-
retval = usb_hcd_alloc_bandwidth(dev, NULL,
1566-
intf->cur_altsetting, alt);
1567-
if (retval < 0)
1568-
break;
1569-
}
1570-
/* If not, reinstate the old alternate settings */
1570+
/* xHCI adds all endpoints in usb_hcd_alloc_bandwidth */
1571+
retval = usb_hcd_alloc_bandwidth(dev, config, NULL, NULL);
15711572
if (retval < 0) {
1572-
reset_old_alts:
1573-
for (i--; i >= 0; i--) {
1574-
struct usb_interface *intf = config->interface[i];
1575-
struct usb_host_interface *alt;
1576-
1577-
alt = usb_altnum_to_altsetting(intf, 0);
1578-
if (!alt)
1579-
alt = &intf->altsetting[0];
1580-
if (alt != intf->cur_altsetting)
1581-
usb_hcd_alloc_bandwidth(dev, NULL,
1582-
alt, intf->cur_altsetting);
1583-
}
15841573
usb_enable_lpm(dev);
15851574
mutex_unlock(hcd->bandwidth_mutex);
15861575
return retval;
@@ -1589,8 +1578,12 @@ int usb_reset_configuration(struct usb_device *dev)
15891578
USB_REQ_SET_CONFIGURATION, 0,
15901579
config->desc.bConfigurationValue, 0,
15911580
NULL, 0, USB_CTRL_SET_TIMEOUT);
1592-
if (retval < 0)
1593-
goto reset_old_alts;
1581+
if (retval < 0) {
1582+
usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
1583+
usb_enable_lpm(dev);
1584+
mutex_unlock(hcd->bandwidth_mutex);
1585+
return retval;
1586+
}
15941587
mutex_unlock(hcd->bandwidth_mutex);
15951588

15961589
/* re-init hc/hcd interface/endpoint state */

drivers/usb/core/sysfs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,11 @@ read_descriptors(struct file *filp, struct kobject *kobj,
889889
size_t srclen, n;
890890
int cfgno;
891891
void *src;
892+
int retval;
892893

894+
retval = usb_lock_device_interruptible(udev);
895+
if (retval < 0)
896+
return -EINTR;
893897
/* The binary attribute begins with the device descriptor.
894898
* Following that are the raw descriptor entries for all the
895899
* configurations (config plus subsidiary descriptors).
@@ -914,6 +918,7 @@ read_descriptors(struct file *filp, struct kobject *kobj,
914918
off -= srclen;
915919
}
916920
}
921+
usb_unlock_device(udev);
917922
return count - nleft;
918923
}
919924

drivers/usb/dwc3/dwc3-meson-g12a.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -737,13 +737,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
737737
goto err_disable_clks;
738738
}
739739

740-
ret = reset_control_deassert(priv->reset);
740+
ret = reset_control_reset(priv->reset);
741741
if (ret)
742-
goto err_assert_reset;
742+
goto err_disable_clks;
743743

744744
ret = dwc3_meson_g12a_get_phys(priv);
745745
if (ret)
746-
goto err_assert_reset;
746+
goto err_disable_clks;
747747

748748
ret = priv->drvdata->setup_regmaps(priv, base);
749749
if (ret)
@@ -752,7 +752,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
752752
if (priv->vbus) {
753753
ret = regulator_enable(priv->vbus);
754754
if (ret)
755-
goto err_assert_reset;
755+
goto err_disable_clks;
756756
}
757757

758758
/* Get dr_mode */
@@ -765,13 +765,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
765765

766766
ret = priv->drvdata->usb_init(priv);
767767
if (ret)
768-
goto err_assert_reset;
768+
goto err_disable_clks;
769769

770770
/* Init PHYs */
771771
for (i = 0 ; i < PHY_COUNT ; ++i) {
772772
ret = phy_init(priv->phys[i]);
773773
if (ret)
774-
goto err_assert_reset;
774+
goto err_disable_clks;
775775
}
776776

777777
/* Set PHY Power */
@@ -809,9 +809,6 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
809809
for (i = 0 ; i < PHY_COUNT ; ++i)
810810
phy_exit(priv->phys[i]);
811811

812-
err_assert_reset:
813-
reset_control_assert(priv->reset);
814-
815812
err_disable_clks:
816813
clk_bulk_disable_unprepare(priv->drvdata->num_clks,
817814
priv->drvdata->clks);

drivers/usb/serial/ftdi_sio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ static const struct usb_device_id id_table_combined[] = {
713713
{ USB_DEVICE(XSENS_VID, XSENS_AWINDA_STATION_PID) },
714714
{ USB_DEVICE(XSENS_VID, XSENS_CONVERTER_PID) },
715715
{ USB_DEVICE(XSENS_VID, XSENS_MTDEVBOARD_PID) },
716+
{ USB_DEVICE(XSENS_VID, XSENS_MTIUSBCONVERTER_PID) },
716717
{ USB_DEVICE(XSENS_VID, XSENS_MTW_PID) },
717718
{ USB_DEVICE(FTDI_VID, FTDI_OMNI1509) },
718719
{ USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) },

drivers/usb/serial/ftdi_sio_ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160
#define XSENS_AWINDA_DONGLE_PID 0x0102
161161
#define XSENS_MTW_PID 0x0200 /* Xsens MTw */
162162
#define XSENS_MTDEVBOARD_PID 0x0300 /* Motion Tracker Development Board */
163+
#define XSENS_MTIUSBCONVERTER_PID 0x0301 /* MTi USB converter */
163164
#define XSENS_CONVERTER_PID 0xD00D /* Xsens USB-serial converter */
164165

165166
/* Xsens devices using FTDI VID */

drivers/usb/serial/option.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,14 +1094,18 @@ static const struct usb_device_id option_ids[] = {
10941094
{ USB_DEVICE(QUALCOMM_VENDOR_ID, UBLOX_PRODUCT_R410M),
10951095
.driver_info = RSVD(1) | RSVD(3) },
10961096
/* Quectel products using Quectel vendor ID */
1097-
{ USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21),
1098-
.driver_info = RSVD(4) },
1099-
{ USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25),
1100-
.driver_info = RSVD(4) },
1101-
{ USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG95),
1102-
.driver_info = RSVD(4) },
1103-
{ USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96),
1104-
.driver_info = RSVD(4) },
1097+
{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21, 0xff, 0xff, 0xff),
1098+
.driver_info = NUMEP2 },
1099+
{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21, 0xff, 0, 0) },
1100+
{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25, 0xff, 0xff, 0xff),
1101+
.driver_info = NUMEP2 },
1102+
{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25, 0xff, 0, 0) },
1103+
{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG95, 0xff, 0xff, 0xff),
1104+
.driver_info = NUMEP2 },
1105+
{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG95, 0xff, 0, 0) },
1106+
{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96, 0xff, 0xff, 0xff),
1107+
.driver_info = NUMEP2 },
1108+
{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96, 0xff, 0, 0) },
11051109
{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0xff, 0xff),
11061110
.driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) | NUMEP2 },
11071111
{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0, 0) },
@@ -1819,6 +1823,8 @@ static const struct usb_device_id option_ids[] = {
18191823
{ USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9003, 0xff) }, /* Simcom SIM7500/SIM7600 MBIM mode */
18201824
{ USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9011, 0xff), /* Simcom SIM7500/SIM7600 RNDIS mode */
18211825
.driver_info = RSVD(7) },
1826+
{ USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9205, 0xff) }, /* Simcom SIM7070/SIM7080/SIM7090 AT+ECM mode */
1827+
{ USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9206, 0xff) }, /* Simcom SIM7070/SIM7080/SIM7090 AT-only mode */
18221828
{ USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S_X200),
18231829
.driver_info = NCTRL(0) | NCTRL(1) | RSVD(4) },
18241830
{ USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X220_X500D),

drivers/usb/typec/mux/intel_pmc_mux.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,11 @@ enum {
6161

6262
#define PMC_USB_ALTMODE_ORI_SHIFT 1
6363
#define PMC_USB_ALTMODE_UFP_SHIFT 3
64-
#define PMC_USB_ALTMODE_ORI_AUX_SHIFT 4
65-
#define PMC_USB_ALTMODE_ORI_HSL_SHIFT 5
6664

6765
/* DP specific Mode Data bits */
6866
#define PMC_USB_ALTMODE_DP_MODE_SHIFT 8
6967

7068
/* TBT specific Mode Data bits */
71-
#define PMC_USB_ALTMODE_HPD_HIGH BIT(14)
7269
#define PMC_USB_ALTMODE_TBT_TYPE BIT(17)
7370
#define PMC_USB_ALTMODE_CABLE_TYPE BIT(18)
7471
#define PMC_USB_ALTMODE_ACTIVE_LINK BIT(20)
@@ -179,15 +176,9 @@ pmc_usb_mux_dp(struct pmc_usb_port *port, struct typec_mux_state *state)
179176
req.mode_data = (port->orientation - 1) << PMC_USB_ALTMODE_ORI_SHIFT;
180177
req.mode_data |= (port->role - 1) << PMC_USB_ALTMODE_UFP_SHIFT;
181178

182-
req.mode_data |= sbu_orientation(port) << PMC_USB_ALTMODE_ORI_AUX_SHIFT;
183-
req.mode_data |= hsl_orientation(port) << PMC_USB_ALTMODE_ORI_HSL_SHIFT;
184-
185179
req.mode_data |= (state->mode - TYPEC_STATE_MODAL) <<
186180
PMC_USB_ALTMODE_DP_MODE_SHIFT;
187181

188-
if (data->status & DP_STATUS_HPD_STATE)
189-
req.mode_data |= PMC_USB_ALTMODE_HPD_HIGH;
190-
191182
ret = pmc_usb_command(port, (void *)&req, sizeof(req));
192183
if (ret)
193184
return ret;
@@ -212,9 +203,6 @@ pmc_usb_mux_tbt(struct pmc_usb_port *port, struct typec_mux_state *state)
212203
req.mode_data = (port->orientation - 1) << PMC_USB_ALTMODE_ORI_SHIFT;
213204
req.mode_data |= (port->role - 1) << PMC_USB_ALTMODE_UFP_SHIFT;
214205

215-
req.mode_data |= sbu_orientation(port) << PMC_USB_ALTMODE_ORI_AUX_SHIFT;
216-
req.mode_data |= hsl_orientation(port) << PMC_USB_ALTMODE_ORI_HSL_SHIFT;
217-
218206
if (TBT_ADAPTER(data->device_mode) == TBT_ADAPTER_TBT3)
219207
req.mode_data |= PMC_USB_ALTMODE_TBT_TYPE;
220208

@@ -497,6 +485,7 @@ static int pmc_usb_probe(struct platform_device *pdev)
497485
for (i = 0; i < pmc->num_ports; i++) {
498486
typec_switch_unregister(pmc->port[i].typec_sw);
499487
typec_mux_unregister(pmc->port[i].typec_mux);
488+
usb_role_switch_unregister(pmc->port[i].usb_sw);
500489
}
501490

502491
return ret;
@@ -510,6 +499,7 @@ static int pmc_usb_remove(struct platform_device *pdev)
510499
for (i = 0; i < pmc->num_ports; i++) {
511500
typec_switch_unregister(pmc->port[i].typec_sw);
512501
typec_mux_unregister(pmc->port[i].typec_mux);
502+
usb_role_switch_unregister(pmc->port[i].usb_sw);
513503
}
514504

515505
return 0;

drivers/usb/typec/ucsi/ucsi_acpi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,15 @@ static void ucsi_acpi_notify(acpi_handle handle, u32 event, void *data)
112112

113113
static int ucsi_acpi_probe(struct platform_device *pdev)
114114
{
115+
struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
115116
struct ucsi_acpi *ua;
116117
struct resource *res;
117118
acpi_status status;
118119
int ret;
119120

121+
if (adev->dep_unmet)
122+
return -EPROBE_DEFER;
123+
120124
ua = devm_kzalloc(&pdev->dev, sizeof(*ua), GFP_KERNEL);
121125
if (!ua)
122126
return -ENOMEM;

0 commit comments

Comments
 (0)