thunderbolt: Make bandwidth allocation mode function names consistent

Make sure the DisplayPort bandwidth allocation mode function names are
consistent with the existing ones, such as USB3.

No functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This commit is contained in:
Mika Westerberg 2023-02-01 13:21:37 +02:00
parent fd4d58d1fe
commit 8d73f6b8e0
4 changed files with 52 additions and 46 deletions

View file

@ -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, static void tb_discover_bandwidth_group(struct tb_cm *tcm, struct tb_port *in,
struct tb_port *out) struct tb_port *out)
{ {
if (usb4_dp_port_bw_mode_enabled(in)) { if (usb4_dp_port_bandwidth_mode_enabled(in)) {
int index, i; int index, i;
index = usb4_dp_port_group_id(in); 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_tunnel *tunnel;
struct tb_port *out; struct tb_port *out;
if (!usb4_dp_port_bw_mode_enabled(in)) if (!usb4_dp_port_bandwidth_mode_enabled(in))
continue; continue;
tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, NULL); 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 else
estimated_bw = estimated_up; 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"); 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"); 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"); tb_port_warn(in, "bandwidth allocation mode not enabled\n");
goto unlock; goto unlock;
} }
ret = usb4_dp_port_requested_bw(in); ret = usb4_dp_port_requested_bandwidth(in);
if (ret < 0) { if (ret < 0) {
if (ret == -ENODATA) if (ret == -ENODATA)
tb_port_dbg(in, "no bandwidth request active\n"); tb_port_dbg(in, "no bandwidth request active\n");

View file

@ -1292,19 +1292,20 @@ int usb4_usb3_port_release_bandwidth(struct tb_port *port, int *upstream_bw,
int *downstream_bw); int *downstream_bw);
int usb4_dp_port_set_cm_id(struct tb_port *port, int cm_id); 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_bandwidth_mode_supported(struct tb_port *port);
bool usb4_dp_port_bw_mode_enabled(struct tb_port *port); bool usb4_dp_port_bandwidth_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_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_group_id(struct tb_port *port);
int usb4_dp_port_set_group_id(struct tb_port *port, int group_id); 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_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_set_nrd(struct tb_port *port, int rate, int lanes);
int usb4_dp_port_granularity(struct tb_port *port); 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_granularity(struct tb_port *port, int granularity);
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);
int usb4_dp_port_allocated_bw(struct tb_port *port); int usb4_dp_port_allocated_bandwidth(struct tb_port *port);
int usb4_dp_port_allocate_bw(struct tb_port *port, int bw); int usb4_dp_port_allocate_bandwidth(struct tb_port *port, int bw);
int usb4_dp_port_requested_bw(struct tb_port *port); int usb4_dp_port_requested_bandwidth(struct tb_port *port);
int usb4_pci_port_set_ext_encapsulation(struct tb_port *port, bool enable); int usb4_pci_port_set_ext_encapsulation(struct tb_port *port, bool enable);

View file

