From: Ryan Seto <[email protected]>

[Why & How]
In theory, driver should be able to support disabling force pstate allow
after hardware release however this behavior is not tested yet.
Introducing a new toggle to disable the force on the fly.

Reviewed-by: Dillon Varone <[email protected]>
Signed-off-by: Ryan Seto <[email protected]>
Signed-off-by: Roman Li <[email protected]>
---
 drivers/gpu/drm/amd/display/dc/dc.h           |  1 +
 .../amd/display/dc/hwss/dcn401/dcn401_hwseq.c | 36 +++++++++++--------
 .../dc/resource/dcn401/dcn401_resource.c      |  1 +
 3 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index c013b28207a1..a83227f6bb14 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -1073,6 +1073,7 @@ struct dc_debug_options {
        unsigned int force_mall_ss_num_ways;
        bool alloc_extra_way_for_cursor;
        uint32_t subvp_extra_lines;
+       bool disable_force_pstate_allow_on_hw_release;
        bool force_usr_allow;
        /* uses value at boot and disables switch */
        bool disable_dtb_ref_clk_switch;
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c 
b/drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c
index fb949aeb1244..d5b5e2ce6ff6 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c
@@ -1621,20 +1621,28 @@ void dcn401_unblank_stream(struct pipe_ctx *pipe_ctx,
 
 void dcn401_hardware_release(struct dc *dc)
 {
-       dc_dmub_srv_fams2_update_config(dc, dc->current_state, false);
-
-       /* If pstate unsupported, or still supported
-        * by firmware, force it supported by dcn
-        */
-       if (dc->current_state) {
-               if ((!dc->clk_mgr->clks.p_state_change_support ||
-                               
dc->current_state->bw_ctx.bw.dcn.fams2_global_config.features.bits.enable) &&
-                               
dc->res_pool->hubbub->funcs->force_pstate_change_control)
-                       
dc->res_pool->hubbub->funcs->force_pstate_change_control(
-                                       dc->res_pool->hubbub, true, true);
-
-               dc->current_state->bw_ctx.bw.dcn.clk.p_state_change_support = 
true;
-               dc->clk_mgr->funcs->update_clocks(dc->clk_mgr, 
dc->current_state, true);
+       if (!dc->debug.disable_force_pstate_allow_on_hw_release) {
+               dc_dmub_srv_fams2_update_config(dc, dc->current_state, false);
+
+               /* If pstate unsupported, or still supported
+               * by firmware, force it supported by dcn
+               */
+               if (dc->current_state) {
+                       if ((!dc->clk_mgr->clks.p_state_change_support ||
+                                       
dc->current_state->bw_ctx.bw.dcn.fams2_global_config.features.bits.enable) &&
+                                       
dc->res_pool->hubbub->funcs->force_pstate_change_control)
+                               
dc->res_pool->hubbub->funcs->force_pstate_change_control(
+                                               dc->res_pool->hubbub, true, 
true);
+
+                       
dc->current_state->bw_ctx.bw.dcn.clk.p_state_change_support = true;
+                       dc->clk_mgr->funcs->update_clocks(dc->clk_mgr, 
dc->current_state, true);
+               }
+       } else {
+               if (dc->current_state) {
+                       dc->clk_mgr->clks.p_state_change_support = false;
+                       dc->clk_mgr->funcs->update_clocks(dc->clk_mgr, 
dc->current_state, true);
+               }
+               dc_dmub_srv_fams2_update_config(dc, dc->current_state, false);
        }
 }
 
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c 
b/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c
index b3988e38d0a6..068c123ea8a8 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c
@@ -708,6 +708,7 @@ static const struct dc_debug_options debug_defaults_drv = {
        },
        .use_max_lb = true,
        .force_disable_subvp = false,
+       .disable_force_pstate_allow_on_hw_release = false,
        .exit_idle_opt_for_cursor_updates = true,
        .using_dml2 = true,
        .using_dml21 = true,
-- 
2.34.1

Reply via email to