From: Alvin Lee <[email protected]>

In DCN32/321 FPO uses per-pipe P-State force. If there is no plane, then
then HUBP is power gated, in which case any programming in HUBP has no
effect and the pipe is always asserting P-State allow. This is contrary
to what we want to happen for FPO (FW should moderate the P-State
assertion), so block FPO if there's no plane for the FPO pipe.

Acked-by: Rodrigo Siqueira <[email protected]>
Reviewed-by: Samson Tam <[email protected]>
Reviewed-by: Chaitanya Dhere <[email protected]>
Signed-off-by: Alvin Lee <[email protected]>
---
 .../display/dc/dcn32/dcn32_resource_helpers.c  | 18 +++++++++++++++---
 .../drm/amd/display/dc/dml/dcn32/dcn32_fpu.c   | 10 +++++++++-
 .../display/dc/resource/dcn32/dcn32_resource.h |  2 +-
 3 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource_helpers.c 
b/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource_helpers.c
index 1743ebcd6b2e..cca6436ecdf5 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource_helpers.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource_helpers.c
@@ -524,13 +524,14 @@ static int get_refresh_rate(struct dc_stream_state 
*fpo_candidate_stream)
  *
  * Return: Pointer to FPO stream candidate if config can support FPO, 
otherwise NULL
  */
-struct dc_stream_state 
*dcn32_can_support_mclk_switch_using_fw_based_vblank_stretch(struct dc *dc, 
const struct dc_state *context)
+struct dc_stream_state 
*dcn32_can_support_mclk_switch_using_fw_based_vblank_stretch(struct dc *dc, 
struct dc_state *context)
 {
        int refresh_rate = 0;
        const int minimum_refreshrate_supported = 120;
        struct dc_stream_state *fpo_candidate_stream = NULL;
        bool is_fpo_vactive = false;
        uint32_t fpo_vactive_margin_us = 0;
+       struct dc_stream_status *fpo_stream_status = NULL;
 
        if (context == NULL)
                return NULL;
@@ -559,10 +560,21 @@ struct dc_stream_state 
*dcn32_can_support_mclk_switch_using_fw_based_vblank_stre
                DC_FP_END();
                if (!is_fpo_vactive || dc->debug.disable_fpo_vactive)
                        return NULL;
-       } else
+       } else {
                fpo_candidate_stream = context->streams[0];
+               if (fpo_candidate_stream)
+                       fpo_stream_status = dc_state_get_stream_status(context, 
fpo_candidate_stream);
+       }
 
-       if (!fpo_candidate_stream)
+       /* In DCN32/321, FPO uses per-pipe P-State force.
+        * If there's no planes, HUBP is power gated and
+        * therefore programming UCLK_PSTATE_FORCE does
+        * nothing (P-State will always be asserted naturally
+        * on a pipe that has HUBP power gated. Therefore we
+        * only want to enable FPO if the FPO pipe has both
+        * a stream and a plane.
+        */
+       if (!fpo_candidate_stream || !fpo_stream_status || 
fpo_stream_status->plane_count == 0)
                return NULL;
 
        if (fpo_candidate_stream->sink->edid_caps.panel_patch.disable_fams)
diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c 
b/drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c
index cc759b34268b..9f37f717a1f8 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c
@@ -3465,7 +3465,15 @@ void dcn32_assign_fpo_vactive_candidate(struct dc *dc, 
const struct dc_state *co
        for (i = 0, pipe_idx = 0; i < dc->res_pool->pipe_count; i++) {
                const struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
 
-               if (!pipe->stream)
+               /* In DCN32/321, FPO uses per-pipe P-State force.
+                * If there's no planes, HUBP is power gated and
+                * therefore programming UCLK_PSTATE_FORCE does
+                * nothing (P-State will always be asserted naturally
+                * on a pipe that has HUBP power gated. Therefore we
+                * only want to enable FPO if the FPO pipe has both
+                * a stream and a plane.
+                */
+               if (!pipe->stream || !pipe->plane_state)
                        continue;
 
                if 
(vba->ActiveDRAMClockChangeLatencyMarginPerState[vba->VoltageLevel][vba->maxMpcComb][vba->pipe_plane[pipe_idx]]
 <= 0) {
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.h 
b/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.h
index b27fadd452bb..0c87b0fabba7 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.h
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.h
@@ -163,7 +163,7 @@ void dcn32_determine_det_override(struct dc *dc,
 void dcn32_set_det_allocations(struct dc *dc, struct dc_state *context,
        display_e2e_pipe_params_st *pipes);
 
-struct dc_stream_state 
*dcn32_can_support_mclk_switch_using_fw_based_vblank_stretch(struct dc *dc, 
const struct dc_state *context);
+struct dc_stream_state 
*dcn32_can_support_mclk_switch_using_fw_based_vblank_stretch(struct dc *dc, 
struct dc_state *context);
 
 bool dcn32_allow_subvp_with_active_margin(struct pipe_ctx *pipe);
 
-- 
2.42.0

Reply via email to