@ -641,7 +641,7 @@ static int tb_dp_xchg_caps(struct tb_tunnel *tunnel)
in->cap_adap + DP_REMOTE_CAP, 1); in->cap_adap + DP_REMOTE_CAP, 1);
} }
static int tb_dp_bw_alloc_mode_enable(struct tb_tunnel *tunnel) static int tb_dp_bandwidth_alloc_mode_enable(struct tb_tunnel *tunnel)
{ {
int ret, estimated_bw, granularity, tmp; int ret, estimated_bw, granularity, tmp;
struct tb_port *out = tunnel->dst_port; struct tb_port *out = tunnel->dst_port;
@ -653,7 +653,7 @@ static int tb_dp_bw_alloc_mode_enable(struct tb_tunnel *tunnel)
if (!bw_alloc_mode) if (!bw_alloc_mode)
return 0; return 0;
ret = usb4_dp_port_set_cm_bw_mode_supported(in, true); ret = usb4_dp_port_set_cm_bandwidth_mode_supported(in, true);
if (ret) if (ret)
return ret; return ret;
@ -717,12 +717,12 @@ static int tb_dp_bw_alloc_mode_enable(struct tb_tunnel *tunnel)
tb_port_dbg(in, "estimated bandwidth %d Mb/s\n", estimated_bw); tb_port_dbg(in, "estimated bandwidth %d Mb/s\n", estimated_bw);
ret = usb4_dp_port_set_estimated_bw(in, estimated_bw); ret = usb4_dp_port_set_estimated_bandwidth(in, estimated_bw);
if (ret) if (ret)
return ret; return ret;
/* Initial allocation should be 0 according the spec */ /* Initial allocation should be 0 according the spec */
ret = usb4_dp_port_allocate_bw(in, 0); ret = usb4_dp_port_allocate_bandwidth(in, 0);
if (ret) if (ret)
return ret; return ret;
@ -744,7 +744,7 @@ static int tb_dp_init(struct tb_tunnel *tunnel)
if (!tb_switch_is_usb4(sw)) if (!tb_switch_is_usb4(sw))
return 0; return 0;
if (!usb4_dp_port_bw_mode_supported(in)) if (!usb4_dp_port_bandwidth_mode_supported(in))
return 0; return 0;
tb_port_dbg(in, "bandwidth allocation mode supported\n"); tb_port_dbg(in, "bandwidth allocation mode supported\n");
@ -753,17 +753,17 @@ static int tb_dp_init(struct tb_tunnel *tunnel)
if (ret) if (ret)
return ret; return ret;
return tb_dp_bw_alloc_mode_enable(tunnel); return tb_dp_bandwidth_alloc_mode_enable(tunnel);
} }
static void tb_dp_deinit(struct tb_tunnel *tunnel) static void tb_dp_deinit(struct tb_tunnel *tunnel)
{ {
struct tb_port *in = tunnel->src_port; struct tb_port *in = tunnel->src_port;
if (!usb4_dp_port_bw_mode_supported(in)) if (!usb4_dp_port_bandwidth_mode_supported(in))
return; return;
if (usb4_dp_port_bw_mode_enabled(in)) { if (usb4_dp_port_bandwidth_mode_enabled(in)) {
usb4_dp_port_set_cm_bw_mode_supported(in, false); usb4_dp_port_set_cm_bandwidth_mode_supported(in, false);
tb_port_dbg(in, "bandwidth allocation mode disabled\n"); tb_port_dbg(in, "bandwidth allocation mode disabled\n");
} }
} }
@ -827,21 +827,22 @@ static int tb_dp_nrd_bandwidth(struct tb_tunnel *tunnel, int *max_bw)
return nrd_bw; return nrd_bw;
} }
static int tb_dp_bw_mode_consumed_bandwidth(struct tb_tunnel *tunnel, static int tb_dp_bandwidth_mode_consumed_bandwidth(struct tb_tunnel *tunnel,
int *consumed_up, int *consumed_down) int *consumed_up,
int *consumed_down)
{ {
struct tb_port *out = tunnel->dst_port; struct tb_port *out = tunnel->dst_port;
struct tb_port *in = tunnel->src_port; struct tb_port *in = tunnel->src_port;
int ret, allocated_bw, max_bw; int ret, allocated_bw, max_bw;
if (!usb4_dp_port_bw_mode_enabled(in)) if (!usb4_dp_port_bandwidth_mode_enabled(in))
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (!tunnel->bw_mode) if (!tunnel->bw_mode)
return -EOPNOTSUPP; return -EOPNOTSUPP;
/* Read what was allocated previously if any */ /* Read what was allocated previously if any */
ret = usb4_dp_port_allocated_bw(in); ret = usb4_dp_port_allocated_bandwidth(in);
if (ret < 0) if (ret < 0)
return ret; return ret;
allocated_bw = ret; allocated_bw = ret;
@ -876,10 +877,10 @@ static int tb_dp_allocated_bandwidth(struct tb_tunnel *tunnel, int *allocated_up
* If we have already set the allocated bandwidth then use that. * If we have already set the allocated bandwidth then use that.
* Otherwise we read it from the DPRX. * Otherwise we read it from the DPRX.
*/ */
if (usb4_dp_port_bw_mode_enabled(in) && tunnel->bw_mode) { if (usb4_dp_port_bandwidth_mode_enabled(in) && tunnel->bw_mode) {
int ret, allocated_bw, max_bw; int ret, allocated_bw, max_bw;
ret = usb4_dp_port_allocated_bw(in); ret = usb4_dp_port_allocated_bandwidth(in);
if (ret < 0) if (ret < 0)
return ret; return ret;
allocated_bw = ret; allocated_bw = ret;
@ -911,7 +912,7 @@ static int tb_dp_alloc_bandwidth(struct tb_tunnel *tunnel, int *alloc_up,
struct tb_port *in = tunnel->src_port; struct tb_port *in = tunnel->src_port;
int max_bw, ret, tmp; int max_bw, ret, tmp;
if (!usb4_dp_port_bw_mode_enabled(in)) if (!usb4_dp_port_bandwidth_mode_enabled(in))
return -EOPNOTSUPP; return -EOPNOTSUPP;
ret = tb_dp_nrd_bandwidth(tunnel, &max_bw); ret = tb_dp_nrd_bandwidth(tunnel, &max_bw);
@ -920,14 +921,14 @@ static int tb_dp_alloc_bandwidth(struct tb_tunnel *tunnel, int *alloc_up,
if (in->sw->config.depth < out->sw->config.depth) { if (in->sw->config.depth < out->sw->config.depth) {
tmp = min(*alloc_down, max_bw); tmp = min(*alloc_down, max_bw);
ret = usb4_dp_port_allocate_bw(in, tmp); ret = usb4_dp_port_allocate_bandwidth(in, tmp);
if (ret) if (ret)
return ret; return ret;
*alloc_down = tmp; *alloc_down = tmp;
*alloc_up = 0; *alloc_up = 0;
} else { } else {
tmp = min(*alloc_up, max_bw); tmp = min(*alloc_up, max_bw);
ret = usb4_dp_port_allocate_bw(in, tmp); ret = usb4_dp_port_allocate_bandwidth(in, tmp);
if (ret) if (ret)
return ret; return ret;
*alloc_down = 0; *alloc_down = 0;
@ -1048,8 +1049,8 @@ static int tb_dp_consumed_bandwidth(struct tb_tunnel *tunnel, int *consumed_up,
* mode is enabled first and then read the bandwidth * mode is enabled first and then read the bandwidth
* through those registers. * through those registers.
*/ */
ret = tb_dp_bw_mode_consumed_bandwidth(tunnel, consumed_up, ret = tb_dp_bandwidth_mode_consumed_bandwidth(tunnel, consumed_up,
consumed_down); consumed_down);
if (ret < 0) { if (ret < 0) {
if (ret != -EOPNOTSUPP) if (ret != -EOPNOTSUPP)
return ret; return ret;

View file

@ -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 * @port: DP IN adapter to check
* *
* Can be called to any DP IN adapter. Returns true if the adapter * Can be called to any DP IN adapter. Returns true if the adapter
* supports USB4 bandwidth allocation mode, false otherwise. * 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; int ret;
u32 val; 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 * @port: DP IN adapter to check
* *
* Can be called to any DP IN adapter. Returns true if the bandwidth * Can be called to any DP IN adapter. Returns true if the bandwidth
* allocation mode has been enabled, false otherwise. * 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; int ret;
u32 val; 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 * @port: DP IN adapter
* @supported: Does the CM support bandwidth allocation mode * @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 * otherwise. Specifically returns %-OPNOTSUPP if the passed in adapter
* does not support this. * 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; u32 val;
int ret; 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 * @port: DP IN adapter
* @bw: Estimated bandwidth in Mb/s. * @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 * and negative errno otherwise. Specifically returns %-EOPNOTSUPP if
* the adapter does not support this. * 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; u32 val, granularity;
int ret; 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 * @port: DP IN adapter
* *
* Reads and returns allocated bandwidth for @port in Mb/s (taking into * Reads and returns allocated bandwidth for @port in Mb/s (taking into
* account the programmed granularity). Returns negative errno in case * account the programmed granularity). Returns negative errno in case
* of error. * 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; u32 val, granularity;
int ret; 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 * @port: DP IN adapter
* @bw: New allocated bandwidth in Mb/s * @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 * driver). Takes into account the programmed granularity. Returns %0 in
* success and negative errno in case of error. * 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; u32 val, granularity;
int ret; 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 * @port: DP IN adapter
* *
* Reads the DPCD (graphics driver) requested bandwidth and returns it * 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 * the adapter does not support bandwidth allocation mode, and %ENODATA
* if there is no active bandwidth request from the graphics driver. * 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; u32 val, granularity;
int ret; int ret;