thunderbolt: Initial USB4 v2 support
Subsystems (3)
v2 cover thunderbolt: Initial USB4 v2 support
Hi all,
This series adds initial support for the next USB4 version (USB4 v2) and the Intel Barlow Ridge discrete controller. This includes support for the 80G symmetric link, the necessary configuration needed to bring up the router in v2 mode, adaptive TMU, PCIe extended encapsulation, and CL2 low power link state. We will be sending the rest of the USB4 v2 support, including asymmetric 128/80G link support later on once this one has settled.
These are based on thunderbolt.git/next.
The previous version of the series can be found:
https://lore.kernel.org/linux-usb/[email protected]/
Changes from v1:
* Make tb_switch_is_usb4() use usb4_switch_version() as well
* Set TMU mode off by default in tmu_mode_init()
* Log TMU mode change only if it is actually changed in tb_switch_tmu_configure().
Gil Fine (9):
thunderbolt: Identify USB4 v2 routers
thunderbolt: Add support for USB4 v2 80 Gb/s link
thunderbolt: Announce USB4 v2 connection manager support
thunderbolt: Enable USB4 v2 PCIe TLP/DLLP extended encapsulation
thunderbolt: Add two additional double words for adapters TMU for USB4 v2 routers
thunderbolt: Fix DisplayPort IN adapter capability length for USB4 v2 routers
thunderbolt: Fix PCIe adapter capability length for USB4 v2 routers
thunderbolt: Move constants related to NVM into nvm.c
thunderbolt: Increase NVM_MAX_SIZE to support Intel Barlow Ridge controller
Mika Westerberg (11):
thunderbolt: Ignore data CRC mismatch for USB4 routers
thunderbolt: Do not touch lane 1 adapter path config space
thunderbolt: Add the new USB4 v2 notification types
thunderbolt: Reset USB4 v2 host router
thunderbolt: Add Intel Barlow Ridge PCI ID
thunderbolt: Limit Intel Barlow Ridge USB3 bandwidth
thunderbolt: Add support for enhanced uni-directional TMU mode
thunderbolt: Enable CL2 low power state
thunderbolt: Make bandwidth allocation mode function names consistent
thunderbolt: Add DisplayPort 2.x tunneling support
thunderbolt: Add test case for 3 DisplayPort tunnels
drivers/thunderbolt/clx.c | 31 +- drivers/thunderbolt/ctl.c | 28 ++ drivers/thunderbolt/debugfs.c | 29 +- drivers/thunderbolt/dma_test.c | 10 +- drivers/thunderbolt/eeprom.c | 3 +- drivers/thunderbolt/icm.c | 6 +- drivers/thunderbolt/nhi.c | 41 ++- drivers/thunderbolt/nhi.h | 4 + drivers/thunderbolt/nhi_regs.h | 19 +- drivers/thunderbolt/nvm.c | 4 + drivers/thunderbolt/quirks.c | 8 + drivers/thunderbolt/switch.c | 216 ++++++++---- drivers/thunderbolt/tb.c | 132 ++++++-- drivers/thunderbolt/tb.h | 144 ++++---- drivers/thunderbolt/tb_msgs.h | 7 + drivers/thunderbolt/tb_regs.h | 25 +- drivers/thunderbolt/test.c | 83 +++++ drivers/thunderbolt/tmu.c | 595 ++++++++++++++++++++++++++------- drivers/thunderbolt/tunnel.c | 178 +++++++--- drivers/thunderbolt/usb4.c | 108 ++++-- drivers/thunderbolt/xdomain.c | 82 ++++- include/linux/thunderbolt.h | 18 +- 22 files changed, 1380 insertions(+), 391 deletions(-)
Signature · 1 line
2.39.2
PATCH v2 2/20 thunderbolt: Do not touch lane 1 adapter path config space
It is not required to be implemented at all because USB4 does not use lane 1 for tunneling except when aggregated with lane 0. For this reason do not try to read the path config space of USB4 lane 1 adapters.
--- drivers/thunderbolt/switch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thunderbolt/switch.c +1 -1
@@ -723,7 +723,7 @@ static int tb_init_port(struct tb_port *port)* can be read from the path config space. Legacy * devices we use hard-coded value. */ -if (tb_switch_is_usb4 (port->sw)) { +if (port->cap_usb4) {struct tb_regs_hop hop;if (!tb_port_read (port, &hop,TB_CFG_HOPS ,0 ,2 ))
Signature · 1 line
2.39.2
PATCH v2 3/20 thunderbolt: Identify USB4 v2 routers
In reply to Mika WesterbergFrom: Gil Fine <[email protected]>
Add a new function usb4_switch_version() that can be used to figure out the spec version of the router and make tb_switch_is_usb4() to use it as well. Update the uevent accordingly.
--- drivers/thunderbolt/switch.c | 5 +++-- drivers/thunderbolt/tb.h | 34 +++++++++++++++++++++++----------- drivers/thunderbolt/tb_regs.h | 4 ++-- 3 files changed, 28 insertions(+), 15 deletions(-)
drivers/thunderbolt/switch.c +3 -2
@@ -2056,8 +2056,9 @@ static int tb_switch_uevent(const struct device *dev, struct kobj_uevent_env *enconst struct tb_switch *sw =tb_to_switch (dev);const char *type; -if (sw->config.thunderbolt_version ==USB4_VERSION_1_0 ) { -if (add_uevent_var (env,"USB4_VERSION=1.0" )) +if (tb_switch_is_usb4 (sw)) { +if (add_uevent_var (env,"USB4_VERSION=%u.0" , +usb4_switch_version (sw)))return -ENOMEM ; }
drivers/thunderbolt/tb.h +23 -11
@@ -947,17 +947,6 @@ static inline bool tb_switch_is_tiger_lake(const struct tb_switch *sw)return false; } -/** -* tb_switch_is_usb4() - Is the switch USB4 compliant -* @sw: Switch to check -* -* Returns true if the @sw is USB4 compliant router, false otherwise. -*/ -static inline bool tb_switch_is_usb4 (const struct tb_switch *sw) -{ -return sw->config.thunderbolt_version ==USB4_VERSION_1_0 ; -} -/** * tb_switch_is_icm() - Is the switch handled by ICM firmware * @sw: Switch to check
@@ -1198,6 +1187,29 @@ static inline struct tb_retimer *tb_to_retimer(struct device *dev)return NULL ; } +/** +* usb4_switch_version() - Returns USB4 version of the router +* @sw: Router to check +* +* Returns major version of USB4 router (%1 for v1, %2 for v2 and so +* on). Can be called to pre-USB4 router too and in that case returns %0. +*/ +static inline unsigned int usb4_switch_version (const struct tb_switch *sw) +{ +return FIELD_GET (USB4_VERSION_MAJOR_MASK , sw->config.thunderbolt_version); +} + +/** +* tb_switch_is_usb4() - Is the switch USB4 compliant +* @sw: Switch to check +* +* Returns true if the @sw is USB4 compliant router, false otherwise. +*/ +static inline bool tb_switch_is_usb4 (const struct tb_switch *sw) +{ +return usb4_switch_version (sw) >0 ; +} +int usb4_switch_setup (struct tb_switch *sw);int usb4_switch_read_uid (struct tb_switch *sw,u64 *uid); int usb4_switch_drom_read(struct tb_switch *sw, unsigned int address, void *buf,
drivers/thunderbolt/tb_regs.h +2 -2
@@ -190,8 +190,8 @@ struct tb_regs_switch_header { u32 thunderbolt_version:8; } __packed; -/* USB4 version 1.0 */ -#define USB4_VERSION_1_0 0x20 +/* Used with the router thunderbolt_version */ +#define USB4_VERSION_MAJOR_MASK GENMASK(7, 5)#define ROUTER_CS_1 0x01#define ROUTER_CS_4 0x04
Signature · 1 line
2.39.2
PATCH v2 1/20 thunderbolt: Ignore data CRC mismatch for USB4 routers
In reply to Mika WesterbergThis is also something not always updated after the DROM contents itself so issue warning but continue parsing it as we do for pre-USB4 DROMs too.
--- drivers/thunderbolt/eeprom.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/thunderbolt/eeprom.c +1 -2
@@ -605,9 +605,8 @@ static int usb4_drom_parse(struct tb_switch *sw) crc =tb_crc32 (sw->drom +TB_DROM_DATA_START , header->data_len);if (crc != header->data_crc32) {tb_sw_warn (sw, -"DROM data CRC32 mismatch (expected: %#x, got: %#x), aborting\n" , +"DROM data CRC32 mismatch (expected: %#x, got: %#x), continuing\n" , header->data_crc32, crc); -return -EINVAL ; }return tb_drom_parse_entries (sw,USB4_DROM_HEADER_SIZE );
Signature · 1 line
2.39.2
PATCH v2 5/20 thunderbolt: Add the new USB4 v2 notification types
In reply to Mika WesterbergUSB4 v2 spec adds a bunch of new notifications that the connection manager can use instead of polling. While we do not use these yet we need to ack the ones routers expect to be acked.
--- drivers/thunderbolt/ctl.c | 28 ++++++++++++++++++++++++++++ drivers/thunderbolt/tb.c | 17 +++++++++++++---- drivers/thunderbolt/tb_msgs.h | 7 +++++++ 3 files changed, 48 insertions(+), 4 deletions(-)
drivers/thunderbolt/ctl.c +28 -0
@@ -409,6 +409,13 @@ static int tb_async_error(const struct ctl_pkg *pkg)case TB_CFG_ERROR_HEC_ERROR_DETECTED :case TB_CFG_ERROR_FLOW_CONTROL_ERROR :case TB_CFG_ERROR_DP_BW : +case TB_CFG_ERROR_ROP_CMPLT : +case TB_CFG_ERROR_POP_CMPLT : +case TB_CFG_ERROR_PCIE_WAKE : +case TB_CFG_ERROR_DP_CON_CHANGE : +case TB_CFG_ERROR_DPTX_DISCOVERY : +case TB_CFG_ERROR_LINK_RECOVERY : +case TB_CFG_ERROR_ASYM_LINK :return true;default :
@@ -758,6 +765,27 @@ int tb_cfg_ack_notification(struct tb_ctl *ctl, u64 route,case TB_CFG_ERROR_DP_BW : name ="DP_BW" ;break ; +case TB_CFG_ERROR_ROP_CMPLT : + name ="router operation completion" ; +break ; +case TB_CFG_ERROR_POP_CMPLT : + name ="port operation completion" ; +break ; +case TB_CFG_ERROR_PCIE_WAKE : + name ="PCIe wake" ; +break ; +case TB_CFG_ERROR_DP_CON_CHANGE : + name ="DP connector change" ; +break ; +case TB_CFG_ERROR_DPTX_DISCOVERY : + name ="DPTX discovery" ; +break ; +case TB_CFG_ERROR_LINK_RECOVERY : + name ="link recovery" ; +break ; +case TB_CFG_ERROR_ASYM_LINK : + name ="asymmetric link" ; +break ;default : name ="unknown" ;break ;
drivers/thunderbolt/tb.c +13 -4
@@ -1952,17 +1952,26 @@ static void tb_queue_dp_bandwidth_request(struct tb *tb, u64 route, u8 port)static void tb_handle_notification (struct tb *tb,u64 route,const struct cfg_error_pkg *error) { -if (tb_cfg_ack_notification (tb->ctl, route, error)) -tb_warn (tb,"could not ack notification on %llx\n" , route);switch (error->error) { +case TB_CFG_ERROR_PCIE_WAKE : +case TB_CFG_ERROR_DP_CON_CHANGE : +case TB_CFG_ERROR_DPTX_DISCOVERY : +if (tb_cfg_ack_notification (tb->ctl, route, error)) +tb_warn (tb,"could not ack notification on %llx\n" , + route); +break ; +case TB_CFG_ERROR_DP_BW : +if (tb_cfg_ack_notification (tb->ctl, route, error)) +tb_warn (tb,"could not ack notification on %llx\n" , + route);tb_queue_dp_bandwidth_request (tb, route, error->port);break ;default : -/* Ack is enough */ -return ; +/* Ignore for now */ +break ; } }
drivers/thunderbolt/tb_msgs.h +7 -0
@@ -30,6 +30,13 @@ enum tb_cfg_error {TB_CFG_ERROR_FLOW_CONTROL_ERROR =13 ,TB_CFG_ERROR_LOCK =15 ,TB_CFG_ERROR_DP_BW =32 , +TB_CFG_ERROR_ROP_CMPLT =33 , +TB_CFG_ERROR_POP_CMPLT =34 , +TB_CFG_ERROR_PCIE_WAKE =35 , +TB_CFG_ERROR_DP_CON_CHANGE =36 , +TB_CFG_ERROR_DPTX_DISCOVERY =37 , +TB_CFG_ERROR_LINK_RECOVERY =38 , + TB_CFG_ERROR_ASYM_LINK = 39, };/* common header */
Signature · 1 line
2.39.2
PATCH v2 6/20 thunderbolt: Reset USB4 v2 host router
In reply to Mika WesterbergUSB4 v2 added a bit that can be used to reset the host router so we use this to trigger reset when the driver probes. This will reset the already connected topology as well but doing this simplifies things a lot if for instance the link is already set to asymmetric. We also add a module parameter to prevent this in case of problems.
While there rename the REG_HOP_COUNT to REG_CAPS to match the USB4 spec naming better.
--- drivers/thunderbolt/nhi.c | 39 +++++++++++++++++++++++++++++++++- drivers/thunderbolt/nhi_regs.h | 19 +++++++++++------ 2 files changed, 50 insertions(+), 8 deletions(-)
drivers/thunderbolt/nhi.c +38 -1
@@ -46,6 +46,10 @@#define QUIRK_AUTO_CLEAR_INT BIT(0)#define QUIRK_E2E BIT(1) +static bool host_reset = true; +module_param (host_reset, bool,0444 ); +MODULE_PARM_DESC (host_reset,"reset USBv2 host router (default: true)" ); +static int ring_interrupt_index (const struct tb_ring *ring) {int bit = ring->hop;
@@ -1217,6 +1221,37 @@ static void nhi_check_iommu(struct tb_nhi *nhi) str_enabled_disabled(port_ok)); } +static void nhi_reset (struct tb_nhi *nhi) +{ +ktime_t timeout; +u32 val; + + val =ioread32 (nhi->iobase +REG_CAPS ); +/* Reset only v2 and later routers */ +if (FIELD_GET (REG_CAPS_VERSION_MASK , val) <REG_CAPS_VERSION_2 ) +return ; + +if (!host_reset) { +dev_dbg (&nhi->pdev->dev,"skipping host router reset\n" ); +return ; + } + +iowrite32 (REG_RESET_HRR , nhi->iobase +REG_RESET ); +msleep (100 ); + + timeout =ktime_add_ms (ktime_get (),500 ); +do { + val =ioread32 (nhi->iobase +REG_RESET ); +if (!(val ®_RESET_HRR )) { +dev_warn (&nhi->pdev->dev,"host router reset successful\n" ); +return ; + } +usleep_range (10 ,20 ); + }while (ktime_before (ktime_get (), timeout)); + +dev_warn (&nhi->pdev->dev,"timeout resetting host router\n" ); +} +static int nhi_init_msi (struct tb_nhi *nhi) {struct pci_dev *pdev = nhi->pdev;
@@ -1317,7 +1352,7 @@ static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id) nhi->ops = (const struct tb_nhi_ops *)id->driver_data;/* cannot fail - table is allocated in pcim_iomap_regions */ nhi->iobase =pcim_iomap_table (pdev)[0 ]; - nhi->hop_count =ioread32 (nhi->iobase +REG_HOP_COUNT ) &0x3ff ; + nhi->hop_count =ioread32 (nhi->iobase +REG_CAPS ) &0x3ff ;dev_dbg (dev,"total paths: %d\n" , nhi->hop_count); nhi->tx_rings = devm_kcalloc(&pdev->dev, nhi->hop_count,
@@ -1330,6 +1365,8 @@ static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id)nhi_check_quirks (nhi);nhi_check_iommu (nhi); +nhi_reset (nhi); + res =nhi_init_msi (nhi);if (res)return dev_err_probe (dev, res,"cannot enable MSI, aborting\n" );
drivers/thunderbolt/nhi_regs.h +12 -7
@@ -37,7 +37,7 @@ struct ring_desc {/* NHI registers in bar 0 */ /* -* 16 bytes per entry, one entry for every hop (REG_HOP_COUNT) +* 16 bytes per entry, one entry for every hop (REG_CAPS) * 00: physical pointer to an array of struct ring_desc * 08: ring tail (set by NHI) * 10: ring head (index of first non posted descriptor)
@@ -46,7 +46,7 @@ struct ring_desc {#define REG_TX_RING_BASE 0x00000/* -* 16 bytes per entry, one entry for every hop (REG_HOP_COUNT) +* 16 bytes per entry, one entry for every hop (REG_CAPS) * 00: physical pointer to an array of struct ring_desc * 08: ring head (index of first not posted descriptor) * 10: ring tail (set by NHI)
@@ -56,7 +56,7 @@ struct ring_desc {#define REG_RX_RING_BASE 0x08000/* -* 32 bytes per entry, one entry for every hop (REG_HOP_COUNT) +* 32 bytes per entry, one entry for every hop (REG_CAPS) * 00: enum_ring_flags * 04: isoch time stamp ?? (write 0) * ..: unknown
@@ -64,7 +64,7 @@ struct ring_desc {#define REG_TX_OPTIONS_BASE 0x19800/* -* 32 bytes per entry, one entry for every hop (REG_HOP_COUNT) +* 32 bytes per entry, one entry for every hop (REG_CAPS) * 00: enum ring_flags * If RING_FLAG_E2E_FLOW_CONTROL is set then bits 13-23 must be set to * the corresponding TX hop id.
@@ -77,7 +77,7 @@ struct ring_desc {/* * three bitfields: tx, rx, rx overflow -* Every bitfield contains one bit for every hop (REG_HOP_COUNT). +* Every bitfield contains one bit for every hop (REG_CAPS). * New interrupts are fired only after ALL registers have been * read (even those containing only disabled rings). */
@@ -87,7 +87,7 @@ struct ring_desc {/* * two bitfields: rx, tx -* Both bitfields contains one bit for every hop (REG_HOP_COUNT). To +* Both bitfields contains one bit for every hop (REG_CAPS). To * enable/disable interrupts set/clear the corresponding bits. */ #define REG_RING_INTERRUPT_BASE 0x38200
@@ -104,12 +104,17 @@ struct ring_desc {#define REG_INT_VEC_ALLOC_REGS (32 / REG_INT_VEC_ALLOC_BITS)/* The last 11 bits contain the number of hops supported by the NHI port. */ -#define REG_HOP_COUNT 0x39640 +#define REG_CAPS 0x39640 +#define REG_CAPS_VERSION_MASK GENMASK(23, 16) +#define REG_CAPS_VERSION_2 0x40#define REG_DMA_MISC 0x39864#define REG_DMA_MISC_INT_AUTO_CLEAR BIT(2)#define REG_DMA_MISC_DISABLE_AUTO_CLEAR BIT(17) +#define REG_RESET 0x39898 +#define REG_RESET_HRR BIT(0) +#define REG_INMAIL_DATA 0x39900#define REG_INMAIL_CMD 0x39904
Signature · 1 line
2.39.2
PATCH v2 12/20 thunderbolt: Add Intel Barlow Ridge PCI ID
In reply to Mika WesterbergIntel Barlow Ridge is the first USB4 v2 controller from Intel. The controller exposes standard USB4 PCI class ID in typical configurations, however there is a way to configure it so that it uses a special class ID to allow using s different driver than the Windows inbox one. For this reason add the Barlow Ridge PCI ID to the Linux driver too so that the driver can attach regardless of the class ID.
--- drivers/thunderbolt/nhi.c | 2 ++ drivers/thunderbolt/nhi.h | 2 ++ 2 files changed, 4 insertions(+)
drivers/thunderbolt/nhi.c +2 -0
@@ -1517,6 +1517,8 @@ static struct pci_device_id nhi_ids[] = { .driver_data = (kernel_ulong_t)&icl_nhi_ops }, { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MTL_P_NHI1), .driver_data = (kernel_ulong_t)&icl_nhi_ops }, + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_80G_NHI) }, + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_40G_NHI) },/* Any USB4 compliant host */ { PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_USB4, ~0) },
drivers/thunderbolt/nhi.h +2 -0
@@ -75,6 +75,8 @@ extern const struct tb_nhi_ops icl_nhi_ops;#define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_BRIDGE 0x15ef#define PCI_DEVICE_ID_INTEL_ADL_NHI0 0x463e#define PCI_DEVICE_ID_INTEL_ADL_NHI1 0x466d +#define PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_80G_NHI 0x5781 +#define PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_40G_NHI 0x5784#define PCI_DEVICE_ID_INTEL_MTL_M_NHI0 0x7eb2#define PCI_DEVICE_ID_INTEL_MTL_P_NHI0 0x7ec2#define PCI_DEVICE_ID_INTEL_MTL_P_NHI1 0x7ec3
Signature · 1 line
2.39.2
PATCH v2 4/20 thunderbolt: Add support for USB4 v2 80 Gb/s link
In reply to Mika WesterbergFrom: Gil Fine <[email protected]>
USB4 v2 bumps the per-lane speed up to 40 Gb/s. Also the lanes are always bonded which gives 80 Gb/s symmetric link (and 120/40 Gb/s asymmetric). This updates the speed and width of routers and XDomain connections to support the Gen 4 link. For now we keep the link as is even if it is already asymmetric.
While there make tb_port_set_link_width() static.
--- drivers/thunderbolt/dma_test.c | 10 +- drivers/thunderbolt/icm.c | 6 +- drivers/thunderbolt/switch.c | 185 +++++++++++++++++++++++---------- drivers/thunderbolt/tb.c | 38 ++++++- drivers/thunderbolt/tb.h | 14 ++- drivers/thunderbolt/tb_regs.h | 1 + drivers/thunderbolt/xdomain.c | 82 ++++++++++++--- include/linux/thunderbolt.h | 18 +++- 8 files changed, 266 insertions(+), 88 deletions(-)
drivers/thunderbolt/dma_test.c +7 -3
@@ -412,6 +412,7 @@ static void speed_get(const struct dma_test *dt, u64 *val)static int speed_validate (u64 val) {switch (val) { +case 40 :case 20 :case 10 :case 0 :
@@ -489,9 +490,12 @@ static void dma_test_check_errors(struct dma_test *dt, int ret)if (!dt->error_code) {if (dt->link_speed && dt->xd->link_speed != dt->link_speed) { dt->error_code =DMA_TEST_SPEED_ERROR ; - }else if (dt->link_width && - dt->xd->link_width != dt->link_width) { - dt->error_code =DMA_TEST_WIDTH_ERROR ; + }else if (dt->link_width) { +const struct tb_xdomain *xd = dt->xd; + +if ((dt->link_width ==1 && xd->link_width !=TB_LINK_WIDTH_SINGLE ) || + (dt->link_width ==2 && xd->link_width <TB_LINK_WIDTH_DUAL )) + dt->error_code =DMA_TEST_WIDTH_ERROR ; }else if (dt->packets_to_send != dt->packets_sent || dt->packets_to_receive != dt->packets_received || dt->crc_errors || dt->buffer_overflow_errors) {
drivers/thunderbolt/icm.c +4 -2
@@ -850,7 +850,8 @@ icm_fr_device_connected(struct tb *tb, const struct icm_pkg_header *hdr) sw->security_level = security_level; sw->boot = boot; sw->link_speed = speed_gen3 ?20 :10 ; - sw->link_width = dual_lane ?2 :1 ; + sw->link_width = dual_lane ?TB_LINK_WIDTH_DUAL : +TB_LINK_WIDTH_SINGLE ; sw->rpm =intel_vss_is_rtd3 (pkg->ep_name,sizeof (pkg->ep_name));if (add_switch (parent_sw, sw))
@@ -1272,7 +1273,8 @@ __icm_tr_device_connected(struct tb *tb, const struct icm_pkg_header *hdr, sw->security_level = security_level; sw->boot = boot; sw->link_speed = speed_gen3 ?20 :10 ; - sw->link_width = dual_lane ?2 :1 ; + sw->link_width = dual_lane ?TB_LINK_WIDTH_DUAL : +TB_LINK_WIDTH_SINGLE ; sw->rpm = force_rtd3;if (!sw->rpm) sw->rpm = intel_vss_is_rtd3(pkg->ep_name,
drivers/thunderbolt/switch.c +128 -57
340 lines not on this page · raw message
drivers/thunderbolt/tb.c +33 -5
@@ -570,7 +570,8 @@ static int tb_available_bandwidth(struct tb *tb, struct tb_port *src_port, usb3_consumed_down =0 ; } - *available_up = *available_down =40000 ; +/* Maximum possible bandwidth asymmetric Gen 4 link is 120 Gb/s */ + *available_up = *available_down =120000 ;/* Find the minimum available bandwidth over all links */ tb_for_each_port_on_path (src_port, dst_port, port) {
@@ -581,18 +582,45 @@ static int tb_available_bandwidth(struct tb *tb, struct tb_port *src_port,if (tb_is_upstream_port (port)) { link_speed = port->sw->link_speed; +/* +* sw->link_width is from upstream perspective +* so we use the opposite for downstream of the +* host router. +*/ +if (port->sw->link_width ==TB_LINK_WIDTH_ASYM_TX ) { + up_bw = link_speed *3 *1000 ; + down_bw = link_speed *1 *1000 ; + }else if (port->sw->link_width ==TB_LINK_WIDTH_ASYM_RX ) { + up_bw = link_speed *1 *1000 ; + down_bw = link_speed *3 *1000 ; + }else { + up_bw = link_speed * port->sw->link_width *1000 ; + down_bw = up_bw; + } }else { link_speed =tb_port_get_link_speed (port);if (link_speed <0 )return link_speed; - } - link_width = port->bonded ?2 :1 ; + link_width =tb_port_get_link_width (port); +if (link_width <0 ) +return link_width; + +if (link_width ==TB_LINK_WIDTH_ASYM_TX ) { + up_bw = link_speed *1 *1000 ; + down_bw = link_speed *3 *1000 ; + }else if (link_width ==TB_LINK_WIDTH_ASYM_RX ) { + up_bw = link_speed *3 *1000 ; + down_bw = link_speed *1 *1000 ; + }else { + up_bw = link_speed * link_width *1000 ; + down_bw = up_bw; + } + } - up_bw = link_speed * link_width *1000 ;/* Mb/s */ /* Leave 10% guard band */ up_bw -= up_bw /10 ; - down_bw = up_bw; + down_bw -= down_bw /10 ;tb_port_dbg (port,"link total bandwidth %d/%d Mb/s\n" , up_bw, down_bw);
drivers/thunderbolt/tb.h +9 -5
@@ -135,7 +135,7 @@ struct tb_switch_tmu {* @vendor_name: Name of the vendor (or %NULL if not known) * @device_name: Name of the device (or %NULL if not known) * @link_speed: Speed of the link in Gb/s -* @link_width: Width of the link (1 or 2) +* @link_width: Width of the upstream facing link * @link_usb4: Upstream link is USB4 * @generation: Switch Thunderbolt generation * @cap_plug_events: Offset to the plug events capability (%0 if not found)
@@ -173,6 +173,11 @@ struct tb_switch_tmu {* switches) you need to have domain lock held. * * In USB4 terminology this structure represents a router. +* +* Note @link_width is not the same as whether link is bonded or not. +* For Gen 4 links the link is also bonded when it is asymmetric. The +* correct way to find out whether the link is bonded or not is to look +* @bonded field of the upstream port. */ struct tb_switch {struct device dev;
@@ -188,7 +193,7 @@ struct tb_switch {const char *vendor_name;const char *device_name;unsigned int link_speed; -unsigned int link_width; +enum tb_link_width link_width;bool link_usb4;unsigned int generation;int cap_plug_events;
@@ -1050,11 +1055,10 @@ static inline bool tb_port_use_credit_allocation(const struct tb_port *port)int tb_port_get_link_speed (struct tb_port *port);int tb_port_get_link_width (struct tb_port *port); -int tb_port_set_link_width (struct tb_port *port,unsigned int width); -int tb_port_set_lane_bonding (struct tb_port *port,bool bonding); +int tb_port_set_link_width (struct tb_port *port,enum tb_link_width width);int tb_port_lane_bonding_enable (struct tb_port *port);void tb_port_lane_bonding_disable (struct tb_port *port); -int tb_port_wait_for_link_width (struct tb_port *port,int width, +int tb_port_wait_for_link_width (struct tb_port *port,unsigned int width_mask,int timeout_msec);int tb_port_update_credits (struct tb_port *port);
drivers/thunderbolt/tb_regs.h +1 -0
@@ -346,6 +346,7 @@ struct tb_regs_port_header {#define LANE_ADP_CS_1_CURRENT_SPEED_SHIFT 16#define LANE_ADP_CS_1_CURRENT_SPEED_GEN2 0x8#define LANE_ADP_CS_1_CURRENT_SPEED_GEN3 0x4 +#define LANE_ADP_CS_1_CURRENT_SPEED_GEN4 0x2#define LANE_ADP_CS_1_CURRENT_WIDTH_MASK GENMASK(25, 20)#define LANE_ADP_CS_1_CURRENT_WIDTH_SHIFT 20#define LANE_ADP_CS_1_PMS BIT(30)
drivers/thunderbolt/xdomain.c +68 -14
133 lines not on this page · raw message
include/linux/thunderbolt.h +16 -2
@@ -171,6 +171,20 @@ struct tb_property *tb_property_get_next(struct tb_property_dir *dir,int tb_register_property_dir (const char *key,struct tb_property_dir *dir);void tb_unregister_property_dir (const char *key,struct tb_property_dir *dir); +/** +* enum tb_link_width - Thunderbolt/USB4 link width +* @TB_LINK_WIDTH_SINGLE: Single lane link +* @TB_LINK_WIDTH_DUAL: Dual lane symmetric link +* @TB_LINK_WIDTH_ASYM_TX: Dual lane asymmetric Gen 4 link with 3 trasmitters +* @TB_LINK_WIDTH_ASYM_RX: Dual lane asymmetric Gen 4 link with 3 receivers +*/ +enum tb_link_width { +TB_LINK_WIDTH_SINGLE =BIT (0 ), +TB_LINK_WIDTH_DUAL =BIT (1 ), +TB_LINK_WIDTH_ASYM_TX =BIT (2 ), +TB_LINK_WIDTH_ASYM_RX =BIT (3 ), +}; +/** * struct tb_xdomain - Cross-domain (XDomain) connection * @dev: XDomain device
@@ -186,7 +200,7 @@ void tb_unregister_property_dir(const char *key, struct tb_property_dir *dir);* @vendor_name: Name of the vendor (or %NULL if not known) * @device_name: Name of the device (or %NULL if not known) * @link_speed: Speed of the link in Gb/s -* @link_width: Width of the link (1 or 2) +* @link_width: Width of the downstream facing link * @link_usb4: Downstream link is USB4 * @is_unplugged: The XDomain is unplugged * @needs_uuid: If the XDomain does not have @remote_uuid it will be
@@ -234,7 +248,7 @@ struct tb_xdomain {const char *vendor_name;const char *device_name;unsigned int link_speed; -unsigned int link_width; +enum tb_link_width link_width;bool link_usb4;bool is_unplugged;bool needs_uuid;
Signature · 1 line
2.39.2
PATCH v2 8/20 thunderbolt: Enable USB4 v2 PCIe TLP/DLLP extended encapsulation
In reply to Mika WesterbergFrom: Gil Fine <[email protected]>
USB4 v2 spec introduces modified encapsulation of PCIe TLP and DLLP packets. This improves the PCIe tunneled traffic usage by reducing overhead. Enable this if both sides of the link support it.
--- drivers/thunderbolt/tb.h | 2 ++ drivers/thunderbolt/tb_regs.h | 2 ++ drivers/thunderbolt/tunnel.c | 37 ++++++++++++++++++++++++++++++++--- drivers/thunderbolt/usb4.c | 34 ++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 3 deletions(-)
drivers/thunderbolt/tb.h +2 -0
@@ -1301,6 +1301,8 @@ int usb4_dp_port_allocated_bw(struct tb_port *port);int usb4_dp_port_allocate_bw (struct tb_port *port,int bw);int usb4_dp_port_requested_bw (struct tb_port *port); +int usb4_pci_port_set_ext_encapsulation (struct tb_port *port,bool enable); +static inline bool tb_is_usb4_port_device (const struct device *dev) {return dev->type == &usb4_port_device_type;
drivers/thunderbolt/tb_regs.h +2 -0
@@ -451,6 +451,8 @@ struct tb_regs_port_header {/* PCIe adapter registers */ #define ADP_PCIE_CS_0 0x00#define ADP_PCIE_CS_0_PE BIT(31) +#define ADP_PCIE_CS_1 0x01 +#define ADP_PCIE_CS_1_EE BIT(0)/* USB adapter registers */ #define ADP_USB3_CS_0 0x00
drivers/thunderbolt/tunnel.c +34 -3
@@ -153,18 +153,49 @@ static struct tb_tunnel *tb_tunnel_alloc(struct tb *tb, size_t npaths,return tunnel; } +static int tb_pci_set_ext_encapsulation (struct tb_tunnel *tunnel,bool enable) +{ +int ret; + +/* Only supported of both routers are at least USB4 v2 */ +if (usb4_switch_version (tunnel->src_port->sw) <2 || +usb4_switch_version (tunnel->dst_port->sw) <2 ) +return 0 ; + + ret =usb4_pci_port_set_ext_encapsulation (tunnel->src_port, enable); +if (ret) +return ret; + + ret =usb4_pci_port_set_ext_encapsulation (tunnel->dst_port, enable); +if (ret) +return ret; + +tb_tunnel_dbg (tunnel,"extended encapsulation %sabled\n" , + enable ?"en" :"dis" ); +return 0 ; +} +static int tb_pci_activate (struct tb_tunnel *tunnel,bool activate) {int res; +if (activate) { + res =tb_pci_set_ext_encapsulation (tunnel, activate); +if (res) +return res; + } + res =tb_pci_port_enable (tunnel->src_port, activate);if (res)return res; -if (tb_port_is_pcie_up (tunnel->dst_port)) -return tb_pci_port_enable (tunnel->dst_port, activate); +if (tb_port_is_pcie_up (tunnel->dst_port)) { + res =tb_pci_port_enable (tunnel->dst_port, activate); +if (res) +return res; + } -return 0 ; +return activate ?0 :tb_pci_set_ext_encapsulation (tunnel, activate); }static int tb_pci_init_credits (struct tb_path_hop *hop)
drivers/thunderbolt/usb4.c +34 -0
@@ -2796,3 +2796,37 @@ int usb4_dp_port_requested_bw(struct tb_port *port)return (val &ADP_DP_CS_8_REQUESTED_BW_MASK ) * granularity; } + +/** +* usb4_pci_port_set_ext_encapsulation() - Enable/disable extended encapsulation +* @port: PCIe adapter +* @enable: Enable/disable extended encapsulation +* +* Can be called to any adapter. Enables or disables extended +* encapsulation used in PCIe tunneling. Returns %0 on success and +* negative errno otherwise. +*/ +int usb4_pci_port_set_ext_encapsulation (struct tb_port *port,bool enable) +{ +u32 val; +int ret; + +if (!tb_port_is_pcie_up (port) && !tb_port_is_pcie_down (port)) +return 0 ; + +if (usb4_switch_version (port->sw) <2 ) +return 0 ; + + ret =tb_port_read (port, &val,TB_CFG_PORT , + port->cap_adap +ADP_PCIE_CS_1 ,1 ); +if (ret) +return ret; + +if (enable) + val |=ADP_PCIE_CS_1_EE ; +else + val &= ~ADP_PCIE_CS_1_EE ; + +return tb_port_write (port, &val,TB_CFG_PORT , + port->cap_adap +ADP_PCIE_CS_1 ,1 ); +}
Signature · 1 line
2.39.2
PATCH v2 13/20 thunderbolt: Limit Intel Barlow Ridge USB3 bandwidth
In reply to Mika WesterbergIntel Barlow Ridge discrete USB4 host router has the same limitation as the previous generations so make sure the USB3 bandwidth limitation quirk is applied to Barlow Ridge too.
--- drivers/thunderbolt/nhi.h | 2 ++ drivers/thunderbolt/quirks.c | 8 ++++++++ 2 files changed, 10 insertions(+)
drivers/thunderbolt/nhi.h +2 -0
@@ -77,6 +77,8 @@ extern const struct tb_nhi_ops icl_nhi_ops;#define PCI_DEVICE_ID_INTEL_ADL_NHI1 0x466d#define PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_80G_NHI 0x5781#define PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_40G_NHI 0x5784 +#define PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HUB_80G_BRIDGE 0x5786 +#define PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HUB_40G_BRIDGE 0x57a4#define PCI_DEVICE_ID_INTEL_MTL_M_NHI0 0x7eb2#define PCI_DEVICE_ID_INTEL_MTL_P_NHI0 0x7ec2#define PCI_DEVICE_ID_INTEL_MTL_P_NHI1 0x7ec3
drivers/thunderbolt/quirks.c +8 -0
@@ -75,6 +75,14 @@ static const struct tb_quirk tb_quirks[] = { quirk_usb3_maximum_bandwidth }, {0x8087 ,PCI_DEVICE_ID_INTEL_MTL_P_NHI1 ,0x0000 ,0x0000 , quirk_usb3_maximum_bandwidth }, + { 0x8087, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_80G_NHI, 0x0000, 0x0000, + quirk_usb3_maximum_bandwidth }, + { 0x8087, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_40G_NHI, 0x0000, 0x0000, + quirk_usb3_maximum_bandwidth }, + { 0x8087, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HUB_80G_BRIDGE, 0x0000, 0x0000, + quirk_usb3_maximum_bandwidth }, + { 0x8087, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HUB_40G_BRIDGE, 0x0000, 0x0000, + quirk_usb3_maximum_bandwidth },/* * CLx is not supported on AMD USB4 Yellow Carp and Pink Sardine platforms. */
Signature · 1 line
2.39.2
PATCH v2 14/20 thunderbolt: Move constants related to NVM into nvm.c
In reply to Mika WesterbergFrom: Gil Fine <[email protected]>
Move constants related to NVM into nvm.c to make the code cleaner. Use a separate constant for USB4_DATA_DWORDS in usb4.c.
No functional changes.
--- drivers/thunderbolt/nvm.c | 4 ++++ drivers/thunderbolt/tb.h | 4 ---- drivers/thunderbolt/usb4.c | 11 ++++++----- 3 files changed, 10 insertions(+), 9 deletions(-)
drivers/thunderbolt/nvm.c +4 -0
@@ -12,6 +12,10 @@#include "tb.h" +#define NVM_MIN_SIZE SZ_32K +#define NVM_MAX_SIZE SZ_512K +#define NVM_DATA_DWORDS 16 +/* Intel specific NVM offsets */ #define INTEL_NVM_DEVID 0x05#define INTEL_NVM_VERSION 0x08
drivers/thunderbolt/tb.h +0 -4
@@ -19,10 +19,6 @@#include "ctl.h" #include "dma_port.h" -#define NVM_MIN_SIZE SZ_32K -#define NVM_MAX_SIZE SZ_512K -#define NVM_DATA_DWORDS 16 -/* Keep link controller awake during update */ #define QUIRK_FORCE_POWER_LINK_CONTROLLER BIT(0)/* Disable CLx if not supported */
drivers/thunderbolt/usb4.c +6 -5
@@ -15,6 +15,7 @@#include "tb.h" #define USB4_DATA_RETRIES 3 +#define USB4_DATA_DWORDS 16enum usb4_sb_target {USB4_SB_TARGET_ROUTER ,
@@ -112,7 +113,7 @@ static int __usb4_switch_op(struct tb_switch *sw, u16 opcode, u32 *metadata, {const struct tb_cm_ops *cm_ops = sw->tb->cm_ops; -if (tx_dwords >NVM_DATA_DWORDS || rx_dwords >NVM_DATA_DWORDS ) +if (tx_dwords >USB4_DATA_DWORDS || rx_dwords >USB4_DATA_DWORDS )return -EINVAL ;/*
@@ -702,7 +703,7 @@ int usb4_switch_credits_init(struct tb_switch *sw)int max_usb3, min_dp_aux, min_dp_main, max_pcie, max_dma;int ret, length, i, nports;const struct tb_port *port; -u32 data[NVM_DATA_DWORDS ]; +u32 data[USB4_DATA_DWORDS ];u32 metadata =0 ;u8 status =0 ;
@@ -1198,7 +1199,7 @@ static int usb4_port_wait_for_bit(struct tb_port *port, u32 offset, u32 bit,static int usb4_port_read_data (struct tb_port *port,void *data,size_t dwords) { -if (dwords >NVM_DATA_DWORDS ) +if (dwords >USB4_DATA_DWORDS )return -EINVAL ; return tb_port_read(port, data, TB_CFG_PORT, port->cap_usb4 + PORT_CS_2,
@@ -1208,7 +1209,7 @@ static int usb4_port_read_data(struct tb_port *port, void *data, size_t dwords)static int usb4_port_write_data (struct tb_port *port,const void *data,size_t dwords) { -if (dwords >NVM_DATA_DWORDS ) +if (dwords >USB4_DATA_DWORDS )return -EINVAL ; return tb_port_write(port, data, TB_CFG_PORT, port->cap_usb4 + PORT_CS_2,
@@ -1844,7 +1845,7 @@ static int usb4_port_retimer_nvm_read_block(void *data, unsigned int dwaddress,int ret; metadata = dwaddress <<USB4_NVM_READ_OFFSET_SHIFT ; -if (dwords <NVM_DATA_DWORDS ) +if (dwords <USB4_DATA_DWORDS ) metadata |= dwords <<USB4_NVM_READ_LENGTH_SHIFT ; ret = usb4_port_retimer_write(port, index, USB4_SB_METADATA, &metadata,
Signature · 1 line
2.39.2
PATCH v2 7/20 thunderbolt: Announce USB4 v2 connection manager support
In reply to Mika WesterbergFrom: Gil Fine <[email protected]>
Program the CMUV (Connection Manager USB4 Version) field for USB4 v2 and v1 routers according to the spec.
--- drivers/thunderbolt/switch.c | 8 ++++++-- drivers/thunderbolt/tb_regs.h | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/thunderbolt/switch.c +6 -2
@@ -2430,9 +2430,13 @@ int tb_switch_configure(struct tb_switch *sw)/* * For USB4 devices, we need to program the CM version * accordingly so that it knows to expose all the -* additional capabilities. +* additional capabilities. Program it according to USB4 +* version to avoid changing existing (v1) routers behaviour. */ - sw->config.cmuv =USB4_VERSION_1_0 ; +if (usb4_switch_version (sw) <2 ) + sw->config.cmuv =ROUTER_CS_4_CMUV_V1 ; +else + sw->config.cmuv =ROUTER_CS_4_CMUV_V2 ; sw->config.plug_events_delay =0xa ;/* Enumerate the switch */
drivers/thunderbolt/tb_regs.h +3 -0
@@ -195,6 +195,9 @@ struct tb_regs_switch_header {#define ROUTER_CS_1 0x01#define ROUTER_CS_4 0x04 +/* Used with the router cmuv field */ +#define ROUTER_CS_4_CMUV_V1 0x10 +#define ROUTER_CS_4_CMUV_V2 0x20#define ROUTER_CS_5 0x05#define ROUTER_CS_5_SLP BIT(0)#define ROUTER_CS_5_WOP BIT(1)
Signature · 1 line
2.39.2
PATCH v2 11/20 thunderbolt: Fix PCIe adapter capability length for USB4 v2 routers
In reply to Mika WesterbergFrom: Gil Fine <[email protected]>
For USB4 v2 routers, the PCIe adapter capability length is longer. Display the correct capability length in the debugfs register dump.
--- drivers/thunderbolt/debugfs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/thunderbolt/debugfs.c +6 -2
@@ -14,7 +14,8 @@#include "tb.h" #include "sb_regs.h" -#define PORT_CAP_PCIE_LEN 1 +#define PORT_CAP_V1_PCIE_LEN 1 +#define PORT_CAP_V2_PCIE_LEN 2#define PORT_CAP_POWER_LEN 2#define PORT_CAP_LANE_LEN 3#define PORT_CAP_USB3_LEN 5
@@ -1175,7 +1176,10 @@ static void port_cap_show(struct tb_port *port, struct seq_file *s,case TB_PORT_CAP_ADAP :if (tb_port_is_pcie_down (port) ||tb_port_is_pcie_up (port)) { - length =PORT_CAP_PCIE_LEN ; +if (usb4_switch_version (port->sw) <2 ) + length =PORT_CAP_V1_PCIE_LEN ; +else + length =PORT_CAP_V2_PCIE_LEN ; }else if (tb_port_is_dpin (port)) {if (usb4_switch_version (port->sw) <2 ) length =PORT_CAP_DP_V1_LEN ;
Signature · 1 line
2.39.2
PATCH v2 10/20 thunderbolt: Fix DisplayPort IN adapter capability length for USB4 v2 routers
In reply to Mika WesterbergFrom: Gil Fine <[email protected]>
For USB4 v2 routers, the DisplayPort IN adapter capability length is longer. Display the correct capability length in the debugfs register dump.
--- drivers/thunderbolt/debugfs.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/thunderbolt/debugfs.c +8 -5
@@ -18,7 +18,8 @@#define PORT_CAP_POWER_LEN 2#define PORT_CAP_LANE_LEN 3#define PORT_CAP_USB3_LEN 5 -#define PORT_CAP_DP_LEN 8 +#define PORT_CAP_DP_V1_LEN 9 +#define PORT_CAP_DP_V2_LEN 14#define PORT_CAP_TMU_V1_LEN 8#define PORT_CAP_TMU_V2_LEN 10#define PORT_CAP_BASIC_LEN 9
@@ -1175,11 +1176,13 @@ static void port_cap_show(struct tb_port *port, struct seq_file *s,case TB_PORT_CAP_ADAP :if (tb_port_is_pcie_down (port) ||tb_port_is_pcie_up (port)) { length =PORT_CAP_PCIE_LEN ; - }else if (tb_port_is_dpin (port) ||tb_port_is_dpout (port)) { -if (usb4_dp_port_bw_mode_supported (port)) - length =PORT_CAP_DP_LEN +1 ; + }else if (tb_port_is_dpin (port)) { +if (usb4_switch_version (port->sw) <2 ) + length =PORT_CAP_DP_V1_LEN ;else - length =PORT_CAP_DP_LEN ; + length =PORT_CAP_DP_V2_LEN ; + }else if (tb_port_is_dpout (port)) { + length =PORT_CAP_DP_V1_LEN ; }else if (tb_port_is_usb3_down (port) ||tb_port_is_usb3_up (port)) { length =PORT_CAP_USB3_LEN ;
Signature · 1 line
2.39.2
PATCH v2 9/20 thunderbolt: Add two additional double words for adapters TMU for USB4 v2 routers
In reply to Mika WesterbergFrom: Gil Fine <[email protected]>
For USB4 v2 routers, the adapters's TMU capability has two additional double words. Include them in the debugfs register dump.
--- drivers/thunderbolt/debugfs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/thunderbolt/debugfs.c +6 -2
@@ -19,7 +19,8 @@#define PORT_CAP_LANE_LEN 3#define PORT_CAP_USB3_LEN 5#define PORT_CAP_DP_LEN 8 -#define PORT_CAP_TMU_LEN 8 +#define PORT_CAP_TMU_V1_LEN 8 +#define PORT_CAP_TMU_V2_LEN 10#define PORT_CAP_BASIC_LEN 9#define PORT_CAP_USB4_LEN 20
@@ -1161,7 +1162,10 @@ static void port_cap_show(struct tb_port *port, struct seq_file *s,break ;case TB_PORT_CAP_TIME1 : - length =PORT_CAP_TMU_LEN ; +if (usb4_switch_version (port->sw) <2 ) + length =PORT_CAP_TMU_V1_LEN ; +else + length =PORT_CAP_TMU_V2_LEN ;break ;case TB_PORT_CAP_POWER :
Signature · 1 line
2.39.2
PATCH v2 17/20 thunderbolt: Enable CL2 low power state
In reply to Mika WesterbergFor USB4 v2 routers we can also enable CL2 which allows better power savings and thermal management than CL0s and CL1.
--- drivers/thunderbolt/clx.c | 31 +++++++++++++++++++------------ drivers/thunderbolt/tb.c | 9 ++++++--- 2 files changed, 25 insertions(+), 15 deletions(-)
drivers/thunderbolt/clx.c +19 -12
@@ -17,17 +17,22 @@ MODULE_PARM_DESC(clx, "allow low power states on the high-speed lanes (default:static const char *clx_name (unsigned int clx) { -if (!clx) -return "disabled" ; - -if (clx &TB_CL2 ) +switch (clx) { +case TB_CL0S |TB_CL1 |TB_CL2 :return "CL0s/CL1/CL2" ; -if (clx &TB_CL1 ) +case TB_CL1 |TB_CL2 : +return "CL1/CL2" ; +case TB_CL0S |TB_CL2 : +return "CL0s/CL2" ; +case TB_CL0S |TB_CL1 :return "CL0s/CL1" ; -if (clx &TB_CL0S ) +case TB_CL0S :return "CL0s" ; - -return "unknown" ; +case 0 : +return "disabled" ; +default : +return "unknown" ; + } }static int tb_port_pm_secondary_set (struct tb_port *port,bool secondary)
@@ -104,6 +109,8 @@ static int tb_port_clx_set(struct tb_port *port, unsigned int clx, bool enable) mask |=LANE_ADP_CS_1_CL0S_ENABLE ;if (clx &TB_CL1 ) mask |=LANE_ADP_CS_1_CL1_ENABLE ; +if (clx &TB_CL2 ) + mask |=LANE_ADP_CS_1_CL2_ENABLE ;if (!mask)return -EOPNOTSUPP ;
@@ -291,8 +298,6 @@ bool tb_switch_clx_is_supported(const struct tb_switch *sw)static bool validate_mask (unsigned int clx) {/* Previous states need to be enabled */ -if (clx &TB_CL2 ) -return (clx & (TB_CL0S |TB_CL1 )) == (TB_CL0S |TB_CL1 );if (clx &TB_CL1 )return (clx &TB_CL0S ) ==TB_CL0S ;return true;
@@ -331,8 +336,10 @@ int tb_switch_clx_enable(struct tb_switch *sw, unsigned int clx) !tb_switch_clx_is_supported(sw))return 0 ; -/* CL2 is not yet supported */ -if (clx &TB_CL2 ) +/* Only support CL2 for v2 routers */ +if ((clx &TB_CL2 ) && + (usb4_switch_version (parent_sw) <2 || +usb4_switch_version (sw) <2 ))return -EOPNOTSUPP ; ret =tb_switch_pm_secondary_resolve (sw);
drivers/thunderbolt/tb.c +6 -3
@@ -244,6 +244,7 @@ static void tb_discover_dp_resources(struct tb *tb)static int tb_enable_clx (struct tb_switch *sw) {struct tb_cm *tcm =tb_priv (sw->tb); +unsigned int clx =TB_CL0S |TB_CL1 ;const struct tb_tunnel *tunnel;int ret;
@@ -275,10 +276,12 @@ static int tb_enable_clx(struct tb_switch *sw) }/* -* CL0s and CL1 are enabled and supported together. -* Silently ignore CLx enabling in case CLx is not supported. +* Initially try with CL2. If that's not supported by the +* topology try with CL0s and CL1 and then give up. */ - ret =tb_switch_clx_enable (sw,TB_CL0S |TB_CL1 ); + ret =tb_switch_clx_enable (sw, clx |TB_CL2 ); +if (ret == -EOPNOTSUPP ) + ret =tb_switch_clx_enable (sw, clx);return ret == -EOPNOTSUPP ?0 : ret; }
Signature · 1 line
2.39.2
PATCH v2 19/20 thunderbolt: Add DisplayPort 2.x tunneling support
In reply to Mika WesterbergThis adds support for the UHBR (Ultra High Bit Rate) bandwidths introduced with DisplayPort 2.0 (and refined in 2.1). These can go up to 80 Gbit/s and their support is represent in additional bits in the DP IN capability.
This updates the DisplayPort tunneling to support these new rates too.
--- drivers/thunderbolt/tb_regs.h | 3 + drivers/thunderbolt/tunnel.c | 100 ++++++++++++++++++++++++++++------ 2 files changed, 87 insertions(+), 16 deletions(-)
drivers/thunderbolt/tb_regs.h +3 -0
@@ -450,6 +450,9 @@ struct tb_regs_port_header {#define DP_COMMON_CAP_1_LANE 0x0#define DP_COMMON_CAP_2_LANES 0x1#define DP_COMMON_CAP_4_LANES 0x2 +#define DP_COMMON_CAP_UHBR10 BIT(17) +#define DP_COMMON_CAP_UHBR20 BIT(18) +#define DP_COMMON_CAP_UHBR13_5 BIT(19)#define DP_COMMON_CAP_LTTPR_NS BIT(27)#define DP_COMMON_CAP_BW_MODE BIT(28)#define DP_COMMON_CAP_DPRX_DONE BIT(31)
drivers/thunderbolt/tunnel.c +84 -16
174 lines not on this page · raw message
Signature · 1 line
2.39.2
PATCH v2 20/20 thunderbolt: Add test case for 3 DisplayPort tunnels
In reply to Mika WesterbergIntel Barlow Ridge Thunderbolt controller has 3 DP IN adapters. This allows 3 simultaneus DisplayPort tunnels through either one or two USB4 downstream ports (in any possible configuration). Add test case for this.
--- drivers/thunderbolt/test.c | 83 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+)
drivers/thunderbolt/test.c +83 -0
@@ -170,6 +170,23 @@ static struct tb_switch *alloc_host_usb4(struct kunit *test)return sw; } +static struct tb_switch *alloc_host_br (struct kunit *test) +{ +struct tb_switch *sw; + + sw =alloc_host_usb4 (test); +if (!sw) +return NULL ; + + sw->ports[10 ].config.type =TB_TYPE_DP_HDMI_IN ; + sw->ports[10 ].config.max_in_hop_id =9 ; + sw->ports[10 ].config.max_out_hop_id =9 ; + sw->ports[10 ].cap_adap =-1 ; + sw->ports[10 ].disabled = false; + +return sw; +} +static struct tb_switch *alloc_dev_default (struct kunit *test,struct tb_switch *parent,u64 route,bool bonded)
@@ -1583,6 +1600,71 @@ static void tb_test_tunnel_dp_max_length(struct kunit *test)tb_tunnel_free (tunnel); } +static void tb_test_tunnel_3dp (struct kunit *test) +{ +struct tb_switch *host, *dev1, *dev2, *dev3, *dev4, *dev5; +struct tb_port *in1, *in2, *in3, *out1, *out2, *out3; +struct tb_tunnel *tunnel1, *tunnel2, *tunnel3; + +/* +* Create 3 DP tunnels from Host to Devices #2, #5 and #4. +* +* [Host] +* 3 | +* 1 | +* [Device #1] +* 3 / | 5 \ 7 +* 1 / | \ 1 +* [Device #2] | [Device #4] +* | 1 +* [Device #3] +* | 5 +* | 1 +* [Device #5] +*/ + host =alloc_host_br (test); + dev1 =alloc_dev_default (test, host,0x3 , true); + dev2 =alloc_dev_default (test, dev1,0x303 , true); + dev3 =alloc_dev_default (test, dev1,0x503 , true); + dev4 =alloc_dev_default (test, dev1,0x703 , true); + dev5 =alloc_dev_default (test, dev3,0x50503 , true); + + in1 = &host->ports[5 ]; + in2 = &host->ports[6 ]; + in3 = &host->ports[10 ]; + + out1 = &dev2->ports[13 ]; + out2 = &dev5->ports[13 ]; + out3 = &dev4->ports[14 ]; + + tunnel1 =tb_tunnel_alloc_dp (NULL , in1, out1,1 ,0 ,0 ); +KUNIT_ASSERT_TRUE (test, tunnel1 !=NULL ); +KUNIT_EXPECT_EQ (test, tunnel1->type,TB_TUNNEL_DP ); +KUNIT_EXPECT_PTR_EQ (test, tunnel1->src_port, in1); +KUNIT_EXPECT_PTR_EQ (test, tunnel1->dst_port, out1); +KUNIT_ASSERT_EQ (test, tunnel1->npaths,3 ); +KUNIT_ASSERT_EQ (test, tunnel1->paths[0 ]->path_length,3 ); + + tunnel2 =tb_tunnel_alloc_dp (NULL , in2, out2,1 ,0 ,0 ); +KUNIT_ASSERT_TRUE (test, tunnel2 !=NULL ); +KUNIT_EXPECT_EQ (test, tunnel2->type,TB_TUNNEL_DP ); +KUNIT_EXPECT_PTR_EQ (test, tunnel2->src_port, in2); +KUNIT_EXPECT_PTR_EQ (test, tunnel2->dst_port, out2); +KUNIT_ASSERT_EQ (test, tunnel2->npaths,3 ); +KUNIT_ASSERT_EQ (test, tunnel2->paths[0 ]->path_length,4 ); + + tunnel3 =tb_tunnel_alloc_dp (NULL , in3, out3,1 ,0 ,0 ); +KUNIT_ASSERT_TRUE (test, tunnel3 !=NULL ); +KUNIT_EXPECT_EQ (test, tunnel3->type,TB_TUNNEL_DP ); +KUNIT_EXPECT_PTR_EQ (test, tunnel3->src_port, in3); +KUNIT_EXPECT_PTR_EQ (test, tunnel3->dst_port, out3); +KUNIT_ASSERT_EQ (test, tunnel3->npaths,3 ); +KUNIT_ASSERT_EQ (test, tunnel3->paths[0 ]->path_length,3 ); + +tb_tunnel_free (tunnel2); +tb_tunnel_free (tunnel1); +} +static void tb_test_tunnel_usb3 (struct kunit *test) {struct tb_switch *host, *dev1, *dev2;
@@ -2790,6 +2872,7 @@ static struct kunit_case tb_test_cases[] = {KUNIT_CASE (tb_test_tunnel_dp_chain),KUNIT_CASE (tb_test_tunnel_dp_tree),KUNIT_CASE (tb_test_tunnel_dp_max_length), +KUNIT_CASE (tb_test_tunnel_3dp),KUNIT_CASE (tb_test_tunnel_port_on_path),KUNIT_CASE (tb_test_tunnel_usb3), KUNIT_CASE(tb_test_tunnel_dma),
Signature · 1 line
2.39.2
PATCH v2 15/20 thunderbolt: Increase NVM_MAX_SIZE to support Intel Barlow Ridge controller
In reply to Mika WesterbergFrom: Gil Fine <[email protected]>
Intel Barlow Ridge discrete USB4 controller has larger NOR Flash, hence increase NVM_MAX_SIZE to support it.
--- drivers/thunderbolt/nvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thunderbolt/nvm.c +1 -1
@@ -13,7 +13,7 @@#include "tb.h" #define NVM_MIN_SIZE SZ_32K -#define NVM_MAX_SIZE SZ_512K +#define NVM_MAX_SIZE SZ_1M#define NVM_DATA_DWORDS 16/* Intel specific NVM offsets */
Signature · 1 line
2.39.2
PATCH v2 18/20 thunderbolt: Make bandwidth allocation mode function names consistent
In reply to Mika WesterbergMake sure the DisplayPort bandwidth allocation mode function names are consistent with the existing ones, such as USB3.
No functional changes.
--- drivers/thunderbolt/tb.c | 10 ++++----- drivers/thunderbolt/tb.h | 15 +++++++------ drivers/thunderbolt/tunnel.c | 41 ++++++++++++++++++------------------ drivers/thunderbolt/usb4.c | 32 ++++++++++++++++------------ 4 files changed, 52 insertions(+), 46 deletions(-)
drivers/thunderbolt/tb.c +5 -5
@@ -131,7 +131,7 @@ tb_attach_bandwidth_group(struct tb_cm *tcm, struct tb_port *in,static void tb_discover_bandwidth_group (struct tb_cm *tcm,struct tb_port *in,struct tb_port *out) { -if (usb4_dp_port_bw_mode_enabled (in)) { +if (usb4_dp_port_bandwidth_mode_enabled (in)) {int index, i; index =usb4_dp_port_group_id (in);
@@ -1169,7 +1169,7 @@ tb_recalc_estimated_bandwidth_for_group(struct tb_bandwidth_group *group)struct tb_tunnel *tunnel;struct tb_port *out; -if (!usb4_dp_port_bw_mode_enabled (in)) +if (!usb4_dp_port_bandwidth_mode_enabled (in))continue ; tunnel =tb_find_tunnel (tb,TB_TUNNEL_DP , in,NULL );
@@ -1217,7 +1217,7 @@ tb_recalc_estimated_bandwidth_for_group(struct tb_bandwidth_group *group)else estimated_bw = estimated_up; -if (usb4_dp_port_set_estimated_bw (in, estimated_bw)) +if (usb4_dp_port_set_estimated_bandwidth (in, estimated_bw))tb_port_warn (in,"failed to update estimated bandwidth\n" ); }
@@ -1912,12 +1912,12 @@ static void tb_handle_dp_bandwidth_request(struct work_struct *work)tb_port_dbg (in,"handling bandwidth allocation request\n" ); -if (!usb4_dp_port_bw_mode_enabled (in)) { +if (!usb4_dp_port_bandwidth_mode_enabled (in)) {tb_port_warn (in,"bandwidth allocation mode not enabled\n" ); goto unlock; } - ret =usb4_dp_port_requested_bw (in); + ret =usb4_dp_port_requested_bandwidth (in);if (ret <0 ) {if (ret == -ENODATA )tb_port_dbg (in,"no bandwidth request active\n" );
drivers/thunderbolt/tb.h +8 -7
@@ -1292,19 +1292,20 @@ int usb4_usb3_port_release_bandwidth(struct tb_port *port, int *upstream_bw, int *downstream_bw);int usb4_dp_port_set_cm_id (struct tb_port *port,int cm_id); -bool usb4_dp_port_bw_mode_supported (struct tb_port *port); -bool usb4_dp_port_bw_mode_enabled (struct tb_port *port); -int usb4_dp_port_set_cm_bw_mode_supported (struct tb_port *port,bool supported); +bool usb4_dp_port_bandwidth_mode_supported (struct tb_port *port); +bool usb4_dp_port_bandwidth_mode_enabled (struct tb_port *port); +int usb4_dp_port_set_cm_bandwidth_mode_supported (struct tb_port *port, +bool supported);int usb4_dp_port_group_id (struct tb_port *port);int usb4_dp_port_set_group_id (struct tb_port *port,int group_id);int usb4_dp_port_nrd (struct tb_port *port,int *rate,int *lanes);int usb4_dp_port_set_nrd (struct tb_port *port,int rate,int lanes);int usb4_dp_port_granularity (struct tb_port *port);int usb4_dp_port_set_granularity (struct tb_port *port,int granularity); -int usb4_dp_port_set_estimated_bw (struct tb_port *port,int bw); -int usb4_dp_port_allocated_bw (struct tb_port *port); -int usb4_dp_port_allocate_bw (struct tb_port *port,int bw); -int usb4_dp_port_requested_bw (struct tb_port *port); +int usb4_dp_port_set_estimated_bandwidth (struct tb_port *port,int bw); +int usb4_dp_port_allocated_bandwidth (struct tb_port *port); +int usb4_dp_port_allocate_bandwidth (struct tb_port *port,int bw); +int usb4_dp_port_requested_bandwidth (struct tb_port *port);int usb4_pci_port_set_ext_encapsulation (struct tb_port *port,bool enable);
drivers/thunderbolt/tunnel.c +21 -20
131 lines not on this page · raw message
drivers/thunderbolt/usb4.c +18 -14
@@ -2294,13 +2294,14 @@ int usb4_dp_port_set_cm_id(struct tb_port *port, int cm_id) }/** -* usb4_dp_port_bw_mode_supported() - Is the bandwidth allocation mode supported +* usb4_dp_port_bandwidth_mode_supported() - Is the bandwidth allocation mode +* supported * @port: DP IN adapter to check * * Can be called to any DP IN adapter. Returns true if the adapter * supports USB4 bandwidth allocation mode, false otherwise. */ -bool usb4_dp_port_bw_mode_supported (struct tb_port *port) +bool usb4_dp_port_bandwidth_mode_supported (struct tb_port *port) {int ret;u32 val;
@@ -2317,13 +2318,14 @@ bool usb4_dp_port_bw_mode_supported(struct tb_port *port) }/** -* usb4_dp_port_bw_mode_enabled() - Is the bandwidth allocation mode enabled +* usb4_dp_port_bandwidth_mode_enabled() - Is the bandwidth allocation mode +* enabled * @port: DP IN adapter to check * * Can be called to any DP IN adapter. Returns true if the bandwidth * allocation mode has been enabled, false otherwise. */ -bool usb4_dp_port_bw_mode_enabled (struct tb_port *port) +bool usb4_dp_port_bandwidth_mode_enabled (struct tb_port *port) {int ret;u32 val;
@@ -2340,7 +2342,8 @@ bool usb4_dp_port_bw_mode_enabled(struct tb_port *port) }/** -* usb4_dp_port_set_cm_bw_mode_supported() - Set/clear CM support for bandwidth allocation mode +* usb4_dp_port_set_cm_bandwidth_mode_supported() - Set/clear CM support for +* bandwidth allocation mode * @port: DP IN adapter * @supported: Does the CM support bandwidth allocation mode *
@@ -2349,7 +2352,8 @@ bool usb4_dp_port_bw_mode_enabled(struct tb_port *port)* otherwise. Specifically returns %-OPNOTSUPP if the passed in adapter * does not support this. */ -int usb4_dp_port_set_cm_bw_mode_supported (struct tb_port *port,bool supported) +int usb4_dp_port_set_cm_bandwidth_mode_supported (struct tb_port *port, +bool supported) {u32 val;int ret;
@@ -2623,7 +2627,7 @@ int usb4_dp_port_set_granularity(struct tb_port *port, int granularity) }/** -* usb4_dp_port_set_estimated_bw() - Set estimated bandwidth +* usb4_dp_port_set_estimated_bandwidth() - Set estimated bandwidth * @port: DP IN adapter * @bw: Estimated bandwidth in Mb/s. *
@@ -2633,7 +2637,7 @@ int usb4_dp_port_set_granularity(struct tb_port *port, int granularity)* and negative errno otherwise. Specifically returns %-EOPNOTSUPP if * the adapter does not support this. */ -int usb4_dp_port_set_estimated_bw (struct tb_port *port,int bw) +int usb4_dp_port_set_estimated_bandwidth (struct tb_port *port,int bw) {u32 val, granularity;int ret;
@@ -2659,14 +2663,14 @@ int usb4_dp_port_set_estimated_bw(struct tb_port *port, int bw) }/** -* usb4_dp_port_allocated_bw() - Return allocated bandwidth +* usb4_dp_port_allocated_bandwidth() - Return allocated bandwidth * @port: DP IN adapter * * Reads and returns allocated bandwidth for @port in Mb/s (taking into * account the programmed granularity). Returns negative errno in case * of error. */ -int usb4_dp_port_allocated_bw (struct tb_port *port) +int usb4_dp_port_allocated_bandwidth (struct tb_port *port) {u32 val, granularity;int ret;
@@ -2752,7 +2756,7 @@ static int usb4_dp_port_wait_and_clear_cm_ack(struct tb_port *port, }/** -* usb4_dp_port_allocate_bw() - Set allocated bandwidth +* usb4_dp_port_allocate_bandwidth() - Set allocated bandwidth * @port: DP IN adapter * @bw: New allocated bandwidth in Mb/s *
@@ -2760,7 +2764,7 @@ static int usb4_dp_port_wait_and_clear_cm_ack(struct tb_port *port,* driver). Takes into account the programmed granularity. Returns %0 in * success and negative errno in case of error. */ -int usb4_dp_port_allocate_bw (struct tb_port *port,int bw) +int usb4_dp_port_allocate_bandwidth (struct tb_port *port,int bw) {u32 val, granularity;int ret;
@@ -2794,7 +2798,7 @@ int usb4_dp_port_allocate_bw(struct tb_port *port, int bw) }/** -* usb4_dp_port_requested_bw() - Read requested bandwidth +* usb4_dp_port_requested_bandwidth() - Read requested bandwidth * @port: DP IN adapter * * Reads the DPCD (graphics driver) requested bandwidth and returns it
@@ -2803,7 +2807,7 @@ int usb4_dp_port_allocate_bw(struct tb_port *port, int bw)* the adapter does not support bandwidth allocation mode, and %ENODATA * if there is no active bandwidth request from the graphics driver. */ -int usb4_dp_port_requested_bw (struct tb_port *port) +int usb4_dp_port_requested_bandwidth (struct tb_port *port) {u32 val, granularity;int ret;
Signature · 1 line
2.39.2
PATCH v2 16/20 thunderbolt: Add support for enhanced uni-directional TMU mode
In reply to Mika WesterbergThis is new TMU mode introduced with the USB4 v2. This mode is simpler than the existing ones and allows all CL states as well. Enable this for all links where both side routers are v2 and keep the existing functionality for the v1 and earlier links.
Currently only support the MedRes rate. We can add the HiFi rate later too if it turns out to be useful.
--- drivers/thunderbolt/switch.c | 16 + drivers/thunderbolt/tb.c | 58 +++- drivers/thunderbolt/tb.h | 75 +++-- drivers/thunderbolt/tb_regs.h | 12 +- drivers/thunderbolt/tmu.c | 595 +++++++++++++++++++++++++++------- drivers/thunderbolt/usb4.c | 31 +- 6 files changed, 614 insertions(+), 173 deletions(-)
drivers/thunderbolt/switch.c +16 -0
@@ -2466,6 +2466,22 @@ int tb_switch_configure(struct tb_switch *sw)return tb_plug_events_active (sw, true); } +/** +* tb_switch_configuration_valid() - Set the tunneling configuration to be valid +* @sw: Router to configure +* +* Needs to be called before any tunnels can be setup through the +* router. Can be called to any router. +* +* Returns %0 in success and negative errno otherwise. +*/ +int tb_switch_configuration_valid (struct tb_switch *sw) +{ +if (tb_switch_is_usb4 (sw)) +return usb4_switch_configuration_valid (sw); +return 0 ; +} +static int tb_switch_set_uuid (struct tb_switch *sw) {bool uid = false;
drivers/thunderbolt/tb.c +44 -14
95 lines not on this page · raw message
drivers/thunderbolt/tb.h +42 -33
117 lines not on this page · raw message
drivers/thunderbolt/tb_regs.h +11 -1
@@ -252,11 +252,13 @@ enum usb4_switch_op {#define TMU_RTR_CS_3_LOCAL_TIME_NS_MASK GENMASK(15, 0)#define TMU_RTR_CS_3_TS_PACKET_INTERVAL_MASK GENMASK(31, 16)#define TMU_RTR_CS_3_TS_PACKET_INTERVAL_SHIFT 16 -#define TMU_RTR_CS_15 0xf +#define TMU_RTR_CS_15 0x0f#define TMU_RTR_CS_15_FREQ_AVG_MASK GENMASK(5, 0)#define TMU_RTR_CS_15_DELAY_AVG_MASK GENMASK(11, 6)#define TMU_RTR_CS_15_OFFSET_AVG_MASK GENMASK(17, 12)#define TMU_RTR_CS_15_ERROR_AVG_MASK GENMASK(23, 18) +#define TMU_RTR_CS_18 0x12 +#define TMU_RTR_CS_18_DELTA_AVG_CONST_MASK GENMASK(23, 16)#define TMU_RTR_CS_22 0x16#define TMU_RTR_CS_24 0x18#define TMU_RTR_CS_25 0x19
@@ -322,6 +324,14 @@ struct tb_regs_port_header {#define TMU_ADP_CS_3_UDM BIT(29)#define TMU_ADP_CS_6 0x06#define TMU_ADP_CS_6_DTS BIT(1) +#define TMU_ADP_CS_8 0x08 +#define TMU_ADP_CS_8_REPL_TIMEOUT_MASK GENMASK(14, 0) +#define TMU_ADP_CS_8_EUDM BIT(15) +#define TMU_ADP_CS_8_REPL_THRESHOLD_MASK GENMASK(25, 16) +#define TMU_ADP_CS_9 0x09 +#define TMU_ADP_CS_9_REPL_N_MASK GENMASK(7, 0) +#define TMU_ADP_CS_9_DIRSWITCH_N_MASK GENMASK(15, 8) +#define TMU_ADP_CS_9_ADP_TS_INTERVAL_MASK GENMASK(31, 16)/* Lane adapter registers */ #define LANE_ADP_CS_0 0x00
drivers/thunderbolt/tmu.c +471 -124
793 lines not on this page · raw message
drivers/thunderbolt/usb4.c +30 -1
@@ -232,6 +232,9 @@ static bool link_is_usb4(struct tb_port *port)* is not available for some reason (like that there is Thunderbolt 3 * switch upstream) then the internal xHCI controller is enabled * instead. +* +* This does not set the configuration valid bit of the router. To do +* that call usb4_switch_configuration_valid(). */ int usb4_switch_setup (struct tb_switch *sw) {
@@ -288,7 +291,33 @@ int usb4_switch_setup(struct tb_switch *sw)/* TBT3 supported by the CM */ val |=ROUTER_CS_5_C3S ; -/* Tunneling configuration is ready now */ + +return tb_sw_write (sw, &val,TB_CFG_SWITCH ,ROUTER_CS_5 ,1 ); +} + +/** +* usb4_switch_configuration_valid() - Set tunneling configuration to be valid +* @sw: USB4 router +* +* Sets configuration valid bit for the router. Must be called before +* any tunnels can be set through the router and after +* usb4_switch_setup() has been called. Can be called to host and device +* routers (does nothing for the latter). +* +* Returns %0 in success and negative errno otherwise. +*/ +int usb4_switch_configuration_valid (struct tb_switch *sw) +{ +u32 val; +int ret; + +if (!tb_route (sw)) +return 0 ; + + ret =tb_sw_read (sw, &val,TB_CFG_SWITCH ,ROUTER_CS_5 ,1 ); +if (ret) +return ret; + val |=ROUTER_CS_5_CV ; ret =tb_sw_write (sw, &val,TB_CFG_SWITCH ,ROUTER_CS_5 ,1 );
Signature · 1 line
2.39.2
Quoted 23 lines · Mika Westerberg
Hi all,
This series adds initial support for the next USB4 version (USB4 v2) and the Intel Barlow Ridge discrete controller. This includes support for the 80G symmetric link, the necessary configuration needed to bring up the router in v2 mode, adaptive TMU, PCIe extended encapsulation, and CL2 low power link state. We will be sending the rest of the USB4 v2 support, including asymmetric 128/80G link support later on once this one has settled.
These are based on thunderbolt.git/next.
The previous version of the series can be found:
https://lore.kernel.org/linux-usb/[email protected]/
Changes from v1:
* Make
tb_switch_is_usb4()useusb4_switch_version()as well
* Set TMU mode off by default intmu_mode_init()
* Log TMU mode change only if it is actually changed intb_switch_tmu_configure().
Quoted 5 lines
Gil Fine (9):
thunderbolt: Identify USB4 v2 routers
thunderbolt: Add support for USB4 v2 80 Gb/s link
thunderbolt: Announce USB4 v2 connection manager support
thunderbolt: Enable USB4 v2 PCIe TLP/DLLP extended encapsulation
Tweaked this slightly to use str_enabled_disabled(), and return -EINVAL in case of non-PCIe adapter. Updated kernel-doc accordingly.
Quoted 6 lines
thunderbolt: Add two additional double words for adapters TMU for USB4 v2 routers
thunderbolt: Fix DisplayPort IN adapter capability length for USB4 v2 routers
thunderbolt: Fix PCIe adapter capability length for USB4 v2 routers
thunderbolt: Move constants related to NVM intonvm.c
thunderbolt: IncreaseNVM_MAX_SIZEto support Intel Barlow Ridge controller
Quoted 12 lines
Mika Westerberg (11):
thunderbolt: Ignore data CRC mismatch for USB4 routers
thunderbolt: Do not touch lane 1 adapter path config space
thunderbolt: Add the new USB4 v2 notification types
thunderbolt: Reset USB4 v2 host router
thunderbolt: Add Intel Barlow Ridge PCI ID
thunderbolt: Limit Intel Barlow Ridge USB3 bandwidth
thunderbolt: Add support for enhanced uni-directional TMU mode
thunderbolt: Enable CL2 low power state
thunderbolt: Make bandwidth allocation mode function names consistent
thunderbolt: Add DisplayPort 2.x tunneling support
thunderbolt: Add test case for 3 DisplayPort tunnels
All applied to thunderbolt.git/next.