drm/amd/display: make underflow status clear explicit
authorJun Lei <Jun.Lei@amd.com>
Tue, 23 Oct 2018 16:12:50 +0000 (12:12 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 19 Nov 2018 20:27:36 +0000 (15:27 -0500)
[why]
HUBP underflow is never cleared, which causes underflow in one
test to fail another test, violating the independence requirements

[how]
Rather than make clearing implicit, we explicitly clear underflow
status in DTN.

Signed-off-by: Jun Lei <Jun.Lei@amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
Acked-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.h
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer_debug.c
drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h
drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h

index 74132a1f3046bfb8dc617ff27c136632ea329705..6127fd30899b4576d1a080e80ad38862c328d752 100644 (file)
@@ -99,6 +99,14 @@ static unsigned int hubp1_get_underflow_status(struct hubp *hubp)
        return hubp_underflow;
 }
 
+
+void hubp1_clear_underflow(struct hubp *hubp)
+{
+       struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
+
+       REG_UPDATE(DCHUBP_CNTL, HUBP_UNDERFLOW_CLEAR, 1);
+}
+
 static void hubp1_set_hubp_blank_en(struct hubp *hubp, bool blank)
 {
        struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
@@ -1190,6 +1198,7 @@ static const struct hubp_funcs dcn10_hubp_funcs = {
        .hubp_clk_cntl = hubp1_clk_cntl,
        .hubp_vtg_sel = hubp1_vtg_sel,
        .hubp_read_state = hubp1_read_state,
+       .hubp_clear_underflow = hubp1_clear_underflow,
        .hubp_disable_control =  hubp1_disable_control,
        .hubp_get_underflow_status = hubp1_get_underflow_status,
 
index 4890273b632b576388d7532cbdf86b9bf4bd308f..62d4232e7796cfa2d2064f088083c4500e687510 100644 (file)
        HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_BLANK_EN, mask_sh),\
        HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_TTU_DISABLE, mask_sh),\
        HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_UNDERFLOW_STATUS, mask_sh),\
+       HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_UNDERFLOW_CLEAR, mask_sh),\
        HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_NO_OUTSTANDING_REQ, mask_sh),\
        HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_VTG_SEL, mask_sh),\
        HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_DISABLE, mask_sh),\
        type HUBP_NO_OUTSTANDING_REQ;\
        type HUBP_VTG_SEL;\
        type HUBP_UNDERFLOW_STATUS;\
+       type HUBP_UNDERFLOW_CLEAR;\
        type NUM_PIPES;\
        type NUM_BANKS;\
        type PIPE_INTERLEAVE;\
@@ -739,6 +741,7 @@ void dcn10_hubp_construct(
        const struct dcn_mi_mask *hubp_mask);
 
 void hubp1_read_state(struct hubp *hubp);
+void hubp1_clear_underflow(struct hubp *hubp);
 
 enum cursor_pitch hubp1_get_cursor_pitch(unsigned int pitch);
 
index 6b8a4da4f3c8b48e020bd63627de9ae26440dd00..a59b89b27583c41a0f0ce378eb83b9ab0277e967 100644 (file)
@@ -2710,6 +2710,7 @@ static const struct hw_sequencer_funcs dcn10_funcs = {
        .set_avmute = dce110_set_avmute,
        .log_hw_state = dcn10_log_hw_state,
        .get_hw_state = dcn10_get_hw_state,
+       .clear_status_bits = dcn10_clear_status_bits,
        .wait_for_mpcc_disconnect = dcn10_wait_for_mpcc_disconnect,
        .edp_backlight_control = hwss_edp_backlight_control,
        .edp_power_control = hwss_edp_power_control,
index 5e5610c9e600dd0b63e6351d2b56f5dfc7baacd9..91bb77b468ddc63895234ece7d36a85f292881f4 100644 (file)
@@ -51,6 +51,8 @@ void dcn10_get_hw_state(
                char *pBuf, unsigned int bufSize,
                unsigned int mask);
 
+void dcn10_clear_status_bits(struct dc *dc, unsigned int mask);
+
 bool is_lower_pipe_tree_visible(struct pipe_ctx *pipe_ctx);
 
 bool is_upper_pipe_tree_visible(struct pipe_ctx *pipe_ctx);
index 64158900730f3a8b7357785d3942e295b04ee24c..211bb240a7203b530228d7fc2389b79f24d42c44 100644 (file)
@@ -454,12 +454,6 @@ static unsigned int dcn10_get_otg_states(struct dc *dc, char *pBuf, unsigned int
 
                        remaining_buffer -= chars_printed;
                        pBuf += chars_printed;
-
-                       // Clear underflow for debug purposes
-                       // We want to keep underflow sticky bit on for the longevity tests outside of test environment.
-                       // This function is called only from Windows or Diags test environment, hence it's safe to clear
-                       // it from here without affecting the original intent.
-                       tg->funcs->clear_optc_underflow(tg);
                }
        }
 
