Skip to content

Commit 11d3f72

Browse files
committed
Merge tag 'usb-6.6-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB / Thunderbolt fixes from Greg KH: "Here are some USB and Thunderbolt driver fixes for 6.6-rc6 to resolve a number of small reported issues. Included in here are: - thunderbolt driver fixes - xhci driver fixes - cdns3 driver fixes - musb driver fixes - a number of typec driver fixes - a few other small driver fixes All of these have been in linux-next with no reported issues" * tag 'usb-6.6-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (22 commits) usb: typec: ucsi: Use GET_CAPABILITY attributes data to set power supply scope usb: typec: ucsi: Fix missing link removal usb: typec: altmodes/displayport: Signal hpd low when exiting mode xhci: Preserve RsvdP bits in ERSTBA register correctly xhci: Clear EHB bit only at end of interrupt handler xhci: track port suspend state correctly in unsuccessful resume cases usb: xhci: xhci-ring: Use sysdev for mapping bounce buffer usb: typec: ucsi: Clear EVENT_PENDING bit if ucsi_send_command fails usb: misc: onboard_hub: add support for Microchip USB2412 USB 2.0 hub usb: gadget: udc-xilinx: replace memcpy with memcpy_toio usb: cdns3: Modify the return value of cdns_set_active () to void when CONFIG_PM_SLEEP is disabled usb: dwc3: Soft reset phy on probe for host usb: hub: Guard against accesses to uninitialized BOS descriptors usb: typec: qcom: Update the logic of regulator enable and disable usb: gadget: ncm: Handle decoding of multiple NTB's in unwrap call usb: musb: Get the musb_qh poniter after musb_giveback usb: musb: Modify the "HWVers" register address usb: cdnsp: Fixes issue with dequeuing not queued requests thunderbolt: Restart XDomain discovery handshake after failure thunderbolt: Correct TMU mode initialization from hardware ...
2 parents 41226a3 + c9ca8de commit 11d3f72

File tree

23 files changed

+220
-87
lines changed

23 files changed

+220
-87
lines changed

drivers/thunderbolt/icm.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#define PHY_PORT_CS1_LINK_STATE_SHIFT 26
4242

4343
#define ICM_TIMEOUT 5000 /* ms */
44+
#define ICM_RETRIES 3
4445
#define ICM_APPROVE_TIMEOUT 10000 /* ms */
4546
#define ICM_MAX_LINK 4
4647

@@ -296,10 +297,9 @@ static bool icm_copy(struct tb_cfg_request *req, const struct ctl_pkg *pkg)
296297

297298
static int icm_request(struct tb *tb, const void *request, size_t request_size,
298299
void *response, size_t response_size, size_t npackets,
299-
unsigned int timeout_msec)
300+
int retries, unsigned int timeout_msec)
300301
{
301302
struct icm *icm = tb_priv(tb);
302-
int retries = 3;
303303

304304
do {
305305
struct tb_cfg_request *req;
@@ -410,7 +410,7 @@ static int icm_fr_get_route(struct tb *tb, u8 link, u8 depth, u64 *route)
410410
return -ENOMEM;
411411

412412
ret = icm_request(tb, &request, sizeof(request), switches,
413-
sizeof(*switches), npackets, ICM_TIMEOUT);
413+
sizeof(*switches), npackets, ICM_RETRIES, ICM_TIMEOUT);
414414
if (ret)
415415
goto err_free;
416416

@@ -463,7 +463,7 @@ icm_fr_driver_ready(struct tb *tb, enum tb_security_level *security_level,
463463

464464
memset(&reply, 0, sizeof(reply));
465465
ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
466-
1, ICM_TIMEOUT);
466+
1, ICM_RETRIES, ICM_TIMEOUT);
467467
if (ret)
468468
return ret;
469469

@@ -488,7 +488,7 @@ static int icm_fr_approve_switch(struct tb *tb, struct tb_switch *sw)
488488
memset(&reply, 0, sizeof(reply));
489489
/* Use larger timeout as establishing tunnels can take some time */
490490
ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
491-
1, ICM_APPROVE_TIMEOUT);
491+
1, ICM_RETRIES, ICM_APPROVE_TIMEOUT);
492492
if (ret)
493493
return ret;
494494

@@ -515,7 +515,7 @@ static int icm_fr_add_switch_key(struct tb *tb, struct tb_switch *sw)
515515

516516
memset(&reply, 0, sizeof(reply));
517517
ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
518-
1, ICM_TIMEOUT);
518+
1, ICM_RETRIES, ICM_TIMEOUT);
519519
if (ret)
520520
return ret;
521521

@@ -543,7 +543,7 @@ static int icm_fr_challenge_switch_key(struct tb *tb, struct tb_switch *sw,
543543

544544
memset(&reply, 0, sizeof(reply));
545545
ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
546-
1, ICM_TIMEOUT);
546+
1, ICM_RETRIES, ICM_TIMEOUT);
547547
if (ret)
548548
return ret;
549549

@@ -577,7 +577,7 @@ static int icm_fr_approve_xdomain_paths(struct tb *tb, struct tb_xdomain *xd,
577577

578578
memset(&reply, 0, sizeof(reply));
579579
ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
580-
1, ICM_TIMEOUT);
580+
1, ICM_RETRIES, ICM_TIMEOUT);
581581
if (ret)
582582
return ret;
583583

@@ -1020,7 +1020,7 @@ icm_tr_driver_ready(struct tb *tb, enum tb_security_level *security_level,
10201020

10211021
memset(&reply, 0, sizeof(reply));
10221022
ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
1023-
1, 20000);
1023+
1, 10, 2000);
10241024
if (ret)
10251025
return ret;
10261026

@@ -1053,7 +1053,7 @@ static int icm_tr_approve_switch(struct tb *tb, struct tb_switch *sw)
10531053

10541054
memset(&reply, 0, sizeof(reply));
10551055
ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
1056-
1, ICM_APPROVE_TIMEOUT);
1056+
1, ICM_RETRIES, ICM_APPROVE_TIMEOUT);
10571057
if (ret)
10581058
return ret;
10591059

@@ -1081,7 +1081,7 @@ static int icm_tr_add_switch_key(struct tb *tb, struct tb_switch *sw)
10811081

10821082
memset(&reply, 0, sizeof(reply));
10831083
ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
1084-
1, ICM_TIMEOUT);
1084+
1, ICM_RETRIES, ICM_TIMEOUT);
10851085
if (ret)
10861086
return ret;
10871087

@@ -1110,7 +1110,7 @@ static int icm_tr_challenge_switch_key(struct tb *tb, struct tb_switch *sw,
11101110

11111111
memset(&reply, 0, sizeof(reply));
11121112
ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
1113-
1, ICM_TIMEOUT);
1113+
1, ICM_RETRIES, ICM_TIMEOUT);
11141114
if (ret)
11151115
return ret;
11161116

@@ -1144,7 +1144,7 @@ static int icm_tr_approve_xdomain_paths(struct tb *tb, struct tb_xdomain *xd,
11441144

11451145
memset(&reply, 0, sizeof(reply));
11461146
ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
1147-
1, ICM_TIMEOUT);
1147+
1, ICM_RETRIES, ICM_TIMEOUT);
11481148
if (ret)
11491149
return ret;
11501150

@@ -1170,7 +1170,7 @@ static int icm_tr_xdomain_tear_down(struct tb *tb, struct tb_xdomain *xd,
11701170

11711171
memset(&reply, 0, sizeof(reply));
11721172
ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
1173-
1, ICM_TIMEOUT);
1173+
1, ICM_RETRIES, ICM_TIMEOUT);
11741174
if (ret)
11751175
return ret;
11761176

@@ -1496,7 +1496,7 @@ icm_ar_driver_ready(struct tb *tb, enum tb_security_level *security_level,
14961496

14971497
memset(&reply, 0, sizeof(reply));
14981498
ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
1499-
1, ICM_TIMEOUT);
1499+
1, ICM_RETRIES, ICM_TIMEOUT);
15001500
if (ret)
15011501
return ret;
15021502

@@ -1522,7 +1522,7 @@ static int icm_ar_get_route(struct tb *tb, u8 link, u8 depth, u64 *route)
15221522

