drm/amd/display: fix workaround for incorrect double buffer register for DLG ADL...
authorTony Cheng <tony.cheng@amd.com>
Tue, 28 Jan 2020 08:00:22 +0000 (16:00 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 6 Feb 2020 20:04:38 +0000 (15:04 -0500)
[Why]
these registers should have been double buffered. SW workaround we will have SW program the more aggressive (lower) values
whenever we are upating this register, so we will not have underflow at expense of less optimzal request pattern.

[How]
there is a driver bug where we don't check for 0, which is uninitialzed HW default.  since 0 is smaller than any value we need to program,
driver end up with not programming these registers

Signed-off-by: Tony Cheng <tony.cheng@amd.com>
Reviewed-by: Yongqiang Sun <yongqiang.sun@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/dcn21/dcn21_hubp.c

index cf09b933572801c9ef605f56a71fc412a6f554ed..aa7b0e7eb945d6222ce507ebd7666a46f2f6f1a9 100644 (file)
@@ -79,32 +79,47 @@ void apply_DEDCN21_142_wa_for_hostvm_deadline(
                struct _vcs_dpi_display_dlg_regs_st *dlg_attr)
 {
        struct dcn21_hubp *hubp21 = TO_DCN21_HUBP(hubp);
-       uint32_t cur_value;
+       uint32_t refcyc_per_vm_group_vblank;
+       uint32_t refcyc_per_vm_req_vblank;
+       uint32_t refcyc_per_vm_group_flip;
+       uint32_t refcyc_per_vm_req_flip;
+       const uint32_t uninitialized_hw_default = 0;
 
-       REG_GET(VBLANK_PARAMETERS_5, REFCYC_PER_VM_GROUP_VBLANK, &cur_value);
-       if (cur_value > dlg_attr->refcyc_per_vm_group_vblank)
+       REG_GET(VBLANK_PARAMETERS_5,
+                       REFCYC_PER_VM_GROUP_VBLANK, &refcyc_per_vm_group_vblank);
+
+       if (refcyc_per_vm_group_vblank == uninitialized_hw_default ||
+                       refcyc_per_vm_group_vblank > dlg_attr->refcyc_per_vm_group_vblank)
                REG_SET(VBLANK_PARAMETERS_5, 0,
                                REFCYC_PER_VM_GROUP_VBLANK, dlg_attr->refcyc_per_vm_group_vblank);
 
        REG_GET(VBLANK_PARAMETERS_6,
-                       REFCYC_PER_VM_REQ_VBLANK,
-                       &cur_value);
-       if (cur_value > dlg_attr->refcyc_per_vm_req_vblank)
+                       REFCYC_PER_VM_REQ_VBLANK, &refcyc_per_vm_req_vblank);
+
+       if (refcyc_per_vm_req_vblank == uninitialized_hw_default ||
+                       refcyc_per_vm_req_vblank > dlg_attr->refcyc_per_vm_req_vblank)
                REG_SET(VBLANK_PARAMETERS_6, 0,
                                REFCYC_PER_VM_REQ_VBLANK, dlg_attr->refcyc_per_vm_req_vblank);
 
-       REG_GET(FLIP_PARAMETERS_3, REFCYC_PER_VM_GROUP_FLIP, &cur_value);
-       if (cur_value > dlg_attr->refcyc_per_vm_group_flip)
+       REG_GET(FLIP_PARAMETERS_3,
+                       REFCYC_PER_VM_GROUP_FLIP, &refcyc_per_vm_group_flip);
+
+       if (refcyc_per_vm_group_flip == uninitialized_hw_default ||
+                       refcyc_per_vm_group_flip > dlg_attr->refcyc_per_vm_group_flip)
                REG_SET(FLIP_PARAMETERS_3, 0,
                                REFCYC_PER_VM_GROUP_FLIP, dlg_attr->refcyc_per_vm_group_flip);
 
-       REG_GET(FLIP_PARAMETERS_4, REFCYC_PER_VM_REQ_FLIP, &cur_value);
-       if (cur_value > dlg_attr->refcyc_per_vm_req_flip)
+       REG_GET(FLIP_PARAMETERS_4,
+                       REFCYC_PER_VM_REQ_FLIP, &refcyc_per_vm_req_flip);
+
+       if (refcyc_per_vm_req_flip == uninitialized_hw_default ||
+                       refcyc_per_vm_req_flip > dlg_attr->refcyc_per_vm_req_flip)
                REG_SET(FLIP_PARAMETERS_4, 0,
                                        REFCYC_PER_VM_REQ_FLIP, dlg_attr->refcyc_per_vm_req_flip);
 
        REG_SET(FLIP_PARAMETERS_5, 0,
                        REFCYC_PER_PTE_GROUP_FLIP_C, dlg_attr->refcyc_per_pte_group_flip_c);
+
        REG_SET(FLIP_PARAMETERS_6, 0,
                        REFCYC_PER_META_CHUNK_FLIP_C, dlg_attr->refcyc_per_meta_chunk_flip_c);
 }