drm/amd/display: Fix calculation of virtual channel payload
authorMikita Lipski <mikita.lipski@amd.com>
Mon, 1 Jun 2020 14:26:11 +0000 (10:26 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 1 Jul 2020 05:59:25 +0000 (01:59 -0400)
[why]
The calculation of virtual channel payload would not take link settings
in account. As we calculate VCPI slots needed both PBN for stream and
also PBN per time slot.  Before we would use generic PBN per time slot,
which would not change with link settings causing wrong Payload
allocation.

[how]
Provide PBN per time slot for each Virtual channel payload calculation.

Signed-off-by: Mikita Lipski <mikita.lipski@amd.com>
Reviewed-by: Nicholas Kazlauskas <Nicholas.Kazlauskas@amd.com>
Acked-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c

index 7094c3b..991516e 100644 (file)
@@ -5452,7 +5452,7 @@ static int dm_encoder_helper_atomic_check(struct drm_encoder *encoder,
                                                                           mst_mgr,
                                                                           mst_port,
                                                                           dm_new_connector_state->pbn,
-                                                                          0);
+                                                                          dm_mst_get_pbn_divider(aconnector->dc_link));
        if (dm_new_connector_state->vcpi_slots < 0) {
                DRM_DEBUG_ATOMIC("failed finding vcpi slots: %d\n", (int)dm_new_connector_state->vcpi_slots);
                return dm_new_connector_state->vcpi_slots;
index ae0a7ef..cf15248 100644 (file)
@@ -522,6 +522,8 @@ static void increase_dsc_bpp(struct drm_atomic_state *state,
        int link_timeslots_used;
        int fair_pbn_alloc;
 
+       pbn_per_timeslot = dm_mst_get_pbn_divider(dc_link);
+
        for (i = 0; i < count; i++) {
                if (vars[i].dsc_enabled) {
                        initial_slack[i] = kbps_to_peak_pbn(params[i].bw_range.max_kbps) - vars[i].pbn;
@@ -533,9 +535,6 @@ static void increase_dsc_bpp(struct drm_atomic_state *state,
                }
        }
 
-       pbn_per_timeslot = dc_link_bandwidth_kbps(dc_link,
-                       dc_link_get_link_cap(dc_link)) / (8 * 1000 * 54);
-
        while (remaining_to_increase) {
                next_index = -1;
                min_initial_slack = -1;
@@ -564,7 +563,7 @@ static void increase_dsc_bpp(struct drm_atomic_state *state,
                                                          params[next_index].port->mgr,
                                                          params[next_index].port,
                                                          vars[next_index].pbn,
-                                                         dm_mst_get_pbn_divider(dc_link)) < 0)
+                                                         pbn_per_timeslot) < 0)
                                return;
                        if (!drm_dp_mst_atomic_check(state)) {
                                vars[next_index].bpp_x16 = bpp_x16_from_pbn(params[next_index], vars[next_index].pbn);
@@ -574,7 +573,7 @@ static void increase_dsc_bpp(struct drm_atomic_state *state,
                                                                  params[next_index].port->mgr,
                                                                  params[next_index].port,
                                                                  vars[next_index].pbn,
-                                                                 dm_mst_get_pbn_divider(dc_link)) < 0)
+                                                                 pbn_per_timeslot) < 0)
                                        return;
                        }
                } else {
@@ -583,7 +582,7 @@ static void increase_dsc_bpp(struct drm_atomic_state *state,
                                                          params[next_index].port->mgr,
                                                          params[next_index].port,
                                                          vars[next_index].pbn,
-                                                         dm_mst_get_pbn_divider(dc_link)) < 0)
+                                                         pbn_per_timeslot) < 0)
                                return;
                        if (!drm_dp_mst_atomic_check(state)) {
                                vars[next_index].bpp_x16 = params[next_index].bw_range.max_target_bpp_x16;
@@ -593,7 +592,7 @@ static void increase_dsc_bpp(struct drm_atomic_state *state,
                                                                  params[next_index].port->mgr,
                                                                  params[next_index].port,
                                                                  vars[next_index].pbn,
-                                                                 dm_mst_get_pbn_divider(dc_link)) < 0)
+                                                                 pbn_per_timeslot) < 0)
                                        return;
                        }
                }
@@ -647,7 +646,7 @@ static void try_disable_dsc(struct drm_atomic_state *state,
                                                  params[next_index].port->mgr,
                                                  params[next_index].port,
                                                  vars[next_index].pbn,
-                                                 0) < 0)
+                                                 dm_mst_get_pbn_divider(dc_link)) < 0)
                        return;
 
                if (!drm_dp_mst_atomic_check(state)) {
@@ -718,7 +717,7 @@ static bool compute_mst_dsc_configs_for_link(struct drm_atomic_state *state,
                                                 params[i].port->mgr,
                                                 params[i].port,
                                                 vars[i].pbn,
-                                                0) < 0)
+                                                dm_mst_get_pbn_divider(dc_link)) < 0)
                        return false;
        }
        if (!drm_dp_mst_atomic_check(state)) {
@@ -746,7 +745,7 @@ static bool compute_mst_dsc_configs_for_link(struct drm_atomic_state *state,
                                                          params[i].port->mgr,
                                                          params[i].port,
                                                          vars[i].pbn,
-                                                         0) < 0)
+                                                         dm_mst_get_pbn_divider(dc_link)) < 0)
                                return false;
                }
        }