15231523
memset(&reply, 0, sizeof(reply));
15241524
ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
1525-
1, ICM_TIMEOUT);
1525+
1, ICM_RETRIES, ICM_TIMEOUT);
15261526
if (ret)
15271527
return ret;
15281528

@@ -1543,7 +1543,7 @@ static int icm_ar_get_boot_acl(struct tb *tb, uuid_t *uuids, size_t nuuids)
15431543

15441544
memset(&reply, 0, sizeof(reply));
15451545
ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
1546-
1, ICM_TIMEOUT);
1546+
1, ICM_RETRIES, ICM_TIMEOUT);
15471547
if (ret)
15481548
return ret;
15491549

@@ -1604,7 +1604,7 @@ static int icm_ar_set_boot_acl(struct tb *tb, const uuid_t *uuids,
16041604

16051605
memset(&reply, 0, sizeof(reply));
16061606
ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
1607-
1, ICM_TIMEOUT);
1607+
1, ICM_RETRIES, ICM_TIMEOUT);
16081608
if (ret)
16091609
return ret;
16101610

@@ -1626,7 +1626,7 @@ icm_icl_driver_ready(struct tb *tb, enum tb_security_level *security_level,
16261626

16271627
memset(&reply, 0, sizeof(reply));
16281628
ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
1629-
1, 20000);
1629+
1, ICM_RETRIES, 20000);
16301630
if (ret)
16311631
return ret;
16321632

@@ -2298,7 +2298,7 @@ static int icm_usb4_switch_op(struct tb_switch *sw, u16 opcode, u32 *metadata,
22982298

22992299
memset(&reply, 0, sizeof(reply));
23002300
ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
2301-
1, ICM_TIMEOUT);
2301+
1, ICM_RETRIES, ICM_TIMEOUT);
23022302
if (ret)
23032303
return ret;
23042304

drivers/thunderbolt/switch.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2725,6 +2725,13 @@ int tb_switch_lane_bonding_enable(struct tb_switch *sw)
27252725
!tb_port_is_width_supported(down, TB_LINK_WIDTH_DUAL))
27262726
return 0;
27272727

2728+
/*
2729+
* Both lanes need to be in CL0. Here we assume lane 0 already be in
2730+
* CL0 and check just for lane 1.
2731+
*/
2732+
if (tb_wait_for_port(down->dual_link_port, false) <= 0)
2733+
return -ENOTCONN;
2734+
27282735
ret = tb_port_lane_bonding_enable(up);
27292736
if (ret) {
27302737
tb_port_warn(up, "failed to enable lane bonding\n");

drivers/thunderbolt/tmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ static int tmu_mode_init(struct tb_switch *sw)
382382
} else if (ucap && tb_port_tmu_is_unidirectional(up)) {
383383
if (tmu_rates[TB_SWITCH_TMU_MODE_LOWRES] == rate)
384384
sw->tmu.mode = TB_SWITCH_TMU_MODE_LOWRES;
385-
else if (tmu_rates[TB_SWITCH_TMU_MODE_LOWRES] == rate)
385+
else if (tmu_rates[TB_SWITCH_TMU_MODE_HIFI_UNI] == rate)
386386
sw->tmu.mode = TB_SWITCH_TMU_MODE_HIFI_UNI;
387387
} else if (rate) {
388388
sw->tmu.mode = TB_SWITCH_TMU_MODE_HIFI_BI;

drivers/thunderbolt/xdomain.c

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,27 @@ static void update_property_block(struct tb_xdomain *xd)
703703
mutex_unlock(&xdomain_lock);
704704
}
705705

