Skip to content

Commit 4c3adc0

Browse files
Wenjing Liualexdeucher
authored andcommitted
drm/amd/display: get and restore link res map
[why] When reboot the link res map should be persisted. So during boot up, driver will look at the map to determine which link should take priority to use certain link res. This is to ensure that link res remains unshuffled after a reboot. Tested-by: Daniel Wheeler <[email protected]> Reviewed-by: Jun Lei <[email protected]> Acked-by: Rodrigo Siqueira <[email protected]> Signed-off-by: Wenjing Liu <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 6dd8931 commit 4c3adc0

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

drivers/gpu/drm/amd/display/dc/core/dc_link.c

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4890,3 +4890,106 @@ const struct link_resource *dc_link_get_cur_link_res(const struct dc_link *link)
48904890

48914891
return link_res;
48924892
}
4893+
4894+
/**
4895+
* dc_get_cur_link_res_map() - take a snapshot of current link resource allocation state
4896+
* @dc: pointer to dc of the dm calling this
4897+
* @map: a dc link resource snapshot defined internally to dc.
4898+
*
4899+
* DM needs to capture a snapshot of current link resource allocation mapping
4900+
* and store it in its persistent storage.
4901+
*
4902+
* Some of the link resource is using first come first serve policy.
4903+
* The allocation mapping depends on original hotplug order. This information
4904+
* is lost after driver is loaded next time. The snapshot is used in order to
4905+
* restore link resource to its previous state so user will get consistent
4906+
* link capability allocation across reboot.
4907+
*
4908+
* Return: none (void function)
4909+
*
4910+
*/
4911+
void dc_get_cur_link_res_map(const struct dc *dc, uint32_t *map)
4912+
{
4913+
#if defined(CONFIG_DRM_AMD_DC_DCN)
4914+
struct dc_link *link;
4915+
uint8_t i;
4916+
uint32_t hpo_dp_recycle_map = 0;
4917+
4918+
*map = 0;
4919+
4920+
if (dc->caps.dp_hpo) {
4921+
for (i = 0; i < dc->caps.max_links; i++) {
4922+
link = dc->links[i];
4923+
if (link->link_status.link_active &&
4924+
dp_get_link_encoding_format(&link->reported_link_cap) == DP_128b_132b_ENCODING &&
4925+
dp_get_link_encoding_format(&link->cur_link_settings) != DP_128b_132b_ENCODING)
4926+
/* hpo dp link encoder is considered as recycled, when RX reports 128b/132b encoding capability
4927+
* but current link doesn't use it.
4928+
*/
4929+
hpo_dp_recycle_map |= (1 << i);
4930+
}
4931+
*map |= (hpo_dp_recycle_map << LINK_RES_HPO_DP_REC_MAP__SHIFT);
4932+
}
4933+
#endif
4934+
}
4935+
4936+
/**
4937+
* dc_restore_link_res_map() - restore link resource allocation state from a snapshot
4938+
* @dc: pointer to dc of the dm calling this
4939+
* @map: a dc link resource snapshot defined internally to dc.
4940+
*
4941+
* DM needs to call this function after initial link detection on boot and
4942+
* before first commit streams to restore link resource allocation state
4943+
* from previous boot session.
4944+
*
4945+
* Some of the link resource is using first come first serve policy.
4946+
* The allocation mapping depends on original hotplug order. This information
4947+
* is lost after driver is loaded next time. The snapshot is used in order to
4948+
* restore link resource to its previous state so user will get consistent
4949+
* link capability allocation across reboot.
4950+
*
4951+
* Return: none (void function)
4952+
*
4953+
*/
4954+
void dc_restore_link_res_map(const struct dc *dc, uint32_t *map)
4955+
{
4956+
#if defined(CONFIG_DRM_AMD_DC_DCN)
4957+
struct dc_link *link;
4958+
uint8_t i;
4959+
unsigned int available_hpo_dp_count;
4960+
uint32_t hpo_dp_recycle_map = (*map & LINK_RES_HPO_DP_REC_MAP__MASK)
4961+
>> LINK_RES_HPO_DP_REC_MAP__SHIFT;
4962+
4963+
if (dc->caps.dp_hpo) {
4964+
available_hpo_dp_count = dc->res_pool->hpo_dp_link_enc_count;
4965+
/* remove excess 128b/132b encoding support for not recycled links */
4966+
for (i = 0; i < dc->caps.max_links; i++) {
4967+
if ((hpo_dp_recycle_map & (1 << i)) == 0) {
4968+
link = dc->links[i];
4969+
if (link->type != dc_connection_none &&
4970+
dp_get_link_encoding_format(&link->verified_link_cap) == DP_128b_132b_ENCODING) {
4971+
if (available_hpo_dp_count > 0)
4972+
available_hpo_dp_count--;
4973+
else
4974+
/* remove 128b/132b encoding capability by limiting verified link rate to HBR3 */
4975+
link->verified_link_cap.link_rate = LINK_RATE_HIGH3;
4976+
}
4977+
}
4978+
}
4979+
/* remove excess 128b/132b encoding support for recycled links */
4980+
for (i = 0; i < dc->caps.max_links; i++) {
4981+
if ((hpo_dp_recycle_map & (1 << i)) != 0) {
4982+
link = dc->links[i];
4983+
if (link->type != dc_connection_none &&
4984+
dp_get_link_encoding_format(&link->verified_link_cap) == DP_128b_132b_ENCODING) {
4985+
if (available_hpo_dp_count > 0)
4986+
available_hpo_dp_count--;
4987+
else
4988+
/* remove 128b/132b encoding capability by limiting verified link rate to HBR3 */
4989+
link->verified_link_cap.link_rate = LINK_RATE_HIGH3;
4990+
}
4991+
}
4992+
}
4993+
}
4994+
#endif
4995+
}

drivers/gpu/drm/amd/display/dc/dc_link.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,4 +459,8 @@ enum dp_link_encoding dc_link_dp_mst_decide_link_encoding_format(const struct dc
459459
#endif
460460

461461
const struct link_resource *dc_link_get_cur_link_res(const struct dc_link *link);
462+
/* take a snapshot of current link resource allocation state */
463+
void dc_get_cur_link_res_map(const struct dc *dc, uint32_t *map);
464+
/* restore link resource allocation state from a snapshot */
465+
void dc_restore_link_res_map(const struct dc *dc, uint32_t *map);
462466
#endif /* DC_LINK_H_ */

drivers/gpu/drm/amd/display/dc/inc/core_types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@ struct plane_resource {
334334
struct dcn_fe_bandwidth bw;
335335
};
336336

337+
#if defined(CONFIG_DRM_AMD_DC_DCN)
338+
#define LINK_RES_HPO_DP_REC_MAP__MASK 0xFFFF
339+
#define LINK_RES_HPO_DP_REC_MAP__SHIFT 0
340+
#endif
341+
337342
/* all mappable hardware resources used to enable a link */
338343
struct link_resource {
339344
#if defined(CONFIG_DRM_AMD_DC_DCN)

0 commit comments

Comments
 (0)