@@ -484,6 +478,59 @@ static unsigned int dcn10_get_clock_states(struct dc *dc, char *pBuf, unsigned i
        return chars_printed;
 }
 
+static void dcn10_clear_otpc_underflow(struct dc *dc)
+{
+       struct resource_pool *pool = dc->res_pool;
+       int i;
+
+       for (i = 0; i < pool->timing_generator_count; i++) {
+               struct timing_generator *tg = pool->timing_generators[i];
+               struct dcn_otg_state s = {0};
+
+               optc1_read_otg_state(DCN10TG_FROM_TG(tg), &s);
+
+               if (s.otg_enabled & 1)
+                       tg->funcs->clear_optc_underflow(tg);
+       }
+}
+
+static void dcn10_clear_hubp_underflow(struct dc *dc)
+{
+       struct resource_pool *pool = dc->res_pool;
+       int i;
+
+       for (i = 0; i < pool->pipe_count; i++) {
+               struct hubp *hubp = pool->hubps[i];
+               struct dcn_hubp_state *s = &(TO_DCN10_HUBP(hubp)->state);
+
+               hubp->funcs->hubp_read_state(hubp);
+
+               if (!s->blank_en)
+                       hubp->funcs->hubp_clear_underflow(hubp);
+       }
+}
+
+void dcn10_clear_status_bits(struct dc *dc, unsigned int mask)
+{
+       /*
+        *  Mask Format
+        *  Bit 0 - 31: Status bit to clear
+        *
+        *  Mask = 0x0 means clear all status bits
+        */
+       const unsigned int DC_HW_STATE_MASK_HUBP_UNDERFLOW      = 0x1;
+       const unsigned int DC_HW_STATE_MASK_OTPC_UNDERFLOW      = 0x2;
+
+       if (mask == 0x0)
+               mask = 0xFFFFFFFF;
+
+       if (mask & DC_HW_STATE_MASK_HUBP_UNDERFLOW)
+               dcn10_clear_hubp_underflow(dc);
+
+       if (mask & DC_HW_STATE_MASK_OTPC_UNDERFLOW)
+               dcn10_clear_otpc_underflow(dc);
+}
+
 void dcn10_get_hw_state(struct dc *dc, char *pBuf, unsigned int bufSize, unsigned int mask)
 {
        /*
index 334c48cdafdc29cb347dcecbd44b6ae7a9a7ec6f..8f4f40646b4db88796a10ac77570bcd533ffa112 100644 (file)
@@ -121,6 +121,7 @@ struct hubp_funcs {
        void (*hubp_clk_cntl)(struct hubp *hubp, bool enable);
        void (*hubp_vtg_sel)(struct hubp *hubp, uint32_t otg_inst);
        void (*hubp_read_state)(struct hubp *hubp);
+       void (*hubp_clear_underflow)(struct hubp *hubp);
        void (*hubp_disable_control)(struct hubp *hubp, bool disable_hubp);
        unsigned int (*hubp_get_underflow_status)(struct hubp *hubp);
 
index e9b702ce02ddca675fbaf4b0331dfc201209f9a3..d6a85f48b6d17434cc62b07629c17463ad1fac18 100644 (file)
@@ -200,6 +200,7 @@ struct hw_sequencer_funcs {
        void (*log_hw_state)(struct dc *dc,
                struct dc_log_buffer_ctx *log_ctx);
        void (*get_hw_state)(struct dc *dc, char *pBuf, unsigned int bufSize, unsigned int mask);
+       void (*clear_status_bits)(struct dc *dc, unsigned int mask);
 
        void (*wait_for_mpcc_disconnect)(struct dc *dc,
                        struct resource_pool *res_pool,