Skip to content

Commit e430611

Browse files
committed
Merge tag 'thunderbolt-for-v6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into usb-next
Mika writes: thunderbolt: Changes for v6.10 merge window This includes following USB4/Thunderbolt changes for the v6.10 merge window: - Enable NVM firmare upgrade on Intel Maple Ridge Thunderbolt 4 controller - Improve USB3 tunnel bandwidth calculation - Improve sideband access - Minor cleanups and fixes. All these have been in linux-next with no reported issues. * tag 'thunderbolt-for-v6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt: thunderbolt: Correct trace output of firmware connection manager packets thunderbolt: Fix kernel-doc for tb_tunnel_alloc_dp() thunderbolt: Fix uninitialized variable in tb_tunnel_alloc_usb3() thunderbolt: There are only 5 basic router registers in pre-USB4 routers thunderbolt: No need to loop over all retimers if access fails thunderbolt: Increase sideband access polling delay thunderbolt: Get rid of TB_CFG_PKG_PREPARE_TO_SLEEP thunderbolt: Use correct error code with ERROR_NOT_SUPPORTED thunderbolt: Allow USB3 bandwidth to be lower than maximum supported thunderbolt: Fix calculation of consumed USB3 bandwidth on a path thunderbolt: Enable NVM upgrade support on Intel Maple Ridge
2 parents adeab5b + a3dc6d8 commit e430611

File tree

10 files changed

+59
-48
lines changed

10 files changed

+59
-48
lines changed

drivers/thunderbolt/debugfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ static int switch_basic_regs_show(struct tb_switch *sw, struct seq_file *s)
13461346
if (tb_switch_is_usb4(sw))
13471347
dwords = ARRAY_SIZE(data);
13481348
else
1349-
dwords = 7;
1349+
dwords = 5;
13501350

13511351
ret = tb_sw_read(sw, data, TB_CFG_SWITCH, 0, dwords);
13521352
if (ret)

drivers/thunderbolt/icm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,6 +2532,7 @@ struct tb *icm_probe(struct tb_nhi *nhi)
25322532

25332533
case PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_2C_NHI:
25342534
case PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_4C_NHI:
2535+
icm->can_upgrade_nvm = true;
25352536
icm->is_supported = icm_tgl_is_supported;
25362537
icm->get_mode = icm_ar_get_mode;
25372538
icm->driver_ready = icm_tr_driver_ready;

drivers/thunderbolt/retimer.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,10 @@ static void tb_retimer_nvm_authenticate_status(struct tb_port *port, u32 *status
199199
* If the retimer has it set, store it for the new retimer
200200
* device instance.
201201
*/
202-
for (i = 1; i <= TB_MAX_RETIMER_INDEX; i++)
203-
usb4_port_retimer_nvm_authenticate_status(port, i, &status[i]);
202+
for (i = 1; i <= TB_MAX_RETIMER_INDEX; i++) {
203+
if (usb4_port_retimer_nvm_authenticate_status(port, i, &status[i]))
204+
break;
205+
}
204206
}
205207

206208
static void tb_retimer_set_inbound_sbtx(struct tb_port *port)
@@ -234,8 +236,10 @@ static void tb_retimer_unset_inbound_sbtx(struct tb_port *port)
234236

235237
tb_port_dbg(port, "disabling sideband transactions\n");
236238

237-
for (i = TB_MAX_RETIMER_INDEX; i >= 1; i--)
238-
usb4_port_retimer_unset_inbound_sbtx(port, i);
239+
for (i = TB_MAX_RETIMER_INDEX; i >= 1; i--) {
240+
if (usb4_port_retimer_unset_inbound_sbtx(port, i))
241+
break;
242+
}
239243
}
240244

241245
static ssize_t nvm_authenticate_store(struct device *dev,

drivers/thunderbolt/tb.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,9 @@ static struct tb_tunnel *tb_find_first_usb3_tunnel(struct tb *tb,
498498
* @consumed_down: Consumed downstream bandwidth (Mb/s)
499499
*
500500
* Calculates consumed USB3 and PCIe bandwidth at @port between path
501-
* from @src_port to @dst_port. Does not take tunnel starting from
502-
* @src_port and ending from @src_port into account.
501+
* from @src_port to @dst_port. Does not take USB3 tunnel starting from
502+
* @src_port and ending on @src_port into account because that bandwidth is
503+
* already included in as part of the "first hop" USB3 tunnel.
503504
*/
504505
static int tb_consumed_usb3_pcie_bandwidth(struct tb *tb,
505506
struct tb_port *src_port,
@@ -514,8 +515,8 @@ static int tb_consumed_usb3_pcie_bandwidth(struct tb *tb,
514515
*consumed_up = *consumed_down = 0;
515516

516517
tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port);
517-
if (tunnel && tunnel->src_port != src_port &&
518-
tunnel->dst_port != dst_port) {
518+
if (tunnel && !tb_port_is_usb3_down(src_port) &&
519+
!tb_port_is_usb3_up(dst_port)) {
519520
int ret;
520521

521522
ret = tb_tunnel_consumed_bandwidth(tunnel, consumed_up,

drivers/thunderbolt/tb_msgs.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,6 @@ struct cfg_reset_pkg {
9898
struct tb_cfg_header header;
9999
} __packed;
100100

101-
/* TB_CFG_PKG_PREPARE_TO_SLEEP */
102-
struct cfg_pts_pkg {
103-
struct tb_cfg_header header;
104-
u32 data;
105-
} __packed;
106-
107101
/* ICM messages */
108102

109103
enum icm_pkg_code {

drivers/thunderbolt/trace.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,32 @@ static inline const char *show_data(struct trace_seq *p, u8 type,
8787
const char *prefix = "";
8888
int i;
8989

90-
show_route(p, data);
91-
9290
switch (type) {
9391
case TB_CFG_PKG_READ:
9492
case TB_CFG_PKG_WRITE:
93+
show_route(p, data);
9594
show_data_read_write(p, data);
9695
break;
9796

9897
case TB_CFG_PKG_ERROR:
98+
show_route(p, data);
9999
show_data_error(p, data);
100100
break;
101101

102102
case TB_CFG_PKG_EVENT:
103+
show_route(p, data);
103104
show_data_event(p, data);
104105
break;
105106

107+
case TB_CFG_PKG_ICM_EVENT:
108+
case TB_CFG_PKG_ICM_CMD:
109+
case TB_CFG_PKG_ICM_RESP:
110+
/* ICM messages always target the host router */
111+
trace_seq_puts(p, "route=0, ");
112+
break;
113+
106114
default:
115+
show_route(p, data);
107116
break;
108117
}
109118

drivers/thunderbolt/tunnel.c

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,10 +1435,10 @@ struct tb_tunnel *tb_tunnel_discover_dp(struct tb *tb, struct tb_port *in,
14351435
* @in: DP in adapter port
14361436
* @out: DP out adapter port
14371437
* @link_nr: Preferred lane adapter when the link is not bonded
1438-
* @max_up: Maximum available upstream bandwidth for the DP tunnel (%0
1439-
* if not limited)
1440-
* @max_down: Maximum available downstream bandwidth for the DP tunnel
1441-
* (%0 if not limited)
1438+
* @max_up: Maximum available upstream bandwidth for the DP tunnel.
1439+
* %0 if no available bandwidth.
1440+
* @max_down: Maximum available downstream bandwidth for the DP tunnel.
1441+
* %0 if no available bandwidth.
14421442
*
14431443
* Allocates a tunnel between @in and @out that is capable of tunneling
14441444
* Display Port traffic.
@@ -2048,10 +2048,10 @@ struct tb_tunnel *tb_tunnel_discover_usb3(struct tb *tb, struct tb_port *down,
20482048
* @tb: Pointer to the domain structure
20492049
* @up: USB3 upstream adapter port
20502050
* @down: USB3 downstream adapter port
2051-
* @max_up: Maximum available upstream bandwidth for the USB3 tunnel (%0
2052-
* if not limited).
2053-
* @max_down: Maximum available downstream bandwidth for the USB3 tunnel
2054-
* (%0 if not limited).
2051+
* @max_up: Maximum available upstream bandwidth for the USB3 tunnel.
2052+
* %0 if no available bandwidth.
2053+
* @max_down: Maximum available downstream bandwidth for the USB3 tunnel.
2054+
* %0 if no available bandwidth.
20552055
*
20562056
* Allocate an USB3 tunnel. The ports must be of type @TB_TYPE_USB3_UP and
20572057
* @TB_TYPE_USB3_DOWN.
@@ -2066,24 +2066,19 @@ struct tb_tunnel *tb_tunnel_alloc_usb3(struct tb *tb, struct tb_port *up,
20662066
struct tb_path *path;
20672067
int max_rate = 0;
20682068

2069-
/*
2070-
* Check that we have enough bandwidth available for the new
2071-
* USB3 tunnel.
2072-
*/
2073-
if (max_up > 0 || max_down > 0) {
2069+
if (!tb_route(down->sw) && (max_up > 0 || max_down > 0)) {
2070+
/*
2071+
* For USB3 isochronous transfers, we allow bandwidth which is
2072+
* not higher than 90% of maximum supported bandwidth by USB3
2073+
* adapters.
2074+
*/
20742075
max_rate = tb_usb3_max_link_rate(down, up);
20752076
if (max_rate < 0)
20762077
return NULL;
20772078

2078-
/* Only 90% can be allocated for USB3 isochronous transfers */
20792079
max_rate = max_rate * 90 / 100;
2080-
tb_port_dbg(up, "required bandwidth for USB3 tunnel %d Mb/s\n",
2080+
tb_port_dbg(up, "maximum required bandwidth for USB3 tunnel %d Mb/s\n",
20812081
max_rate);
2082-
2083-
if (max_rate > max_up || max_rate > max_down) {
2084-
tb_port_warn(up, "not enough bandwidth for USB3 tunnel\n");
2085-
return NULL;
2086-
}
20872082
}
20882083

20892084
tunnel = tb_tunnel_alloc(tb, 2, TB_TUNNEL_USB3);
@@ -2115,8 +2110,8 @@ struct tb_tunnel *tb_tunnel_alloc_usb3(struct tb *tb, struct tb_port *up,
21152110
tunnel->paths[TB_USB3_PATH_UP] = path;
21162111

21172112
if (!tb_route(down->sw)) {
2118-
tunnel->allocated_up = max_rate;
2119-
tunnel->allocated_down = max_rate;
2113+
tunnel->allocated_up = min(max_rate, max_up);
2114+
tunnel->allocated_down = min(max_rate, max_down);
21202115

21212116
tunnel->init = tb_usb3_init;
21222117
tunnel->consumed_bandwidth = tb_usb3_consumed_bandwidth;

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,
@@ -1245,7 +1249,7 @@ void usb4_port_unconfigure_xdomain(struct tb_port *port)
12451249
}
12461250

12471251
static int usb4_port_wait_for_bit(struct tb_port *port, u32 offset, u32 bit,
1248-
u32 value, int timeout_msec)
1252+
u32 value, int timeout_msec, unsigned long delay_usec)
12491253
{
12501254
ktime_t timeout = ktime_add_ms(ktime_get(), timeout_msec);
12511255

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

1263-
usleep_range(50, 100);
1267+
fsleep(delay_usec);
12641268
} while (ktime_before(ktime_get(), timeout));
12651269

12661270
return -ETIMEDOUT;
@@ -1308,7 +1312,7 @@ static int usb4_port_sb_read(struct tb_port *port, enum usb4_sb_target target,
13081312
return ret;
13091313

13101314
ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_1,
1311-
PORT_CS_1_PND, 0, 500);
1315+
PORT_CS_1_PND, 0, 500, USB4_PORT_SB_DELAY);
13121316
if (ret)
13131317
return ret;
13141318

@@ -1355,7 +1359,7 @@ static int usb4_port_sb_write(struct tb_port *port, enum usb4_sb_target target,
13551359
return ret;
13561360

13571361
ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_1,
1358-
PORT_CS_1_PND, 0, 500);
1362+
PORT_CS_1_PND, 0, 500, USB4_PORT_SB_DELAY);
13591363
if (ret)
13601364
return ret;
13611365

@@ -1410,6 +1414,8 @@ static int usb4_port_sb_op(struct tb_port *port, enum usb4_sb_target target,
14101414

14111415
if (val != opcode)
14121416
return usb4_port_sb_opcode_err_to_errno(val);
1417+
1418+
fsleep(USB4_PORT_SB_DELAY);
14131419
} while (ktime_before(ktime_get(), timeout));
14141420

14151421
return -ETIMEDOUT;
@@ -1591,13 +1597,14 @@ int usb4_port_asym_start(struct tb_port *port)
15911597
* port started the symmetry transition.
15921598
*/
15931599
ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_19,
1594-
PORT_CS_19_START_ASYM, 0, 1000);
1600+
PORT_CS_19_START_ASYM, 0, 1000,
1601+
USB4_PORT_DELAY);
15951602
if (ret)
15961603
return ret;
15971604

15981605
/* Then wait for the transtion to be completed */
15991606
return usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_18,
1600-
PORT_CS_18_TIP, 0, 5000);
1607+
PORT_CS_18_TIP, 0, 5000, USB4_PORT_DELAY);
16011608
}
16021609

16031610
/**
@@ -2123,7 +2130,8 @@ static int usb4_usb3_port_cm_request(struct tb_port *port, bool request)
21232130
*/
21242131
val &= ADP_USB3_CS_2_CMR;
21252132
return usb4_port_wait_for_bit(port, port->cap_adap + ADP_USB3_CS_1,
2126-
ADP_USB3_CS_1_HCA, val, 1500);
2133+
ADP_USB3_CS_1_HCA, val, 1500,
2134+
USB4_PORT_DELAY);
21272135
}
21282136

21292137
static inline int usb4_usb3_port_set_cm_request(struct tb_port *port)

drivers/thunderbolt/xdomain.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static int tb_xdp_handle_error(const struct tb_xdp_error_response *res)
250250
case ERROR_UNKNOWN_DOMAIN:
251251
return -EIO;
252252
case ERROR_NOT_SUPPORTED:
253-
return -ENOTSUPP;
253+
return -EOPNOTSUPP;
254254
case ERROR_NOT_READY:
255255
return -EAGAIN;
256256
default:

include/linux/thunderbolt.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ enum tb_cfg_pkg_type {
3333
TB_CFG_PKG_ICM_EVENT = 10,
3434
TB_CFG_PKG_ICM_CMD = 11,
3535
TB_CFG_PKG_ICM_RESP = 12,
36-
TB_CFG_PKG_PREPARE_TO_SLEEP = 13,
3736
};
3837

3938
/**

0 commit comments

Comments
 (0)