706+
static void start_handshake(struct tb_xdomain *xd)
707+
{
708+
xd->state = XDOMAIN_STATE_INIT;
709+
queue_delayed_work(xd->tb->wq, &xd->state_work,
710+
msecs_to_jiffies(XDOMAIN_SHORT_TIMEOUT));
711+
}
712+
713+
/* Can be called from state_work */
714+
static void __stop_handshake(struct tb_xdomain *xd)
715+
{
716+
cancel_delayed_work_sync(&xd->properties_changed_work);
717+
xd->properties_changed_retries = 0;
718+
xd->state_retries = 0;
719+
}
720+
721+
static void stop_handshake(struct tb_xdomain *xd)
722+
{
723+
cancel_delayed_work_sync(&xd->state_work);
724+
__stop_handshake(xd);
725+
}
726+
706727
static void tb_xdp_handle_request(struct work_struct *work)
707728
{
708729
struct xdomain_request_work *xw = container_of(work, typeof(*xw), work);
@@ -765,6 +786,15 @@ static void tb_xdp_handle_request(struct work_struct *work)
765786
case UUID_REQUEST:
766787
tb_dbg(tb, "%llx: received XDomain UUID request\n", route);
767788
ret = tb_xdp_uuid_response(ctl, route, sequence, uuid);
789+
/*
790+
* If we've stopped the discovery with an error such as
791+
* timing out, we will restart the handshake now that we
792+
* received UUID request from the remote host.
793+
*/
794+
if (!ret && xd && xd->state == XDOMAIN_STATE_ERROR) {
795+
dev_dbg(&xd->dev, "restarting handshake\n");
796+
start_handshake(xd);
797+
}
768798
break;
769799

770800
case LINK_STATE_STATUS_REQUEST:
@@ -1521,6 +1551,13 @@ static void tb_xdomain_queue_properties_changed(struct tb_xdomain *xd)
15211551
msecs_to_jiffies(XDOMAIN_SHORT_TIMEOUT));
15221552
}
15231553

