Skip to content

Commit c6ca1ac

Browse files
committed
thunderbolt: Increase sideband access polling delay
The USB4 sideband access is slow compared to the high-speed link and the access timing parameters are tens of milliseconds according the spec. To avoid too much unnecessary polling for the sideband pass the wait delay to usb4_port_wait_for_bit() and use larger (5ms) value compared to the high-speed access. Signed-off-by: Mika Westerberg <[email protected]>
1 parent c936e28 commit c6ca1ac

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

drivers/thunderbolt/usb4.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ enum usb4_ba_index {
5252
#define USB4_BA_VALUE_MASK GENMASK(31, 16)
5353
#define USB4_BA_VALUE_SHIFT 16
5454

55+
/* Delays in us used with usb4_port_wait_for_bit() */
56+
#define USB4_PORT_DELAY 50
57+
#define USB4_PORT_SB_DELAY 5000
58+
5559
static int usb4_native_switch_op(struct tb_switch *sw, u16 opcode,
5660
u32 *metadata, u8 *status,
5761
const void *tx_data, size_t tx_dwords,
@@ -1244,7 +1248,7 @@ void usb4_port_unconfigure_xdomain(struct tb_port *port)
12441248
}
12451249

12461250
static int usb4_port_wait_for_bit(struct tb_port *port, u32 offset, u32 bit,
1247-
u32 value, int timeout_msec)
1251+
u32 value, int timeout_msec, unsigned long delay_usec)
12481252
{
12491253
ktime_t timeout = ktime_add_ms(ktime_get(), timeout_msec);
12501254

@@ -1259,7 +1263,7 @@ static int usb4_port_wait_for_bit(struct tb_port *port, u32 offset, u32 bit,
12591263
if ((val & bit) == value)
12601264
return 0;
12611265

1262-
usleep_range(50, 100);
1266+
fsleep(delay_usec);
12631267
} while (ktime_before(ktime_get(), timeout));
12641268

12651269
return -ETIMEDOUT;
@@ -1307,7 +1311,7 @@ static int usb4_port_sb_read(struct tb_port *port, enum usb4_sb_target target,
13071311
return ret;
13081312

13091313
ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_1,
1310-
PORT_CS_1_PND, 0, 500);
1314+
PORT_CS_1_PND, 0, 500, USB4_PORT_SB_DELAY);
13111315
if (ret)
13121316
return ret;
13131317

@@ -1354,7 +1358,7 @@ static int usb4_port_sb_write(struct tb_port *port, enum usb4_sb_target target,
13541358
return ret;
13551359

13561360
ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_1,
1357-
PORT_CS_1_PND, 0, 500);
1361+
PORT_CS_1_PND, 0, 500, USB4_PORT_SB_DELAY);
13581362
if (ret)
13591363
return ret;
13601364

@@ -1409,6 +1413,8 @@ static int usb4_port_sb_op(struct tb_port *port, enum usb4_sb_target target,
14091413

14101414
if (val != opcode)
14111415
return usb4_port_sb_opcode_err_to_errno(val);
1416+
1417+
fsleep(USB4_PORT_SB_DELAY);
14121418
} while (ktime_before(ktime_get(), timeout));
14131419

14141420
return -ETIMEDOUT;
@@ -1590,13 +1596,14 @@ int usb4_port_asym_start(struct tb_port *port)
15901596
* port started the symmetry transition.
15911597
*/
15921598
ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_19,
1593-
PORT_CS_19_START_ASYM, 0, 1000);
1599+
PORT_CS_19_START_ASYM, 0, 1000,
1600+
USB4_PORT_DELAY);
15941601
if (ret)
15951602
return ret;
15961603

15971604
/* Then wait for the transtion to be completed */
15981605
return usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_18,
1599-
PORT_CS_18_TIP, 0, 5000);
1606+
PORT_CS_18_TIP, 0, 5000, USB4_PORT_DELAY);
16001607
}
16011608

16021609
/**
@@ -2122,7 +2129,8 @@ static int usb4_usb3_port_cm_request(struct tb_port *port, bool request)
21222129
*/
21232130
val &= ADP_USB3_CS_2_CMR;
21242131
return usb4_port_wait_for_bit(port, port->cap_adap + ADP_USB3_CS_1,
2125-
ADP_USB3_CS_1_HCA, val, 1500);
2132+
ADP_USB3_CS_1_HCA, val, 1500,
2133+
USB4_PORT_DELAY);
21262134
}
21272135

21282136
static inline int usb4_usb3_port_set_cm_request(struct tb_port *port)

0 commit comments

Comments
 (0)