Skip to content

Commit ef30f44

Browse files
Wenjing Liualexdeucher
authored andcommitted
drm/amd/display: define link res and make it accessible to all link interfaces
[why] There will be a series of re-arch changes in Link Resource Management. They are more and more muxable link resource objects and the resource is insufficient for a one to one allocation to all links created. Therefore a link resource sharing logic is required to determine which link should use certain link resource. This commit is the first one in this series that starts by defining a link resource struct, this struct will be available to all interfaces that need to perform link programming sequence. In later commits, we will granduately decouple link resource objects out of dc link. So instead of access a link resource from dc link. Current link's resource can be accessible through pipe_ctx->link_res during commit, or by calling dc_link_get_cur_link_res function with current link passed in after commit. 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 19afe66 commit ef30f44

File tree

9 files changed

+229
-114
lines changed

9 files changed

+229
-114
lines changed

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

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ static bool dc_link_detect_helper(struct dc_link *link,
986986
* empty which leads to allocate_mst_payload() has "0"
987987
* pbn_per_slot value leading to exception on dc_fixpt_div()
988988
*/
989-
dp_verify_mst_link_cap(link);
989+
dp_verify_mst_link_cap(link, NULL);
990990

991991
/*
992992
* This call will initiate MST topology discovery. Which
@@ -1150,6 +1150,7 @@ static bool dc_link_detect_helper(struct dc_link *link,
11501150
// verify link cap for SST non-seamless boot
11511151
if (!perform_dp_seamless_boot)
11521152
dp_verify_link_cap_with_retries(link,
1153+
NULL,
11531154
&link->reported_link_cap,
11541155
LINK_TRAINING_MAX_VERIFY_RETRY);
11551156
} else {
@@ -2503,7 +2504,8 @@ static void write_i2c_redriver_setting(
25032504
DC_LOG_DEBUG("Set redriver failed");
25042505
}
25052506

2506-
static void disable_link(struct dc_link *link, enum signal_type signal)
2507+
static void disable_link(struct dc_link *link, const struct link_resource *link_res,
2508+
enum signal_type signal)
25072509
{
25082510
/*
25092511
* TODO: implement call for dp_set_hw_test_pattern
@@ -2522,20 +2524,20 @@ static void disable_link(struct dc_link *link, enum signal_type signal)
25222524
struct dc_link_settings link_settings = link->cur_link_settings;
25232525
#endif
25242526
if (dc_is_dp_sst_signal(signal))
2525-
dp_disable_link_phy(link, signal);
2527+
dp_disable_link_phy(link, link_res, signal);
25262528
else
2527-
dp_disable_link_phy_mst(link, signal);
2529+
dp_disable_link_phy_mst(link, link_res, signal);
25282530

25292531
if (dc_is_dp_sst_signal(signal) ||
25302532
link->mst_stream_alloc_table.stream_count == 0) {
25312533
#if defined(CONFIG_DRM_AMD_DC_DCN)
25322534
if (dp_get_link_encoding_format(&link_settings) == DP_8b_10b_ENCODING) {
25332535
dp_set_fec_enable(link, false);
2534-
dp_set_fec_ready(link, false);
2536+
dp_set_fec_ready(link, link_res, false);
25352537
}
25362538
#else
25372539
dp_set_fec_enable(link, false);
2538-
dp_set_fec_ready(link, false);
2540+
dp_set_fec_ready(link, link_res, false);
25392541
#endif
25402542
}
25412543
} else {
@@ -2646,7 +2648,7 @@ static enum dc_status enable_link(
26462648
* new link settings.
26472649
*/
26482650
if (link->link_status.link_active) {
2649-
disable_link(link, pipe_ctx->stream->signal);
2651+
disable_link(link, &pipe_ctx->link_res, pipe_ctx->stream->signal);
26502652
}
26512653

26522654
switch (pipe_ctx->stream->signal) {
@@ -4109,7 +4111,7 @@ static void fpga_dp_hpo_enable_link_and_stream(struct dc_state *state, struct pi
41094111
stream->link->cur_link_settings = link_settings;
41104112

41114113
/* Enable clock, Configure lane count, and Enable Link Encoder*/
4112-
enable_dp_hpo_output(stream->link, &stream->link->cur_link_settings);
4114+
enable_dp_hpo_output(stream->link, &pipe_ctx->link_res, &stream->link->cur_link_settings);
41134115

41144116
#ifdef DIAGS_BUILD
41154117
/* Workaround for FPGA HPO capture DP link data:
@@ -4353,7 +4355,8 @@ void core_link_enable_stream(
43534355
if (status != DC_FAIL_DP_LINK_TRAINING ||
43544356
pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST) {
43554357
if (false == stream->link->link_status.link_active)
4356-
disable_link(stream->link, pipe_ctx->stream->signal);
4358+
disable_link(stream->link, &pipe_ctx->link_res,
4359+
pipe_ctx->stream->signal);
43574360
BREAK_TO_DEBUGGER();
43584361
return;
43594362
}
@@ -4502,14 +4505,14 @@ void core_link_disable_stream(struct pipe_ctx *pipe_ctx)
45024505
* state machine.
45034506
* In DP2 or MST mode, our encoder will stay video active
45044507
*/
4505-
disable_link(pipe_ctx->stream->link, pipe_ctx->stream->signal);
4508+
disable_link(pipe_ctx->stream->link, &pipe_ctx->link_res, pipe_ctx->stream->signal);
45064509
dc->hwss.disable_stream(pipe_ctx);
45074510
} else {
45084511
dc->hwss.disable_stream(pipe_ctx);
4509-
disable_link(pipe_ctx->stream->link, pipe_ctx->stream->signal);
4512+
disable_link(pipe_ctx->stream->link, &pipe_ctx->link_res, pipe_ctx->stream->signal);
45104513
}
45114514
#else
4512-
disable_link(pipe_ctx->stream->link, pipe_ctx->stream->signal);
4515+
disable_link(pipe_ctx->stream->link, &pipe_ctx->link_res, pipe_ctx->stream->signal);
45134516

45144517
dc->hwss.disable_stream(pipe_ctx);
45154518
#endif
@@ -4592,16 +4595,22 @@ void dc_link_set_drive_settings(struct dc *dc,
45924595
{
45934596

45944597
int i;
4598+
struct pipe_ctx *pipe = NULL;
4599+
const struct link_resource *link_res;
45954600

4596-
for (i = 0; i < dc->link_count; i++) {
4597-
if (dc->links[i] == link)
4598-
break;
4599-
}
4601+
link_res = dc_link_get_cur_link_res(link);
46004602

4601-
if (i >= dc->link_count)
4603+
for (i = 0; i < MAX_PIPES; i++) {
4604+
pipe = &dc->current_state->res_ctx.pipe_ctx[i];
4605+
if (pipe->stream && pipe->stream->link) {
4606+
if (pipe->stream->link == link)
4607+
break;
4608+
}
4609+
}
4610+
if (pipe && link_res)
4611+
dc_link_dp_set_drive_settings(pipe->stream->link, link_res, lt_settings);
4612+
else
46024613
ASSERT_CRITICAL(false);
4603-
4604-
dc_link_dp_set_drive_settings(dc->links[i], lt_settings);
46054614
}
46064615

46074616
void dc_link_set_preferred_link_settings(struct dc *dc,
@@ -4793,6 +4802,9 @@ void dc_link_overwrite_extended_receiver_cap(
47934802

47944803
bool dc_link_is_fec_supported(const struct dc_link *link)
47954804
{
4805+
/* TODO - use asic cap instead of link_enc->features
4806+
* we no longer know which link enc to use for this link before commit
4807+
*/
47964808
struct link_encoder *link_enc = NULL;
47974809

47984810
/* Links supporting dynamically assigned link encoder will be assigned next
@@ -4887,3 +4899,22 @@ uint32_t dc_bandwidth_in_kbps_from_timing(
48874899
return kbps;
48884900

48894901
}
4902+
4903+
const struct link_resource *dc_link_get_cur_link_res(const struct dc_link *link)
4904+
{
4905+
int i;
4906+
struct pipe_ctx *pipe = NULL;
4907+
const struct link_resource *link_res = NULL;
4908+
4909+
for (i = 0; i < MAX_PIPES; i++) {
4910+
pipe = &link->dc->current_state->res_ctx.pipe_ctx[i];
4911+
if (pipe->stream && pipe->stream->link && pipe->top_pipe == NULL) {
4912+
if (pipe->stream->link == link) {
4913+
link_res = &pipe->link_res;
4914+
break;
4915+
}
4916+
}
4917+
}
4918+
4919+
return link_res;
4920+
}

0 commit comments

Comments
 (0)