thunderbolt: Add support for DisplayPort bandwidth allocation mode
Subsystems (2)
cover thunderbolt: Add support for DisplayPort bandwidth allocation mode
Hi all,
This series implements an optional feature in USB4 spec called DisplayPort bandwidth allocation mode. This allows the graphics driver to negotiate with the Thunderbolt driver the bandwidth requirements dynamically through DP IN adapters of the host router (graphics driver uses DP AUX registers for this). This enables more "fine grained" bandwidth allocation.
Mika Westerberg (8):
thunderbolt: Use decimal port number in control and tunnel logs too
thunderbolt: Log DP adapter type
thunderbolt: Improve debug logging in tb_available_bandwidth()
thunderbolt: Take CL states into account when waiting for link to come up
thunderbolt: Increase timeout of DP OUT adapter handshake
thunderbolt: Add functions to support DisplayPort bandwidth allocation mode
thunderbolt: Include the additional DP IN double word in debugfs dump
thunderbolt: Add support for DisplayPort bandwidth allocation mode
drivers/thunderbolt/ctl.c | 52 +++- drivers/thunderbolt/ctl.h | 2 + drivers/thunderbolt/debugfs.c | 5 +- drivers/thunderbolt/switch.c | 42 ++- drivers/thunderbolt/tb.c | 504 ++++++++++++++++++++++++++++-- drivers/thunderbolt/tb.h | 37 +++ drivers/thunderbolt/tb_msgs.h | 11 +- drivers/thunderbolt/tb_regs.h | 36 +++ drivers/thunderbolt/tunnel.c | 496 ++++++++++++++++++++++++++--- drivers/thunderbolt/tunnel.h | 18 ++ drivers/thunderbolt/usb4.c | 571 ++++++++++++++++++++++++++++++++++ 11 files changed, 1689 insertions(+), 85 deletions(-)
Signature · 1 line
2.35.1
PATCH 1/8 thunderbolt: Use decimal port number in control and tunnel logs too
Use decimal number instead of hex in port numbers as we have been doing with other logging functions too. This makes the output more consistent.
--- drivers/thunderbolt/ctl.c | 2 +- drivers/thunderbolt/tunnel.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/thunderbolt/ctl.c +1 -1
@@ -754,7 +754,7 @@ int tb_cfg_ack_plug(struct tb_ctl *ctl, u64 route, u32 port, bool unplug) .pg = unplug ? TB_CFG_ERROR_PG_HOT_UNPLUG : TB_CFG_ERROR_PG_HOT_PLUG, }; -tb_ctl_dbg (ctl,"acking hot %splug event on %llx:%x\n" , +tb_ctl_dbg (ctl,"acking hot %splug event on %llx:%u\n" , unplug ?"un" :"" , route, port);return tb_ctl_tx (ctl, &pkg,sizeof (pkg),TB_CFG_PKG_ERROR ); }
drivers/thunderbolt/tunnel.c +1 -1
@@ -49,7 +49,7 @@ static const char * const tb_tunnel_names[] = { "PCI", "DP", "DMA", "USB3" }; #define __TB_TUNNEL_PRINT(level, tunnel, fmt, arg...) \ do { \ struct tb_tunnel *__tunnel = (tunnel); \ - level(__tunnel->tb, "%llx:%x <-> %llx:%x (%s): " fmt, \ + level(__tunnel->tb, "%llx:%u <-> %llx:%u (%s): " fmt, \ tb_route(__tunnel->src_port->sw), \ __tunnel->src_port->port, \ tb_route(__tunnel->dst_port->sw), \
Signature · 1 line
2.35.1
PATCH 2/8 thunderbolt: Log DP adapter type
In reply to Mika WesterbergThis makes it easier to see from the debug logs what type of DisplayPort adapter is in use or available.
No functional changes.
--- drivers/thunderbolt/tb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/thunderbolt/tb.c +2 -2
@@ -892,7 +892,7 @@ static struct tb_port *tb_find_dp_out(struct tb *tb, struct tb_port *in)continue ;if (tb_port_is_enabled (port)) { -tb_port_dbg (port,"in use\n" ); +tb_port_dbg (port,"DP OUT in use\n" );continue ; }
@@ -941,7 +941,7 @@ static void tb_tunnel_dp(struct tb *tb)continue ;if (tb_port_is_enabled (port)) { -tb_port_dbg (port,"in use\n" ); +tb_port_dbg (port,"DP IN in use\n" );continue ; }
Signature · 1 line
2.35.1
PATCH 3/8 thunderbolt: Improve debug logging in tb_available_bandwidth()
In reply to Mika WesterbergThis makes it easier to see what is going on when bandwidth is being allocated for tunneling.
--- drivers/thunderbolt/tb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/thunderbolt/tb.c +5 -2
@@ -350,7 +350,9 @@ static int tb_available_bandwidth(struct tb *tb, struct tb_port *src_port,struct tb_tunnel *tunnel;struct tb_port *port; -tb_port_dbg (dst_port,"calculating available bandwidth\n" ); +tb_dbg (tb,"calculating available bandwidth between %llx:%u <-> %llx:%u\n" , +tb_route (src_port->sw), src_port->port,tb_route (dst_port->sw), + dst_port->port); tunnel =tb_find_first_usb3_tunnel (tb, src_port, dst_port);if (tunnel) {
@@ -387,7 +389,8 @@ static int tb_available_bandwidth(struct tb *tb, struct tb_port *src_port, up_bw -= up_bw /10 ; down_bw = up_bw; -tb_port_dbg (port,"link total bandwidth %d Mb/s\n" , up_bw); +tb_port_dbg (port,"link total bandwidth %d/%d Mb/s\n" , up_bw, + down_bw);/* * Find all DP tunnels that cross the port and reduce
Signature · 1 line
2.35.1
PATCH 4/8 thunderbolt: Take CL states into account when waiting for link to come up
In reply to Mika WesterbergIf CL states are enabled for the link it may be in these states too when reading the lane adapter state but it will enter CL0 as soon as there is traffic in the high-speed lanes. Upon discovery we want to make sure that is accounted as the link being up, otherwise we end up tearing down the topology with no good reason.
--- drivers/thunderbolt/switch.c | 42 +++++++++++++++++++++-------------- drivers/thunderbolt/tb_regs.h | 4 ++++ 2 files changed, 29 insertions(+), 17 deletions(-)
drivers/thunderbolt/switch.c +25 -17
@@ -513,36 +513,44 @@ int tb_wait_for_port(struct tb_port *port, bool wait_if_unplugged)while (retries--) { state =tb_port_state (port); -if (state <0 ) -return state; -if (state ==TB_PORT_DISABLED ) { +switch (state) { +case TB_PORT_DISABLED :tb_port_dbg (port,"is disabled (state: 0)\n" );return 0 ; - } -if (state ==TB_PORT_UNPLUGGED ) { + +case TB_PORT_UNPLUGGED :if (wait_if_unplugged) {/* used during resume */ tb_port_dbg (port,"is unplugged (state: 7), retrying...\n" );msleep (100 ); -continue ; +break ; }tb_port_dbg (port,"is unplugged (state: 7)\n" );return 0 ; - } -if (state ==TB_PORT_UP ) { -tb_port_dbg (port,"is connected, link is up (state: 2)\n" ); + +case TB_PORT_UP : +case TB_PORT_TX_CL0S : +case TB_PORT_RX_CL0S : +case TB_PORT_CL1 : +case TB_PORT_CL2 : +tb_port_dbg (port,"is connected, link is up (state: %d)\n" , state);return 1 ; + +default : +if (state <0 ) +return state; + +/* +* After plug-in the state is TB_PORT_CONNECTING. Give it some +* time. +*/ +tb_port_dbg (port, +"is connected, link is not up (state: %d), retrying...\n" , + state); +msleep (100 ); } -/* -* After plug-in the state is TB_PORT_CONNECTING. Give it some -* time. -*/ -tb_port_dbg (port, -"is connected, link is not up (state: %d), retrying...\n" , - state); -msleep (100 ); }tb_port_warn (port,"failed to reach state TB_PORT_UP. Ignoring port...\n" );
drivers/thunderbolt/tb_regs.h +4 -0
@@ -50,6 +50,10 @@ enum tb_port_state {TB_PORT_DISABLED =0 ,/* tb_cap_phy.disable == 1 */ TB_PORT_CONNECTING =1 ,/* retry */ TB_PORT_UP =2 , +TB_PORT_TX_CL0S =3 , +TB_PORT_RX_CL0S =4 , +TB_PORT_CL1 =5 , +TB_PORT_CL2 =6 , TB_PORT_UNPLUGGED = 7, };
Signature · 1 line
2.35.1
PATCH 5/8 thunderbolt: Increase timeout of DP OUT adapter handshake
In reply to Mika WesterbergSometimes the current timeout is not enough so increase it to 1500 ms and while there make the loop use ktime instead.
--- drivers/thunderbolt/tunnel.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/thunderbolt/tunnel.c +6 -5
@@ -339,9 +339,10 @@ static bool tb_dp_is_usb4(const struct tb_switch *sw)return tb_switch_is_usb4 (sw) ||tb_switch_is_titan_ridge (sw); } -static int tb_dp_cm_handshake (struct tb_port *in,struct tb_port *out) +static int tb_dp_cm_handshake (struct tb_port *in,struct tb_port *out, +int timeout_msec) { -int timeout =10 ; +ktime_t timeout =ktime_add_ms (ktime_get (), timeout_msec);u32 val;int ret;
@@ -368,8 +369,8 @@ static int tb_dp_cm_handshake(struct tb_port *in, struct tb_port *out)return ret;if (!(val &DP_STATUS_CTRL_CMHS ))return 0 ; -usleep_range (10 ,100 ); - }while (timeout--); +usleep_range (100 ,150 ); + }while (ktime_before (ktime_get (), timeout));return -ETIMEDOUT ; }
@@ -519,7 +520,7 @@ static int tb_dp_xchg_caps(struct tb_tunnel *tunnel)* Perform connection manager handshake between IN and OUT ports * before capabilities exchange can take place. */ - ret =tb_dp_cm_handshake (in, out); + ret =tb_dp_cm_handshake (in, out,1500 );if (ret)return ret;
Signature · 1 line
2.35.1
PATCH 6/8 thunderbolt: Add functions to support DisplayPort bandwidth allocation mode
In reply to Mika WesterbergUSB4 spec defines an additional feature that DP IN adapters can implement (alongside with the graphics DPCD register set) to support more dynamic bandwidth management for DisplayPort tunnels. For the connection manager the communication happens through the DP IN adapter using a set of registers in the adapter config space allocated for this. Add functions that export this functionality for the rest of the driver.
--- drivers/thunderbolt/tb.h | 15 + drivers/thunderbolt/tb_regs.h | 32 ++ drivers/thunderbolt/usb4.c | 571 ++++++++++++++++++++++++++++++++++ 3 files changed, 618 insertions(+)
drivers/thunderbolt/tb.h +15 -0
@@ -1238,6 +1238,21 @@ int usb4_usb3_port_allocate_bandwidth(struct tb_port *port, int *upstream_bw,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); +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); +static inline bool tb_is_usb4_port_device (const struct device *dev) {return dev->type == &usb4_port_device_type;
drivers/thunderbolt/tb_regs.h +32 -0
@@ -385,15 +385,42 @@ struct tb_regs_port_header {#define ADP_DP_CS_1_AUX_RX_HOPID_MASK GENMASK(21, 11)#define ADP_DP_CS_1_AUX_RX_HOPID_SHIFT 11#define ADP_DP_CS_2 0x02 +#define ADP_DP_CS_2_NRD_MLC_MASK GENMASK(2, 0)#define ADP_DP_CS_2_HDP BIT(6) +#define ADP_DP_CS_2_NRD_MLR_MASK GENMASK(9, 7) +#define ADP_DP_CS_2_NRD_MLR_SHIFT 7 +#define ADP_DP_CS_2_CA BIT(10) +#define ADP_DP_CS_2_GR_MASK GENMASK(12, 11) +#define ADP_DP_CS_2_GR_SHIFT 11 +#define ADP_DP_CS_2_GR_0_25G 0x0 +#define ADP_DP_CS_2_GR_0_5G 0x1 +#define ADP_DP_CS_2_GR_1G 0x2 +#define ADP_DP_CS_2_GROUP_ID_MASK GENMASK(15, 13) +#define ADP_DP_CS_2_GROUP_ID_SHIFT 13 +#define ADP_DP_CS_2_CM_ID_MASK GENMASK(19, 16) +#define ADP_DP_CS_2_CM_ID_SHIFT 16 +#define ADP_DP_CS_2_CMMS BIT(20) +#define ADP_DP_CS_2_ESTIMATED_BW_MASK GENMASK(31, 24) +#define ADP_DP_CS_2_ESTIMATED_BW_SHIFT 24#define ADP_DP_CS_3 0x03#define ADP_DP_CS_3_HDPC BIT(9)#define DP_LOCAL_CAP 0x04#define DP_REMOTE_CAP 0x05 +/* For DP IN adapter */ +#define DP_STATUS 0x06 +#define DP_STATUS_ALLOCATED_BW_MASK GENMASK(31, 24) +#define DP_STATUS_ALLOCATED_BW_SHIFT 24 +/* For DP OUT adapter */ #define DP_STATUS_CTRL 0x06#define DP_STATUS_CTRL_CMHS BIT(25)#define DP_STATUS_CTRL_UF BIT(26)#define DP_COMMON_CAP 0x07 +/* Only if DP IN supports BW allocation mode */ +#define ADP_DP_CS_8 0x08 +#define ADP_DP_CS_8_REQUESTED_BW_MASK GENMASK(7, 0) +#define ADP_DP_CS_8_DPME BIT(30) +#define ADP_DP_CS_8_DR BIT(31) +/* * DP_COMMON_CAP offsets work also for DP_LOCAL_CAP and DP_REMOTE_CAP * with exception of DPRX done.
@@ -410,7 +437,12 @@ struct tb_regs_port_header {#define DP_COMMON_CAP_2_LANES 0x1#define DP_COMMON_CAP_4_LANES 0x2#define DP_COMMON_CAP_LTTPR_NS BIT(27) +#define DP_COMMON_CAP_BW_MODE BIT(28)#define DP_COMMON_CAP_DPRX_DONE BIT(31) +/* Only present if DP IN supports BW allocation mode */ +#define ADP_DP_CS_8 0x08 +#define ADP_DP_CS_8_DPME BIT(30) +#define ADP_DP_CS_8_DR BIT(31)/* PCIe adapter registers */ #define ADP_PCIE_CS_0 0x00
drivers/thunderbolt/usb4.c +571 -0
574 lines not on this page · raw message
Signature · 1 line
2.35.1
PATCH 7/8 thunderbolt: Include the additional DP IN double word in debugfs dump
In reply to Mika WesterbergWhen DisplayPort bandwidth allocation mode is supported by the DP IN adapter it has an extra double word in the adapter config space. Include this in the debugfs register dump.
--- drivers/thunderbolt/debugfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/thunderbolt/debugfs.c +4 -1
@@ -1159,7 +1159,10 @@ static void port_cap_show(struct tb_port *port, struct seq_file *s,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)) { - length =PORT_CAP_DP_LEN ; +if (usb4_dp_port_bw_mode_supported (port)) + length =PORT_CAP_DP_LEN +1 ; +else + length =PORT_CAP_DP_LEN ; }else if (tb_port_is_usb3_down (port) ||tb_port_is_usb3_up (port)) { length =PORT_CAP_USB3_LEN ;
Signature · 1 line
2.35.1
PATCH 8/8 thunderbolt: Add support for DisplayPort bandwidth allocation mode
In reply to Mika WesterbergThe USB4 spec defines an optional feature that allows the connection manager to negotiate with the graphics through DPCD registers changes in the bandwidth allocation dynamically. This is referred as "bandwidth allocation mode" in the spec. The connection manager uses DP IN adapters registers to communicate with the graphics, and also gets notifications from these adapters when the graphics wants to change the bandwidth allocation. Both the connection manager and the graphics driver needs to support this.
We check if the DP IN adapter supports this and if it does enable it before establishing a DP tunnel. Then we react on DP_BW notifications coming from the DP IN adapter and update the bandwidth allocation accordingly (within the maximum common capabilities the DP IN/OUT support).
--- drivers/thunderbolt/ctl.c | 50 +++- drivers/thunderbolt/ctl.h | 2 + drivers/thunderbolt/tb.c | 493 +++++++++++++++++++++++++++++++++- drivers/thunderbolt/tb.h | 22 ++ drivers/thunderbolt/tb_msgs.h | 11 +- drivers/thunderbolt/tunnel.c | 483 ++++++++++++++++++++++++++++++--- drivers/thunderbolt/tunnel.h | 18 ++ 7 files changed, 1023 insertions(+), 56 deletions(-)
drivers/thunderbolt/ctl.c +42 -8
@@ -230,7 +230,6 @@ static int check_config_address(struct tb_cfg_address addr,static struct tb_cfg_result decode_error (const struct ctl_pkg *response) {struct cfg_error_pkg *pkg = response->buffer; -struct tb_ctl *ctl = response->ctl;struct tb_cfg_result res = {0 }; res.response_route =tb_cfg_get_route (&pkg->header); res.response_port =0 ;
@@ -239,13 +238,6 @@ static struct tb_cfg_result decode_error(const struct ctl_pkg *response)if (res.err)return res; -if (pkg->zero1) -tb_ctl_warn (ctl,"pkg->zero1 is %#x\n" , pkg->zero1); -if (pkg->zero2) -tb_ctl_warn (ctl,"pkg->zero2 is %#x\n" , pkg->zero2); -if (pkg->zero3) -tb_ctl_warn (ctl,"pkg->zero3 is %#x\n" , pkg->zero3); - res.err =1 ; res.tb_error = pkg->error; res.response_port = pkg->port;
@@ -416,6 +408,7 @@ static int tb_async_error(const struct ctl_pkg *pkg)case TB_CFG_ERROR_LINK_ERROR :case TB_CFG_ERROR_HEC_ERROR_DETECTED :case TB_CFG_ERROR_FLOW_CONTROL_ERROR : +case TB_CFG_ERROR_DP_BW :return true;default :
@@ -735,6 +728,47 @@ void tb_ctl_stop(struct tb_ctl *ctl)/* public interface, commands */ +/** +* tb_cfg_ack_notification() - Ack notification +* @ctl: Control channel to use +* @route: Router that originated the event +* @error: Pointer to the notification package +* +* Call this as response for non-plug notification to ack it. Returns +* %0 on success or an error code on failure. +*/ +int tb_cfg_ack_notification (struct tb_ctl *ctl,u64 route, +const struct cfg_error_pkg *error) +{ +struct cfg_ack_pkg pkg = { + .header =tb_cfg_make_header (route), + }; +const char *name; + +switch (error->error) { +case TB_CFG_ERROR_LINK_ERROR : + name ="link error" ; +break ; +case TB_CFG_ERROR_HEC_ERROR_DETECTED : + name ="HEC error" ; +break ; +case TB_CFG_ERROR_FLOW_CONTROL_ERROR : + name ="flow control error" ; +break ; +case TB_CFG_ERROR_DP_BW : + name ="DP_BW" ; +break ; +default : + name ="unknown" ; +break ; + } + +tb_ctl_dbg (ctl,"acking %s (%#x) notification on %llx\n" , name, + error->error, route); + +return tb_ctl_tx (ctl, &pkg,sizeof (pkg),TB_CFG_PKG_NOTIFY_ACK ); +} +/** * tb_cfg_ack_plug() - Ack hot plug/unplug event * @ctl: Control channel to use
drivers/thunderbolt/ctl.h +2 -0
@@ -122,6 +122,8 @@ static inline struct tb_cfg_header tb_cfg_make_header(u64 route)return header; } +int tb_cfg_ack_notification (struct tb_ctl *ctl,u64 route, +const struct cfg_error_pkg *error);int tb_cfg_ack_plug (struct tb_ctl *ctl,u64 route,u32 port,bool unplug);struct tb_cfg_result tb_cfg_reset (struct tb_ctl *ctl,u64 route); struct tb_cfg_result tb_cfg_read_raw(struct tb_ctl *ctl, void *buffer,
drivers/thunderbolt/tb.c +479 -14
621 lines not on this page · raw message
drivers/thunderbolt/tb.h +22 -0
@@ -223,6 +223,23 @@ struct tb_switch {enum tb_clx clx; }; +/** +* struct tb_bandwidth_group - Bandwidth management group +* @tb: Pointer to the domain the group belongs to +* @index: Index of the group (aka Group_ID). Valid values %1-%7 +* @ports: DP IN adapters belonging to this group are linked here +* +* Any tunnel that requires isochronous bandwidth (that's DP for now) is +* attached to a bandwidth group. All tunnels going through the same +* USB4 links share the same group and can dynamically distribute the +* bandwidth within the group. +*/ +struct tb_bandwidth_group { +struct tb *tb; +int index; +struct list_head ports; +}; +/** * struct tb_port - a thunderbolt port, part of a tb_switch * @config: Cached port configuration read from registers
@@ -247,6 +264,9 @@ struct tb_switch {* @ctl_credits: Buffers reserved for control path * @dma_credits: Number of credits allocated for DMA tunneling for all * DMA paths through this port. +* @group: Bandwidth allocation group the adapter is assigned to. Only +* used for DP IN adapters for now. +* @group_list: The adapter is linked to the group's list of ports through this * * In USB4 terminology this structure represents an adapter (protocol or * lane adapter).
@@ -272,6 +292,8 @@ struct tb_port {unsigned int total_credits;unsigned int ctl_credits;unsigned int dma_credits; +struct tb_bandwidth_group *group; +struct list_head group_list; };/**
drivers/thunderbolt/tb_msgs.h +7 -4
@@ -29,6 +29,7 @@ enum tb_cfg_error {TB_CFG_ERROR_HEC_ERROR_DETECTED =12 ,TB_CFG_ERROR_FLOW_CONTROL_ERROR =13 ,TB_CFG_ERROR_LOCK =15 , + TB_CFG_ERROR_DP_BW = 32, };/* common header */
@@ -64,14 +65,16 @@ struct cfg_write_pkg {/* TB_CFG_PKG_ERROR */ struct cfg_error_pkg {struct tb_cfg_header header; -enum tb_cfg_error error:4 ; -u32 zero1:4 ; +enum tb_cfg_error error:8 ;u32 port:6 ; -u32 zero2:2 ;/* Both should be zero, still they are different fields. */ -u32 zero3:14 ; +u32 reserved:16 ;u32 pg:2 ; } __packed; +struct cfg_ack_pkg { +struct tb_cfg_header header; +}; +#define TB_CFG_ERROR_PG_HOT_PLUG 0x2#define TB_CFG_ERROR_PG_HOT_UNPLUG 0x3
drivers/thunderbolt/tunnel.c +453 -30
542 lines not on this page · raw message
drivers/thunderbolt/tunnel.h +18 -0
@@ -29,6 +29,9 @@ enum tb_tunnel_type {* @init: Optional tunnel specific initialization * @deinit: Optional tunnel specific de-initialization * @activate: Optional tunnel specific activation/deactivation +* @maximum_bandwidth: +* @allocated_bandwidth: Return how much bandwidth is allocated for the tunnel +* @alloc_bandwidth: Change tunnel bandwidth allocation * @consumed_bandwidth: Return how much bandwidth the tunnel consumes * @release_unused_bandwidth: Release all unused bandwidth * @reclaim_available_bandwidth: Reclaim back available bandwidth
@@ -40,6 +43,8 @@ enum tb_tunnel_type {* Only set if the bandwidth needs to be limited. * @allocated_up: Allocated upstream bandwidth (only for USB3) * @allocated_down: Allocated downstream bandwidth (only for USB3) +* @bw_mode: DP bandwidth allocation mode registers can be used to +* determine consumed and allocated bandwidth */ struct tb_tunnel {struct tb *tb;
@@ -50,6 +55,12 @@ struct tb_tunnel {int (*init)(struct tb_tunnel *tunnel);void (*deinit)(struct tb_tunnel *tunnel);int (*activate)(struct tb_tunnel *tunnel,bool activate); +int (*maximum_bandwidth)(struct tb_tunnel *tunnel,int *max_up, +int *max_down); +int (*allocated_bandwidth)(struct tb_tunnel *tunnel,int *allocated_up, +int *allocated_down); +int (*alloc_bandwidth)(struct tb_tunnel *tunnel,int *alloc_up, +int *alloc_down);int (*consumed_bandwidth)(struct tb_tunnel *tunnel,int *consumed_up,int *consumed_down);int (*release_unused_bandwidth)(struct tb_tunnel *tunnel);
@@ -62,6 +73,7 @@ struct tb_tunnel {int max_down;int allocated_up;int allocated_down; +bool bw_mode; }; struct tb_tunnel *tb_tunnel_discover_pci(struct tb *tb, struct tb_port *down,
@@ -92,6 +104,12 @@ void tb_tunnel_deactivate(struct tb_tunnel *tunnel);bool tb_tunnel_is_invalid (struct tb_tunnel *tunnel);bool tb_tunnel_port_on_path (const struct tb_tunnel *tunnel,const struct tb_port *port); +int tb_tunnel_maximum_bandwidth (struct tb_tunnel *tunnel,int *max_up, +int *max_down); +int tb_tunnel_allocated_bandwidth (struct tb_tunnel *tunnel,int *allocated_up, +int *allocated_down); +int tb_tunnel_alloc_bandwidth (struct tb_tunnel *tunnel,int *alloc_up, +int *alloc_down);int tb_tunnel_consumed_bandwidth (struct tb_tunnel *tunnel,int *consumed_up,int *consumed_down);int tb_tunnel_release_unused_bandwidth (struct tb_tunnel *tunnel);
Signature · 1 line
2.35.1
Quoted 9 lines · Mika Westerberg
Hi all,
This series implements an optional feature in USB4 spec called DisplayPort bandwidth allocation mode. This allows the graphics driver to negotiate with the Thunderbolt driver the bandwidth requirements dynamically through DP IN adapters of the host router (graphics driver uses DP AUX registers for this). This enables more "fine grained" bandwidth allocation.
Quoted 9 lines
Mika Westerberg (8):
thunderbolt: Use decimal port number in control and tunnel logs too
thunderbolt: Log DP adapter type
thunderbolt: Improve debug logging intb_available_bandwidth()
thunderbolt: Take CL states into account when waiting for link to come up
thunderbolt: Increase timeout of DP OUT adapter handshake
thunderbolt: Add functions to support DisplayPort bandwidth allocation mode
thunderbolt: Include the additional DP IN double word in debugfs dump
thunderbolt: Add support for DisplayPort bandwidth allocation mode
All applied to thunderbolt.git/next.