drm/amd/display: Implement workaround for writing to OTG_PIXEL_RATE_DIV register
authorjsg <jsg@openbsd.org>
Thu, 24 Aug 2023 06:27:21 +0000 (06:27 +0000)
committerjsg <jsg@openbsd.org>
Thu, 24 Aug 2023 06:27:21 +0000 (06:27 +0000)
From Saaem Rizvi
4bdfe20d85b32274234bbcd705d5547fd70a4ea1 in linux-6.1.y/6.1.47
74fa4c81aadf418341f0d073c864ea7dca730a2e in mainline linux

sys/dev/pci/drm/amd/display/dc/dcn20/dcn20_dccg.h
sys/dev/pci/drm/amd/display/dc/dcn32/dcn32_dccg.c
sys/dev/pci/drm/amd/display/dc/dcn32/dcn32_dccg.h
sys/dev/pci/drm/amd/display/dc/dcn32/dcn32_hwseq.c
sys/dev/pci/drm/amd/display/dc/dcn32/dcn32_resource.h

index 915a204..893c080 100644 (file)
        type DTBCLK_P2_SRC_SEL;\
        type DTBCLK_P2_EN;\
        type DTBCLK_P3_SRC_SEL;\
-       type DTBCLK_P3_EN;
+       type DTBCLK_P3_EN;\
+       type DENTIST_DISPCLK_CHG_DONE;
 
 struct dccg_shift {
        DCCG_REG_FIELD_LIST(uint8_t)
index 3fb4bcc..ffbb739 100644 (file)
 #define DC_LOGGER \
        dccg->ctx->logger
 
+/* This function is a workaround for writing to OTG_PIXEL_RATE_DIV
+ * without the probability of causing a DIG FIFO error.
+ */
+static void dccg32_wait_for_dentist_change_done(
+       struct dccg *dccg)
+{
+       struct dcn_dccg *dccg_dcn = TO_DCN_DCCG(dccg);
+
+       uint32_t dentist_dispclk_value = REG_READ(DENTIST_DISPCLK_CNTL);
+
+       REG_WRITE(DENTIST_DISPCLK_CNTL, dentist_dispclk_value);
+       REG_WAIT(DENTIST_DISPCLK_CNTL, DENTIST_DISPCLK_CHG_DONE, 1, 50, 2000);
+}
+
 static void dccg32_get_pixel_rate_div(
                struct dccg *dccg,
                uint32_t otg_inst,
@@ -110,21 +124,29 @@ static void dccg32_set_pixel_rate_div(
                REG_UPDATE_2(OTG_PIXEL_RATE_DIV,
                                OTG0_PIXEL_RATE_DIVK1, k1,
                                OTG0_PIXEL_RATE_DIVK2, k2);
+
+               dccg32_wait_for_dentist_change_done(dccg);
                break;
        case 1:
                REG_UPDATE_2(OTG_PIXEL_RATE_DIV,
                                OTG1_PIXEL_RATE_DIVK1, k1,
                                OTG1_PIXEL_RATE_DIVK2, k2);
+
+               dccg32_wait_for_dentist_change_done(dccg);
                break;
        case 2:
                REG_UPDATE_2(OTG_PIXEL_RATE_DIV,
                                OTG2_PIXEL_RATE_DIVK1, k1,
                                OTG2_PIXEL_RATE_DIVK2, k2);
+
+               dccg32_wait_for_dentist_change_done(dccg);
                break;
        case 3:
                REG_UPDATE_2(OTG_PIXEL_RATE_DIV,
                                OTG3_PIXEL_RATE_DIVK1, k1,
                                OTG3_PIXEL_RATE_DIVK2, k2);
+
+               dccg32_wait_for_dentist_change_done(dccg);
                break;
        default:
                BREAK_TO_DEBUGGER();
index 1c46fad..fc3c9c6 100644 (file)
        DCCG_SF(DTBCLK_P_CNTL, DTBCLK_P3_SRC_SEL, mask_sh),\
        DCCG_SF(DTBCLK_P_CNTL, DTBCLK_P3_EN, mask_sh),\
        DCCG_SF(DCCG_AUDIO_DTO_SOURCE, DCCG_AUDIO_DTO_SEL, mask_sh),\
-       DCCG_SF(DCCG_AUDIO_DTO_SOURCE, DCCG_AUDIO_DTO0_SOURCE_SEL, mask_sh)
+       DCCG_SF(DCCG_AUDIO_DTO_SOURCE, DCCG_AUDIO_DTO0_SOURCE_SEL, mask_sh),\
+       DCCG_SF(DENTIST_DISPCLK_CNTL, DENTIST_DISPCLK_CHG_DONE, mask_sh)
 
 
 struct dccg *dccg32_create(
index 601b654..fa07578 100644 (file)
@@ -1177,7 +1177,7 @@ unsigned int dcn32_calculate_dccg_k1_k2_values(struct pipe_ctx *pipe_ctx, unsign
                        *k2_div = PIXEL_RATE_DIV_BY_2;
                else
                        *k2_div = PIXEL_RATE_DIV_BY_4;
-       } else if (dc_is_dp_signal(stream->signal)) {
+       } else if (dc_is_dp_signal(stream->signal) || dc_is_virtual_signal(stream->signal)) {
                if (two_pix_per_container) {
                        *k1_div = PIXEL_RATE_DIV_BY_1;
                        *k2_div = PIXEL_RATE_DIV_BY_2;
index 026cf13..03cdfb5 100644 (file)
@@ -1272,7 +1272,8 @@ unsigned int dcn32_calc_num_avail_chans_for_mall(struct dc *dc, int num_chans);
       DCCG_SRII(PHASE, DTBCLK_DTO, 0), DCCG_SRII(PHASE, DTBCLK_DTO, 1),        \
       DCCG_SRII(PHASE, DTBCLK_DTO, 2), DCCG_SRII(PHASE, DTBCLK_DTO, 3),        \
       SR(DCCG_AUDIO_DTBCLK_DTO_MODULO), SR(DCCG_AUDIO_DTBCLK_DTO_PHASE),       \
-      SR(OTG_PIXEL_RATE_DIV), SR(DTBCLK_P_CNTL), SR(DCCG_AUDIO_DTO_SOURCE)     \
+      SR(OTG_PIXEL_RATE_DIV), SR(DTBCLK_P_CNTL),                               \
+      SR(DCCG_AUDIO_DTO_SOURCE), SR(DENTIST_DISPCLK_CNTL)                      \
   )
 
 /* VMID */