1554+
static void tb_xdomain_failed(struct tb_xdomain *xd)
1555+
{
1556+
xd->state = XDOMAIN_STATE_ERROR;
1557+
queue_delayed_work(xd->tb->wq, &xd->state_work,
1558+
msecs_to_jiffies(XDOMAIN_DEFAULT_TIMEOUT));
1559+
}
1560+
15241561
static void tb_xdomain_state_work(struct work_struct *work)
15251562
{
15261563
struct tb_xdomain *xd = container_of(work, typeof(*xd), state_work.work);
@@ -1547,7 +1584,7 @@ static void tb_xdomain_state_work(struct work_struct *work)
15471584
if (ret) {
15481585
if (ret == -EAGAIN)
15491586
goto retry_state;
1550-
xd->state = XDOMAIN_STATE_ERROR;
1587+
tb_xdomain_failed(xd);
15511588
} else {
15521589
tb_xdomain_queue_properties_changed(xd);
15531590
if (xd->bonding_possible)
@@ -1612,7 +1649,7 @@ static void tb_xdomain_state_work(struct work_struct *work)
16121649
if (ret) {
16131650
if (ret == -EAGAIN)
16141651
goto retry_state;
1615-
xd->state = XDOMAIN_STATE_ERROR;
1652+
tb_xdomain_failed(xd);
16161653
} else {
16171654
xd->state = XDOMAIN_STATE_ENUMERATED;
16181655
}
@@ -1623,6 +1660,8 @@ static void tb_xdomain_state_work(struct work_struct *work)
16231660
break;
16241661

16251662
case XDOMAIN_STATE_ERROR:
1663+
dev_dbg(&xd->dev, "discovery failed, stopping handshake\n");
1664+
__stop_handshake(xd);
16261665
break;
16271666

16281667
default:
@@ -1833,21 +1872,6 @@ static void tb_xdomain_release(struct device *dev)
18331872
kfree(xd);
18341873
}
18351874

1836-
static void start_handshake(struct tb_xdomain *xd)
1837-
{
1838-
xd->state = XDOMAIN_STATE_INIT;
1839-
queue_delayed_work(xd->tb->wq, &xd->state_work,
1840-
msecs_to_jiffies(XDOMAIN_SHORT_TIMEOUT));
1841-
}
1842-
1843-
static void stop_handshake(struct tb_xdomain *xd)
1844-
{
1845-
cancel_delayed_work_sync(&xd->properties_changed_work);
1846-
cancel_delayed_work_sync(&xd->state_work);
1847-
xd->properties_changed_retries = 0;
1848-
xd->state_retries = 0;
1849-
}
1850-
18511875
static int __maybe_unused tb_xdomain_suspend(struct device *dev)
18521876
{
18531877
stop_handshake(tb_to_xdomain(dev));

drivers/usb/cdns3/cdnsp-gadget.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,9 @@ static int cdnsp_gadget_ep_dequeue(struct usb_ep *ep,
11251125
unsigned long flags;
11261126
int ret;
11271127

1128+
if (request->status != -EINPROGRESS)
1129+
return 0;
1130+
11281131
if (!pep->endpoint.desc) {
11291132
dev_err(pdev->dev,
11301133
"%s: can't dequeue to disabled endpoint\n",

drivers/usb/cdns3/core.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ void cdns_set_active(struct cdns *cdns, u8 set_active);
131131
#else /* CONFIG_PM_SLEEP */
132132
static inline int cdns_resume(struct cdns *cdns)
133133
{ return 0; }
134-
static inline int cdns_set_active(struct cdns *cdns, u8 set_active)
135-
{ return 0; }
134+
static inline void cdns_set_active(struct cdns *cdns, u8 set_active) { }
136135
static inline int cdns_suspend(struct cdns *cdns)
137136
{ return 0; }
138137
#endif /* CONFIG_PM_SLEEP */

drivers/usb/core/hub.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ int usb_device_supports_lpm(struct usb_device *udev)
151151
if (udev->quirks & USB_QUIRK_NO_LPM)
152152
return 0;
153153

154+
/* Skip if the device BOS descriptor couldn't be read */
155+
if (!udev->bos)
156+
return 0;
157+
154158
/* USB 2.1 (and greater) devices indicate LPM support through
155159
* their USB 2.0 Extended Capabilities BOS descriptor.
156160
*/
@@ -327,6 +331,10 @@ static void usb_set_lpm_parameters(struct usb_device *udev)
327331
if (!udev->lpm_capable || udev->speed < USB_SPEED_SUPER)
328332
return;
329333

334+
/* Skip if the device BOS descriptor couldn't be read */
335+
if (!udev->bos)
336+
return;
337+
330338
hub = usb_hub_to_struct_hub(udev->parent);
331339
/* It doesn't take time to transition the roothub into U0, since it
332340
* doesn't have an upstream link.
@@ -2704,13 +2712,17 @@ int usb_authorize_device(struct usb_device *usb_dev)
27042712
static enum usb_ssp_rate get_port_ssp_rate(struct usb_device *hdev,
27052713
u32 ext_portstatus)
27062714
{
2707-
struct usb_ssp_cap_descriptor *ssp_cap = hdev->bos->ssp_cap;
2715+
struct usb_ssp_cap_descriptor *ssp_cap;
27082716
u32 attr;
27092717
u8 speed_id;
27102718
u8 ssac;
27112719
u8 lanes;
27122720
int i;
27132721

2722+
if (!hdev->bos)
2723+
goto out;
2724+
2725+
ssp_cap = hdev->bos->ssp_cap;
27142726
if (!ssp_cap)
27152727
goto out;
27162728

@@ -4215,8 +4227,15 @@ static void usb_enable_link_state(struct usb_hcd *hcd, struct usb_device *udev,
42154227
enum usb3_link_state state)
42164228
{
42174229
int timeout;
4218-
__u8 u1_mel = udev->bos->ss_cap->bU1devExitLat;
4219-
__le16 u2_mel = udev->bos->ss_cap->bU2DevExitLat;
4230+
__u8 u1_mel;
4231+
__le16 u2_mel;
4232+
4233+
/* Skip if the device BOS descriptor couldn't be read */
4234+
if (!udev->bos)
4235+
return;
4236+
4237+
u1_mel = udev->bos->ss_cap->bU1devExitLat;
4238+
u2_mel = udev->bos->ss_cap->bU2DevExitLat;
42204239

42214240
/* If the device says it doesn't have *any* exit latency to come out of
42224241
* U1 or U2, it's probably lying. Assume it doesn't implement that link

drivers/usb/core/hub.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static inline int hub_is_superspeedplus(struct usb_device *hdev)
153153
{
154154
return (hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS &&
155155
le16_to_cpu(hdev->descriptor.bcdUSB) >= 0x0310 &&
156-
hdev->bos->ssp_cap);
156+
hdev->bos && hdev->bos->ssp_cap);
157157
}
158158

159159
static inline unsigned hub_power_on_good_delay(struct usb_hub *hub)

0 commit comments

Comments
 (0)