Commit a06d565b authored by Mustapha Ghaddar's avatar Mustapha Ghaddar Committed by Alex Deucher

drm/amd/display: Allocation at stream Enable

[WHY & HOW]
After we allocate BW at plug, we will de-alloc
and allocate only what stream needs at
stream_enable()

[HOW]
Introduce bw allocation check at link_enable()
for DPIA links
Reviewed-by: default avatarWenjing Liu <Wenjing.Liu@amd.com>
Acked-by: default avatarQingqing Zhuo <qingqing.zhuo@amd.com>
Signed-off-by: default avatarMustapha Ghaddar <mghaddar@amd.com>
Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 36951fc9
......@@ -293,6 +293,8 @@ struct dc_link {
struct dc_panel_config panel_config;
struct phy_state phy_state;
// BW ALLOCATON USB4 ONLY
struct dc_dpia_bw_alloc dpia_bw_alloc_config;
};
......
......@@ -46,6 +46,7 @@
#include "protocols/link_dp_capability.h"
#include "protocols/link_dp_training.h"
#include "protocols/link_edp_panel_control.h"
#include "protocols/link_dp_dpia_bw.h"
#include "dm_helpers.h"
#include "link_enc_cfg.h"
......@@ -2044,11 +2045,17 @@ static enum dc_status enable_link_dp(struct dc_state *state,
}
}
/* Train with fallback when enabling DPIA link. Conventional links are
/*
* If the link is DP-over-USB4 do the following:
* - Train with fallback when enabling DPIA link. Conventional links are
* trained with fallback during sink detection.
* - Allocate only what the stream needs for bw in Gbps. Inform the CM
* in case stream needs more or less bw from what has been allocated
* earlier at plug time.
*/
if (link->ep_type == DISPLAY_ENDPOINT_USB4_DPIA)
if (link->ep_type == DISPLAY_ENDPOINT_USB4_DPIA) {
do_fallback = true;
}
/*
* Temporary w/a to get DP2.0 link rates to work with SST.
......
......@@ -246,7 +246,7 @@ static bool get_cm_response_ready_flag(struct dc_link *link)
// ------------------------------------------------------------------
// PUBLIC FUNCTIONS
// ------------------------------------------------------------------
bool set_dptx_usb4_bw_alloc_support(struct dc_link *link)
bool link_dp_dpia_set_dptx_usb4_bw_alloc_support(struct dc_link *link)
{
bool ret = false;
uint8_t response = 0,
......@@ -439,3 +439,34 @@ int dc_link_dp_dpia_handle_usb4_bandwidth_allocation_for_link(struct dc_link *li
out:
return ret;
}
int link_dp_dpia_allocate_usb4_bandwidth_for_stream(struct dc_link *link, int req_bw)
{
int ret = 0;
uint8_t timeout = 10;
if (!get_bw_alloc_proceed_flag(link))
goto out;
/*
* Sometimes stream uses same timing parameters as the already
* allocated max sink bw so no need to re-alloc
*/
if (req_bw != link->dpia_bw_alloc_config.sink_allocated_bw) {
dc_link_set_usb4_req_bw_req(link, req_bw);
do {
if (!timeout > 0)
timeout--;
else
break;
udelay(10 * 1000);
} while (!get_cm_response_ready_flag(link));
if (!timeout)
ret = 0;// ERROR TIMEOUT waiting for response for allocating bw
else if (link->dpia_bw_alloc_config.sink_allocated_bw > 0)
ret = get_host_router_total_bw(link, HOST_ROUTER_BW_ALLOCATED);
}
out:
return ret;
}
......@@ -42,6 +42,18 @@ enum bw_type {
*
* return: SUCCESS or FAILURE
*/
bool set_dptx_usb4_bw_alloc_support(struct dc_link *link);
bool link_dp_dpia_set_dptx_usb4_bw_alloc_support(struct dc_link *link);
/*
* Allocates only what the stream needs for bw, so if:
* If (stream_req_bw < or > already_allocated_bw_at_HPD)
* => Deallocate Max Bw & then allocate only what the stream needs
*
* @link: pointer to the dc_link struct instance
* @req_bw: Bw requested by the stream
*
* return: allocated bw else return 0
*/
int link_dp_dpia_allocate_usb4_bandwidth_for_stream(struct dc_link *link, int req_bw);
#endif /* DC_INC_LINK_DP_DPIA_BW_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment