From: Ovidiu Bunea <[email protected]>

[Why]
The FAMS2 PMO stutter optimization uses the Z8 stutter exit latency
both to decide whether Z8 meets its eco requirement and as the vblank
time to reserve for Z8. The reserved vblank time is what feeds
min_ttu_vblank, so it only covered the exit latency rather than the
full Z8 enter plus exit latency.

Also, the stutter candidate index is never advanced, so when the Z8
candidate fails mode support the regular stutter candidate is never
attempted and the whole stutter optimization is dropped.

[How]
Use z8_stutter_enter_plus_exit_latency_us instead of
z8_stutter_exit_latency_us in pmo_dcn4_fams2_init_for_stutter() for
the Z8 eco check and for the Z8 vblank reserved time candidate, and in
pmo_dcn4_fams2_test_for_stutter() for the reserved vblank time check.

In pmo_dcn4_fams2_optimize_for_stutter(), advance to the next
candidate on each attempt instead of giving up after the first one
fails. Track which candidate is the Z8 one, and only require the Z8
reserved time in the stutter test while that candidate is the one
being attempted.

Fewer configs now meet the Z8 eco check. Configs that still meet it
reserve more vblank time (Z8 enter plus exit latency). Configs that no
longer meet it fall back to the regular stutter candidate.

Cc: Dillon Varone <[email protected]>
Signed-off-by: Ovidiu Bunea <[email protected]>
Signed-off-by: Chenyu Chen <[email protected]>
---
 .../dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c  | 35 +++++++++++--------
 .../src/inc/dml2_internal_shared_types.h      |  1 +
 2 files changed, 21 insertions(+), 15 deletions(-)

diff --git 
a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c
 
b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c
index 62ac29dfe9be..cd68b5010a06 100644
--- 
a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c
+++ 
b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c
@@ -2387,7 +2387,7 @@ bool pmo_dcn4_fams2_init_for_stutter(struct 
dml2_pmo_init_for_stutter_in_out *in
 
        for (i = 0; i < in_out->base_display_config->display_config.num_planes; 
i++) {
                if 
(in_out->base_display_config->mode_support_result.cfg_support_info.plane_support_info[i].active_latency_hiding_us
 <
-                       
pmo->soc_bb->power_management_parameters.z8_stutter_exit_latency_us + 
pmo->soc_bb->power_management_parameters.z8_min_idle_time) {
+                       
pmo->soc_bb->power_management_parameters.z8_stutter_enter_plus_exit_latency_us 
+ pmo->soc_bb->power_management_parameters.z8_min_idle_time) {
                        stutter_period_meets_z8_eco = false;
                        break;
                }
@@ -2414,8 +2414,9 @@ bool pmo_dcn4_fams2_init_for_stutter(struct 
dml2_pmo_init_for_stutter_in_out *in
        pmo->scratch.pmo_dcn4.cur_stutter_candidate = 0;
 
        if (stutter_period_meets_z8_eco && 
!z8_stutter_optimization_too_expensive) {
-               if 
(pmo->soc_bb->power_management_parameters.z8_stutter_exit_latency_us > 0) {
-                       
pmo->scratch.pmo_dcn4.optimal_vblank_reserved_time_for_stutter_us[pmo->scratch.pmo_dcn4.num_stutter_candidates]
 = (unsigned 
int)pmo->soc_bb->power_management_parameters.z8_stutter_exit_latency_us;
+               if 
(pmo->soc_bb->power_management_parameters.z8_stutter_enter_plus_exit_latency_us 
> 0) {
+                       
pmo->scratch.pmo_dcn4.optimal_vblank_reserved_time_for_stutter_us[pmo->scratch.pmo_dcn4.num_stutter_candidates]
 = (unsigned 
int)pmo->soc_bb->power_management_parameters.z8_stutter_enter_plus_exit_latency_us;
+                       
pmo->scratch.pmo_dcn4.stutter_candidate_is_z8[pmo->scratch.pmo_dcn4.num_stutter_candidates]
 = true;
                        pmo->scratch.pmo_dcn4.num_stutter_candidates++;
                        pmo->scratch.pmo_dcn4.z8_vblank_optimizable = true;
                }
@@ -2425,6 +2426,7 @@ bool pmo_dcn4_fams2_init_for_stutter(struct 
dml2_pmo_init_for_stutter_in_out *in
 
        if (!stutter_optimization_too_expensive && 
pmo->soc_bb->power_management_parameters.stutter_enter_plus_exit_latency_us > 
0) {
                
pmo->scratch.pmo_dcn4.optimal_vblank_reserved_time_for_stutter_us[pmo->scratch.pmo_dcn4.num_stutter_candidates]
 = (unsigned 
int)pmo->soc_bb->power_management_parameters.stutter_enter_plus_exit_latency_us;
+               
pmo->scratch.pmo_dcn4.stutter_candidate_is_z8[pmo->scratch.pmo_dcn4.num_stutter_candidates]
 = false;
                pmo->scratch.pmo_dcn4.num_stutter_candidates++;
        }
 
@@ -2442,9 +2444,9 @@ bool pmo_dcn4_fams2_test_for_stutter(struct 
dml2_pmo_test_for_stutter_in_out *in
        unsigned int i;
 
        for (i = 0; i < in_out->base_display_config->display_config.num_planes; 
i++) {
-               if 
(pmo->soc_bb->power_management_parameters.z8_stutter_exit_latency_us > 0 &&
+               if 
(pmo->soc_bb->power_management_parameters.z8_stutter_enter_plus_exit_latency_us 
> 0 &&
                        pmo->scratch.pmo_dcn4.z8_vblank_optimizable &&
-                       
in_out->base_display_config->display_config.plane_descriptors[i].overrides.reserved_vblank_time_ns
 < (int)pmo->soc_bb->power_management_parameters.z8_stutter_exit_latency_us * 
1000) {
+                       
in_out->base_display_config->display_config.plane_descriptors[i].overrides.reserved_vblank_time_ns
 < 
(int)pmo->soc_bb->power_management_parameters.z8_stutter_enter_plus_exit_latency_us
 * 1000) {
                        success = false;
                        break;
                }
@@ -2466,17 +2468,20 @@ bool pmo_dcn4_fams2_optimize_for_stutter(struct 
dml2_pmo_optimize_for_stutter_in
 
        memcpy(in_out->optimized_display_config, in_out->base_display_config, 
sizeof(struct display_configuation_with_meta));
 
-       if (!in_out->last_candidate_failed) {
-               if (pmo->scratch.pmo_dcn4.cur_stutter_candidate < 
pmo->scratch.pmo_dcn4.num_stutter_candidates) {
-                       for (i = 0; i < 
in_out->optimized_display_config->display_config.num_planes; i++) {
-                               /* take the max of the current and the optimal 
reserved time */
-                               
in_out->optimized_display_config->display_config.plane_descriptors[i].overrides.reserved_vblank_time_ns
 =
-                                               
(long)math_max2(pmo->scratch.pmo_dcn4.optimal_vblank_reserved_time_for_stutter_us[pmo->scratch.pmo_dcn4.cur_stutter_candidate]
 * 1000,
-                                               
in_out->optimized_display_config->display_config.plane_descriptors[i].overrides.reserved_vblank_time_ns);
-                       }
-
-                       success = true;
+       if (pmo->scratch.pmo_dcn4.cur_stutter_candidate < 
pmo->scratch.pmo_dcn4.num_stutter_candidates) {
+               for (i = 0; i < 
in_out->optimized_display_config->display_config.num_planes; i++) {
+                       /* take the max of the current and the optimal reserved 
time */
+                       
in_out->optimized_display_config->display_config.plane_descriptors[i].overrides.reserved_vblank_time_ns
 =
+                                       
(long)math_max2(pmo->scratch.pmo_dcn4.optimal_vblank_reserved_time_for_stutter_us[pmo->scratch.pmo_dcn4.cur_stutter_candidate]
 * 1000,
+                                       
in_out->optimized_display_config->display_config.plane_descriptors[i].overrides.reserved_vblank_time_ns);
                }
+
+               /* only require the Z8 reserved time in the stutter test while 
the Z8 candidate is the one being attempted */
+               pmo->scratch.pmo_dcn4.z8_vblank_optimizable =
+                               
pmo->scratch.pmo_dcn4.stutter_candidate_is_z8[pmo->scratch.pmo_dcn4.cur_stutter_candidate];
+
+               pmo->scratch.pmo_dcn4.cur_stutter_candidate++;
+               success = true;
        }
 
        return success;
diff --git 
a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/inc/dml2_internal_shared_types.h
 
b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/inc/dml2_internal_shared_types.h
index 54ec7ef7cbae..3f51c26dc238 100644
--- 
a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/inc/dml2_internal_shared_types.h
+++ 
b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/inc/dml2_internal_shared_types.h
@@ -1093,6 +1093,7 @@ struct dml2_pmo_scratch {
                        struct dml2_pstate_meta 
stream_pstate_meta[DML2_MAX_PLANES];
 
                        unsigned int 
optimal_vblank_reserved_time_for_stutter_us[DML2_PMO_STUTTER_CANDIDATE_LIST_SIZE];
+                       bool 
stutter_candidate_is_z8[DML2_PMO_STUTTER_CANDIDATE_LIST_SIZE];
                        unsigned int num_stutter_candidates;
                        unsigned int cur_stutter_candidate;
                        bool z8_vblank_optimizable;
-- 
2.43.0

Reply via email to